From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf
Date: Wed, 27 Apr 2022 23:35:36 -0400 [thread overview]
Message-ID: <20220428033542.1636284-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220428033542.1636284-1-simon.marchi@polymtl.ca>
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
---
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 b136c605b1ae..b6dea7ece2be 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1047,12 +1047,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
@@ -1064,9 +1060,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;
}
@@ -1170,8 +1164,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 cbd0ad223928..f4cb89590ff0 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 402d6085fe61..57703fe215e6 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1384,7 +1384,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. */
@@ -1395,13 +1395,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 6f546f5b0591..b9ecef045377 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 8c2837cfa8b0..854167dde452 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2600,6 +2600,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;
--
2.35.2
next prev parent reply other threads:[~2022-04-28 3:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 3:35 [PATCH v3 0/7] Fix printing macros Simon Marchi
2022-04-28 3:35 ` Simon Marchi [this message]
2022-04-28 15:49 ` [PATCH v3 1/7] gdb: introduce symtab_create_debug_printf Tom Tromey
2022-04-28 3:35 ` [PATCH v3 2/7] gdb: add debug prints in buildsym.c Simon Marchi
2022-04-28 15:50 ` Tom Tromey
2022-04-28 3:35 ` [PATCH v3 3/7] gdb/dwarf: pass compilation directory to line header Simon Marchi
2022-04-28 15:48 ` Tom Tromey
2022-04-28 15:59 ` Simon Marchi
2022-04-28 3:35 ` [PATCH v3 4/7] gdb/dwarf: pass a file_entry to line_header::file_file_name Simon Marchi
2022-05-03 20:12 ` Bruno Larsen
2022-07-28 16:26 ` Simon Marchi
2022-04-28 3:35 ` [PATCH v3 5/7] gdb: add "id" fields to identify symtabs and subfiles Simon Marchi
2022-04-28 23:53 ` Lancelot SIX
2022-07-28 17:46 ` Simon Marchi
2022-04-28 3:35 ` [PATCH v3 6/7] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile Simon Marchi
2022-05-12 13:07 ` Bruno Larsen
2022-07-28 17:47 ` Simon Marchi
2022-04-28 3:35 ` [PATCH v3 7/7] gdb/testsuite: add macros test for source files compiled in various ways Simon Marchi
2022-05-12 13:17 ` Bruno Larsen
2022-07-28 17:51 ` Simon Marchi
2022-07-30 0:56 ` [PATCH v3 0/7] Fix printing macros 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=20220428033542.1636284-2-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--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).