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 8F7693857C47 for ; Wed, 1 Dec 2021 15:47:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F7693857C47 X-ASG-Debug-ID: 1638373650-0c856e2e463e6fb0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id nCYZA3O5ZOmwLXKF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 01 Dec 2021 10:47:31 -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 B573E441D68; Wed, 1 Dec 2021 10:47:30 -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 6/6] gdb: move compunit_filetabs to compunit_symtab::filetabs Date: Wed, 1 Dec 2021 10:47:29 -0500 X-ASG-Orig-Subj: [PATCH 6/6] gdb: move compunit_filetabs to compunit_symtab::filetabs Message-Id: <20211201154729.671498-6-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211201154729.671498-1-simon.marchi@polymtl.ca> References: <20211201154729.671498-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: 1638373651 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: 10671 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.94331 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP 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: Wed, 01 Dec 2021 15:47:45 -0000 From: Simon Marchi Make compunit_filetabs, used to iterate a compunit_symtab's filetabs, a method of compunit_symtab. The name filetabs conflicts with the current name of the field. Rename the field to m_filetabs, since at this point nothing outside of compunit_symtab uses it, so we should treat it as private (even though it's not actually private). Rename the last_filetab field to m_last_filetab as well (it's only used on compunit_symtab::add_filetab). Adjust the COMPUNIT_FILETABS macro to keep its current behavior of returning the first filetab. Change-Id: I537b553a44451c52d24b18ee1bfa47e23747cfc3 --- gdb/coffread.c | 2 +- gdb/maint.c | 4 ++-- gdb/objfiles.c | 2 +- gdb/source.c | 4 ++-- gdb/symmisc.c | 10 +++++----- gdb/symtab.c | 22 +++++++++++----------- gdb/symtab.h | 36 +++++++++++++++++------------------- 7 files changed, 39 insertions(+), 41 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index 4723662f1408..044cd82d61ae 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1177,7 +1177,7 @@ coff_symtab_read (minimal_symbol_reader &reader, { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) patch_opaque_types (s); } } diff --git a/gdb/maint.c b/gdb/maint.c index e03abfacdae7..1c6b89f2519b 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -947,8 +947,8 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, { ++nr_compunit_symtabs; nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu)); - nr_symtabs += std::distance (compunit_filetabs (cu).begin (), - compunit_filetabs (cu).end ()); + nr_symtabs += std::distance (cu->filetabs ().begin (), + cu->filetabs ().end ()); } } } diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 3da6f5211aa1..cd8eb916329b 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -651,7 +651,7 @@ objfile_relocate1 (struct objfile *objfile, { for (compunit_symtab *cust : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cust)) + for (symtab *s : cust->filetabs ()) { struct linetable *l; diff --git a/gdb/source.c b/gdb/source.c index 55fd1fd2b9b5..99fe69bdf5bd 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -338,7 +338,7 @@ select_source_symtab (struct symtab *s) { for (compunit_symtab *cu : ofp->compunits ()) { - for (symtab *symtab : compunit_filetabs (cu)) + for (symtab *symtab : cu->filetabs ()) { const char *name = symtab->filename; int len = strlen (name); @@ -418,7 +418,7 @@ forget_cached_source_info_for_objfile (struct objfile *objfile) { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { if (s->fullname != NULL) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index dc43ea666739..be4e350e7b38 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -72,7 +72,7 @@ print_objfile_statistics (void) i = linetables = 0; for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { i++; if (SYMTAB_LINETABLE (s) != NULL) @@ -126,7 +126,7 @@ dump_objfile (struct objfile *objfile) printf_filtered ("Symtabs:\n"); for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *symtab : compunit_filetabs (cu)) + for (symtab *symtab : cu->filetabs ()) { printf_filtered ("%s at ", symtab_to_filename_for_display (symtab)); @@ -472,7 +472,7 @@ maintenance_print_symbols (const char *args, int from_tty) for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { int print_for_source = 0; @@ -764,7 +764,7 @@ maintenance_info_symtabs (const char *regexp, int from_tty) { int printed_compunit_symtab_start = 0; - for (symtab *symtab : compunit_filetabs (cust)) + for (symtab *symtab : cust->filetabs ()) { QUIT; @@ -1030,7 +1030,7 @@ maintenance_info_line_tables (const char *regexp, int from_tty) { for (compunit_symtab *cust : objfile->compunits ()) { - for (symtab *symtab : compunit_filetabs (cust)) + for (symtab *symtab : cust->filetabs ()) { QUIT; diff --git a/gdb/symtab.c b/gdb/symtab.c index 47202ae46b96..d48bf11aa00d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -367,15 +367,15 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) symtab *prev_filetab = nullptr; /* Move PRIMARY_FILETAB to the head of the filetab list. */ - for (symtab *filetab : compunit_filetabs (this)) + for (symtab *filetab : this->filetabs ()) { if (filetab == primary_filetab) { if (prev_filetab != nullptr) { prev_filetab->next = primary_filetab->next; - primary_filetab->next = this->filetabs; - this->filetabs = primary_filetab; + primary_filetab->next = m_filetabs; + m_filetabs = primary_filetab; } break; @@ -384,7 +384,7 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) prev_filetab = filetab; } - gdb_assert (primary_filetab == this->filetabs); + gdb_assert (primary_filetab == m_filetabs); } /* See symtab.h. */ @@ -392,10 +392,10 @@ compunit_symtab::set_primary_filetab (symtab *primary_filetab) struct symtab * compunit_symtab::primary_filetab () const { - gdb_assert (this->filetabs != nullptr); + gdb_assert (m_filetabs != nullptr); /* The primary file symtab is the first one in the list. */ - return this->filetabs; + return m_filetabs; } /* See symtab.h. */ @@ -533,7 +533,7 @@ iterate_over_some_symtabs (const char *name, for (cust = first; cust != NULL && cust != after_last; cust = cust->next) { - for (symtab *s : compunit_filetabs (cust)) + for (symtab *s : cust->filetabs ()) { if (compare_filenames_for_search (s->filename, name)) { @@ -3282,7 +3282,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) They all have the same apriori range, that we found was right; but they have different line tables. */ - for (symtab *iter_s : compunit_filetabs (cust)) + for (symtab *iter_s : cust->filetabs ()) { /* Find the best line in this symtab. */ l = SYMTAB_LINETABLE (iter_s); @@ -3483,7 +3483,7 @@ find_line_symtab (struct symtab *sym_tab, int line, { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { struct linetable *l; int ind; @@ -4531,7 +4531,7 @@ info_sources_worker (struct ui_out *uiout, for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { const char *file = symtab_to_filename_for_display (s); const char *fullname = symtab_to_fullname (s); @@ -6185,7 +6185,7 @@ make_source_files_completion_list (const char *text, const char *word) { for (compunit_symtab *cu : objfile->compunits ()) { - for (symtab *s : compunit_filetabs (cu)) + for (symtab *s : cu->filetabs ()) { if (not_interesting_fname (s->filename)) continue; diff --git a/gdb/symtab.h b/gdb/symtab.h index ba8a94384f69..4d5916fbf6cd 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1401,6 +1401,10 @@ struct symtab char *fullname; }; +/* A range adapter to allowing iterating over all the file tables in a list. */ + +using symtab_range = next_range; + #define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab) #define SYMTAB_LINETABLE(symtab) ((symtab)->linetable) #define SYMTAB_LANGUAGE(symtab) ((symtab)->language) @@ -1459,17 +1463,22 @@ struct compunit_symtab m_objfile = objfile; } + symtab_range filetabs () const + { + return symtab_range (m_filetabs); + } + void add_filetab (symtab *filetab) { - if (this->filetabs == nullptr) + if (m_filetabs == nullptr) { - this->filetabs = filetab; - this->last_filetab = filetab; + m_filetabs = filetab; + m_last_filetab = filetab; } else { - this->last_filetab->next = filetab; - this->last_filetab = filetab; + m_last_filetab->next = filetab; + m_last_filetab = filetab; } } @@ -1503,14 +1512,14 @@ struct compunit_symtab source file (e.g., .c, .cc) is guaranteed to be first. Each symtab is a file, either the "main" source file (e.g., .c, .cc) or header (e.g., .h). */ - struct symtab *filetabs; + symtab *m_filetabs; /* Last entry in FILETABS list. Subfiles are added to the end of the list so they accumulate in order, with the main source subfile living at the front. The main reason is so that the main source file symtab is at the head of the list, and the rest appear in order for debugging convenience. */ - struct symtab *last_filetab; + symtab *m_last_filetab; /* Non-NULL string that identifies the format of the debugging information, such as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful @@ -1568,7 +1577,7 @@ struct compunit_symtab using compunit_symtab_range = next_range; -#define COMPUNIT_FILETABS(cust) ((cust)->filetabs) +#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) @@ -1578,17 +1587,6 @@ using compunit_symtab_range = next_range; #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid) #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table) -/* A range adapter to allowing iterating over all the file tables - within a compunit. */ - -using symtab_range = next_range; - -static inline symtab_range -compunit_filetabs (compunit_symtab *cu) -{ - return symtab_range (cu->filetabs); -} - /* Return the language of CUST. */ extern enum language compunit_language (const struct compunit_symtab *cust); -- 2.33.1