From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: GDB Patches Subject: [rfa/sym*] Look at N_MAIN Date: Fri, 16 Mar 2001 07:41:00 -0000 Message-id: <3AB23416.EF23DDB2@cygnus.com> X-SW-Source: 2001-03/msg00282.html (resolving this is part of the 5.1 release criteria) The attatched patch gets GDB to make use of N_MAIN when available. The original, submitted by Anthony Green, needed some improvements (see attatched e-mails). I've addressed just the memory leak problem. Andrew 2001-03-16 Andrew Cagney * symtab.c (main_name): New function. (set_main_name): New function. * symtab.h: Declare. 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. Index: blockframe.c =================================================================== RCS file: /cvs/src/src/gdb/blockframe.c,v retrieving revision 1.13 diff -p -r1.13 blockframe.c *** blockframe.c 2001/03/06 08:21:05 1.13 --- blockframe.c 2001/03/16 15:35:39 *************** inside_main_func (CORE_ADDR pc) *** 120,126 **** { 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 = --- 120,126 ---- { 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: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.15 diff -p -r1.15 dbxread.c *** dbxread.c 2001/03/07 02:57:08 1.15 --- dbxread.c 2001/03/16 15:35:40 *************** process_one_symbol (int type, int desc, *** 2389,2401 **** } 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; } --- 2389,2405 ---- } break; + case N_MAIN: /* Name of main routine. */ + if (name) + 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_ALIAS: /* SunPro F77: alias name, ignore for now. */ break; } Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.43 diff -p -r1.43 defs.h *** defs.h 2001/03/14 16:42:29 1.43 --- defs.h 2001/03/16 15:35:40 *************** enum gdb_rc gdb_list_thread_ids (/* outp *** 1300,1303 **** --- 1300,1304 ---- /* Switch thread and print notification. */ #endif + #endif /* #ifndef DEFS_H */ Index: nlmread.c =================================================================== RCS file: /cvs/src/src/gdb/nlmread.c,v retrieving revision 1.7 diff -p -r1.7 nlmread.c *** nlmread.c 2001/03/07 02:57:08 1.7 --- nlmread.c 2001/03/16 15:35:40 *************** nlm_symfile_read (struct objfile *objfil *** 193,199 **** stabsect_build_psymtabs (objfile, mainline, ".stab", ".stabstr", ".text"); ! mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL); if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) --- 193,199 ---- 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: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.20 diff -p -r1.20 rs6000-tdep.c *** rs6000-tdep.c 2001/03/06 08:21:16 1.20 --- rs6000-tdep.c 2001/03/16 15:35:41 *************** skip_prologue (CORE_ADDR pc, CORE_ADDR l *** 752,758 **** function as well. */ tmp = find_pc_misc_function (pc); ! if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main")) return pc + 8; } } --- 752,758 ---- function as well. */ tmp = find_pc_misc_function (pc); ! if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name ())) return pc + 8; } } Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.10 diff -p -r1.10 source.c *** source.c 2001/03/06 08:21:17 1.10 --- source.c 2001/03/16 15:35:41 *************** select_source_symtab (register struct sy *** 153,161 **** /* 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]; xfree (sals.sals); current_source_symtab = sal.symtab; --- 153,161 ---- /* 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]; xfree (sals.sals); current_source_symtab = sal.symtab; Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.32 diff -p -r1.32 symtab.c *** symtab.c 2001/03/06 08:21:17 1.32 --- symtab.c 2001/03/16 15:35:42 *************** find_main_psymtab (void) *** 1174,1180 **** ALL_PSYMTABS (objfile, pst) { ! if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE)) { return (pst); } --- 1174,1180 ---- ALL_PSYMTABS (objfile, pst) { ! if (lookup_partial_symbol (pst, main_name (), 1, VAR_NAMESPACE)) { return (pst); } *************** decode_line_spec (char *string, int funf *** 3351,3356 **** --- 3351,3383 ---- error ("Junk at end of line specification: %s", string); 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) Index: symtab.h =================================================================== RCS file: /cvs/src/src/gdb/symtab.h,v retrieving revision 1.20 diff -p -r1.20 symtab.h *** symtab.h 2001/03/07 02:57:08 1.20 --- symtab.h 2001/03/16 15:35:59 *************** extern void search_symbols (char *, name *** 1447,1450 **** --- 1447,1457 ---- 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) */ >From chastain@cygnus.com Fri Mar 16 10:07:00 2001 From: Michael Elizabeth Chastain To: chastain@cygnus.com, fnasser@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] testsuite/gdb.c++/ref-types.exp: use runto Date: Fri, 16 Mar 2001 10:07:00 -0000 Message-id: <200103161807.KAA06081@bosch.cygnus.com> X-SW-Source: 2001-03/msg00283.html Content-length: 511 Fernando Nasser writes: > But I wonder if we should not call gdb_start_again() the first time > around instead of having the code duplicated. It is exactly the same > thing. Doh! I'm so busy with individual lines, I missed an opportunity to take out a whole section. ref_types.exp works now, so I am going to leave it alone and fix more pressing problems first: like gdb.c++/userdef.exp, which has no code, and gdb.c++/virtfunc.exp, which XFAILs some tests because gdb doesn't do the right thing. Michael