From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 825933947424 for ; Fri, 28 Jan 2022 12:45:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 825933947424 X-ASG-Debug-ID: 1643373932-0c856e06ab271b30001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 86L9MNAHbFq8183l (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 28 Jan 2022 07:45:32 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 268D7441D69; Fri, 28 Jan 2022 07:45:32 -0500 (EST) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Date: Fri, 28 Jan 2022 07:45:05 -0500 X-ASG-Orig-Subj: [PATCH 07/33] gdb: remove COMPUNIT_FILETABS macro Message-Id: <20220128124531.2302941-8-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128124531.2302941-1-simon.marchi@polymtl.ca> References: <20220128124531.2302941-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1643373932 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 9733 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.95629 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3612.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 12:45:47 -0000 From: Simon Marchi I think that most remaining uses of COMPUNIT_FILETABS intend to get the primary filetab of the compunit_symtab specifically (and not to iterate over all filetabs, for example, those cases would use compunit_filetabs, which has been converted to compunit_symtab::filetabs), so replace mosts uses with compunit_symtab::primary_filetab. In jit.c, function finalize_symtab, we can save the symtab object returned by allocate_symtab and use it, it makes things simpler. Change-Id: I4e51d6d4b40759de8768b61292e5e13c8eae2e38 --- gdb/buildsym.c | 4 ++-- gdb/dwarf2/read.c | 8 ++++---- gdb/jit.c | 8 ++++---- gdb/linespec.c | 2 +- gdb/mdebugread.c | 16 ++++++++-------- gdb/symmisc.c | 7 ++++--- gdb/symtab.h | 3 +-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 914834f8e51f..855d84bd27a6 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1031,7 +1031,7 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, int block_i; /* The main source file's symtab. */ - struct symtab *symtab = COMPUNIT_FILETABS (cu); + struct symtab *symtab = cu->primary_filetab (); for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++) { @@ -1150,7 +1150,7 @@ set_missing_symtab (struct pending *pending_list, for (i = 0; i < pending->nsyms; ++i) { if (symbol_symtab (pending->symbol[i]) == NULL) - symbol_set_symtab (pending->symbol[i], COMPUNIT_FILETABS (cu)); + symbol_set_symtab (pending->symbol[i], cu->primary_filetab ()); } } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 84877e6c7fe0..7e62d11aa2cc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9477,8 +9477,8 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && COMPUNIT_FILETABS (cust)->language != language_unknown)) - COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang; + && cust->primary_filetab ()->language != language_unknown)) + cust->primary_filetab ()->language = cu->per_cu->lang; /* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can produce DW_AT_location with location lists but it can be possibly @@ -9562,8 +9562,8 @@ process_full_type_unit (dwarf2_cu *cu, do not set the language if it was already deduced by start_subfile. */ if (!(cu->per_cu->lang == language_c - && COMPUNIT_FILETABS (cust)->language != language_c)) - COMPUNIT_FILETABS (cust)->language = cu->per_cu->lang; + && cust->primary_filetab ()->language != language_c)) + cust->primary_filetab ()->language = cu->per_cu->lang; } } else diff --git a/gdb/jit.c b/gdb/jit.c index 42776b956832..007313d3b800 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -500,7 +500,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) }); cust = allocate_compunit_symtab (objfile, stab->file_name.c_str ()); - allocate_symtab (cust, stab->file_name.c_str ()); + symtab *filetab = allocate_symtab (cust, stab->file_name.c_str ()); add_compunit_symtab_to_objfile (cust); /* JIT compilers compile in memory. */ @@ -512,9 +512,9 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) size_t size = ((stab->linetable->nitems - 1) * sizeof (struct linetable_entry) + sizeof (struct linetable)); - SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)) + SYMTAB_LINETABLE (filetab) = (struct linetable *) obstack_alloc (&objfile->objfile_obstack, size); - memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)), + memcpy (SYMTAB_LINETABLE (filetab), stab->linetable.get (), size); } @@ -553,7 +553,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) /* The name. */ SYMBOL_DOMAIN (block_name) = VAR_DOMAIN; SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK; - symbol_set_symtab (block_name, COMPUNIT_FILETABS (cust)); + symbol_set_symtab (block_name, filetab); SYMBOL_TYPE (block_name) = lookup_function_type (block_type); SYMBOL_BLOCK_VALUE (block_name) = new_block; diff --git a/gdb/linespec.c b/gdb/linespec.c index b24cf30dc712..f8b4b86a1e8e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1179,7 +1179,7 @@ iterate_over_all_matching_symtabs for (compunit_symtab *cu : objfile->compunits ()) { - struct symtab *symtab = COMPUNIT_FILETABS (cu); + struct symtab *symtab = cu->primary_filetab (); iterate_over_file_blocks (symtab, lookup_name, name_domain, callback); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 1b327ad61153..836da8a3b8ca 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4084,17 +4084,17 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) /* The proper language was already determined when building the psymtab, use it. */ - COMPUNIT_FILETABS (cust)->language = PST_PRIVATE (pst)->pst_language; + cust->primary_filetab ()->language = PST_PRIVATE (pst)->pst_language; } - psymtab_language = COMPUNIT_FILETABS (cust)->language; + psymtab_language = cust->primary_filetab ()->language; - lines = SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)); + lines = SYMTAB_LINETABLE (cust->primary_filetab ()); /* Get a new lexical context. */ push_parse_stack (); - top_stack->cur_st = COMPUNIT_FILETABS (cust); + top_stack->cur_st = cust->primary_filetab (); top_stack->cur_block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK); BLOCK_START (top_stack->cur_block) = pst->text_low (objfile); @@ -4173,7 +4173,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) size = lines->nitems; if (size > 1) --size; - SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)) + SYMTAB_LINETABLE (cust->primary_filetab ()) = ((struct linetable *) obstack_copy (&mdebugread_objfile->objfile_obstack, lines, (sizeof (struct linetable) @@ -4183,7 +4183,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) /* .. and our share of externals. XXX use the global list to speed up things here. How? FIXME, Maybe quit once we have found the right number of ext's? */ - top_stack->cur_st = COMPUNIT_FILETABS (cust); + top_stack->cur_st = cust->primary_filetab (); top_stack->cur_block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st), GLOBAL_BLOCK); @@ -4201,7 +4201,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) { printf_filtered (_("File %s contains %d unresolved references:"), symtab_to_filename_for_display - (COMPUNIT_FILETABS (cust)), + (cust->primary_filetab ()), n_undef_symbols); printf_filtered ("\n\t%4d variables\n\t%4d " "procedures\n\t%4d labels\n", @@ -4211,7 +4211,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile) } pop_parse_stack (); - sort_blocks (COMPUNIT_FILETABS (cust)); + sort_blocks (cust->primary_filetab ()); } /* Now link the psymtab and the symtab. */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index b4b58f6e0f51..61e3eff562e5 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -329,8 +329,9 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) } else { + compunit_symtab *compunit = SYMTAB_COMPUNIT (symtab); const char *compunit_filename - = symtab_to_filename_for_display (COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab))); + = symtab_to_filename_for_display (compunit->primary_filetab ()); fprintf_filtered (outfile, "\nBlockvector same as owning compunit: %s\n\n", @@ -346,7 +347,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) if (cust->user != nullptr) { const char *addr - = host_address_to_string (COMPUNIT_FILETABS (cust->user)); + = host_address_to_string (cust->user->primary_filetab ()); fprintf_filtered (outfile, "Compunit user: %s\n", addr); } if (cust->includes != nullptr) @@ -356,7 +357,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) if (include == nullptr) break; const char *addr - = host_address_to_string (COMPUNIT_FILETABS (include)); + = host_address_to_string (include->primary_filetab ()); fprintf_filtered (outfile, "Compunit include: %s\n", addr); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 670826dd1832..45d4bc4dc299 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1577,7 +1577,6 @@ struct compunit_symtab using compunit_symtab_range = next_range; -#define COMPUNIT_FILETABS(cust) (*(cust)->filetabs ().begin ()) #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat) #define COMPUNIT_PRODUCER(cust) ((cust)->producer) #define COMPUNIT_DIRNAME(cust) ((cust)->dirname) @@ -1596,7 +1595,7 @@ extern enum language compunit_language (const struct compunit_symtab *cust); static inline bool is_main_symtab_of_compunit_symtab (struct symtab *symtab) { - return symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)); + return symtab == SYMTAB_COMPUNIT (symtab)->primary_filetab (); } -- 2.34.1