public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: introduce symtab_create_debug_printf
Date: Sat, 30 Jul 2022 00:55:09 +0000 (GMT)	[thread overview]
Message-ID: <20220730005509.6A33F384B833@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2ab317fb8290ea96bdb446957d2e221634fd25c8

commit 2ab317fb8290ea96bdb446957d2e221634fd25c8
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Thu Apr 7 08:00:16 2022 -0400

    gdb: introduce symtab_create_debug_printf
    
    Introduce symtab_create_debug_printf and symtab_create_debug_printf_v,
    to print the debug messages enabled by "set debug symtab-create".
    
    Change-Id: I442500903f72d4635c2dd9eaef770111f317dc04

Diff:
---
 gdb/elfread.c | 15 ++++-----------
 gdb/minsyms.c | 16 +++++-----------
 gdb/psymtab.c | 14 +++++++-------
 gdb/symfile.c | 22 +++++++++-------------
 gdb/symtab.h  | 11 +++++++++++
 5 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index deed34c35c7..e0de52cd1b9 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1046,12 +1046,8 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
   asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
   asymbol *synthsyms;
 
-  if (symtab_create_debug)
-    {
-      gdb_printf (gdb_stdlog,
-		  "Reading minimal symbols of objfile %s ...\n",
-		  objfile_name (objfile));
-    }
+  symtab_create_debug_printf ("reading minimal symbols of objfile %s",
+			      objfile_name (objfile));
 
   /* If we already have minsyms, then we can skip some work here.
      However, if there were stabs or mdebug sections, we go ahead and
@@ -1063,9 +1059,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
       && ei->mdebugsect == NULL
       && ei->ctfsect == NULL)
     {
-      if (symtab_create_debug)
-	gdb_printf (gdb_stdlog,
-		    "... minimal symbols previously read\n");
+      symtab_create_debug_printf ("minimal symbols were previously read");
       return;
     }
 
@@ -1169,8 +1163,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
 
   reader.install ();
 
-  if (symtab_create_debug)
-    gdb_printf (gdb_stdlog, "Done reading minimal symbols.\n");
+  symtab_create_debug_printf ("done reading minimal symbols");
 }
 
 /* Scan and build partial symbols for a symbol file.
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4ec62558b69..3f4ad90dbd3 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1184,11 +1184,9 @@ minimal_symbol_reader::record_full (gdb::string_view name,
   if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
     return (NULL);
 
-  if (symtab_create_debug >= 2)
-    gdb_printf (gdb_stdlog,
-		"Recording minsym:  %-21s  %18s  %4d  %.*s\n",
-		mst_str (ms_type), hex_string (address), section,
-		(int) name.size (), name.data ());
+  symtab_create_debug_printf_v ("recording minsym:  %-21s  %18s  %4d  %.*s",
+				mst_str (ms_type), hex_string (address), section,
+				(int) name.size (), name.data ());
 
   if (m_msym_bunch_index == BUNCH_SIZE)
     {
@@ -1389,12 +1387,8 @@ minimal_symbol_reader::install ()
 
   if (m_msym_count > 0)
     {
-      if (symtab_create_debug)
-	{
-	  gdb_printf (gdb_stdlog,
-		      "Installing %d minimal symbols of objfile %s.\n",
-		      m_msym_count, objfile_name (m_objfile));
-	}
+      symtab_create_debug_printf ("installing %d minimal symbols of objfile %s",
+				  m_msym_count, objfile_name (m_objfile));
 
       /* Allocate enough space, into which we will gather the bunches
 	 of new and existing minimal symbols, sort them, and then
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index d16c3bb3083..012073d8bbe 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1314,7 +1314,7 @@ partial_symtab::partial_symtab (const char *filename_,
 
   filename = objfile_per_bfd->intern (filename_);
 
-  if (symtab_create_debug)
+  if (symtab_create_debug >= 1)
     {
       /* Be a bit clever with debugging messages, and don't print objfile
 	 every time, only when it changes.  */
@@ -1325,13 +1325,13 @@ partial_symtab::partial_symtab (const char *filename_,
       if (last_bfd_name.empty () || last_bfd_name != this_bfd_name)
 	{
 	  last_bfd_name = this_bfd_name;
-	  gdb_printf (gdb_stdlog,
-		      "Creating one or more psymtabs for %s ...\n",
-		      this_bfd_name);
+
+	  symtab_create_debug_printf ("creating one or more psymtabs for %s",
+				      this_bfd_name);
 	}
-      gdb_printf (gdb_stdlog,
-		  "Created psymtab %s for module %s.\n",
-		  host_address_to_string (this), filename);
+
+      symtab_create_debug_printf ("created psymtab %s for module %s",
+				  host_address_to_string (this), filename);
     }
 }
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ec3244269b1..27e95718327 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2794,13 +2794,13 @@ allocate_symtab (struct compunit_symtab *cust, const char *filename)
       if (last_objfile_name.empty () || last_objfile_name != this_objfile_name)
 	{
 	  last_objfile_name = this_objfile_name;
-	  gdb_printf (gdb_stdlog,
-		      "Creating one or more symtabs for objfile %s ...\n",
-		      this_objfile_name);
+
+	  symtab_create_debug_printf_v
+	    ("creating one or more symtabs for objfile %s", this_objfile_name);
 	}
-      gdb_printf (gdb_stdlog,
-		  "Created symtab %s for module %s.\n",
-		  host_address_to_string (symtab), filename);
+
+      symtab_create_debug_printf_v ("created symtab %s for module %s",
+				    host_address_to_string (symtab), filename);
     }
 
   /* Add it to CUST's list of symtabs.  */
@@ -2833,13 +2833,9 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 
   cu->set_debugformat ("unknown");
 
-  if (symtab_create_debug)
-    {
-      gdb_printf (gdb_stdlog,
-		  "Created compunit symtab %s for %s.\n",
-		  host_address_to_string (cu),
-		  cu->name);
-    }
+  symtab_create_debug_printf_v ("created compunit symtab %s for %s",
+				host_address_to_string (cu),
+				cu->name);
 
   return cu;
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index ac902a4cbbe..4bc86645e2c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2601,6 +2601,17 @@ void fixup_section (struct general_symbol_info *ginfo,
 
 extern unsigned int symtab_create_debug;
 
+/* Print a "symtab-create" debug statement.  */
+
+#define symtab_create_debug_printf(fmt, ...) \
+  debug_prefixed_printf_cond (symtab_create_debug >= 1, "symtab-create", fmt, ##__VA_ARGS__)
+
+/* Print a verbose "symtab-create" debug statement, only if
+   "set debug symtab-create" is set to 2 or higher.  */
+
+#define symtab_create_debug_printf_v(fmt, ...) \
+  debug_prefixed_printf_cond (symtab_create_debug >= 2, "symtab-create", fmt, ##__VA_ARGS__)
+
 extern unsigned int symbol_lookup_debug;
 
 extern bool basenames_may_differ;


                 reply	other threads:[~2022-07-30  0:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220730005509.6A33F384B833@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@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).