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 3FE58385BF9C for ; Fri, 28 Jan 2022 12:45:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3FE58385BF9C X-ASG-Debug-ID: 1643373932-0c856e06ab271b20001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id IZyPFT2M9QZ49ZoD (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 056C6441B21; 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 05/33] gdb: add compunit_symtab::set_primary_filetab method Date: Fri, 28 Jan 2022 07:45:03 -0500 X-ASG-Orig-Subj: [PATCH 05/33] gdb: add compunit_symtab::set_primary_filetab method Message-Id: <20220128124531.2302941-6-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: 2948 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.95629 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-3613.3 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, 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:40 -0000 From: Simon Marchi Add a method to set the primary filetab of the CU. This is currently done in buildsym_compunit::end_symtab_with_blockvector. Change-Id: I16c51a6b90a4cb4c0c5f183b0f2e12bc64b6fd74 --- gdb/buildsym.c | 24 ++---------------------- gdb/symtab.c | 28 ++++++++++++++++++++++++++++ gdb/symtab.h | 6 ++++++ 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 1754f5ffe6ed..914834f8e51f 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -996,28 +996,8 @@ buildsym_compunit::end_symtab_with_blockvector (struct block *static_block, symtab->language = subfile->language; } - /* Make sure the symtab of main_subfile is the first in its list. */ - { - struct symtab *main_symtab, *prev_symtab; - - main_symtab = m_main_subfile->symtab; - prev_symtab = NULL; - for (symtab *symtab : compunit_filetabs (cu)) - { - if (symtab == main_symtab) - { - if (prev_symtab != NULL) - { - prev_symtab->next = main_symtab->next; - main_symtab->next = COMPUNIT_FILETABS (cu); - COMPUNIT_FILETABS (cu) = main_symtab; - } - break; - } - prev_symtab = symtab; - } - gdb_assert (main_symtab == COMPUNIT_FILETABS (cu)); - } + /* Make sure the filetab of main_subfile is the primary filetab of the CU. */ + cu->set_primary_filetab (m_main_subfile->symtab); /* Fill out the compunit symtab. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 2028e837f0f1..f4f5f09f215a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -361,6 +361,34 @@ compunit_symtab::set_call_site_htab (htab_t call_site_htab) /* See symtab.h. */ +void +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)) + { + if (filetab == primary_filetab) + { + if (prev_filetab != nullptr) + { + prev_filetab->next = primary_filetab->next; + primary_filetab->next = this->filetabs; + this->filetabs = primary_filetab; + } + + break; + } + + prev_filetab = filetab; + } + + gdb_assert (primary_filetab == this->filetabs); +} + +/* See symtab.h. */ + struct symtab * compunit_symtab::primary_filetab () const { diff --git a/gdb/symtab.h b/gdb/symtab.h index 3fa4d5f5d0eb..23a348a381ce 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1473,6 +1473,12 @@ struct compunit_symtab } } + /* Make PRIMARY_FILETAB the primary filetab of this compunit symtab. + + PRIMARY_FILETAB must already be a filetab of this compunit symtab. */ + + void set_primary_filetab (symtab *primary_filetab); + /* Return the primary filetab of the compunit. */ symtab *primary_filetab () const; -- 2.34.1