Compare commits

...
8 changed files with 109 additions and 21 deletions
+14 -19
View File
@@ -68,33 +68,28 @@ typedef struct Statement_ * Statement,
typedef struct Scope_ * Increment;
/****************/
/* modules used */
/****************/
#include "expr.h"
#include "alg.h"
/***************************/
/* hidden type definitions */
/***************************/
#define STMT_ASSIGN 0x1
#define STMT_CASE 0x2
#define STMT_COMPOUND 0x4
#define STMT_COND 0x8
#define STMT_LOOP 0x10
#define STMT_PCALL 0x20
#define STMT_RETURN 0x40
#define STMT_ALIAS 0x80
#define STMT_SKIP 0x100
#define STMT_ESCAPE 0x200
typedef enum {
STMT_ASSIGN = 0x1,
STMT_CASE = 0x2,
STMT_COMPOUND = 0x4,
STMT_COND = 0x8,
STMT_LOOP = 0x10,
STMT_PCALL = 0x20,
STMT_RETURN = 0x40,
STMT_ALIAS = 0x80,
STMT_SKIP = 0x100,
STMT_ESCAPE = 0x200
} Statement_type;
/* these should probably all be expression types */
struct Statement_ {
Symbol symbol; /**< can hold pcall or alias name but otherwise is not used for anything */
int type; /**< one of STMT_XXX above */
Statement_type type; /**< one of STMT_XXX above */
/* hey, is there nothing in common beside symbol and private data?? */
union u_statement {
struct Alias_ * alias;
@@ -234,7 +229,7 @@ extern SC_EXPRESS_EXPORT Statement CONDcreate PROTO( ( Expression, Linked_Lis
extern SC_EXPRESS_EXPORT Statement LOOPcreate PROTO( ( struct Scope_ *, Expression, Expression, Linked_List ) );
extern SC_EXPRESS_EXPORT Statement PCALLcreate PROTO( ( Linked_List ) );
extern SC_EXPRESS_EXPORT Statement RETcreate PROTO( ( Expression ) );
extern SC_EXPRESS_EXPORT void STMTinitialize PROTO( ( void ) );
extern SC_EXPRESS_EXPORT void STMTinitialize PROTO( ( void ) );
extern SC_EXPRESS_EXPORT struct Scope_ * INCR_CTLcreate PROTO( ( Symbol *, Expression start,
Expression end, Expression increment ) );
+3 -1
View File
@@ -5,13 +5,15 @@
This is for Kate, the KDE editor. Rename to express.xml and place in the syntax directory (on Debian, this is /usr/share/kde4/apps/katepart/syntax )
-->
<language name="EXPRESS" version="0.1" kateversion="2.5" section="Database" extensions="*.exp;*.EXP;*.p11" mimetype="text/x-express" casesensitive="0" author="Mark Pictor (mpictor@gmail.com)" license="">
<language name="EXPRESS" version="0.1" kateversion="2.5" section="3D" extensions="*.exp;*.EXP;*.p11" mimetype="text/x-express" casesensitive="0" author="Mark Pictor (mpictor@gmail.com)" license="">
<highlighting>
<list name="keywords">
<item> of </item>
<item> or </item>
<item> xor </item>
<item> to </item>
<item> where </item>
<item> unique </item>
<item> subtype </item>
<item> supertype </item>
<item> abstract </item>
+21
View File
@@ -0,0 +1,21 @@
#ifndef GDB_SCRIPT_AUTOLOAD_H
#define GDB_SCRIPT_AUTOLOAD_H
// https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html, section 23.4.2.1 Script File Entries
/* Embed a section that tells gdb to auto-load a python script.
* In spite of sourceware documentation to the contrary, it appears that gdb
* only tries the file name as absolute path and as something relative to the
* CWD - thus, script_name is practically useless if it isn't an absolute path.
*
* Note: The "MS" section flags are to remove duplicates. */
#define DEFINE_GDB_PY_SCRIPT(script_name) \
asm("\
.pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
.byte 1 /* Python */\n\
.asciz \"" script_name "\"\n\
.popsection \n\
");
#endif //GDB_SCRIPT_AUTOLOAD_H
+1 -1
View File
@@ -45,7 +45,7 @@ STEPattribute & STEPattributeList::operator []( int n ) {
// else
cerr << "\nERROR in STEP Core library: " << __FILE__ << ":"
<< __LINE__ << "\n" << _POC_ << "\n\n";
return *( STEPattribute * ) 0;
return nullptr;
}
int STEPattributeList::list_length() {
+6
View File
@@ -119,6 +119,12 @@ if(SC_GENERATE_LP_SOURCES)
endif (TARGET express-static)
endif(SC_GENERATE_LP_SOURCES)
# Adds a section to libexpress so gdb can find pretty printers. To take
# advantage, add 'add-auto-load-safe-path /path/to/stepcode' to ~/.gdbinit
if( NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
set_property(TARGET express APPEND PROPERTY COMPILE_DEFINITIONS EXPRESS_PYEMBEDPATH="${CMAKE_CURRENT_SOURCE_DIR}/libexpress-gdb-printers.py")
endif()
if(SC_GENERATE_LP_SOURCES)
add_custom_command(TARGET express POST_BUILD
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/express_verify.cmake
+1
View File
@@ -362,6 +362,7 @@ va_dcl {
what->message = "%s";
ERRORreport_with_symbol( what, &sym, buf );
what->message = savemsg;
va_end( args );
}
void
+8
View File
@@ -86,6 +86,14 @@
#include "express/lexact.h"
#include "express/exp_kw.h"
/* Adds a section to libexpress so gdb can find pretty printers. To take
advantage, add 'add-auto-load-safe-path /path/to/stepcode' to ~/.gdbinit
*/
#if defined(EXPRESS_PYEMBEDPATH)
# include "gdb_script_autoload.h"
DEFINE_GDB_PY_SCRIPT(EXPRESS_PYEMBEDPATH)
#endif //EXPRESS_PYEMBEDPATH
void * ParseAlloc( void * ( *mallocProc )( size_t ) );
void ParseFree( void * parser, void ( *freeProc )( void * ) );
void Parse( void * parser, int tokenID, YYSTYPE data, parse_data_t parseData );
+55
View File
@@ -0,0 +1,55 @@
#https://www.rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers/
class Variable:
def __init__(self, val):
self.val = val
def to_string(self):
t=Type(self.val['type']).to_string()
s=Symbol(self.val['name']['symbol']).to_string()
return t + ' ' + s
class Symbol:
def __init__(self, val):
self.val = val
def to_string(self):
if not self.val:
return ""
fn = os.path.basename(get_char_star(self.val['filename']))
res=' '
if self.val['resolved']==0:
res='??'
name=get_char_star(self.val['name'])
#myvar ??[file.exp:123] (where ?? indicates not resolved)
v="{} {}[{}:{}]".format(name,res,fn,self.val['line'])
return v
def get_char_star(val):
'''make possibly-null strings print sanely'''
if not val:
return ''
try:
return str(val.string())
except:
return ''
class Type:
def __init__(self, val):
self.val = val
def to_string(self):
if self.val['type'] != ord('t'):
return str(self.val['type'])
t = str(self.val['u']['type']['body']['type'])
return t[:len(t)-1].upper()
import gdb.printing
import os.path
def build_pretty_printer():
pp = gdb.printing.RegexpCollectionPrettyPrinter("STEPcode - libexpress")
#pp.add_printer('Variable', '^Variable$', Variable)
pp.add_printer('Symbol', '\*?Symbol', Symbol)
pp.add_printer('Type', '^Type$', Type)
return pp
gdb.printing.register_pretty_printer( gdb.current_objfile(), build_pretty_printer())