diff --git a/common/h/bg_compute_headers.h b/common/h/bg_compute_headers.h index 82a4172..46e8575 100644 --- a/common/h/bg_compute_headers.h +++ b/common/h/bg_compute_headers.h @@ -37,5 +37,17 @@ inline const char * P_strrchr (const char *P_STRING, int C) {return (strrchr(P_STRING, C));} inline char * P_strrchr (char *P_STRING, int C) {return (strrchr(P_STRING, C));} +inline void * P_memcpy (void *A1, const void *A2, size_t SIZE) + { return memcpy( A1, A2, SIZE ); } +/* The following values are taken from demangle.h in binutils */ +#define DMGL_PARAMS (1 << 0) /* Include function args */ +#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ + +#define DMGL_ARM (1 << 11) /* Use C++ ARM name mangling */ + +extern "C" char *cplus_demangle(char *, int); +extern void dedemangle( char * demangled, char * dedemangled ); +extern char * P_cplus_demangle( const char * symbol, bool nativeCompiler, + bool includeTypes = false ); #endif // _bgl_compute_headers_h diff --git a/dynC_API/doc/dynC_API_Manual.pdf b/dynC_API/doc/dynC_API_Manual.pdf index 703184c..2578db9 100644 Binary files a/dynC_API/doc/dynC_API_Manual.pdf and b/dynC_API/doc/dynC_API_Manual.pdf differ diff --git a/dynC_API/doc/dynC_API_Manual.tex b/dynC_API/doc/dynC_API_Manual.tex index 4ce08b2..a335a8e 100644 --- a/dynC_API/doc/dynC_API_Manual.tex +++ b/dynC_API/doc/dynC_API_Manual.tex @@ -12,10 +12,9 @@ \linespread{1.5} \begin{document} -\begin{center} \Huge{DynC API Manual} \\ -\huge{Version 0.0.2}\\ +\begin{center} \Huge{DynC API Programmer's Guide} \\ +\huge{Version 1.0 beta}\\ \vspace{8cm} -\textbf{\Huge{DRAFT}} \end{center} \pagebreak \tableofcontents diff --git a/dynC_API/h/dynC.tab.h b/dynC_API/h/dynC.tab.h index 87ab0a7..6be101d 100644 --- a/dynC_API/h/dynC.tab.h +++ b/dynC_API/h/dynC.tab.h @@ -48,8 +48,8 @@ ERROR = 264, EOL = 265, SIZEOF = 266, - TRUE = 267, - FALSE = 268, + D_TRUE = 267, + D_FALSE = 268, PTR_OP = 269, INC_OP = 270, DEC_OP = 271, @@ -133,8 +133,8 @@ #define ERROR 264 #define EOL 265 #define SIZEOF 266 -#define TRUE 267 -#define FALSE 268 +#define D_TRUE 267 +#define D_FALSE 268 #define PTR_OP 269 #define INC_OP 270 #define DEC_OP 271 diff --git a/dynC_API/make.module.tmpl b/dynC_API/make.module.tmpl index 292dcc6..69d85b2 100644 --- a/dynC_API/make.module.tmpl +++ b/dynC_API/make.module.tmpl @@ -11,10 +11,10 @@ RELEASE_MAJOR = 7 RELEASE_MINOR = 0 DYNCNAME = dynC -CFLAGS += $(USEFULWARNINGS) -I$(TO_CORE)/../include -CXXFLAGS += $(USEFULWARNINGS) -I$(TO_CORE)/../include +CFLAGS += $(USEFULWARNINGS) -I$(TO_CORE)/dyninstAPI/h -I$(TO_CORE)/dynutil/h +CXXFLAGS += $(USEFULWARNINGS) -I$(TO_CORE)/dyninstAPI/h -I$(TO_CORE)/dynutil/h -LDFLAGS += -lcommon -lsymtabAPI -ldyninstAPI +LDFLAGS += -L$(TO_CORE)/dyninstAPI/$(PLATFORM) -L$(TO_CORE)/common/$(PLATFORM) -L$(TO_CORE)/symtabAPI/$(PLATFORM) -L$(TO_CORE)/instructionAPI/$(PLATFORM) -L$(LIBRARY_DEST) -lcommon -lsymtabAPI -ldyninstAPI LDFLAGS += $(LIBDIR) ifndef USES_NATIVE_CC @@ -35,8 +35,8 @@ endif TO_INC = ../h PUBLIC_H = \ - ../h/dynC.h\ - ../h/snippetGen.h + dynC.h\ + snippetGen.h SRCS += ../src/dynC.C ../src/snippetGen.C ../src/lex.$(DYNCNAME).C ../src/$(DYNCNAME).tab.C diff --git a/dynC_API/src/C.l b/dynC_API/src/C.l index 9232790..743dcf4 100644 --- a/dynC_API/src/C.l +++ b/dynC_API/src/C.l @@ -84,8 +84,8 @@ char|int|long|float|double|short|void|bool { yylval.sval = strdup(yytext); retur "static" { return(STATIC); } "switch" { return(SWITCH); } "typedef" { return(TYPEDEF); } -"true" { return(TRUE); } -"false" { return(FALSE); } +"true" { return(D_TRUE); } +"false" { return(D_FALSE); } "local" { return(LOCAL); } "param" { return(PARAM); } diff --git a/dynC_API/src/C.y b/dynC_API/src/C.y index c9ee728..c79bed1 100644 --- a/dynC_API/src/C.y +++ b/dynC_API/src/C.y @@ -105,7 +105,7 @@ std::vector endSnippets; %token NUMBER %token ERROR %token EOL -%token SIZEOF TRUE FALSE +%token SIZEOF D_TRUE D_FALSE %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP %token LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN %token XOR_ASSIGN OR_ASSIGN TYPE_NAME @@ -561,11 +561,11 @@ param_list: ; -bool_constant: TRUE +bool_constant: D_TRUE { $$ = new BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(0)); } - | FALSE + | D_FALSE { $$ = new BPatch_boolExpr(BPatch_ne, BPatch_constExpr(0), BPatch_constExpr(0)); } diff --git a/dynC_API/src/cmd.l b/dynC_API/src/cmd.l deleted file mode 100644 index f5a6f86..0000000 --- a/dynC_API/src/cmd.l +++ /dev/null @@ -1,247 +0,0 @@ -%option noyywrap - -%x incl -%x comment -%x stringmode -%x cparse -%{ - -#include -#include "BPatch_snippet.h" -#include "command.tab.h" - -extern "C" { - void set_lex_input(char *); -} - -extern void commanderror (char const *s) { - fprintf (stderr, "%s\n", s); -} - - -static char *input_str = NULL; -/* -#ifdef FLEX_SCANNER -#undef YY_INPUT - -#define YY_INPUT(b,r,ms) (r = my_yyinput(b, ms)) - -int my_yyinput(char *buf, int max_size); - -#else -#undef input -#undef unput - -#define input() (*input_str++) -#define unput(c) (*--input_str = c) - -#endif -*/ -std::string string_buf = ""; - -int line_num = 1; - -%} - -%% - -^"#"[ \t]*include[ \t]*\[\"<] { BEGIN incl; } - -[^ \t\n\">]+ { commandlval.sval = strdup(yytext); - BEGIN INITIAL; - return INCLUDE;} - -"$"[A-Z]+ { return MACRO; } - -{ - -[^*\n]* /* eat anything that's not a '*' */ -"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -\n ++line_num; -"*"+"/" BEGIN(INITIAL); - -} - -load { return LOAD; } - -vars { return VARS; } - - - -int { return INT; } - -void { return VOID; } - -long { return LONG; } - -bool { return BOOL; } - -char { return CHAR; } - -double { return DOUBLE; } - -[0-9]+ { commandlval.ival = atoi(yytext); return NUMBER; } - -entry|exit|preCall|subroutine|all { commandlval.sval = strdup(yytext); return POINTTYPE; } - -put { return PUT; } - -at { return AT; } - -in { return IN; } - -if { return IF; } - -with { return WITH; } - -termination { return TERMINATION; } - -replace { return REPLACE; } - -remove { return REMOVE; } - -call { return F_CALL; } - -calls { return F_CALLS; } - -trace { return TRACE; } - -untrace { return UNTRACE; } - -enable { return ENABLE; } - -disable { return DISABLE; } - -toggle { return TOGGLE; } - -snippets { return SNIPPETS; } - -mutations { return MUTATIONS; } - -detach { return DETACH; } - -reattach { return REATTACH; } - -print { return PRINT; } - -about { return ABOUT; } - -assert { return ASSERT; } - -kill { return KILL; } - -break { return BREAK; } - -write { return WRITE; } - -true { return TRUE; } - -false { return FALSE; } - -[A-za-z][A-Za-z0-9_]* { commandlval.sval = strdup(yytext); return IDENTIFIER; } - -<*>"//".* { /* inline comment */; ++line_num; } - -<*>"/*" BEGIN(comment); - -[ \t]+ { /* whitespace */; } - -\n { ++line_num; } - -\" string_buf = ""; BEGIN(stringmode); - -{ - - \" { /* saw closing quote - all done */ - // this string handling code was taken from the flex manual - BEGIN(INITIAL); - char * cstr = new char[string_buf.size() + 1]; - strcpy (cstr, string_buf.c_str()); - commandlval.sval = strdup(cstr); - delete[] cstr; - return STRING; - } - - \n { /* error - unterminated string constant */ - commandlval.context = "unterminated string constant"; - commandlval.line_number = line_num; - return ERROR; - } - - \\[0-7]{1,3} { /* octal escape sequence */ - int result; - - (void) sscanf( yytext + 1, "%o", &result ); - - if ( result > 0xff ){ - /* error, constant is out-of-bounds */ - commandlval.context = "constant out of bounds"; - commandlval.line_number = line_num; - return ERROR; - } - - string_buf += result; - } - - \\[0-9]+ { /* generate error - bad escape sequence */ - commandlval.context = "bad escape sequence"; - commandlval.line_number = line_num; - return ERROR; - } - - \\n string_buf += '\n'; - \\t string_buf += '\t'; - \\r string_buf += '\r'; - \\b string_buf += '\b'; - \\f string_buf += '\f'; - - \\(.|\n) string_buf += yytext[1]; - - [^\\\n\"]+ { - char *yptr = yytext; - while ( *yptr ) { string_buf += *yptr++; } - } - -} - -[()] { return yytext[0]; } - -";" { return SEMI; } - -":" { return COLON; } - -"=" { return ASSIGN; } - -"%{" { return START_C_BLOCK; } - -"%}" { return END_C_BLOCK; } - -\{ { return START_BLOCK; } - -\} { return END_BLOCK; } - -%% - -void set_lex_input(char *str) -{ - static int firstCall = 1; - - input_str = str; - - if (!firstCall) yy_flush_buffer(YY_CURRENT_BUFFER); - firstCall = 0; -} - -#ifdef FLEX_SCANNER -int my_yyinput(char *buf, int max_size) -{ - int sz = 0; - - while (*input_str != '\0' && sz < max_size) { - *buf++ = *input_str++; - sz++; - } - - return sz; -} -#endif diff --git a/dynC_API/src/cmd.y b/dynC_API/src/cmd.y deleted file mode 100644 index ac871b5..0000000 --- a/dynC_API/src/cmd.y +++ /dev/null @@ -1,100 +0,0 @@ -//cmd.y -%{ - -/* - * Yacc will define token IF, conflicting with dyn_regs.h - * This undef is safe b/c yacc also creates an enum IF - * which serves the same purpose. - */ -#undef IF - -#include -#include -#include "BPatch_type.h" -#include "BPatch_snippet.h" -#include "symtab.h" - -extern "C" { - void yyerror(char *s); - int yyparse(void); -} - -int yylex(); - -extern BPatch_process *appProc; -extern BPatch_image *appImage; - -//SymbolTable *symtab; - -//ST_Entry thisEntry; - -//std::map symtable; - -BPatch_snippet parse_result; -BPatch_snippet *cParse_result; -%} - -%union { - int ival; - long lval; - double dval; - char *sval; - - char *context; - int line_number; - - BPatch_snippet *snippet; - BPatch_boolExpr *boolExpr; - BPatch_funcCallExpr *funcCall; -}; - -%token IDENTIFIER MACRO INCLUDE POINTTYPE STRING -%token NUMBER -%token TRUE FALSE -%token INT VOID LONG BOOL CHAR DOUBLE -%token LOAD VARS PUT AT IF IN WITH -%token REPLACE REMOVE F_CALL F_CALLS TRACE UNTRACE -%token ENABLE DISABLE TOGGLE DETACH REATTACH -%token SNIPPETS MUTATIONS -%token PRINT ABOUT -%token ASSERT KILL BREAK WRITE -%token TERMINATION -%token ERROR - -%left COLON -%left ASSIGN -%left SEMI -%left START_BLOCK END_BLOCK -%left START_C_BLOCK END_C_BLOCK - -%% - -start: IDENTIFIER ASSIGN NUMBER SEMI { printf("%s = %d", $1, $3); /*parse_result = */} ; - -%% - - -#if 0 // For testing the parser independently -extern "C" void set_lex_input(char *str); - -int main(int argc, char *argv[]) -{ - int ret; - - char str[512]; - printf("here> "); - gets(str); - - set_lex_input(str); - - ret = yyparse(); - - printf("Returned: %d\n", ret); - return 0; -} -#endif - -void yyerror(char *s) -{ - fprintf(stderr, "Error on command line: %s\n",s); -} diff --git a/dynC_API/src/cmdline.l b/dynC_API/src/cmdline.l deleted file mode 100644 index 6cd677a..0000000 --- a/dynC_API/src/cmdline.l +++ /dev/null @@ -1,190 +0,0 @@ -%option noyywrap - -%{ - -#include -#include "BPatch_snippet.h" -#include "dyner.tab.h" - -extern "C" { -void set_lex_input(char *); -} - -static char *input_str = NULL; - -#ifdef FLEX_SCANNER -#undef YY_INPUT - -#define YY_INPUT(b,r,ms) (r = my_yyinput(b, ms)) - -int my_yyinput(char *buf, int max_size); - -#else -#undef input -#undef unput - -#define input() (*input_str++) -#define unput(c) (*--input_str = c) - -#endif - -static int yyinput(void); -static void yyunput(int, char *); - -void yyunput_wrapper(int i, char *s) -{ - yyunput(i, s); -} - - -static int doubleQuote() -{ - int count; - char ch; - bool backSlash = false; - - count = 0; - while (1) { - ch = yyinput(); - yyleng++; - switch (ch) { - case '"': - if (backSlash) { - /* \" */ - yytext[count++] = '"'; - } else { - --yyleng; - yytext[count] = '\0'; // eating up the string - dynerlval.sval = strdup(yytext); - return(STRING); - } - break; - - case '\n': - /* New line before end of string */ - return(_ERROR); // Why? Cant a string take up more than one line? - break; - - case '\\': - yytext[count++] = ch; - backSlash = true; - break; - - case 'n': - if (backSlash) { - yytext[count-1] = '\n'; - } else { - yytext[count++] = ch; - } - backSlash = false; - break; - - default: - yytext[count++] = ch; - backSlash = false; - break; - } - } -} - -%} - -%% - -if { return IF; } - -else { return ELSE; } - -true { return TRUE; } - -false { return FALSE; } - -int|float|double|char { dynerlval.sval = strdup(yytext); return TYPE; } - -[0-9]+ { dynerlval.ival = atoi(yytext); return NUMBER; } - -[A-za-z][A-Za-z0-9_]* { dynerlval.sval = strdup(yytext); return IDENTIFIER; } - -\* { return ASTERISK; } - -"&" { return AMPERSAND; } - -\<= { return LESS_EQ; } - -\>= { return GREATER_EQ; } - -"==" { return EQ; } - -"," { return COMMA; } - -"=" { return ASSIGN; } - -"!=" { return NOT_EQ; } - -\{ { return START_BLOCK; } - -\} { return END_BLOCK; } - -\$ { return DOLLAR; } - -\. { return DOT; } - -";" { return SEMI; } - -":" { return COLON; } - -"?" { return QUESTION_MARK; } - -"%" { return yytext[0]; } - -"+=" { return ADD_ASSIGN; } - -"-=" { return SUB_ASSIGN; } - -"*=" { return MUL_ASSIGN; } - -"/=" { return DIV_ASSIGN; } - -"%=" { return MOD_ASSIGN; } - -[()<>+*/-] { return yytext[0]; } - -"&&" { return AND; } - -\|\| { return OR; } - -[ \t\n]+ { /* Nothing */; } - -\" { int ret; ret = doubleQuote(); return(ret); } - -"++" { return PLUSPLUS; } - -"--" { return MINUSMINUS; } - -. { return _ERROR; } - -%% - -void set_lex_input(char *str) -{ - static int firstCall = 1; - - input_str = str; - - if (!firstCall) yy_flush_buffer(YY_CURRENT_BUFFER); - firstCall = 0; -} - -#ifdef FLEX_SCANNER -int my_yyinput(char *buf, int max_size) -{ - int sz = 0; - - while (*input_str != '\0' && sz < max_size) { - *buf++ = *input_str++; - sz++; - } - - return sz; -} -#endif diff --git a/dynC_API/src/cmdline.y b/dynC_API/src/cmdline.y deleted file mode 100644 index 172fb5b..0000000 --- a/dynC_API/src/cmdline.y +++ /dev/null @@ -1,478 +0,0 @@ -%{ -#if defined(i386_unknown_nt4_0) -#include -#include -#endif - -/* - * Yacc will define token IF, conflicting with dyn_regs.h - * This undef is safe b/c yacc also creates an enum IF - * which serves the same purpose. -*/ -#undef IF - -#include "BPatch_thread.h" -#include "BPatch_image.h" -#include "BPatch_type.h" -#include "BPatch_snippet.h" -#include "breakpoint.h" - -extern "C" { -void yyerror(char *s); -int yyparse(void); -} - -const bool verbose = true; - -int yylex(); - -BPatch_snippet *parse_result; -parse_ret parse_type; - -%} - -%union { - int ival; - long lval; - double dval; - char *sval; - - BPatch_snippet *snippet; - BPatch_boolExpr *boolExpr; - BPatch_Vector *snippetList; - BPatch_funcCallExpr *funcCall; - BPatch_variableExpr *varExpr; -}; - - -%token TYPE IDENTIFIER STRING -%token NUMBER -%token TRUE FALSE -%token QUESTION_MARK COLON -%token _ERROR IF ELSE -%token PLUSPLUS MINUSMINUS - -%left DOT DOLLAR ASTERISK AMPERSAND -%left NOT -%left OR -%left AND -%left EQ NOT_EQ LESS_EQ GREATER_EQ -%left ASSIGN ADD_ASSIGN SUB_ASSIGN DIV_ASSIGN MUL_ASSIGN MOD_ASSIGN -%left '?' -%left ':' -%left '+' '-' -%left '*' '/' '%' -%left COMMA -%left SEMI -%left START_BLOCK END_BLOCK - -%type bool_expression bool_constant -%type arith_expression statement inc_decr_expr -%type param block -%type param_list statement_list -%type func_call -%type variable_expr - - -%% - -start: - '(' bool_expression ')' - { - if(verbose) printf(" \n"); - parse_result = $2; - parse_type = parsed_bool; - } - | statement_list - { - parse_result = new BPatch_sequence(*$1); - parse_type = parsed_statement; - delete $1; - } - ; - -statement_list: - statement - { - if(verbose) printf("\n"); - $$ = new BPatch_Vector; - $$->push_back($1); - } - | statement_list statement - { - $1->push_back($2); - $$ = $1; - } - ; - -statement: - // 1 + 2; - arith_expression SEMI - { - $$ = $1; - } - // if (x == y) {} - | IF '(' bool_expression ')' block - { - if(verbose) printf(" if () "); - $$ = new BPatch_ifExpr(*$3, *$5); - delete $3; - delete $5; - } - // if (x == y) {} else {} - | IF '(' bool_expression ')' block ELSE block - { - if(verbose) printf(" if () else "); - $$ = new BPatch_ifExpr(*$3, *$5, *$7); - delete $3; - delete $5; - delete $7; - } - ; - -block: statement - // {stuff} - | START_BLOCK statement_list END_BLOCK - { - $$ = new BPatch_sequence(*$2); - delete $2; - } - ; - -func_call: IDENTIFIER '(' param_list ')' - //funct(stuff,stuff) - { - if(verbose) printf(" %s () ", $1); - BPatch_Vectorbpfv; - if (NULL == appImage->findFunction($1, bpfv) || !bpfv.size()) { - printf("unable to find function %s\n", $1); - free($1); - return 1; - } - if (bpfv.size() > 1) { -// make this non verbose -- have it return errors through proper channels or as part of generated code. - printf("found %d references to %s\n", (int) bpfv.size(), $1); - } - - BPatch_function *func = bpfv[0]; - - if (!func) { - printf("unable to find function %s\n", $1); - free($1); - return 1; - } - - free($1); - $$ = new BPatch_funcCallExpr(*func, *$3); - delete $3; - } - ; - -param_list: - //() - { - //No parameters, return an empty vector - $$ = new BPatch_Vector; - } - //(stuff) - | param - { - $$ = new BPatch_Vector; - $$->push_back($1); - } - //(stuff,stuff) - | param_list COMMA param - { - if(verbose) printf(" , "); - $1->push_back($3); - $$ = $1; - } - ; - -param: arith_expression //funct(2+5) - //funct("hi") - | STRING { - $$ = new BPatch_constExpr($1); - } - ; - -bool_constant: TRUE - { - $$ = new BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(0)); - } - | FALSE - { - $$ = new BPatch_boolExpr(BPatch_ne, BPatch_constExpr(0), BPatch_constExpr(0)); - } - ; - -bool_expression: bool_constant - |arith_expression '<' arith_expression - { - if(verbose) printf(" < "); - $$ = new BPatch_boolExpr(BPatch_lt, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression '>' arith_expression - { - if(verbose) printf(" > "); - $$ = new BPatch_boolExpr(BPatch_gt, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression EQ arith_expression - { - if(verbose) printf(" == "); - $$ = new BPatch_boolExpr(BPatch_eq, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression LESS_EQ arith_expression - { - if(verbose) printf(" <= "); - $$ = new BPatch_boolExpr(BPatch_le, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression GREATER_EQ arith_expression - { - if(verbose) printf(" >= "); - $$ = new BPatch_boolExpr(BPatch_ge, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression NOT_EQ arith_expression - { - if(verbose) printf(" != "); - $$ = new BPatch_boolExpr(BPatch_ne, *$1, *$3); - delete $1; - delete $3; - } - | bool_expression AND bool_expression - { - if(verbose) printf(" AND "); - $$ = new BPatch_boolExpr(BPatch_and, *$1, *$3); - delete $1; - delete $3; - } - | bool_expression OR bool_expression - { if(verbose) printf(" OR "); - $$ = new BPatch_boolExpr(BPatch_or, *$1, *$3); - delete $1; - delete $3; - } - // add not - ; - -variable_expr: IDENTIFIER - { - BPatch_variableExpr *var = findVariable($1); - if (var == NULL) { - fprintf(stderr, "Cannot find variable: %s\n", $1); - free($1); - return 1; - $$ = NULL; - } - if(verbose) printf(" var(%s) ", $1); - free($1); - $$ = var; - } - | IDENTIFIER DOT IDENTIFIER - { - bool foundField = false; - - BPatch_variableExpr *var = findVariable($1); - if (var == NULL) { - fprintf(stderr, "Cannot find variable: %s\n", $1); - free($1); - return 1; - } - - BPatch_Vector *vars = var->getComponents(); - if (!vars) { - fprintf(stderr, "is not an aggregate type: %s\n", $1); - free($1); - return 1; - } - for (unsigned int i=0; i < vars->size(); i++) { - if (!strcmp($3, (*vars)[i]->getName())) { - $$ = (*vars)[i]; - foundField = true; - } - } - - if (!foundField) { - fprintf(stderr, "%s is not a field of %s\n", $3, $1); - free($1); - return 1; - } - - free($1); - } - ; -/* - | DOLLAR NUMBER - { - if (($2 < 0) || ($2 >= 8)) { - printf("parameter %d is not valid\n", $2); - return 1; - } - $$ = new BPatch_paramExpr($2); - } - ; -*/ -arith_expression: variable_expr { $$ = (BPatch_snippet *)$1;} - | bool_expression '?' arith_expression ':' arith_expression - { - //can't allow arith_expressions that don't return a val, i.e. assigns - //type checking ? - // throw away expression: - BPatch_arithExpr retExpr = BPatch_arithExpr(BPatch_negate, BPatch_constExpr(1)); - BPatch_arithExpr assignFirst = BPatch_arithExpr(BPatch_assign, retExpr, *$3); - BPatch_arithExpr assignSecond = BPatch_arithExpr(BPatch_assign, retExpr, *$5); - - $$ = new BPatch_arithExpr(BPatch_seq, BPatch_ifExpr(*$1, assignFirst, assignSecond), retExpr); - } - | NUMBER { if(verbose) printf(" %d ", $1); $$ = new BPatch_constExpr($1);} - | arith_expression '*' arith_expression - { - if(verbose) printf(" * "); - $$ = new BPatch_arithExpr(BPatch_times, *$1, *$3); - delete $1; - delete $3; - } - | func_call {$$ = $1;} - | variable_expr ASSIGN arith_expression - { - if(verbose) printf(" = "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, *$3); - delete $1; - delete $3; - } - - | variable_expr ADD_ASSIGN arith_expression - { - if(verbose) printf(" += "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_plus, *$1, *$3)); - delete $1; - delete $3; - } - | variable_expr SUB_ASSIGN arith_expression - { - if(verbose) printf(" -= "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_minus, *$1, *$3)); - delete $1; - delete $3; - } - | variable_expr MUL_ASSIGN arith_expression - { - if(verbose) printf(" *= "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_times, *$1, *$3)); - delete $1; - delete $3; - } - | variable_expr DIV_ASSIGN arith_expression - { - if(verbose) printf(" /= "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_divide, *$1, *$3)); - delete $1; - delete $3; - } - | variable_expr MOD_ASSIGN arith_expression - { - if(verbose) printf(" %%= "); - $$ = new BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_minus, *$1, BPatch_arithExpr(BPatch_times, BPatch_arithExpr(BPatch_divide, *$1, *$3), *$3))); - delete $1; - delete $3; - } - - | arith_expression '/' arith_expression - { - if(verbose) printf(" / "); - $$ = new BPatch_arithExpr(BPatch_divide, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression '%' arith_expression - { - if(verbose) printf(" %% "); - $$ = new BPatch_arithExpr(BPatch_minus, *$1, BPatch_arithExpr(BPatch_times, BPatch_arithExpr(BPatch_divide, *$1, *$3), *$3)); - delete $1; - delete $3; - } - | arith_expression '+' arith_expression - { - if(verbose) printf(" + "); - $$ = new BPatch_arithExpr(BPatch_plus, *$1, *$3); - delete $1; - delete $3; - } - | arith_expression '-' arith_expression - { - if(verbose) printf(" - "); - $$ = new BPatch_arithExpr(BPatch_minus, *$1, *$3); - delete $1; - delete $3; - } - | '(' arith_expression ')' {$$ = $2;} - | inc_decr_expr {$$ = $1;} - - ; - -inc_decr_expr: - variable_expr PLUSPLUS - { - if(verbose) printf(" <++ "); - BPatch_arithExpr addOne = BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_plus, *$1, BPatch_constExpr(1))); - $$ = new BPatch_arithExpr(BPatch_seq, (BPatch_snippet &)addOne, BPatch_arithExpr(BPatch_minus, *$1, BPatch_constExpr(1))); - } - | PLUSPLUS variable_expr - { - if(verbose) printf(" ++> "); - BPatch_arithExpr addOne = BPatch_arithExpr(BPatch_assign, *$2, BPatch_arithExpr(BPatch_plus, *$2, BPatch_constExpr(1))); - $$ = new BPatch_arithExpr(BPatch_seq, (BPatch_snippet &)addOne, *$2); - } - | variable_expr MINUSMINUS - { - if(verbose) printf(" -- "); - BPatch_arithExpr subOne = BPatch_arithExpr(BPatch_assign, *$1, BPatch_arithExpr(BPatch_minus, *$1, BPatch_constExpr(1))); - $$ = new BPatch_arithExpr(BPatch_seq, (BPatch_snippet &)subOne, BPatch_arithExpr(BPatch_plus, *$1, BPatch_constExpr(1))); - } - | MINUSMINUS variable_expr - { - if(verbose) printf(" -- "); - BPatch_arithExpr subOne = BPatch_arithExpr(BPatch_assign, *$2, BPatch_arithExpr(BPatch_minus, *$2, BPatch_constExpr(1))); - $$ = new BPatch_arithExpr(BPatch_seq, (BPatch_snippet &)subOne, *$2); - } - ; - -%% - - -#if 0 // For testing the parser independently -extern "C" void set_lex_input(char *str); - -main(int argc, char *argv[]) -{ - int ret; - - char str[512]; - printf("here> "); - gets(str); - - set_lex_input(str); - - ret = yyparse(); - - printf("Returned: %d\n", ret); -} -#endif - - - -void yyerror(char *s) -{ - fflush(stderr); - fprintf(stderr, "Error on command line: %s\n",s); -} diff --git a/dynC_API/src/dynC.tab.C b/dynC_API/src/dynC.tab.C index 5b6a9a2..874b362 100644 --- a/dynC_API/src/dynC.tab.C +++ b/dynC_API/src/dynC.tab.C @@ -83,8 +83,8 @@ ERROR = 264, EOL = 265, SIZEOF = 266, - TRUE = 267, - FALSE = 268, + D_TRUE = 267, + D_FALSE = 268, PTR_OP = 269, INC_OP = 270, DEC_OP = 271, @@ -168,8 +168,8 @@ #define ERROR 264 #define EOL 265 #define SIZEOF 266 -#define TRUE 267 -#define FALSE 268 +#define D_TRUE 267 +#define D_FALSE 268 #define PTR_OP 269 #define INC_OP 270 #define DEC_OP 271 @@ -719,15 +719,15 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 157, 157, 172, 195, 219, 255, 294, 350, 355, - 427, 433, 438, 446, 456, 461, 467, 472, 483, 491, - 502, 504, 511, 528, 548, 553, 559, 568, 572, 579, - 580, 585, 590, 595, 600, 605, 610, 615, 625, 631, - 637, 658, 669, 681, 694, 705, 717, 731, 760, 787, - 814, 835, 857, 881, 909, 915, 924, 930, 936, 937, - 938, 939, 1013, 1019, 1024, 1030, 1036, 1042, 1048, 1054, - 1060, 1066, 1072, 1078, 1084, 1093, 1094, 1103, 1109, 1115, - 1121 + 0, 157, 157, 172, 195, 215, 251, 290, 346, 351, + 423, 429, 434, 442, 452, 457, 463, 468, 479, 487, + 498, 500, 507, 524, 544, 549, 555, 564, 568, 575, + 576, 581, 586, 591, 596, 601, 606, 611, 621, 627, + 633, 654, 665, 677, 690, 701, 713, 727, 756, 783, + 810, 831, 853, 877, 905, 911, 920, 926, 932, 933, + 934, 935, 1009, 1015, 1020, 1026, 1032, 1038, 1044, 1050, + 1056, 1062, 1068, 1074, 1080, 1089, 1090, 1099, 1105, 1111, + 1117 }; #endif @@ -737,8 +737,8 @@ static const yytype_uint16 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "KNOWN_ERROR_TOK", "IDENTIFIER", - "CONSTANT", "STRING", "TYPE", "NUMBER", "ERROR", "EOL", "SIZEOF", "TRUE", - "FALSE", "PTR_OP", "INC_OP", "DEC_OP", "LEFT_OP", "RIGHT_OP", + "CONSTANT", "STRING", "TYPE", "NUMBER", "ERROR", "EOL", "SIZEOF", + "D_TRUE", "D_FALSE", "PTR_OP", "INC_OP", "DEC_OP", "LEFT_OP", "RIGHT_OP", "LEFT_ASSIGN", "RIGHT_ASSIGN", "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "TYPE_NAME", "TYPEDEF", "EXTERN", "STATIC", "CHAR", "SHORT", "INT", "LONG", "SIGNED", "UNSIGNED", "FLOAT", "DOUBLE", "CONST", "VOID", @@ -1851,7 +1851,7 @@ yyreduce: //IDENTIFIER leaks, but how to fix b/c use of $0? std::string mangledName; mangledName = dynC_API::mangle((yyvsp[(2) - (2)].sval), dynCSnippetName, (yyvsp[(1) - (2)].varSpec).type); - printf("name : %s\n", mangledName.c_str()); + if(verbose) printf("name : %s\n", mangledName.c_str()); (yyval.snippet) = snippetGen->findOrCreateVariable(mangledName.c_str(), (yyvsp[(1) - (2)].varSpec).type); if((yyval.snippet) == NULL){ (yyval.snippet) = new BPatch_nullExpr(); @@ -1876,7 +1876,7 @@ yyreduce: { std::string mangledName = dynC_API::mangle((yyvsp[(2) - (4)].sval), dynCSnippetName, (yyvsp[(1) - (4)].varSpec).type); - printf("name : %s\n", mangledName.c_str()); + if(verbose) printf("name : %s\n", mangledName.c_str()); BPatch_snippet *alloc = snippetGen->findOrCreateVariable(mangledName.c_str(), (yyvsp[(1) - (4)].varSpec).type); if(alloc == NULL){ (yyval.snippet) = new BPatch_nullExpr(); @@ -1890,16 +1890,12 @@ yyreduce: if((yyvsp[(1) - (4)].varSpec).isStatic || (yyvsp[(1) - (4)].varSpec).isGlobal){ makeOneTimeStatementGbl(*(yyval.snippet)); - } - - //david changed this: - //makeOneTimeStatement(*$$); - + } ;} break; case 5: -#line 220 "../src/C.y" +#line 216 "../src/C.y" { //IDENTIFIER leaks, but how to fix b/c use of $0? if((yyvsp[(4) - (5)].ival) < 0){ @@ -1938,7 +1934,7 @@ yyreduce: break; case 6: -#line 256 "../src/C.y" +#line 252 "../src/C.y" { //IDENTIFIER leaks, but how to fix b/c use of $0? std::stringstream type; @@ -1980,7 +1976,7 @@ yyreduce: break; case 7: -#line 295 "../src/C.y" +#line 291 "../src/C.y" { //IDENTIFIER leaks, but how to fix b/c use of $0? std::vector argVect; @@ -2037,7 +2033,7 @@ yyreduce: break; case 8: -#line 351 "../src/C.y" +#line 347 "../src/C.y" { YYSTYPE::VariableSpec rSpec = {false,false,false,false,false,false,false,false,(yyvsp[(1) - (1)].sval)}; (yyval.varSpec) = rSpec; @@ -2045,7 +2041,7 @@ yyreduce: break; case 9: -#line 356 "../src/C.y" +#line 352 "../src/C.y" { if ((yyvsp[(2) - (2)].varSpec).isStatic){ //throw error: two static @@ -2058,7 +2054,7 @@ yyreduce: break; case 10: -#line 428 "../src/C.y" +#line 424 "../src/C.y" { if(verbose) printf("\n"); (yyval.snippetList) = new BPatch_Vector; @@ -2067,7 +2063,7 @@ yyreduce: break; case 11: -#line 434 "../src/C.y" +#line 430 "../src/C.y" { (yyvsp[(1) - (2)].snippetList)->push_back((yyvsp[(2) - (2)].snippet)); (yyval.snippetList) = (yyvsp[(1) - (2)].snippetList); @@ -2075,7 +2071,7 @@ yyreduce: break; case 12: -#line 439 "../src/C.y" +#line 435 "../src/C.y" { BPatch_sequence *seq = new BPatch_sequence(*(yyvsp[(2) - (3)].snippetList)); makeOneTimeStatementGbl(*seq); @@ -2086,7 +2082,7 @@ yyreduce: break; case 13: -#line 447 "../src/C.y" +#line 443 "../src/C.y" { BPatch_sequence seq = BPatch_sequence(*(yyvsp[(3) - (4)].snippetList)); makeOneTimeStatementGbl(seq); @@ -2096,7 +2092,7 @@ yyreduce: break; case 14: -#line 457 "../src/C.y" +#line 453 "../src/C.y" { (yyval.snippet) = new BPatch_nullExpr(); actionTaken = false; @@ -2104,7 +2100,7 @@ yyreduce: break; case 15: -#line 462 "../src/C.y" +#line 458 "../src/C.y" { yyerrorNoTok((yyvsp[(1) - (1)].context)); (yyval.snippet) = new BPatch_nullExpr(); @@ -2113,14 +2109,14 @@ yyreduce: break; case 16: -#line 468 "../src/C.y" +#line 464 "../src/C.y" { (yyval.snippet) = (yyvsp[(1) - (2)].snippet); ;} break; case 17: -#line 473 "../src/C.y" +#line 469 "../src/C.y" { if(!actionTaken){ yywarn("Statement does nothing!"); @@ -2133,7 +2129,7 @@ yyreduce: break; case 18: -#line 484 "../src/C.y" +#line 480 "../src/C.y" { if(verbose) printf(" if () "); (yyval.snippet) = new BPatch_ifExpr(*(yyvsp[(3) - (5)].boolExpr), *(yyvsp[(5) - (5)].snippet)); @@ -2143,7 +2139,7 @@ yyreduce: break; case 19: -#line 492 "../src/C.y" +#line 488 "../src/C.y" { if(verbose) printf(" if () else "); (yyval.snippet) = new BPatch_ifExpr(*(yyvsp[(3) - (7)].boolExpr), *(yyvsp[(5) - (7)].snippet), *(yyvsp[(7) - (7)].snippet)); @@ -2154,7 +2150,7 @@ yyreduce: break; case 21: -#line 505 "../src/C.y" +#line 501 "../src/C.y" { (yyval.snippet) = new BPatch_sequence(*(yyvsp[(2) - (3)].snippetList)); delete (yyvsp[(2) - (3)].snippetList); @@ -2162,7 +2158,7 @@ yyreduce: break; case 22: -#line 512 "../src/C.y" +#line 508 "../src/C.y" { //TODO: built in dyninst actions and (future) other snippet calls? if(strcmp((yyvsp[(3) - (6)].sval), "break") == 0){ @@ -2181,7 +2177,7 @@ yyreduce: break; case 23: -#line 530 "../src/C.y" +#line 526 "../src/C.y" { BPatch_function *func = snippetGen->findFunction((yyvsp[(3) - (6)].sval), *(yyvsp[(5) - (6)].snippetList)); if(func == NULL){ @@ -2199,7 +2195,7 @@ yyreduce: break; case 24: -#line 548 "../src/C.y" +#line 544 "../src/C.y" { //No parameters, return an empty vector (yyval.snippetList) = new BPatch_Vector; @@ -2207,7 +2203,7 @@ yyreduce: break; case 25: -#line 554 "../src/C.y" +#line 550 "../src/C.y" { (yyval.snippetList) = new BPatch_Vector; (yyval.snippetList)->push_back((yyvsp[(1) - (1)].snippet)); @@ -2215,7 +2211,7 @@ yyreduce: break; case 26: -#line 560 "../src/C.y" +#line 556 "../src/C.y" { if(verbose) printf(" , "); (yyvsp[(1) - (3)].snippetList)->push_back((yyvsp[(3) - (3)].snippet)); @@ -2224,21 +2220,21 @@ yyreduce: break; case 27: -#line 569 "../src/C.y" +#line 565 "../src/C.y" { (yyval.boolExpr) = new BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(0)); ;} break; case 28: -#line 573 "../src/C.y" +#line 569 "../src/C.y" { (yyval.boolExpr) = new BPatch_boolExpr(BPatch_ne, BPatch_constExpr(0), BPatch_constExpr(0)); ;} break; case 30: -#line 581 "../src/C.y" +#line 577 "../src/C.y" { if(verbose) printf(" < "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_lt, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2246,7 +2242,7 @@ yyreduce: break; case 31: -#line 586 "../src/C.y" +#line 582 "../src/C.y" { if(verbose) printf(" > "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_gt, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2254,7 +2250,7 @@ yyreduce: break; case 32: -#line 591 "../src/C.y" +#line 587 "../src/C.y" { if(verbose) printf(" == "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_eq, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2262,7 +2258,7 @@ yyreduce: break; case 33: -#line 596 "../src/C.y" +#line 592 "../src/C.y" { if(verbose) printf(" <= "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_le, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2270,7 +2266,7 @@ yyreduce: break; case 34: -#line 601 "../src/C.y" +#line 597 "../src/C.y" { if(verbose) printf(" >= "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_ge, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2278,7 +2274,7 @@ yyreduce: break; case 35: -#line 606 "../src/C.y" +#line 602 "../src/C.y" { if(verbose) printf(" != "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_ne, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2286,7 +2282,7 @@ yyreduce: break; case 36: -#line 611 "../src/C.y" +#line 607 "../src/C.y" { if(verbose) printf(" AND "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_and, *(yyvsp[(1) - (3)].boolExpr), *(yyvsp[(3) - (3)].boolExpr)); @@ -2294,14 +2290,14 @@ yyreduce: break; case 37: -#line 616 "../src/C.y" +#line 612 "../src/C.y" { if(verbose) printf(" OR "); (yyval.boolExpr) = new BPatch_boolExpr(BPatch_or, *(yyvsp[(1) - (3)].boolExpr), *(yyvsp[(3) - (3)].boolExpr)); ;} break; case 38: -#line 626 "../src/C.y" +#line 622 "../src/C.y" { YYSTYPE::VariableSpec vSpec = {false,false,false,false,false,false,false,false,""}; vSpec.isGlobal = true; @@ -2310,7 +2306,7 @@ yyreduce: break; case 39: -#line 632 "../src/C.y" +#line 628 "../src/C.y" { YYSTYPE::VariableSpec vSpec = {false,false,false,false,false,false,false,false,""}; vSpec.isLocal = true; @@ -2319,7 +2315,7 @@ yyreduce: break; case 40: -#line 638 "../src/C.y" +#line 634 "../src/C.y" { YYSTYPE::VariableSpec vSpec = {false,false,false,false,false,false,false,false,""}; vSpec.isParam = true; @@ -2328,7 +2324,7 @@ yyreduce: break; case 41: -#line 659 "../src/C.y" +#line 655 "../src/C.y" { (yyval.snippet) = snippetGen->findInstVariable(dynC_API::getMangledStub((yyvsp[(1) - (1)].sval), dynCSnippetName).c_str(), (yyvsp[(1) - (1)].sval)); if((yyval.snippet) == NULL){ @@ -2342,7 +2338,7 @@ yyreduce: break; case 42: -#line 670 "../src/C.y" +#line 666 "../src/C.y" { (yyval.snippet) = snippetGen->findInstVariable(dynC_API::getMangledStub((yyvsp[(2) - (2)].sval), dynCSnippetName).c_str(), (yyvsp[(2) - (2)].sval)); if((yyval.snippet) == NULL){ @@ -2357,7 +2353,7 @@ yyreduce: break; case 43: -#line 682 "../src/C.y" +#line 678 "../src/C.y" { (yyval.snippet) = snippetGen->findInstVariable(dynC_API::getMangledStub((yyvsp[(2) - (2)].sval), dynCSnippetName).c_str(), (yyvsp[(2) - (2)].sval)); if((yyval.snippet) == NULL){ @@ -2372,7 +2368,7 @@ yyreduce: break; case 44: -#line 695 "../src/C.y" +#line 691 "../src/C.y" { (yyval.snippet) = snippetGen->findAppVariable((yyvsp[(3) - (3)].sval)); if((yyval.snippet) == NULL){ @@ -2386,7 +2382,7 @@ yyreduce: break; case 45: -#line 706 "../src/C.y" +#line 702 "../src/C.y" { (yyval.snippet) = snippetGen->findAppVariable((yyvsp[(4) - (4)].sval)); if((yyval.snippet) == NULL){ @@ -2401,7 +2397,7 @@ yyreduce: break; case 46: -#line 718 "../src/C.y" +#line 714 "../src/C.y" { (yyval.snippet) = snippetGen->findAppVariable((yyvsp[(4) - (4)].sval)); if((yyval.snippet) == NULL){ @@ -2416,7 +2412,7 @@ yyreduce: break; case 47: -#line 732 "../src/C.y" +#line 728 "../src/C.y" { //disallowed if there is no point specifier if(!(yyvsp[(1) - (3)].varSpec).isGlobal && snippetPoint == NULL){ @@ -2448,7 +2444,7 @@ yyreduce: break; case 48: -#line 761 "../src/C.y" +#line 757 "../src/C.y" { if(snippetPoint == NULL){ yyerrorNoTok("Local variables not allowed when snippet point is unspecified."); @@ -2477,7 +2473,7 @@ yyreduce: break; case 49: -#line 788 "../src/C.y" +#line 784 "../src/C.y" { if(snippetPoint == NULL){ yyerrorNoTok("Local variables not allowed when snippet point is unspecified."); @@ -2506,7 +2502,7 @@ yyreduce: break; case 50: -#line 815 "../src/C.y" +#line 811 "../src/C.y" { //special case for indexed parameters if(snippetPoint == NULL){ @@ -2530,7 +2526,7 @@ yyreduce: break; case 51: -#line 836 "../src/C.y" +#line 832 "../src/C.y" { //special case for indexed parameters if(snippetPoint == NULL){ @@ -2555,7 +2551,7 @@ yyreduce: break; case 52: -#line 858 "../src/C.y" +#line 854 "../src/C.y" { //special case for indexed parameters if(snippetPoint == NULL){ @@ -2581,7 +2577,7 @@ yyreduce: break; case 53: -#line 882 "../src/C.y" +#line 878 "../src/C.y" { //array referance //check for integer in arith_expression @@ -2597,7 +2593,7 @@ yyreduce: break; case 54: -#line 910 "../src/C.y" +#line 906 "../src/C.y" { if(verbose) printf(" %d ", (yyvsp[(1) - (1)].ival)); BPatch_snippet * c = new BPatch_constExpr((yyvsp[(1) - (1)].ival)); @@ -2606,7 +2602,7 @@ yyreduce: break; case 55: -#line 916 "../src/C.y" +#line 912 "../src/C.y" { if(verbose) printf(" %s ", (yyvsp[(1) - (1)].sval)); BPatch_snippet * c = new BPatch_constExpr((yyvsp[(1) - (1)].sval)); @@ -2615,7 +2611,7 @@ yyreduce: break; case 56: -#line 925 "../src/C.y" +#line 921 "../src/C.y" { std::vector > *cnlist = new std::vector >(); cnlist->push_back(*(yyvsp[(1) - (1)].snippetStringPair)); @@ -2624,7 +2620,7 @@ yyreduce: break; case 57: -#line 931 "../src/C.y" +#line 927 "../src/C.y" { (yyvsp[(1) - (3)].snippetStringListPair)->push_back(*(yyvsp[(3) - (3)].snippetStringPair)); (yyval.snippetStringListPair) = (yyvsp[(1) - (3)].snippetStringListPair); @@ -2632,17 +2628,17 @@ yyreduce: break; case 59: -#line 937 "../src/C.y" +#line 933 "../src/C.y" {(yyval.snippet) = (yyvsp[(1) - (1)].snippetStringPair)->first;} break; case 60: -#line 938 "../src/C.y" +#line 934 "../src/C.y" {(yyval.snippet) = new BPatch_nullExpr();;} break; case 61: -#line 940 "../src/C.y" +#line 936 "../src/C.y" { if(verbose) printf("dyninst`%s ", (yyvsp[(3) - (3)].sval)); @@ -2719,7 +2715,7 @@ yyreduce: break; case 62: -#line 1014 "../src/C.y" +#line 1010 "../src/C.y" { if(verbose) printf(" * "); (yyval.snippet) = new BPatch_arithExpr(BPatch_times, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2728,7 +2724,7 @@ yyreduce: break; case 63: -#line 1020 "../src/C.y" +#line 1016 "../src/C.y" { (yyval.snippet) = (yyvsp[(1) - (1)].snippet); actionTaken = true; @@ -2736,7 +2732,7 @@ yyreduce: break; case 64: -#line 1025 "../src/C.y" +#line 1021 "../src/C.y" { if(verbose) printf(" = "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2745,7 +2741,7 @@ yyreduce: break; case 65: -#line 1031 "../src/C.y" +#line 1027 "../src/C.y" { if(verbose) printf(" += "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_plus, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet))); @@ -2754,7 +2750,7 @@ yyreduce: break; case 66: -#line 1037 "../src/C.y" +#line 1033 "../src/C.y" { if(verbose) printf(" -= "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_minus, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet))); @@ -2763,7 +2759,7 @@ yyreduce: break; case 67: -#line 1043 "../src/C.y" +#line 1039 "../src/C.y" { if(verbose) printf(" *= "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_times, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet))); @@ -2772,7 +2768,7 @@ yyreduce: break; case 68: -#line 1049 "../src/C.y" +#line 1045 "../src/C.y" { if(verbose) printf(" /= "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_divide, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet))); @@ -2781,7 +2777,7 @@ yyreduce: break; case 69: -#line 1055 "../src/C.y" +#line 1051 "../src/C.y" { if(verbose) printf(" %%= "); (yyval.snippet) = new BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_minus, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_times, BPatch_arithExpr(BPatch_divide, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)), *(yyvsp[(3) - (3)].snippet)))); @@ -2790,7 +2786,7 @@ yyreduce: break; case 70: -#line 1061 "../src/C.y" +#line 1057 "../src/C.y" { if(verbose) printf(" / "); (yyval.snippet) = new BPatch_arithExpr(BPatch_divide, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2799,7 +2795,7 @@ yyreduce: break; case 71: -#line 1067 "../src/C.y" +#line 1063 "../src/C.y" { if(verbose) printf(" %% "); (yyval.snippet) = new BPatch_arithExpr(BPatch_minus, *(yyvsp[(1) - (3)].snippet), BPatch_arithExpr(BPatch_times, BPatch_arithExpr(BPatch_divide, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)), *(yyvsp[(3) - (3)].snippet))); @@ -2808,7 +2804,7 @@ yyreduce: break; case 72: -#line 1073 "../src/C.y" +#line 1069 "../src/C.y" { if(verbose) printf(" + "); (yyval.snippet) = new BPatch_arithExpr(BPatch_plus, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2817,7 +2813,7 @@ yyreduce: break; case 73: -#line 1079 "../src/C.y" +#line 1075 "../src/C.y" { if(verbose) printf(" - "); (yyval.snippet) = new BPatch_arithExpr(BPatch_minus, *(yyvsp[(1) - (3)].snippet), *(yyvsp[(3) - (3)].snippet)); @@ -2826,7 +2822,7 @@ yyreduce: break; case 74: -#line 1085 "../src/C.y" +#line 1081 "../src/C.y" { if(dynamic_cast((yyvsp[(1) - (3)].snippet))){ printf("Picked second\n"); @@ -2838,12 +2834,12 @@ yyreduce: break; case 75: -#line 1093 "../src/C.y" +#line 1089 "../src/C.y" {(yyval.snippet) = (yyvsp[(2) - (3)].snippet);;} break; case 76: -#line 1095 "../src/C.y" +#line 1091 "../src/C.y" { (yyval.snippet) = (yyvsp[(1) - (1)].snippet); actionTaken = true; @@ -2851,7 +2847,7 @@ yyreduce: break; case 77: -#line 1104 "../src/C.y" +#line 1100 "../src/C.y" { if(verbose) printf(" ++ "); BPatch_arithExpr addOne = BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (2)].snippet), BPatch_arithExpr(BPatch_plus, *(yyvsp[(1) - (2)].snippet), BPatch_constExpr(1))); @@ -2860,7 +2856,7 @@ yyreduce: break; case 78: -#line 1110 "../src/C.y" +#line 1106 "../src/C.y" { if(verbose) printf(" ++ "); BPatch_arithExpr addOne = BPatch_arithExpr(BPatch_assign, *(yyvsp[(2) - (2)].snippet), BPatch_arithExpr(BPatch_plus, *(yyvsp[(2) - (2)].snippet), BPatch_constExpr(1))); @@ -2869,7 +2865,7 @@ yyreduce: break; case 79: -#line 1116 "../src/C.y" +#line 1112 "../src/C.y" { if(verbose) printf(" -- "); BPatch_arithExpr subOne = BPatch_arithExpr(BPatch_assign, *(yyvsp[(1) - (2)].snippet), BPatch_arithExpr(BPatch_minus, *(yyvsp[(1) - (2)].snippet), BPatch_constExpr(1))); @@ -2878,7 +2874,7 @@ yyreduce: break; case 80: -#line 1122 "../src/C.y" +#line 1118 "../src/C.y" { if(verbose) printf(" -- "); BPatch_arithExpr subOne = BPatch_arithExpr(BPatch_assign, *(yyvsp[(2) - (2)].snippet), BPatch_arithExpr(BPatch_minus, *(yyvsp[(2) - (2)].snippet), BPatch_constExpr(1))); @@ -2888,7 +2884,7 @@ yyreduce: /* Line 1267 of yacc.c. */ -#line 2892 "dynC.tab.c" +#line 2888 "dynC.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3108,7 +3104,7 @@ yyreturn: } -#line 1129 "../src/C.y" +#line 1125 "../src/C.y" #include diff --git a/dynC_API/src/lex.dynC.C b/dynC_API/src/lex.dynC.C index 440063f..b0b6078 100644 --- a/dynC_API/src/lex.dynC.C +++ b/dynC_API/src/lex.dynC.C @@ -1287,12 +1287,12 @@ YY_RULE_SETUP case 22: YY_RULE_SETUP #line 87 "../src/C.l" -{ return(TRUE); } +{ return(D_TRUE); } YY_BREAK case 23: YY_RULE_SETUP #line 88 "../src/C.l" -{ return(FALSE); } +{ return(D_FALSE); } YY_BREAK case 24: YY_RULE_SETUP diff --git a/dynC_API/src/symtab.h b/dynC_API/src/symtab.h deleted file mode 100644 index 87aae1b..0000000 --- a/dynC_API/src/symtab.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 1996-2011 Barton P. Miller - * - * We provide the Paradyn Parallel Performance Tools (below - * described as "Paradyn") on an AS IS basis, and do not warrant its - * validity or performance. We reserve the right to update, modify, - * or discontinue this software at any time. We shall have no - * obligation to supply such updates or modifications or any other - * form of support to you. - * - * By your use of Paradyn, you understand and agree that we (or any - * other person or entity with proprietary rights in Paradyn) are - * under no obligation to provide either maintenance services, - * update services, notices of latent defects, or correction of - * defects for Paradyn. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -//symtab.h - -#ifndef SYMBOLTABLE_H -#define SYMBOLTABLE_H - -#include "BPatch_snippet.h" -#include "BPatch_type.h" -#include "BPatch_point.h" - -#include -#include - -typedef enum symbolKind {ST_userVar, ST_internalVar, ST_snippet, ST_boolean, ST_mutateeVar, ST_function, ST_cFunction}; - -enum Scope {LOCAL_, GLOBAL_MUTATEE_, GLOBAL_MUTATOR_}; - -enum varType {VT_string, VT_int, VT_long, VT_double, VT_bool}; - -enum insertActions {get_local_var}; - -class ST_Entry{ - - public: - ST_Entry(){}; - ~ST_Entry(){}; -//variable constructors - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_){ - ST_Entry(); - kind = kind_; - type = type_; - varExpr = varExpr_; - }; - - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_, char *value_) {ST_Entry(kind_, varExpr_, type_); vtype = VT_string; varValue.sval = strdup(value_);} - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_, int value_) {ST_Entry(kind_, varExpr_, type_); vtype = VT_int; varValue.ival = value_;}; - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_, long value_) {ST_Entry(kind_, varExpr_, type_); vtype = VT_long; varValue.lval = value_;}; - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_, double value_) {ST_Entry(kind_, varExpr_, type_); vtype = VT_double; varValue.dval = value_;}; - ST_Entry (const symbolKind kind_, BPatch_variableExpr *varExpr_, const BPatch_type *type_, bool value_) {ST_Entry(kind_, varExpr_, type_); vtype = VT_bool; varValue.bval = value_;}; - -//BPatch_function constructior - - ST_Entry (const symbolKind kind_, BPatch_function * function_) {ST_Entry(); kind = kind_; function = function_;}; - -//BPatch_snippet constructor - ST_Entry (const symbolKind kind_, BPatch_snippet * snippet_) {ST_Entry(); kind = kind_; snippet = snippet_;}; - -//accessor methods - - symbolKind getKind() { return kind; }; - void setKind(symbolKind kind_) { kind = kind_; }; - - const BPatch_type * getType() { return type; }; - void setType(BPatch_type * type_) { type = type_; }; - - int getTimesCalled() { return timesCalled; }; - void setTimesCalled(int timesCalled_) { timesCalled = timesCalled_ ;}; - - int getTimesModified() { return timesModified; }; - void setTimesModified(int timesModified_) { timesCalled = timesModified_ ;}; - - bool getHasAbout() { return hasAbout; }; - void setHasAbout(bool hasAbout_) { hasAbout = hasAbout_; }; - - bool getIsStatic() { return isStatic; }; - void setIsStatic(bool isStatic_) { isStatic = isStatic_; }; - - bool getIsConst() { return isConst; }; - void setIsConst(bool isConst_) { isConst = isConst_; }; - - Scope getScope() { return scope; }; - void setScope(Scope scope_) { scope = scope_; }; - - char * getDeclaredInFile(char * buf, int len) { strncpy(declaredInFile, buf, len); return buf; }; - void setDeclaredInFile(char *declaredInFile_) { declaredInFile = strdup(declaredInFile_); }; - - int getDeclaredOnLine() { return declaredOnLine; }; - void setDeclaredOnLine(int declaredOnLine_) { declaredOnLine = declaredOnLine_ ;}; - - const std::vector * getLocations() { return locations; }; - void setLocations(std::vector * locations_) { locations = locations_; }; - void addLocation(BPatch_point * pt) { locations->push_back(pt); } - void removeLocation(BPatch_point * pt) - { std::vector< BPatch_point * >::iterator it; - it = std::find(locations->begin(), locations->end(), pt); - locations->erase(it); } - - varType getVariabletype() { return vtype; }; - void setVariableType(varType vtype_) { vtype = vtype_; }; - -//user must free the returned string - char * getSValue() { return strdup(varValue.sval); }; - void setValue(char *value_) { varValue.sval = strdup(value_); }; - - int getIValue() { return varValue.ival; }; - void setValue(int value_) { varValue.ival = value_; }; - - long getLValue() { return varValue.lval; }; - void setValue(long value_) { varValue.lval = value_; }; - - double getDValue() { return varValue.dval; }; - void setValue(double value_) { varValue.dval = value_; }; - - bool getBValue() { return varValue.bval; }; - void setValue(bool value_) { varValue.bval = value_; }; - - - - BPatch_function * getFunction() { return function; }; - void setFunction(BPatch_function * function_) { function = function_; }; - - BPatch_variableExpr * getVarExpr() { return varExpr; }; - void setVarExpr(BPatch_variableExpr * varExpr_) { varExpr = varExpr_; }; - - BPatch_snippet * getSnippet(){ return snippet; }; - void setSnippet(BPatch_snippet * snippet_) { snippet = snippet_; }; - - std::map > *getActionsOnInsert(){return actionsOnInsert;}; - void addActionOnInsert(BPatch_snippet * snippet, insertActions action, char *info){(*actionsOnInsert)[snippet] = std::make_pair(action, strdup(info));}; - - - private: - - //all - symbolKind kind; - const BPatch_type *type; - int timesCalled; - int timesModified; - bool hasAbout; //true if an about has been placed on the symbol - bool isStatic; - bool isConst; - Scope scope; - //_USERVAR, _SNIPPET, _BOOLEAN, _MUTATEEVAR, _CFUNCTION - char *declaredInFile; //file where declared - int declaredOnLine; //this is possible for mutattee vars (see symtabAPI pg 54) - - std::vector *locations; - std::map > *actionsOnInsert; - varType vtype; - - //_USERVAR, _MUTATEEVAR - union varVal{ - char *sval; - int ival; - long lval; - double dval; - bool bval; - } varValue; - - BPatch_function *function; - BPatch_variableExpr *varExpr; - BPatch_snippet *snippet; -}; - - - -class SymbolTable{ - - public: - - bool put(char *name, ST_Entry entry) { - if (SymbolTable::contains(name)){ - return false; - } - table[name] = entry; - return true; - }; - - ST_Entry * get(char *name){ - if (!SymbolTable::contains(name)){ - return NULL; - } - return & table[name]; - }; - - bool contains(char *name) { return table.find(name) != table.end(); }; - - bool empty(){ return table.empty(); }; - - void clear(){ table.clear(); }; - private: - std::map table; - -}; - - -#endif diff --git a/dynC_API/tests/testMutator.cpp b/dynC_API/tests/testMutator.cpp index 6db4d65..ffe6d8e 100644 --- a/dynC_API/tests/testMutator.cpp +++ b/dynC_API/tests/testMutator.cpp @@ -89,7 +89,7 @@ int main(){ printf("entry point %d is null \n", i); } char str[] = "printf(\"Flow!\\n\");"; - BPatch_snippet *retSnippet = dynC_API::createSnippet(str, *(*entry_points)[i], "entrySnippet"); + BPatch_snippet *retSnippet = dynC_API::createSnippet(fileString, *(*entry_points)[i], "entrySnippet"); if (retSnippet != NULL){ appProc->insertSnippet(*retSnippet, *(*entry_points)[i]); } diff --git a/dynC_API/tests/testStatements b/dynC_API/tests/testStatements index f0ea4de..565c589 100644 --- a/dynC_API/tests/testStatements +++ b/dynC_API/tests/testStatements @@ -1 +1,2 @@ -printf("Hi!\n"); +inf`printf("Hi!\n"); +inf`printf("Hi -> %p.\n", &inf`hi); diff --git a/make.config b/make.config index 40f4732..714f66f 100644 --- a/make.config +++ b/make.config @@ -92,10 +92,10 @@ INCLUDE_DEST ?= ${TO_CORE_ABS}/../include # with cvs), then we should look in a backup location. That's what this vrble # is about. It's used several times below in this file. ifeq ($(PLATFORM),ppc32_bgl_compute) -GCC = powerpc-bgp-linux-gcc -GXX = powerpc-bgp-linux-g++ -CC = powerpc-bgp-linux-gcc -CXX = powerpc-bgp-linux-g++ +GCC = mpgcc +GXX = mpg++ +CC = mpgcc +CXX = mpg++ endif ifeq ($(PLATFORM),ppc32_bgp_compute) GCC = powerpc-bgp-linux-gcc diff --git a/parseThat/Makefile b/parseThat/Makefile index 7f54b07..de7e975 100644 --- a/parseThat/Makefile +++ b/parseThat/Makefile @@ -17,11 +17,8 @@ CONFIG_ARGS += "--with-dyninst-include=$(ABS_INCLUDE_DEST)" CONFIG_ARGS += "--with-dwarf-lib=$(ABS_LIBDWARF_DEST)" CONFIG_ARGS += "--with-elf-lib=$(ABS_LIBELF_DEST)" -ifdef LINK_LIBERTY - CONFIG_LD_FLAGS += "-liberty" -ifdef LIBIBERTY_LIB - CONFIG_LD_FLAGS += "-L$(LIBIBERTY_LIB)" -endif +ifdef DEMANGLER_EXEC_LINK +CONFIG_ARGS += "--with-liberty-lib=\"$(DEMANGLER_EXEC_LINK)\"" endif diff --git a/parseThat/Makefile.in b/parseThat/Makefile.in index 44f0a46..c38e1c0 100644 --- a/parseThat/Makefile.in +++ b/parseThat/Makefile.in @@ -9,7 +9,7 @@ LDFLAGS = @LDFLAGS@ DWARFFLAGS = @DWARFFLAGS@ ELFFLAGS = @ELFFLAGS@ LIBS = @LIBS@ - +DEMANGLER_LINK = @LIBERTYFLAGS@ prefix = @prefix@ PLATFORM ?= @build@ DYNINST_VER = @DYNINST_VER@ @@ -47,10 +47,8 @@ OBJS = $(SRCS:%.C=%.o) CXXFLAGS += -Wall LIBS += -lcommon -ldyninstAPI -lsymtabAPI -lparseAPI -# FreeBSD doesn't need to be linked with libiberty -ifeq (, $(findstring freebsd, $(PLATFORM))) -LIBS += -liberty -endif +# The echo will remove the quotes +LIBS += $(shell echo $(DEMANGLER_LINK)) ifneq (, $(findstring solaris, $(PLATFORM))) LIBS += -ldwarf -lelf diff --git a/parseThat/configure b/parseThat/configure index 0b0d41e..cdc5690 100755 --- a/parseThat/configure +++ b/parseThat/configure @@ -273,7 +273,7 @@ PACKAGE_BUGREPORT='' ac_unique_file="src/config.C" ac_default_prefix=. -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS LDFLAGS DWARFFLAGS ELFFLAGS CPPFLAGS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS ac_ct_CXX EXEEXT OBJEXT DYNINST_VER INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS LDFLAGS DWARFFLAGS ELFFLAGS LIBERTYFLAGS CPPFLAGS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CXX CXXFLAGS ac_ct_CXX EXEEXT OBJEXT DYNINST_VER INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -812,6 +812,7 @@ Optional Packages: --with-dyninst-include Directory to look for dyninst headers --with-dwarf-include Directory to look for libdwarf --with-elf-include Directory to look for libelf + --with-liberty-lib Link string to use for libiberty Some influential environment variables: CXX C++ compiler command @@ -1308,6 +1309,13 @@ if test "${with_elf_lib+set}" = set; then ELF_LIB="${withval}" fi; + +# Check whether --with-liberty-lib or --without-liberty-lib was given. +if test "${with_liberty_lib+set}" = set; then + withval="$with_liberty_lib" + LIBERTY_LIB="${withval}" +fi; + if test -n ${DYNINST_ROOT}; then # Add search paths to CPPFLAGS and LDFLAGS. if test -z ${DYNINST_LIB}; then @@ -1324,6 +1332,8 @@ DWARFFLAGS="-L${DWARF_LIB}" ELFFLAGS="-L${ELF_LIB}" +LIBERTYFLAGS="${LIBERTY_LIB}" + CPPFLAGS="-I${DYNINST_INC} ${CPPFLAGS}" @@ -3174,6 +3184,7 @@ s,@LIBS@,$LIBS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@DWARFFLAGS@,$DWARFFLAGS,;t t s,@ELFFLAGS@,$ELFFLAGS,;t t +s,@LIBERTYFLAGS@,$LIBERTYFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t diff --git a/parseThat/configure.ac b/parseThat/configure.ac index 688ba23..eb0cd36 100644 --- a/parseThat/configure.ac +++ b/parseThat/configure.ac @@ -24,6 +24,10 @@ AC_ARG_WITH(elf-lib, [AS_HELP_STRING([--with-elf-include],[Directory to look for libelf])], [ELF_LIB="${withval}"],) +AC_ARG_WITH(liberty-lib, + [AS_HELP_STRING([--with-liberty-lib],[Link string to use for libiberty])], + [LIBERTY_LIB="${withval}"],) + if test -n ${DYNINST_ROOT}; then # Add search paths to CPPFLAGS and LDFLAGS. if test -z ${DYNINST_LIB}; then @@ -37,6 +41,7 @@ fi AC_SUBST([LDFLAGS], ["-L${DYNINST_LIB} ${LDFLAGS}"]) AC_SUBST([DWARFFLAGS], ["-L${DWARF_LIB}"]) AC_SUBST([ELFFLAGS], ["-L${ELF_LIB}"]) +AC_SUBST([LIBERTYFLAGS], ["${LIBERTY_LIB}"]) AC_SUBST([CPPFLAGS], ["-I${DYNINST_INC} ${CPPFLAGS}"]) # Generate host string. diff --git a/stackwalk/make.module.tmpl b/stackwalk/make.module.tmpl index 1ace00e..e2a96d7 100644 --- a/stackwalk/make.module.tmpl +++ b/stackwalk/make.module.tmpl @@ -23,6 +23,7 @@ MYFLAGS += -fPIC endif endif +LDFLAGS += -L$(TO_CORE)/common/$(PLATFORM) -L$(LIBRARY_DEST) ifndef USES_NATIVE_CC LD = $(GXX) LDFLAGS += -shared diff --git a/stackwalk/ppc32_bgl_compute/Makefile b/stackwalk/ppc32_bgl_compute/Makefile index 1d457bf..e527d8a 100644 --- a/stackwalk/ppc32_bgl_compute/Makefile +++ b/stackwalk/ppc32_bgl_compute/Makefile @@ -14,6 +14,15 @@ STATIC_COMPS = true; # in the paradyn tree. include ../../make.config +ifdef LIBELF_INC +CXXFLAGS += -I$(LIBELF_INC) +endif + +ifdef LIBELF_LIB +LIBS += -L$(LIBELF_LIB) +endif +LIBS += -lelf + # Now make any necessary architecture specific changes to variables: MYFLAGS += -I../../common/src -I../../common/h CXXFLAGS += $(MYFLAGS) @@ -28,19 +37,10 @@ SRCS = ../src/ppc-swk.C \ ../src/firstparty.C \ dyn_regs.C \ addrtranslate.C \ - addrtranslate-sysv.C \ - addrtranslate-bluegenep.C \ + addrtranslate-static.C \ bluegeneKludges.C \ string-regex.C -ifdef LIBELF_INC -MYFLAGS += -I$(LIBELF_INC) -endif - -ifdef LIBELF_LIB -LIBS += -L$(LIBELF_LIB) -lelf -endif - # Include the module-specific Makefile, which defines everything about # the module that is common across architectures. diff --git a/stackwalk/ppc32_bgp_compute/Makefile b/stackwalk/ppc32_bgp_compute/Makefile index d6576ff..571c0a7 100644 --- a/stackwalk/ppc32_bgp_compute/Makefile +++ b/stackwalk/ppc32_bgp_compute/Makefile @@ -23,23 +23,24 @@ CFLAGS += $(MYFLAGS) TFLAGS += $(MYFLAGS) SRCS = ../src/ppc-swk.C \ - ../src/bg_firstparty.C \ - ../../common/src/Elf_X.C \ - ../src/firstparty.C \ - dyn_regs.C \ - addrtranslate.C \ - addrtranslate-sysv.C \ - addrtranslate-bluegenep.C \ - bluegeneKludges.C \ - string-regex.C + ../src/bg_firstparty.C \ + ../src/firstparty.C \ + ../../common/src/dyn_regs.C \ + ../../common/src/addrtranslate.C \ + ../../common/src/addrtranslate-sysv.C \ + ../../common/src/addrtranslate-bluegenep.C \ + ../../common/src/Elf_X.C \ + ../../common/src/bluegeneKludges.C \ + ../../common/src/string-regex.C ifdef LIBELF_INC MYFLAGS += -I$(LIBELF_INC) endif ifdef LIBELF_LIB -LIBS += -L$(LIBELF_LIB) -lelf +LIBS += -L$(LIBELF_LIB) endif +LIBS += -lelf # Include the module-specific Makefile, which defines everything about # the module that is common across architectures. diff --git a/stackwalk/src/bluegenel-swk.C b/stackwalk/src/bluegenel-swk.C index e97ed77..30288fe 100644 --- a/stackwalk/src/bluegenel-swk.C +++ b/stackwalk/src/bluegenel-swk.C @@ -47,6 +47,7 @@ #include #include #include +#include using namespace Dyninst; using namespace Dyninst::Stackwalker; diff --git a/stackwalk/x86_64-unknown-linux2.4/Makefile b/stackwalk/x86_64-unknown-linux2.4/Makefile index 87dba54..874a3c3 100644 --- a/stackwalk/x86_64-unknown-linux2.4/Makefile +++ b/stackwalk/x86_64-unknown-linux2.4/Makefile @@ -11,7 +11,7 @@ NO_IMPLICIT_TEMPLATES = true include ../../make.config -LDFLAGS += $(LIBDIR) -lcommon +LDFLAGS += -lcommon SRCS = ../src/linux-swk.C \ ../src/linux-x86-swk.C \