From patchwork Tue Sep 27 04:08:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16045 Received: (qmail 82706 invoked by alias); 27 Sep 2016 04:40:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 82608 invoked by uid 89); 27 Sep 2016 04:40:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*r:4.86_1, H*F:U*tom, xfree, reader X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Tue, 27 Sep 2016 04:40:42 +0000 Received: (qmail 29297 invoked by uid 0); 27 Sep 2016 04:40:41 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy8.mail.unifiedlayer.com with SMTP; 27 Sep 2016 04:40:41 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id oUgd1t00F2f2jeq01Uggu2; Mon, 26 Sep 2016 22:40:41 -0600 X-Authority-Analysis: v=2.1 cv=Hq7lRSjS c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=GW1xBdLrtEIA:10 a=zstS-IiYAAAA:8 a=8oeJ51YZf6lhJMm9aWYA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 71-218-192-86.hlrn.qwest.net ([71.218.192.86]:56110 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bojhR-0006Nj-Lw; Mon, 26 Sep 2016 22:08:57 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 07/22] Change scoped_minimal_symbol_reader to store objfile Date: Mon, 26 Sep 2016 22:08:35 -0600 Message-Id: <1474949330-4307-8-git-send-email-tom@tromey.com> In-Reply-To: <1474949330-4307-1-git-send-email-tom@tromey.com> References: <1474949330-4307-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bojhR-0006Nj-Lw X-Source-Sender: 71-218-192-86.hlrn.qwest.net (bapiya.Home) [71.218.192.86]:56110 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This changes scoped_minimal_symbol_reader to require the objfile to be passed to the constructor. The class now records the objfile and automatically uses it later in "install". This is a minor cleanup that will come in useful in the next patch. It is separate from the first patch to keep that one a bit simpler to understand. 2016-09-26 Tom Tromey * xcoffread.c (xcoff_initial_scan): Update. * mipsread.c (mipscoff_symfile_read): Update. * minsyms.c (scoped_minimal_symbol_reader): Add obj argument. Initialize member. (install): Remove objfile argument. * mdebugread.c (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symfile_read): Update. * elfread.c (elf_read_minimal_symbols): Update. * dbxread.c (dbx_symfile_read): Update. * coffread.c (coff_symfile_read): Update. * minsyms.h (scoped_minimal_symbol_reader): Add objfile member. (constructor): Add objfile argument. (scoped_minimal_symbol_reader::install): Remove objfile argument. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/coffread.c | 4 ++-- gdb/dbxread.c | 4 ++-- gdb/elfread.c | 4 ++-- gdb/machoread.c | 4 ++-- gdb/mdebugread.c | 4 ++-- gdb/minsyms.c | 5 +++-- gdb/minsyms.h | 6 ++++-- gdb/mipsread.c | 4 ++-- gdb/xcoffread.c | 4 ++-- 10 files changed, 37 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81aeec9..dac71f3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,21 @@ 2016-09-26 Tom Tromey + * xcoffread.c (xcoff_initial_scan): Update. + * mipsread.c (mipscoff_symfile_read): Update. + * minsyms.c (scoped_minimal_symbol_reader): Add obj argument. + Initialize member. + (install): Remove objfile argument. + * mdebugread.c (elfmdebug_build_psymtabs): Update. + * machoread.c (macho_symfile_read): Update. + * elfread.c (elf_read_minimal_symbols): Update. + * dbxread.c (dbx_symfile_read): Update. + * coffread.c (coff_symfile_read): Update. + * minsyms.h (scoped_minimal_symbol_reader): Add objfile member. + (constructor): Add objfile argument. + (scoped_minimal_symbol_reader::install): Remove objfile argument. + +2016-09-26 Tom Tromey + * xcoffread.c (xcoff_initial_scan): Use scoped_minimal_symbol_reader. * mipsread.c (mipscoff_symfile_read): Use diff --git a/gdb/coffread.c b/gdb/coffread.c index e504cde..a86f223 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -645,7 +645,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) if (val < 0) error (_("\"%s\": can't get string table"), name); - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); /* Now that the executable file is positioned at symbol table, process it and define symbols accordingly. */ @@ -655,7 +655,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ - reader.install (objfile); + reader.install (); if (pe_file) { diff --git a/gdb/dbxread.c b/gdb/dbxread.c index a0e1cac..59c809a 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -558,7 +558,7 @@ dbx_symfile_read (struct objfile *objfile, int symfile_flags) free_pending_blocks (); back_to = make_cleanup (really_free_pendings, 0); - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); /* Read stabs data from executable file and define symbols. */ @@ -571,7 +571,7 @@ dbx_symfile_read (struct objfile *objfile, int symfile_flags) /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ - reader.install (objfile); + reader.install (); do_cleanups (back_to); } diff --git a/gdb/elfread.c b/gdb/elfread.c index e1ae92a..98574ca 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1049,7 +1049,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, return; } - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); back_to = make_cleanup (null_cleanup, NULL); /* Allocate struct to keep track of the symfile. */ @@ -1149,7 +1149,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, responsibility to install them. "mdebug" appears to be the only one which will do this. */ - reader.install (objfile); + reader.install (); do_cleanups (back_to); if (symtab_create_debug) diff --git a/gdb/machoread.c b/gdb/machoread.c index 19a2f42..0eb438a 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -861,7 +861,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags) symbol_table = (asymbol **) xmalloc (storage_needed); make_cleanup (xfree, symbol_table); - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table); @@ -872,7 +872,7 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags) macho_symtab_read (objfile, symcount, symbol_table, &oso_vector); - reader.install (objfile); + reader.install (); } /* Try to read .eh_frame / .debug_frame. */ diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index d07e683..b93024b 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4875,7 +4875,7 @@ elfmdebug_build_psymtabs (struct objfile *objfile, information from .mdebug in an ELF file, or whether we will. Re-initialize the minimal symbol reader in case we do. */ - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); info = ((struct ecoff_debug_info *) obstack_alloc (&objfile->objfile_obstack, @@ -4887,7 +4887,7 @@ elfmdebug_build_psymtabs (struct objfile *objfile, mdebug_build_psymtabs (objfile, swap, info); - reader.install (objfile); + reader.install (); } void diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 7b316ce..b6f306b 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -921,7 +921,8 @@ get_symbol_leading_char (bfd *abfd) /* See minsyms.h. */ -scoped_minimal_symbol_reader::scoped_minimal_symbol_reader () +scoped_minimal_symbol_reader::scoped_minimal_symbol_reader (struct objfile *obj) +: objfile (obj) { msym_count = 0; msym_bunch = NULL; @@ -1232,7 +1233,7 @@ build_minimal_symbol_hash_tables (struct objfile *objfile) attempts to demangle them if we later add more minimal symbols. */ void -scoped_minimal_symbol_reader::install (struct objfile *objfile) +scoped_minimal_symbol_reader::install () { int bindex; int mcount; diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 5ea3610..7ba5991 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -64,14 +64,14 @@ class scoped_minimal_symbol_reader Currently, minimal symbol table creation is not reentrant; it relies on global (static) variables in minsyms.c. */ - explicit scoped_minimal_symbol_reader (); + explicit scoped_minimal_symbol_reader (struct objfile *); ~scoped_minimal_symbol_reader (); /* Install the minimal symbols that have been collected into the given objfile. */ - void install (struct objfile *); + void install (); private: @@ -79,6 +79,8 @@ class scoped_minimal_symbol_reader scoped_minimal_symbol_reader &operator= (const scoped_minimal_symbol_reader &); scoped_minimal_symbol_reader (const scoped_minimal_symbol_reader &); + + struct objfile *objfile; }; /* Record a new minimal symbol. This is the "full" entry point; diff --git a/gdb/mipsread.c b/gdb/mipsread.c index da09c03..e5285d2 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -70,7 +70,7 @@ mipscoff_symfile_read (struct objfile *objfile, int symfile_flags) { bfd *abfd = objfile->obfd; - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); /* Now that the executable file is positioned at symbol table, process it and define symbols accordingly. */ @@ -89,7 +89,7 @@ mipscoff_symfile_read (struct objfile *objfile, int symfile_flags) /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ - reader.install (objfile); + reader.install (); } /* Perform any local cleanups required when we are done with a diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 81b323c..6545e94 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -3006,7 +3006,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags) free_pending_blocks (); back_to = make_cleanup (really_free_pendings, 0); - scoped_minimal_symbol_reader reader; + scoped_minimal_symbol_reader reader (objfile); /* Now that the symbol table data of the executable file are all in core, process them and define symbols accordingly. */ @@ -3016,7 +3016,7 @@ xcoff_initial_scan (struct objfile *objfile, int symfile_flags) /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ - reader.install (objfile); + reader.install (); /* DWARF2 sections. */