public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
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	[thread overview]
Message-ID: <20210322193417.2376788-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20210322193417.2376788-1-simon.marchi@efficios.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

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


  parent reply	other threads:[~2021-03-22 19:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 19:34 [PATCH 0/4] Small Misc psymtabs / objfile cleanups Simon Marchi
2021-03-22 19:34 ` [PATCH 1/4] gdb: add intern method to objfile_per_bfd_storage Simon Marchi
2021-03-23 14:47   ` Christian Biesinger
2021-03-23 15:48     ` Simon Marchi
2021-03-23 15:53       ` Christian Biesinger
2021-03-23 16:08         ` Simon Marchi
2021-04-01 17:44       ` Tom Tromey
2021-04-02 15:38         ` Simon Marchi
2021-03-22 19:34 ` Simon Marchi [this message]
2021-04-01 17:43   ` [PATCH 2/4] gdb: use std::string in partial_symtab::partial_symtab / allocate_symtab Tom Tromey
2021-03-22 19:34 ` [PATCH 3/4] gdb: pass objfile_per_bfd_storage instead of objfile to partial_symtab Simon Marchi
2021-04-01 17:47   ` Tom Tromey
2021-04-02 15:42     ` Simon Marchi
2021-03-22 19:34 ` [PATCH 4/4] gdb: remove objfile parameter from get_objfile_bfd_data Simon Marchi
2021-04-01 17:52   ` Tom Tromey
2021-04-02 15:52     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210322193417.2376788-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).