From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27064 invoked by alias); 6 Jan 2014 17:11:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26874 invoked by uid 89); 6 Jan 2014 17:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Jan 2014 17:11:44 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s06HBgiR016190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Jan 2014 12:11:43 -0500 Received: from barimba.redhat.com (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s06HBepU011728; Mon, 6 Jan 2014 12:11:42 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] move the "main" data into the per-BFD object Date: Mon, 06 Jan 2014 17:11:00 -0000 Message-Id: <1389028297-16977-4-git-send-email-tromey@redhat.com> In-Reply-To: <1389028297-16977-1-git-send-email-tromey@redhat.com> References: <1389028297-16977-1-git-send-email-tromey@redhat.com> X-SW-Source: 2014-01/txt/msg00067.txt.bz2 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-06 Tom Tromey * 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) : 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. * symtab.h (set_main_name): Don't declare. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/dbxread.c | 2 +- gdb/dwarf2read.c | 2 +- gdb/objfiles.c | 15 +++++++++++++++ gdb/objfiles.h | 12 ++++++++++++ gdb/symtab.c | 13 ++++++++++++- gdb/symtab.h | 1 - 7 files changed, 55 insertions(+), 4 deletions(-) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 71eb5f8..6512735 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -3251,7 +3251,7 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name, N_MAIN within a given objfile, complain() and choose arbitrarily. (kingdon) */ if (name != NULL) - set_main_name (name, language_unknown); + set_objfile_main_name (objfile, name, language_unknown); break; /* The following symbol types can be ignored. */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0bd7100..68de1df 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -15313,7 +15313,7 @@ read_partial_die (const struct die_reader_specs *reader, practice. */ if (DW_UNSND (&attr) == DW_CC_program && cu->language == language_fortran) - set_main_name (part_die->name, language_fortran); + set_objfile_main_name (objfile, part_die->name, language_fortran); break; case DW_AT_inline: if (DW_UNSND (&attr) == DW_INL_inlined diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 73847bd..84b13d7 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -152,6 +152,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) obstack_init (&storage->storage_obstack); storage->filename_cache = bcache_xmalloc (NULL, NULL); storage->macro_cache = bcache_xmalloc (NULL, NULL); + storage->language_of_main = language_unknown; } return storage; @@ -186,6 +187,20 @@ set_objfile_per_bfd (struct objfile *objfile) objfile->per_bfd = get_objfile_bfd_data (objfile, objfile->obfd); } +/* Set the objfile's per-BFD notion of the "main" name and + language. */ + +void +set_objfile_main_name (struct objfile *objfile, + const char *name, enum language lang) +{ + if (objfile->per_bfd->name_of_main == NULL + || strcmp (objfile->per_bfd->name_of_main, name) != 0) + objfile->per_bfd->name_of_main + = obstack_copy0 (&objfile->per_bfd->storage_obstack, name, strlen (name)); + objfile->per_bfd->language_of_main = lang; +} + /* Called via bfd_map_over_sections to build up the section table that diff --git a/gdb/objfiles.h b/gdb/objfiles.h index c2b6177..a7db251 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -192,6 +192,13 @@ struct objfile_per_bfd_storage name, and the second is the demangled name or just a zero byte if the name doesn't demangle. */ struct htab *demangled_names_hash; + + /* The name and language of any "main" found in this objfile. The + name can be NULL, which means that the information was not + recorded. */ + + const char *name_of_main; + enum language language_of_main; }; /* Master structure for keeping track of each file from which @@ -685,4 +692,9 @@ void set_objfile_per_bfd (struct objfile *obj); const char *objfile_name (const struct objfile *objfile); +/* Set the objfile's notion of the "main" name and language. */ + +extern void set_objfile_main_name (struct objfile *objfile, + const char *name, enum language lang); + #endif /* !defined (OBJFILES_H) */ diff --git a/gdb/symtab.c b/gdb/symtab.c index d01a7d7..0c25609 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5057,7 +5057,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 (); @@ -5082,6 +5082,17 @@ static void find_main_name (void) { const char *new_main_name; + struct objfile *objfile; + + 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 diff --git a/gdb/symtab.h b/gdb/symtab.h index 4a93374..25ac028 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1324,7 +1324,6 @@ extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search 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, enum language lang); extern /*const */ char *main_name (void); extern enum language main_language (void); -- 1.8.1.4