This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Patch: handle N_MAIN stab
- To: green at redhat dot com
- Subject: Re: Patch: handle N_MAIN stab
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 27 Mar 2000 18:37:22 +1000
- CC: gdb-patches at sourceware dot cygnus dot com, jimb at cygnus dot com, tromey at cygnus dot com
- Organization: Cygnus Solutions
- References: <200003051039.CAA04980@hoser.cygnus.com>
FYI,
I think this patch slipped into limbo as it tweeks a number of files.
I believe JimK identified a memory leak.
For my part, I'd suggest ``main_name ()'' (or what ever) in symtab.[hc]
or source.h (anyway somewhere more applicable then defs.h which as
enough fluff :-).
enjoy,
Andrew
> 2000-03-05 Anthony Green <green@redhat.com>
>
> * defs.h (main_name): Declare.
> * 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.
>
> Index: gdb//blockframe.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/blockframe.c,v
> retrieving revision 1.1.1.11
> diff -p -r1.1.1.11 blockframe.c
> *** blockframe.c 1999/12/22 21:45:03 1.1.1.11
> --- blockframe.c 2000/03/05 10:20:27
> *************** inside_main_func (pc)
> *** 127,133 ****
> {
> struct symbol *mainsym;
>
> ! mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
> if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> {
> symfile_objfile->ei.main_func_lowpc =
> --- 127,133 ----
> {
> struct symbol *mainsym;
>
> ! mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
> if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> {
> symfile_objfile->ei.main_func_lowpc =
> Index: gdb//dbxread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dbxread.c,v
> retrieving revision 1.1.1.10
> diff -p -r1.1.1.10 dbxread.c
> *** dbxread.c 2000/01/06 03:06:36 1.1.1.10
> --- dbxread.c 2000/03/05 10:20:29
> *************** process_one_symbol (type, desc, valu, na
> *** 2426,2438 ****
> }
> 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;
> }
> --- 2426,2442 ----
> }
> break;
>
> + case N_MAIN: /* Name of main routine. */
> + if (name)
> + main_name = xstrdup (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_ALIAS: /* SunPro F77: alias name, ignore for now. */
> break;
> }
> Index: gdb//defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.9
> diff -p -r1.9 defs.h
> *** defs.h 2000/03/04 02:23:06 1.9
> --- defs.h 2000/03/05 10:20:30
> *************** enum gdb_rc gdb_list_thread_ids (/* outp
> *** 1314,1317 ****
> --- 1314,1321 ----
>
> /* Switch thread and print notification. */
> #endif
> +
> + /* From source.c */
> + extern char *main_name;
> +
> #endif /* #ifndef DEFS_H */
> Index: gdb//nlmread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/nlmread.c,v
> retrieving revision 1.1.1.4
> diff -p -r1.1.1.4 nlmread.c
> *** nlmread.c 1999/08/09 21:33:43 1.1.1.4
> --- nlmread.c 2000/03/05 10:20:31
> *************** nlm_symfile_read (objfile, mainline)
> *** 206,212 ****
> stabsect_build_psymtabs (objfile, mainline, ".stab",
> ".stabstr", ".text");
>
> ! mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
>
> if (mainsym
> && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> --- 206,212 ----
> stabsect_build_psymtabs (objfile, mainline, ".stab",
> ".stabstr", ".text");
>
> ! mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
>
> if (mainsym
> && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> Index: gdb//rs6000-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
> retrieving revision 1.5
> diff -p -r1.5 rs6000-tdep.c
> *** rs6000-tdep.c 2000/02/26 09:30:30 1.5
> --- rs6000-tdep.c 2000/03/05 10:20:32
> *************** skip_prologue (CORE_ADDR pc, struct rs60
> *** 573,579 ****
> function as well. */
>
> tmp = find_pc_misc_function (pc);
> ! if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main"))
> return pc + 8;
> }
> }
> --- 573,579 ----
> function as well. */
>
> tmp = find_pc_misc_function (pc);
> ! if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name))
> return pc + 8;
> }
> }
> Index: gdb//source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.1.1.12
> diff -p -r1.1.1.12 source.c
> *** source.c 2000/02/03 04:14:35 1.1.1.12
> --- source.c 2000/03/05 10:20:35
> *************** static int first_line_listed;
> *** 119,124 ****
> --- 119,127 ----
>
> static struct symtab *last_source_visited = NULL;
> static int last_source_error = 0;
> +
> + /* The default "main" symbol. */
> + char *main_name = "main";
>
>
> /* Set the source file default for the "list" command to be S.
> *************** select_source_symtab (s)
> *** 151,159 ****
>
> /* Make the default place to list be the function `main'
> if one exists. */
> ! if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL))
> {
> ! sals = decode_line_spec ("main", 1);
> sal = sals.sals[0];
> free (sals.sals);
> current_source_symtab = sal.symtab;
> --- 154,162 ----
>
> /* Make the default place to list be the function `main'
> if one exists. */
> ! if (lookup_symbol (main_name, 0, VAR_NAMESPACE, 0, NULL))
> {
> ! sals = decode_line_spec (main_name, 1);
> sal = sals.sals[0];
> free (sals.sals);
> current_source_symtab = sal.symtab;
> Index: gdb//symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.2
> diff -p -r1.2 symtab.c
> *** symtab.c 2000/02/08 04:39:02 1.2
> --- symtab.c 2000/03/05 10:20:37
> *************** find_main_psymtab ()
> *** 1172,1178 ****
>
> ALL_PSYMTABS (objfile, pst)
> {
> ! if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
> {
> return (pst);
> }
> --- 1172,1178 ----
>
> ALL_PSYMTABS (objfile, pst)
> {
> ! if (lookup_partial_symbol (pst, main_name, 1, VAR_NAMESPACE))
> {
> return (pst);
> }
>
> --
> Anthony Green Red Hat
> Sunnyvale, California