Add the -debug-lsymbols option for displaying the target language layer symbols.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11854 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-02-11 22:56:39 +00:00
commit f4cfc9bce5
5 changed files with 50 additions and 5 deletions

View file

@ -1,6 +1,9 @@
Version 1.3.41 (in progress) Version 1.3.41 (in progress)
============================ ============================
2010-02-11: wsfulton
Add the -debug-lsymbols option for displaying the target language layer symbols.
2010-02-09: wsfulton 2010-02-09: wsfulton
Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as
they should be. they should be.

View file

@ -3601,6 +3601,7 @@ There are various command line options which can aid debugging a SWIG interface
-debug-symtabs - Display symbol tables information -debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables -debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables -debug-csymbols - Display C symbols in the symbol tables
-debug-lsymbols - Display target language layer symbols
-debug-tags - Display information about the tags found in the interface -debug-tags - Display information about the tags found in the interface
-debug-template - Display information for debugging templates -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 -debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages

View file

@ -308,12 +308,14 @@ none_comparison(NewString("$arg != 0")),
director_ctor_code(NewString("")), director_ctor_code(NewString("")),
director_prot_ctor_code(0), director_prot_ctor_code(0),
symbols(NewHash()), symbols(NewHash()),
symbolDump(NewString("")),
classtypes(NewHash()), classtypes(NewHash()),
enumtypes(NewHash()), enumtypes(NewHash()),
overloading(0), overloading(0),
multiinput(0), multiinput(0),
cplus_runtime(0), cplus_runtime(0),
directors(0) { directors(0),
symbol_table_dump(0) {
argc_template_string = NewString("argc"); argc_template_string = NewString("argc");
argv_template_string = NewString("argv[%d]"); argv_template_string = NewString("argv[%d]");
@ -333,6 +335,7 @@ directors(0) {
Language::~Language() { Language::~Language() {
Delete(symbols); Delete(symbols);
Delete(symbolDump);
Delete(classtypes); Delete(classtypes);
Delete(enumtypes); Delete(enumtypes);
Delete(director_ctor_code); Delete(director_ctor_code);
@ -2916,18 +2919,35 @@ void Language::main(int argc, char *argv[]) {
* Prints an error message and returns 0 if a conflict occurs. * Prints an error message and returns 0 if a conflict occurs.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
int int Language::addSymbol(const String *s, const Node *n) {
Language::addSymbol(const String *s, const Node *n) {
Node *c = Getattr(symbols, s); Node *c = Getattr(symbols, s);
if (c && (c != n)) { if (c && (c != n)) {
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s); Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
return 0; return 0;
} }
Setattr(symbols, s, n); Setattr(symbols, s, n);
if (symbol_table_dump)
Printf(symbolDump, "%s\n", s);
return 1; return 1;
} }
/* -----------------------------------------------------------------------------
* Language::dumpSymbols()
* ----------------------------------------------------------------------------- */
void Language::dumpSymbols() {
if (symbol_table_dump) {
Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n");
/* The symbol table is a hash so no ordering is possible if we iterate through it.
* Instead we gather the symbols as they are added and display them here. */
Printf(stdout, "%s", symbolDump);
Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n");
}
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Language::symbolLookup() * Language::symbolLookup()
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
@ -3376,6 +3396,10 @@ void Language::setOverloadResolutionTemplates(String *argc, String *argv) {
argv_template_string = Copy(argv); argv_template_string = Copy(argv);
} }
void Language::setSymbolsDumpNeeded() {
symbol_table_dump = 1;
}
int Language::is_assignable(Node *n) { int Language::is_assignable(Node *n) {
if (GetFlag(n, "feature:immutable")) if (GetFlag(n, "feature:immutable"))
return 0; return 0;

View file

@ -65,6 +65,7 @@ static const char *usage1 = (const char *) "\
-debug-symtabs - Display symbol tables information\n\ -debug-symtabs - Display symbol tables information\n\
-debug-symbols - Display target language symbols in the symbol tables\n\ -debug-symbols - Display target language symbols in the symbol tables\n\
-debug-csymbols - Display C symbols in the symbol tables\n\ -debug-csymbols - Display C symbols in the symbol tables\n\
-debug-lsymbols - Display target language layer symbols\n\
-debug-tags - Display information about the tags found in the interface\n\ -debug-tags - Display information about the tags found in the interface\n\
-debug-template - Display information for debugging templates\n\ -debug-template - Display information for debugging templates\n\
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\ -debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages\n\
@ -170,6 +171,7 @@ static int tm_debug = 0;
static int dump_symtabs = 0; static int dump_symtabs = 0;
static int dump_symbols = 0; static int dump_symbols = 0;
static int dump_csymbols = 0; static int dump_csymbols = 0;
static int dump_lang_symbols = 0;
static int dump_tags = 0; static int dump_tags = 0;
static int dump_module = 0; static int dump_module = 0;
static int dump_top = 0; static int dump_top = 0;
@ -740,6 +742,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-debug-csymbols") == 0) { } else if (strcmp(argv[i], "-debug-csymbols") == 0) {
dump_csymbols = 1; dump_csymbols = 1;
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (strcmp(argv[i], "-debug-lsymbols") == 0) {
dump_lang_symbols = 1;
Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) { } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
dump_tags = 1; dump_tags = 1;
Swig_mark_arg(i); Swig_mark_arg(i);
@ -903,6 +908,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SWIG_getoptions(argc, argv); SWIG_getoptions(argc, argv);
if (dump_lang_symbols)
lang->setSymbolsDumpNeeded();
// Define the __cplusplus symbol // Define the __cplusplus symbol
if (CPlusPlus) if (CPlusPlus)
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
@ -1079,7 +1087,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
for (int i = 0; i < Len(files); i++) { for (int i = 0; i < Len(files); i++) {
int use_file = 1; int use_file = 1;
if (depend == 2) { if (depend == 2) {
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)) if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
use_file = 0; use_file = 0;
} }
if (use_file) if (use_file)
@ -1227,6 +1235,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
} }
} }
} }
if (dump_lang_symbols) {
lang->dumpSymbols();
}
if (dump_top & STAGE4) { if (dump_top & STAGE4) {
Printf(stdout, "debug-top stage 4\n"); Printf(stdout, "debug-top stage 4\n");
Swig_print_tree(top); Swig_print_tree(top);

View file

@ -209,6 +209,7 @@ public:
/* Miscellaneous */ /* Miscellaneous */
virtual int validIdentifier(String *s); /* valid identifier? */ virtual int validIdentifier(String *s); /* valid identifier? */
virtual int addSymbol(const String *s, const Node *n); /* Add symbol */ virtual int addSymbol(const String *s, const Node *n); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s); /* Symbol lookup */ virtual Node *symbolLookup(String *s); /* Symbol lookup */
virtual Node *classLookup(SwigType *s); /* Class lookup */ virtual Node *classLookup(SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */
@ -251,6 +252,9 @@ public:
/* Set overload variable templates argc and argv */ /* Set overload variable templates argc and argv */
void setOverloadResolutionTemplates(String *argc, String *argv); void setOverloadResolutionTemplates(String *argc, String *argv);
/* Set language module symbol table dump option */
void setSymbolsDumpNeeded();
/* Language instance is a singleton - get instance */ /* Language instance is a singleton - get instance */
static Language* instance(); static Language* instance();
@ -305,12 +309,14 @@ protected:
private: private:
Hash *symbols; Hash *symbols;
String *symbolDump;
Hash *classtypes; Hash *classtypes;
Hash *enumtypes; Hash *enumtypes;
int overloading; int overloading;
int multiinput; int multiinput;
int cplus_runtime; int cplus_runtime;
int directors; int directors;
int symbol_table_dump;
static Language *this_; static Language *this_;
}; };