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 AB24D3857003 for ; Mon, 22 Mar 2021 19:34:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AB24D3857003 X-ASG-Debug-ID: 1616441658-0c856e6cd5d2b9f0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id cRsKsj6WJ0emLn6X (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Mar 2021 15:34:18 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 916B4441D64; Mon, 22 Mar 2021 15:34:18 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH 1/4] gdb: add intern method to objfile_per_bfd_storage Date: Mon, 22 Mar 2021 15:34:14 -0400 X-ASG-Orig-Subj: [PATCH 1/4] gdb: add intern method to objfile_per_bfd_storage Message-Id: <20210322193417.2376788-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210322193417.2376788-1-simon.marchi@efficios.com> References: <20210322193417.2376788-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1616441658 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 1720 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.88710 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-22.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Mon, 22 Mar 2021 19:34:21 -0000 From: Simon Marchi This allows factoring out the internal implementation details that are currently in the two objfile::intern methods. gdb/ChangeLog: * objfiles.h (struct objfile_per_bfd_storage) : New method. (struct objfile) : Use objfile::objfile_per_bfd_storage::intern. Change-Id: Ifd54026c5efaeffafac9b84ff84c199acc7ce78a --- gdb/objfiles.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 41f8fc913d8..d9aa06636f5 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -270,6 +270,14 @@ struct objfile_per_bfd_storage ~objfile_per_bfd_storage (); + /* Intern STRING in this object's string cache and return the unique copy. + The copy has the same lifetime as this object. */ + + const char *intern (gdb::string_view str) + { + return (const char *) string_cache.insert (str.data (), str.size () + 1); + } + /* The storage has an obstack of its own. */ auto_obstack storage_obstack; @@ -516,15 +524,14 @@ struct objfile lifetime as the per-BFD object. */ const char *intern (const char *str) { - return (const char *) per_bfd->string_cache.insert (str, strlen (str) + 1); + return per_bfd->intern (str); } /* Intern STRING and return the unique copy. The copy has the same lifetime as the per-BFD object. */ const char *intern (const std::string &str) { - return (const char *) per_bfd->string_cache.insert (str.c_str (), - str.size () + 1); + return per_bfd->intern (str); } /* Retrieve the gdbarch associated with this objfile. */ -- 2.30.0