* symtab.c (main_name): New function.

(set_main_name): New function.
* symtab.h: Declare.
* TODO: Update

From 2000-03-05 Anthony Green <green@redhat.com>:
* 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.
This commit is contained in:
Andrew Cagney 2001-07-07 17:19:50 +00:00
parent c72e73889f
commit 51cc5b0737
10 changed files with 71 additions and 24 deletions

View file

@ -1,3 +1,20 @@
2001-07-07 Andrew Cagney <ac131313@redhat.com>
* symtab.c (main_name): New function.
(set_main_name): New function.
* symtab.h: Declare.
* TODO: Update
From 2000-03-05 Anthony Green <green@redhat.com>:
* 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 <ac131313@redhat.com>
* TODO: Convert most items into PRs.

View file

@ -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.

View file

@ -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 =

View file

@ -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;
}

View file

@ -1484,4 +1484,5 @@ enum gdb_rc gdb_list_thread_ids (/* output object */);
/* Switch thread and print notification. */
#endif
#endif /* #ifndef DEFS_H */

View file

@ -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)

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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)
{

View file

@ -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) */