diff --git a/CHANGES.current b/CHANGES.current index b577367db..67d9f9aa1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,11 +1,11 @@ Version 1.3.41 (in progress) ============================ -2009-11-04: wsfulton +2009-11-07: wsfulton Add new debug options: - -debug-symtabs - Display symbol tables information - -debug-qsymtabs - Display symbol tables summary information using fully - qualified names + -debug-symtabs - Display symbol tables information + -debug-symbols - Display target language symbols in the symbol tables + -debug-csymbols - Display C symbols in the symbol tables 2009-11-03: wsfulton Fix some usage of global scope operator, for example: diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 11578db97..040eb65c7 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -2604,24 +2604,24 @@ void Language::main(int argc, char *argv[]) { } else { Swig_arg_error(); } - } else if (strcmp(argv[i],"-globals") == 0) { - if (argv[i+1]) { - global_name = NewString(argv[i+1]); - Swig_mark_arg(i); - Swig_mark_arg(i+1); - i++; - } else { - Swig_arg_error(); - } - } else if ( (strcmp(argv[i],"-proxy") == 0)) { - proxy_flag = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i],"-keyword") == 0) { - use_kw = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i],"-help") == 0) { - fputs(usage,stderr); - } + } else if (strcmp(argv[i],"-globals") == 0) { + if (argv[i+1]) { + global_name = NewString(argv[i+1]); + Swig_mark_arg(i); + Swig_mark_arg(i+1); + i++; + } else { + Swig_arg_error(); + } + } else if ( (strcmp(argv[i],"-proxy") == 0)) { + proxy_flag = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-keyword") == 0) { + use_kw = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-help") == 0) { + fputs(usage,stderr); + } ... } } @@ -3599,7 +3599,8 @@ There are various command line options which can aid debugging a SWIG interface -debug-classes - Display information about the classes found in the interface -debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages -debug-symtabs - Display symbol tables information --debug-qsymtabs - Display symbol tables summary information using fully qualified names +-debug-symbols - Display target language symbols in the symbol tables +-debug-csymbols - Display C symbols in the symbol tables -debug-tags - Display information about the tags found in the interface -debug-template - Display information for debugging templates -debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 30e8eb18a..30d12f26b 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -63,7 +63,8 @@ static const char *usage1 = (const char *) "\ -debug-classes - Display information about the classes found in the interface\n\ -debug-module - Display module parse tree at stages 1-4, is a csv list of stages\n\ -debug-symtabs - Display symbol tables information\n\ - -debug-qsymtabs - Display symbol tables summary information using fully qualified names\n\ + -debug-symbols - Display target language symbols in the symbol tables\n\ + -debug-csymbols - Display C symbols in the symbol tables\n\ -debug-tags - Display information about the tags found in the interface\n\ -debug-template - Display information for debugging templates\n\ -debug-top - Display entire parse tree at stages 1-4, is a csv list of stages\n\ @@ -165,7 +166,8 @@ static char *outfile_name = 0; static char *outfile_name_h = 0; static int tm_debug = 0; static int dump_symtabs = 0; -static int dump_qsymtabs = 0; +static int dump_symbols = 0; +static int dump_csymbols = 0; static int dump_tags = 0; static int dump_module = 0; static int dump_top = 0; @@ -723,8 +725,11 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-debug-symtabs") == 0) { dump_symtabs = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-debug-qsymtabs") == 0) { - dump_qsymtabs = 1; + } else if (strcmp(argv[i], "-debug-symbols") == 0) { + dump_symbols = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-csymbols") == 0) { + dump_csymbols = 1; Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) { dump_tags = 1; @@ -1156,11 +1161,16 @@ int SWIG_main(int argc, char *argv[], Language *l) { } if (dump_symtabs) { - Swig_symbol_tables_print(Swig_symbol_global_scope()); + Swig_symbol_print_tables(Swig_symbol_global_scope()); + Swig_symbol_print_tables_summary(); } - if (dump_qsymtabs) { - Swig_symbol_tables_summary_print(); + if (dump_symbols) { + Swig_symbol_print_symbols(); + } + + if (dump_csymbols) { + Swig_symbol_print_csymbols(); } if (dump_tags) { diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index e415493a0..33f977b52 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -200,8 +200,10 @@ extern "C" { /* --- Symbol table module --- */ - extern void Swig_symbol_tables_print(Symtab *symtab); - extern void Swig_symbol_tables_summary_print(void); + extern void Swig_symbol_print_tables(Symtab *symtab); + extern void Swig_symbol_print_tables_summary(void); + extern void Swig_symbol_print_symbols(void); + extern void Swig_symbol_print_csymbols(void); extern void Swig_symbol_init(void); extern void Swig_symbol_setscopename(const_String_or_char_ptr name); extern String *Swig_symbol_getscopename(void); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index a13361aa8..ae8a274c6 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -176,12 +176,12 @@ static Hash *global_scope = 0; /* Global scope */ /* ----------------------------------------------------------------------------- - * Swig_symbol_tables_print() + * Swig_symbol_print_tables() * * Debug display of symbol tables * ----------------------------------------------------------------------------- */ -void Swig_symbol_tables_print(Symtab *symtab) { +void Swig_symbol_print_tables(Symtab *symtab) { if (!symtab) symtab = current_symtab; @@ -191,17 +191,65 @@ void Swig_symbol_tables_print(Symtab *symtab) { } /* ----------------------------------------------------------------------------- - * Swig_symbol_tables_summary_print() + * Swig_symbol_print_tables_summary() * * Debug summary display of all symbol tables by fully-qualified name * ----------------------------------------------------------------------------- */ -void Swig_symbol_tables_summary_print(void) { +void Swig_symbol_print_tables_summary(void) { Printf(stdout, "SYMBOL TABLES SUMMARY start =======================================\n"); Swig_print_node(symtabs); Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n"); } +/* ----------------------------------------------------------------------------- + * symbol_print_symbols() + * ----------------------------------------------------------------------------- */ + +static void symbol_print_symbols(const char *symboltabletype) { + Node *obj = symtabs; + Iterator ki = First(obj); + while (ki.key) { + String *k = ki.key; + Printf(stdout, "===================================================\n"); + Printf(stdout, "%s -\n", k); + { + Symtab *symtab = Getattr(Getattr(obj, k), symboltabletype); + Iterator it = First(symtab); + while (it.key) { + String *symname = it.key; + Printf(stdout, " %s\n", symname); + it = Next(it); + } + } + ki = Next(ki); + } +} + +/* ----------------------------------------------------------------------------- + * Swig_symbol_print_symbols() + * + * Debug display of all the target language symbols + * ----------------------------------------------------------------------------- */ + +void Swig_symbol_print_symbols(void) { + Printf(stdout, "SYMBOLS start =======================================\n"); + symbol_print_symbols("symtab"); + Printf(stdout, "SYMBOLS finish =======================================\n"); +} + +/* ----------------------------------------------------------------------------- + * Swig_symbol_print_csymbols() + * + * Debug display of all the C symbols + * ----------------------------------------------------------------------------- */ + +void Swig_symbol_print_csymbols(void) { + Printf(stdout, "CSYMBOLS start =======================================\n"); + symbol_print_symbols("csymtab"); + Printf(stdout, "CSYMBOLS finish =======================================\n"); +} + /* ----------------------------------------------------------------------------- * Swig_symbol_init() *