From 51cc5b073771099289e43e0d4a15f71fb0515f0b Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sat, 7 Jul 2001 17:19:50 +0000 Subject: [PATCH] * symtab.c (main_name): New function. (set_main_name): New function. * symtab.h: Declare. * TODO: Update From 2000-03-05 Anthony Green : * dbxread.c (process_one_symbol): Handle the N_MAIN stab by setting main_name. * blockframe.c (inside_main_func): Use main_name instead of "main". * symtab.c (find_main_psymtab): Ditto. * source.c (select_source_symtab): Ditto. * nlmread.c (nlm_symfile_read): Ditto. * rs6000-tdep.c (skip_prologue): Ditto. --- gdb/ChangeLog | 17 +++++++++++++++++ gdb/TODO | 17 ----------------- gdb/blockframe.c | 2 +- gdb/dbxread.c | 14 +++++++++++++- gdb/defs.h | 1 + gdb/nlmread.c | 2 +- gdb/rs6000-tdep.c | 2 +- gdb/source.c | 4 ++-- gdb/symtab.c | 29 ++++++++++++++++++++++++++++- gdb/symtab.h | 7 +++++++ 10 files changed, 71 insertions(+), 24 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1dbeb8d596..e7af45bcc2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2001-07-07 Andrew Cagney + + * symtab.c (main_name): New function. + (set_main_name): New function. + * symtab.h: Declare. + * TODO: Update + + From 2000-03-05 Anthony Green : + * dbxread.c (process_one_symbol): Handle the N_MAIN stab by + setting main_name. + * blockframe.c (inside_main_func): Use main_name instead of + "main". + * symtab.c (find_main_psymtab): Ditto. + * source.c (select_source_symtab): Ditto. + * nlmread.c (nlm_symfile_read): Ditto. + * rs6000-tdep.c (skip_prologue): Ditto. + 2001-07-07 Andrew Cagney * TODO: Convert most items into PRs. diff --git a/gdb/TODO b/gdb/TODO index afa64ce111..15cc5215c8 100644 --- a/gdb/TODO +++ b/gdb/TODO @@ -65,23 +65,6 @@ http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00496.html [I think this has been merged, need to confirm - cagney] --- - -Java (Anthony Green, David Taylor) - -Anthony Green has a number of Java patches that did not make it into -the 5.0 release. The first two are in cvs now, but the third needs -some fixing up before it can go in. - -Patch: java tests -http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00512.html - -Patch: java booleans -http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00515.html - -Patch: handle N_MAIN stab -http://sourceware.cygnus.com/ml/gdb-patches/2000-q1/msg00527.html - -- 2001-03-08 Add CRIS target. diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 34e1484f74..c88649e19d 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -120,7 +120,7 @@ inside_main_func (CORE_ADDR pc) { struct symbol *mainsym; - mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL); + mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) { symfile_objfile->ei.main_func_lowpc = diff --git a/gdb/dbxread.c b/gdb/dbxread.c index d3a1489bc8..5d7ed74e8a 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2390,13 +2390,25 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name, } break; + case N_MAIN: /* Name of main routine. */ + /* FIXME: If one has a symbol file with N_MAIN and then replaces + it with a symbol file with "main" and without N_MAIN. I'm + not sure exactly what rule to follow but probably something + like: N_MAIN takes precedence over "main" no matter what + objfile it is in; If there is more than one N_MAIN, choose + the one in the symfile_objfile; If there is more than one + N_MAIN within a given objfile, complain() and choose + arbitrarily. (kingdon) */ + if (name != NULL) + set_main_name (name); + break; + /* The following symbol types can be ignored. */ case N_OBJ: /* Solaris 2: Object file dir and name */ /* N_UNDF: Solaris 2: file separator mark */ /* N_UNDF: -- we will never encounter it, since we only process one file's symbols at once. */ case N_ENDM: /* Solaris 2: End of module */ - case N_MAIN: /* Name of main routine. */ case N_ALIAS: /* SunPro F77: alias name, ignore for now. */ break; } diff --git a/gdb/defs.h b/gdb/defs.h index aa69216ca3..9467fc74a8 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -1484,4 +1484,5 @@ enum gdb_rc gdb_list_thread_ids (/* output object */); /* Switch thread and print notification. */ #endif + #endif /* #ifndef DEFS_H */ diff --git a/gdb/nlmread.c b/gdb/nlmread.c index 0baf177ffb..e4c4970c8a 100644 --- a/gdb/nlmread.c +++ b/gdb/nlmread.c @@ -193,7 +193,7 @@ nlm_symfile_read (struct objfile *objfile, int mainline) stabsect_build_psymtabs (objfile, mainline, ".stab", ".stabstr", ".text"); - mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL); + mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 864345dd17..2ae392923f 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -753,7 +753,7 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR lim_pc, struct rs6000_framedata *fdata) function as well. */ tmp = find_pc_misc_function (pc); - if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main")) + if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name ())) return pc + 8; } } diff --git a/gdb/source.c b/gdb/source.c index 2895dd388f..417d5886a5 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -153,9 +153,9 @@ select_source_symtab (register struct symtab *s) /* Make the default place to list be the function `main' if one exists. */ - if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL)) + if (lookup_symbol (main_name (), 0, VAR_NAMESPACE, 0, NULL)) { - sals = decode_line_spec ("main", 1); + sals = decode_line_spec (main_name (), 1); sal = sals.sals[0]; xfree (sals.sals); current_source_symtab = sal.symtab; diff --git a/gdb/symtab.c b/gdb/symtab.c index a16393e81a..dcaae5287c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1158,7 +1158,7 @@ find_main_psymtab (void) ALL_PSYMTABS (objfile, pst) { - if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE)) + if (lookup_partial_symbol (pst, main_name (), 1, VAR_NAMESPACE)) { return (pst); } @@ -3624,6 +3624,33 @@ decode_line_spec (char *string, int funfirstline) return sals; } +/* Track MAIN */ +static char *name_of_main; + +void +set_main_name (const char *name) +{ + if (name_of_main != NULL) + { + xfree (name_of_main); + name_of_main = NULL; + } + if (name != NULL) + { + name_of_main = xstrdup (name); + } +} + +char * +main_name (void) +{ + if (name_of_main != NULL) + return name_of_main; + else + return "main"; +} + + void _initialize_symtab (void) { diff --git a/gdb/symtab.h b/gdb/symtab.h index d85add3b3e..7ae9346825 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1427,4 +1427,11 @@ extern void search_symbols (char *, namespace_enum, int, char **, extern void free_search_symbols (struct symbol_search *); extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search *); +/* The name of the ``main'' function. + FIXME: cagney/2001-03-20: Can't make main_name() const since some + of the calling code currently assumes that the string isn't + const. */ +extern void set_main_name (const char *name); +extern /*const*/ char *main_name (void); + #endif /* !defined(SYMTAB_H) */ -- 2.34.1