summaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-12-30 20:34:16 -0700
committerTom Tromey <tromey@redhat.com>2014-01-15 12:06:04 -0700
commit3d548a532dd74f9bf5f2033541f0b504d96baf04 (patch)
treee9ee3226902f33e22bb7baef01bf81457cdb3dcc /gdb/symtab.c
parent32ac0d11e648f4d5fa07c347ab109222a1162a0e (diff)
downloadbinutils-gdb-3d548a532dd74f9bf5f2033541f0b504d96baf04.tar.gz
move the "main" data into the per-BFD object
This adds the "main"-related data into the per-BFD. This is needed because once symbol sharing across objfiles is complete, computing the main name as a side effect of symbol reading will no longer work -- the symbols simply won't be re-read. After this change, set_main_name is only used by the main_name machinery itself, so this patch makes it static. 2014-01-15 Tom Tromey <tromey@redhat.com> * dbxread.c (process_one_symbol): Use set_objfile_main_name. * dwarf2read.c (read_partial_die): Use set_objfile_main_name. * objfiles.c (get_objfile_bfd_data): Initialize language_of_main. (set_objfile_main_name): New function. * objfiles.h (struct objfile_per_bfd_storage) <name_of_main, language_of_main>: New fields. (set_objfile_main_name): Declare. * symtab.c (find_main_name): Loop over objfiles to find the main name and language. (set_main_name): Now static. (get_main_info): Add comment. * symtab.h (set_main_name): Don't declare.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 80a7dd676d5..09b2326ed52 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5028,6 +5028,12 @@ get_main_info (void)
if (info == NULL)
{
+ /* It may seem strange to store the main name in the progspace
+ and also in whatever objfile happens to see a main name in
+ its debug info. The reason for this is mainly historical:
+ gdb returned "main" as the name even if no function named
+ "main" was defined the program; and this approach lets us
+ keep compatibility. */
info = XCNEW (struct main_info);
info->language_of_main = language_unknown;
set_program_space_data (current_program_space, main_progspace_key,
@@ -5050,7 +5056,7 @@ main_info_cleanup (struct program_space *pspace, void *data)
xfree (info);
}
-void
+static void
set_main_name (const char *name, enum language lang)
{
struct main_info *info = get_main_info ();
@@ -5075,6 +5081,23 @@ static void
find_main_name (void)
{
const char *new_main_name;
+ struct objfile *objfile;
+
+ /* First check the objfiles to see whether a debuginfo reader has
+ picked up the appropriate main name. Historically the main name
+ was found in a more or less random way; this approach instead
+ relies on the order of objfile creation -- which still isn't
+ guaranteed to get the correct answer, but is just probably more
+ accurate. */
+ ALL_OBJFILES (objfile)
+ {
+ if (objfile->per_bfd->name_of_main != NULL)
+ {
+ set_main_name (objfile->per_bfd->name_of_main,
+ objfile->per_bfd->language_of_main);
+ return;
+ }
+ }
/* Try to see if the main procedure is in Ada. */
/* FIXME: brobecker/2005-03-07: Another way of doing this would