From patchwork Wed May 23 04:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27418 Received: (qmail 113406 invoked by alias); 23 May 2018 04:59:07 -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 113145 invoked by uid 89); 23 May 2018 04:59:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1059, cust X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 May 2018 04:59:00 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway33.websitewelcome.com (Postfix) with ESMTP id A01AC7AB5C9 for ; Tue, 22 May 2018 23:58:59 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id LLrXfwLSvBcCXLLrXfqn6t; Tue, 22 May 2018 23:58:59 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:56108 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fLLrX-003S5D-Br; Tue, 22 May 2018 23:58:59 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 04/42] Move last_source file to buildsym_compunit Date: Tue, 22 May 2018 22:58:13 -0600 Message-Id: <20180523045851.11660-5-tom@tromey.com> In-Reply-To: <20180523045851.11660-1-tom@tromey.com> References: <20180523045851.11660-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fLLrX-003S5D-Br X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:56108 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This moves the global last_source_file into buildsym_compunit. gdb/ChangeLog 2018-05-22 Tom Tromey * buildsym.c (buildsym_compunit::buildsym_compunit): Add name parameter. (buildsym_compunit::set_last_source_file): New method. : New member. (prepare_for_building): Remove "name" parameter. (start_symtab, restart_symtab, reset_symtab_globals): Update. (last_source_file): Remove. (set_last_source_file, get_last_source_file): Update. --- gdb/ChangeLog | 11 +++++++++++ gdb/buildsym.c | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 9e0c39a4a4..5dd6f7e343 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -105,9 +105,10 @@ struct buildsym_compunit COMP_DIR is the directory in which the compilation unit was compiled (or NULL if not known). */ - buildsym_compunit (struct objfile *objfile_, const char *comp_dir_, - enum language language_) + buildsym_compunit (struct objfile *objfile_, const char *name, + const char *comp_dir_, enum language language_) : objfile (objfile_), + m_last_source_file (name == nullptr ? nullptr : xstrdup (name)), comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)), language (language_) { @@ -128,6 +129,12 @@ struct buildsym_compunit } } + void set_last_source_file (const char *name) + { + char *new_name = name == NULL ? NULL : xstrdup (name); + m_last_source_file.reset (new_name); + } + /* The objfile we're reading debug info from. */ struct objfile *objfile; @@ -140,6 +147,12 @@ struct buildsym_compunit /* The subfile of the main source file. */ struct subfile *main_subfile = nullptr; + /* Name of source file whose symbol data we are now processing. This + comes from a symbol of type N_SO for stabs. For Dwarf it comes + from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */ + + gdb::unique_xmalloc_ptr m_last_source_file; + /* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */ gdb::unique_xmalloc_ptr comp_dir; @@ -1005,9 +1018,8 @@ get_macro_table (void) buildsym_init. */ static void -prepare_for_building (const char *name, CORE_ADDR start_addr) +prepare_for_building (CORE_ADDR start_addr) { - set_last_source_file (name); last_source_start_addr = start_addr; local_symbols = NULL; @@ -1044,9 +1056,9 @@ struct compunit_symtab * start_symtab (struct objfile *objfile, const char *name, const char *comp_dir, CORE_ADDR start_addr, enum language language) { - prepare_for_building (name, start_addr); + prepare_for_building (start_addr); - buildsym_compunit = new struct buildsym_compunit (objfile, comp_dir, + buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir, language); /* Allocate the compunit symtab now. The caller needs it to allocate @@ -1081,10 +1093,11 @@ void restart_symtab (struct compunit_symtab *cust, const char *name, CORE_ADDR start_addr) { - prepare_for_building (name, start_addr); + prepare_for_building (start_addr); buildsym_compunit = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust), + name, COMPUNIT_DIRNAME (cust), compunit_language (cust)); buildsym_compunit->compunit_symtab = cust; @@ -1172,8 +1185,6 @@ watch_main_source_file_lossage (void) static void reset_symtab_globals (void) { - set_last_source_file (NULL); - local_symbols = NULL; local_using_directives = NULL; file_symbols = NULL; @@ -1706,19 +1717,14 @@ merge_symbol_lists (struct pending **srclist, struct pending **targetlist) } -/* Name of source file whose symbol data we are now processing. This - comes from a symbol of type N_SO for stabs. For Dwarf it comes - from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */ - -static char *last_source_file; - /* See buildsym.h. */ void set_last_source_file (const char *name) { - xfree (last_source_file); - last_source_file = name == NULL ? NULL : xstrdup (name); + gdb_assert (buildsym_compunit != nullptr || name == nullptr); + if (buildsym_compunit != nullptr) + buildsym_compunit->set_last_source_file (name); } /* See buildsym.h. */ @@ -1726,7 +1732,9 @@ set_last_source_file (const char *name) const char * get_last_source_file (void) { - return last_source_file; + if (buildsym_compunit == nullptr) + return nullptr; + return buildsym_compunit->m_last_source_file.get (); }