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)
============================
2010-02-11: wsfulton
Add the -debug-lsymbols option for displaying the target language layer symbols.
2010-02-09: wsfulton
Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as
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-symbols - Display target language 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-template - Display information for debugging templates
-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_prot_ctor_code(0),
symbols(NewHash()),
symbolDump(NewString("")),
classtypes(NewHash()),
enumtypes(NewHash()),
overloading(0),
multiinput(0),
cplus_runtime(0),
directors(0) {
directors(0),
symbol_table_dump(0) {
argc_template_string = NewString("argc");
argv_template_string = NewString("argv[%d]");
@ -333,6 +335,7 @@ directors(0) {
Language::~Language() {
Delete(symbols);
Delete(symbolDump);
Delete(classtypes);
Delete(enumtypes);
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.
* ----------------------------------------------------------------------------- */
int
Language::addSymbol(const String *s, const Node *n) {
int Language::addSymbol(const String *s, const Node *n) {
Node *c = Getattr(symbols, s);
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);
return 0;
}
Setattr(symbols, s, n);
if (symbol_table_dump)
Printf(symbolDump, "%s\n", s);
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()
* ----------------------------------------------------------------------------- */
@ -3376,6 +3396,10 @@ void Language::setOverloadResolutionTemplates(String *argc, String *argv) {
argv_template_string = Copy(argv);
}
void Language::setSymbolsDumpNeeded() {
symbol_table_dump = 1;
}
int Language::is_assignable(Node *n) {
if (GetFlag(n, "feature:immutable"))
return 0;

View file

@ -65,6 +65,7 @@ static const char *usage1 = (const char *) "\
-debug-symtabs - Display symbol tables information\n\
-debug-symbols - Display target language 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-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\
@ -170,6 +171,7 @@ static int tm_debug = 0;
static int dump_symtabs = 0;
static int dump_symbols = 0;
static int dump_csymbols = 0;
static int dump_lang_symbols = 0;
static int dump_tags = 0;
static int dump_module = 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) {
dump_csymbols = 1;
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)) {
dump_tags = 1;
Swig_mark_arg(i);
@ -903,6 +908,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SWIG_getoptions(argc, argv);
if (dump_lang_symbols)
lang->setSymbolsDumpNeeded();
// Define the __cplusplus symbol
if (CPlusPlus)
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++) {
int use_file = 1;
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;
}
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) {
Printf(stdout, "debug-top stage 4\n");
Swig_print_tree(top);

View file

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