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 D87F03854813 for ; Mon, 22 Mar 2021 19:34:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D87F03854813 X-ASG-Debug-ID: 1616441658-0c856e67e2a7b490001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id PH2h7PehBbdZJ8kk (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 A65AB441D65; 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 2/4] gdb: use std::string in partial_symtab::partial_symtab / allocate_symtab Date: Mon, 22 Mar 2021 15:34:15 -0400 X-ASG-Orig-Subj: [PATCH 2/4] gdb: use std::string in partial_symtab::partial_symtab / allocate_symtab Message-Id: <20210322193417.2376788-3-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: 2568 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 simplifies the code a bit. gdb/ChangeLog: * psymtab.c (partial_symtab::partial_symtab): Change last_objfile_name to be an std::string. * symfile.c (allocate_symtab): Likewise. Change-Id: I3dfe217233ed9346c2abc04a9b1be0df69a90af8 --- gdb/psymtab.c | 11 +++++------ gdb/symfile.c | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 597817269c1..2ee05ec415b 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1575,16 +1575,15 @@ partial_symtab::partial_symtab (const char *filename_, { /* Be a bit clever with debugging messages, and don't print objfile every time, only when it changes. */ - static char *last_objfile_name = NULL; + static std::string last_objfile_name; + const char *this_objfile_name = objfile_name (objfile); - if (last_objfile_name == NULL - || strcmp (last_objfile_name, objfile_name (objfile)) != 0) + if (last_objfile_name.empty () || last_objfile_name != this_objfile_name) { - xfree (last_objfile_name); - last_objfile_name = xstrdup (objfile_name (objfile)); + last_objfile_name = this_objfile_name; fprintf_filtered (gdb_stdlog, "Creating one or more psymtabs for objfile %s ...\n", - last_objfile_name); + this_objfile_name); } fprintf_filtered (gdb_stdlog, "Created psymtab %s for module %s.\n", diff --git a/gdb/symfile.c b/gdb/symfile.c index adcdc169306..ce696321e25 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2772,16 +2772,15 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename) { /* Be a bit clever with debugging messages, and don't print objfile every time, only when it changes. */ - static char *last_objfile_name = NULL; + static std::string last_objfile_name; + const char *this_objfile_name = objfile_name (objfile); - if (last_objfile_name == NULL - || strcmp (last_objfile_name, objfile_name (objfile)) != 0) + if (last_objfile_name.empty () || last_objfile_name != this_objfile_name) { - xfree (last_objfile_name); - last_objfile_name = xstrdup (objfile_name (objfile)); + last_objfile_name = this_objfile_name; fprintf_filtered (gdb_stdlog, "Creating one or more symtabs for objfile %s ...\n", - last_objfile_name); + this_objfile_name); } fprintf_filtered (gdb_stdlog, "Created symtab %s for module %s.\n", -- 2.30.0