* [PATCH 0/7] Send some logging output to gdb_stdlog
@ 2021-12-28 22:49 Tom Tromey
2021-12-28 22:49 ` [PATCH 1/7] Send debugging data to gdb_stdlog in mips-linux-nat.c Tom Tromey
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches
I found a few spots where gdb was not sending logging output to
gdb_stdlog. This patch fixes the ones I found.
Regression tested on x86-64 Fedora 34, though of course I wouldn't
necessarily expect that to find problems with this patch.
Tom
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/7] Send debugging data to gdb_stdlog in mips-linux-nat.c
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 2/7] Use debug_prefixed_printf_cond_nofunc in microblaze.c Tom Tromey
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes mips-linux-nat.c to send some logging output to
gdb_stdlog, rather than stdout. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/mips-linux-nat.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 1088a7dc1b0..cbf4b59ab4c 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -508,25 +508,26 @@ mips_show_dr (const char *func, CORE_ADDR addr,
{
int i;
- puts_unfiltered (func);
+ fputs_unfiltered (func, gdb_stdlog);
if (addr || len)
- printf_unfiltered (" (addr=%s, len=%d, type=%s)",
- paddress (target_gdbarch (), addr), len,
- type == hw_write ? "data-write"
- : (type == hw_read ? "data-read"
- : (type == hw_access ? "data-read/write"
- : (type == hw_execute ? "instruction-execute"
- : "??unknown??"))));
- puts_unfiltered (":\n");
+ fprintf_unfiltered (gdb_stdlog,
+ " (addr=%s, len=%d, type=%s)",
+ paddress (target_gdbarch (), addr), len,
+ type == hw_write ? "data-write"
+ : (type == hw_read ? "data-read"
+ : (type == hw_access ? "data-read/write"
+ : (type == hw_execute ? "instruction-execute"
+ : "??unknown??"))));
+ fputs_unfiltered (":\n", gdb_stdlog);
for (i = 0; i < MAX_DEBUG_REGISTER; i++)
- printf_unfiltered ("\tDR%d: lo=%s, hi=%s\n", i,
- paddress (target_gdbarch (),
- mips_linux_watch_get_watchlo (&watch_mirror,
- i)),
- paddress (target_gdbarch (),
- mips_linux_watch_get_watchhi (&watch_mirror,
- i)));
+ fprintf_unfiltered (gdb_stdlog, "\tDR%d: lo=%s, hi=%s\n", i,
+ paddress (target_gdbarch (),
+ mips_linux_watch_get_watchlo (&watch_mirror,
+ i)),
+ paddress (target_gdbarch (),
+ mips_linux_watch_get_watchhi (&watch_mirror,
+ i)));
}
/* Target to_can_use_hw_breakpoint implementation. Return 1 if we can
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/7] Use debug_prefixed_printf_cond_nofunc in microblaze.c
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
2021-12-28 22:49 ` [PATCH 1/7] Send debugging data to gdb_stdlog in mips-linux-nat.c Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 3/7] Use debug_prefixed_printf_cond_nofunc in machoread Tom Tromey
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes microblaze.c to use the standard logging macro. As a
side effect, logs will now go to gdb_stdlog. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/microblaze-tdep.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index e50f50d2b8c..0a2cfa2f65c 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -82,19 +82,10 @@ static const char * const microblaze_register_names[] =
\f
static unsigned int microblaze_debug_flag = 0;
-static void ATTRIBUTE_PRINTF (1, 2)
-microblaze_debug (const char *fmt, ...)
-{
- if (microblaze_debug_flag)
- {
- va_list args;
+#define microblaze_debug(fmt, ...) \
+ debug_prefixed_printf_cond_nofunc (microblaze_debug_flag, "MICROBLAZE", \
+ fmt, ## __VA_ARGS__)
- va_start (args, fmt);
- printf_unfiltered ("MICROBLAZE: ");
- vprintf_unfiltered (fmt, args);
- va_end (args);
- }
-}
\f
/* Return the name of register REGNUM. */
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/7] Use debug_prefixed_printf_cond_nofunc in machoread
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
2021-12-28 22:49 ` [PATCH 1/7] Send debugging data to gdb_stdlog in mips-linux-nat.c Tom Tromey
2021-12-28 22:49 ` [PATCH 2/7] Use debug_prefixed_printf_cond_nofunc in microblaze.c Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 4/7] Use gdb_stdlog for separate debug file logging Tom Tromey
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes machoread.c to use debug_prefixed_printf_cond_nofunc. As
a side effect, the logs are now written to gdb_stdlog. This is part
of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/machoread.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/gdb/machoread.c b/gdb/machoread.c
index b3bd54940b4..0272ec7942c 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -37,6 +37,10 @@
/* If non-zero displays debugging message. */
static unsigned int mach_o_debug_level = 0;
+#define macho_debug(LEVEL, FMT, ...) \
+ debug_prefixed_printf_cond_nofunc (mach_o_debug_level > LEVEL, \
+ "machoread", FMT, ## __VA_ARGS__)
+
/* Dwarf debugging information are never in the final executable. They stay
in object files and the executable contains the list of object files read
during the link.
@@ -421,9 +425,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
/* Per section flag to mark which section have been rebased. */
unsigned char *sections_rebased;
- if (mach_o_debug_level > 0)
- printf_unfiltered
- (_("Loading debugging symbols from oso: %s\n"), oso->name);
+ macho_debug (0, _("Loading debugging symbols from oso: %s\n"), oso->name);
if (!bfd_check_format (abfd.get (), bfd_object))
{
@@ -492,13 +494,9 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
complaint (_("Duplicated symbol %s in symbol table"), sym->name);
else
{
- if (mach_o_debug_level > 4)
- {
- struct gdbarch *arch = main_objfile->arch ();
- printf_unfiltered
- (_("Adding symbol %s (addr: %s)\n"),
- sym->name, paddress (arch, sym->value));
- }
+ macho_debug (4, _("Adding symbol %s (addr: %s)\n"),
+ sym->name, paddress (main_objfile->arch (),
+ sym->value));
ent->sym = sym;
}
}
@@ -566,14 +564,9 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
{
CORE_ADDR res = addr - sym->value;
- if (mach_o_debug_level > 3)
- {
- struct gdbarch *arch = main_objfile->arch ();
- printf_unfiltered
- (_("resolve sect %s with %s (set to %s)\n"),
- sec->name, sym->name,
- paddress (arch, res));
- }
+ macho_debug (3, _("resolve sect %s with %s (set to %s)\n"),
+ sec->name, sym->name,
+ paddress (main_objfile->arch (), res));
bfd_set_section_vma (sec, res);
sections_rebased[sec->index] = 1;
}
@@ -843,8 +836,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct bfd_section *asect, *dsect;
- if (mach_o_debug_level > 0)
- printf_unfiltered (_("dsym file found\n"));
+ macho_debug (0, _("dsym file found\n"));
/* Set dsym section size. */
for (asect = objfile->obfd->sections, dsect = dsym_bfd->sections;
@@ -887,9 +879,8 @@ macho_symfile_relocate (struct objfile *objfile, asection *sectp,
if ((sectp->flags & SEC_RELOC) == 0)
return NULL;
- if (mach_o_debug_level > 0)
- printf_unfiltered (_("Relocate section '%s' of %s\n"),
- sectp->name, objfile_name (objfile));
+ macho_debug (0, _("Relocate section '%s' of %s\n"),
+ sectp->name, objfile_name (objfile));
return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
}
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/7] Use gdb_stdlog for separate debug file logging
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
` (2 preceding siblings ...)
2021-12-28 22:49 ` [PATCH 3/7] Use debug_prefixed_printf_cond_nofunc in machoread Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 5/7] Send minsym logging to gdb_stdlog Tom Tromey
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes the separate debug file logging code (spread across two
files) to use gdb_stdlog for its output. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/build-id.c | 18 ++++++++++--------
gdb/symfile.c | 23 +++++++++++++----------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/gdb/build-id.c b/gdb/build-id.c
index d68b7a7af57..e6da0abddbf 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -76,8 +76,8 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
{
if (separate_debug_file_debug)
{
- printf_unfiltered (_(" Trying %s..."), link.c_str ());
- gdb_flush (gdb_stdout);
+ fprintf_unfiltered (gdb_stdlog, _(" Trying %s..."), link.c_str ());
+ gdb_flush (gdb_stdlog);
}
/* lrealpath() is expensive even for the usually non-existent files. */
@@ -94,7 +94,8 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
if (filename == NULL)
{
if (separate_debug_file_debug)
- printf_unfiltered (_(" no, unable to compute real path\n"));
+ fprintf_unfiltered (gdb_stdlog,
+ _(" no, unable to compute real path\n"));
return {};
}
@@ -105,7 +106,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
if (debug_bfd == NULL)
{
if (separate_debug_file_debug)
- printf_unfiltered (_(" no, unable to open.\n"));
+ fprintf_unfiltered (gdb_stdlog, _(" no, unable to open.\n"));
return {};
}
@@ -113,13 +114,13 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
{
if (separate_debug_file_debug)
- printf_unfiltered (_(" no, build-id does not match.\n"));
+ fprintf_unfiltered (gdb_stdlog, _(" no, build-id does not match.\n"));
return {};
}
if (separate_debug_file_debug)
- printf_unfiltered (_(" yes!\n"));
+ fprintf_unfiltered (gdb_stdlog, _(" yes!\n"));
return debug_bfd;
}
@@ -209,8 +210,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
if (build_id != NULL)
{
if (separate_debug_file_debug)
- printf_unfiltered (_("\nLooking for separate debug info (build-id) for "
- "%s\n"), objfile_name (objfile));
+ fprintf_unfiltered (gdb_stdlog,
+ _("\nLooking for separate debug info (build-id) for "
+ "%s\n"), objfile_name (objfile));
gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
build_id->data));
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 89469a3d3dc..6787f37d5c3 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1261,8 +1261,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (separate_debug_file_debug)
{
- printf_filtered (_(" Trying %s..."), name.c_str ());
- gdb_flush (gdb_stdout);
+ fprintf_filtered (gdb_stdlog, _(" Trying %s..."), name.c_str ());
+ gdb_flush (gdb_stdlog);
}
gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget));
@@ -1270,7 +1270,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (abfd == NULL)
{
if (separate_debug_file_debug)
- printf_filtered (_(" no, unable to open.\n"));
+ fprintf_filtered (gdb_stdlog, _(" no, unable to open.\n"));
return 0;
}
@@ -1294,7 +1294,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
&& abfd_stat.st_ino == parent_stat.st_ino)
{
if (separate_debug_file_debug)
- printf_filtered (_(" no, same file as the objfile.\n"));
+ fprintf_filtered (gdb_stdlog,
+ _(" no, same file as the objfile.\n"));
return 0;
}
@@ -1308,7 +1309,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (!file_crc_p)
{
if (separate_debug_file_debug)
- printf_filtered (_(" no, error computing CRC.\n"));
+ fprintf_filtered (gdb_stdlog, _(" no, error computing CRC.\n"));
return 0;
}
@@ -1326,7 +1327,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc))
{
if (separate_debug_file_debug)
- printf_filtered (_(" no, error computing CRC.\n"));
+ fprintf_filtered (gdb_stdlog,
+ _(" no, error computing CRC.\n"));
return 0;
}
@@ -1338,13 +1340,13 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
name.c_str (), objfile_name (parent_objfile));
if (separate_debug_file_debug)
- printf_filtered (_(" no, CRC doesn't match.\n"));
+ fprintf_filtered (gdb_stdlog, _(" no, CRC doesn't match.\n"));
return 0;
}
if (separate_debug_file_debug)
- printf_filtered (_(" yes!\n"));
+ fprintf_filtered (gdb_stdlog, _(" yes!\n"));
return 1;
}
@@ -1379,8 +1381,9 @@ find_separate_debug_file (const char *dir,
unsigned long crc32, struct objfile *objfile)
{
if (separate_debug_file_debug)
- printf_filtered (_("\nLooking for separate debug info (debug link) for "
- "%s\n"), objfile_name (objfile));
+ fprintf_filtered (gdb_stdlog,
+ _("\nLooking for separate debug info (debug link) for "
+ "%s\n"), objfile_name (objfile));
/* First try in the same directory as the original file. */
std::string debugfile = dir;
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/7] Send minsym logging to gdb_stdlog
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
` (3 preceding siblings ...)
2021-12-28 22:49 ` [PATCH 4/7] Use gdb_stdlog for separate debug file logging Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache Tom Tromey
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes minsyms.c to send logging output to gdb_stdlog. This is
part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/minsyms.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 5f4cf54c663..d3a5fb40e5a 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1187,9 +1187,10 @@ minimal_symbol_reader::record_full (gdb::string_view name,
return (NULL);
if (symtab_create_debug >= 2)
- printf_unfiltered ("Recording minsym: %-21s %18s %4d %.*s\n",
- mst_str (ms_type), hex_string (address), section,
- (int) name.size (), name.data ());
+ fprintf_unfiltered (gdb_stdlog,
+ "Recording minsym: %-21s %18s %4d %.*s\n",
+ mst_str (ms_type), hex_string (address), section,
+ (int) name.size (), name.data ());
if (m_msym_bunch_index == BUNCH_SIZE)
{
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
` (4 preceding siblings ...)
2021-12-28 22:49 ` [PATCH 5/7] Send minsym logging to gdb_stdlog Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-29 4:17 ` Joel Brobecker
2021-12-29 13:51 ` Simon Marchi
2021-12-28 22:49 ` [PATCH 7/7] Use gdb_stdlog for MI debugging Tom Tromey
2021-12-29 4:19 ` [PATCH 0/7] Send some logging output to gdb_stdlog Joel Brobecker
7 siblings, 2 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
As a side effect, logs are now written to gdb_stdlog. This is part of
PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/dwarf2/index-cache.c | 43 ++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index 7cb0fd3d9a1..0024334d3c0 100644
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -37,6 +37,10 @@
/* When set to true, show debug messages about the index cache. */
static bool debug_index_cache = false;
+#define cache_debug(FMT, ...) \
+ debug_prefixed_printf_cond_nofunc (debug_index_cache, "index-cache", \
+ FMT, ## __VA_ARGS__)
+
/* The index cache directory, used for "set/show index-cache directory". */
static std::string index_cache_directory;
@@ -59,8 +63,7 @@ index_cache::set_directory (std::string dir)
m_dir = std::move (dir);
- if (debug_index_cache)
- printf_unfiltered ("index cache: now using directory %s\n", m_dir.c_str ());
+ cache_debug ("index cache: now using directory %s\n", m_dir.c_str ());
}
/* See dwarf-index-cache.h. */
@@ -68,8 +71,7 @@ index_cache::set_directory (std::string dir)
void
index_cache::enable ()
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: enabling (%s)\n", m_dir.c_str ());
+ cache_debug ("index cache: enabling (%s)\n", m_dir.c_str ());
m_enabled = true;
}
@@ -79,8 +81,7 @@ index_cache::enable ()
void
index_cache::disable ()
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: disabling\n");
+ cache_debug ("index cache: disabling\n");
m_enabled = false;
}
@@ -99,9 +100,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
if (build_id == nullptr)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: objfile %s has no build id\n",
- objfile_name (obj));
+ cache_debug ("index cache: objfile %s has no build id\n",
+ objfile_name (obj));
return;
}
@@ -118,9 +118,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
if (dwz_build_id == nullptr)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: dwz objfile %s has no build id\n",
- dwz->filename ());
+ cache_debug ("index cache: dwz objfile %s has no build id\n",
+ dwz->filename ());
return;
}
@@ -144,9 +143,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
return;
}
- if (debug_index_cache)
- printf_unfiltered ("index cache: writing index cache for objfile %s\n",
- objfile_name (obj));
+ cache_debug ("index cache: writing index cache for objfile %s\n",
+ objfile_name (obj));
/* Write the index itself to the directory, using the build id as the
filename. */
@@ -156,9 +154,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
}
catch (const gdb_exception_error &except)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: couldn't store index cache for objfile "
- "%s: %s", objfile_name (obj), except.what ());
+ cache_debug ("index cache: couldn't store index cache for objfile "
+ "%s: %s", objfile_name (obj), except.what ());
}
}
@@ -198,9 +195,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
try
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: trying to read %s\n",
- filename.c_str ());
+ cache_debug ("index cache: trying to read %s\n",
+ filename.c_str ());
/* Try to map that file. */
index_cache_resource_mmap *mmap_resource
@@ -215,9 +211,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
}
catch (const gdb_exception_error &except)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: couldn't read %s: %s\n",
- filename.c_str (), except.what ());
+ cache_debug ("index cache: couldn't read %s: %s\n",
+ filename.c_str (), except.what ());
}
return {};
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 7/7] Use gdb_stdlog for MI debugging
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
` (5 preceding siblings ...)
2021-12-28 22:49 ` [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache Tom Tromey
@ 2021-12-28 22:49 ` Tom Tromey
2021-12-29 4:19 ` [PATCH 0/7] Send some logging output to gdb_stdlog Joel Brobecker
7 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-28 22:49 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
When MI debugging is enabled, the logging output should be sent to
gdb_stdlog. This is part of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
---
gdb/mi/mi-cmds.h | 3 ---
gdb/mi/mi-main.c | 8 ++++----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index 5945f03e5d3..c9358a697fc 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -192,9 +192,6 @@ struct mi_command
extern mi_command *mi_cmd_lookup (const char *command);
-/* Debug flag */
-extern int mi_debug_p;
-
extern void mi_execute_command (const char *cmd, int from_tty);
#endif /* MI_MI_CMDS_H */
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 710eef7e725..1f210c161e6 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -68,7 +68,8 @@ enum
FROM_TTY = 0
};
-int mi_debug_p;
+/* Debug flag */
+static int mi_debug_p;
/* This is used to pass the current command timestamp down to
continuation routines. */
@@ -1785,8 +1786,7 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
case MI_COMMAND:
/* A MI command was read from the input stream. */
if (mi_debug_p)
- /* FIXME: gdb_???? */
- fprintf_unfiltered (mi->raw_stdout,
+ fprintf_unfiltered (gdb_stdlog,
" token=`%s' command=`%s' args=`%s'\n",
context->token, context->command, context->args);
@@ -2091,7 +2091,7 @@ mi_execute_cli_command (const char *cmd, bool args_p, const char *args)
gdb_assert (args == nullptr);
if (mi_debug_p)
- fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n",
+ fprintf_unfiltered (gdb_stdlog, "cli=%s run=%s\n",
cmd, run.c_str ());
execute_command (run.c_str (), 0 /* from_tty */ );
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache
2021-12-28 22:49 ` [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache Tom Tromey
@ 2021-12-29 4:17 ` Joel Brobecker
2021-12-29 17:55 ` Tom Tromey
2021-12-29 13:51 ` Simon Marchi
1 sibling, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2021-12-29 4:17 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker
On Tue, Dec 28, 2021 at 03:49:56PM -0700, Tom Tromey wrote:
> This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
> As a side effect, logs are now written to gdb_stdlog. This is part of
> PR gdb/7233.
IIUC, the use of debug_prefixed_printf_cond_nofunc allows us to
avoid having repeat it in the message being passed?
For instance ...
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
> ---
> gdb/dwarf2/index-cache.c | 43 ++++++++++++++++++----------------------
> 1 file changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
> index 7cb0fd3d9a1..0024334d3c0 100644
> --- a/gdb/dwarf2/index-cache.c
> +++ b/gdb/dwarf2/index-cache.c
> @@ -37,6 +37,10 @@
> /* When set to true, show debug messages about the index cache. */
> static bool debug_index_cache = false;
>
> +#define cache_debug(FMT, ...) \
> + debug_prefixed_printf_cond_nofunc (debug_index_cache, "index-cache", \
> + FMT, ## __VA_ARGS__)
> +
> /* The index cache directory, used for "set/show index-cache directory". */
> static std::string index_cache_directory;
>
> @@ -59,8 +63,7 @@ index_cache::set_directory (std::string dir)
>
> m_dir = std::move (dir);
>
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: now using directory %s\n", m_dir.c_str ());
> + cache_debug ("index cache: now using directory %s\n", m_dir.c_str ());
The "index cache:" prefix being used here and below now seems
redundant.
Should we remove them?
> }
>
> /* See dwarf-index-cache.h. */
> @@ -68,8 +71,7 @@ index_cache::set_directory (std::string dir)
> void
> index_cache::enable ()
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: enabling (%s)\n", m_dir.c_str ());
> + cache_debug ("index cache: enabling (%s)\n", m_dir.c_str ());
>
> m_enabled = true;
> }
> @@ -79,8 +81,7 @@ index_cache::enable ()
> void
> index_cache::disable ()
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: disabling\n");
> + cache_debug ("index cache: disabling\n");
>
> m_enabled = false;
> }
> @@ -99,9 +100,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
> const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
> if (build_id == nullptr)
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: objfile %s has no build id\n",
> - objfile_name (obj));
> + cache_debug ("index cache: objfile %s has no build id\n",
> + objfile_name (obj));
> return;
> }
>
> @@ -118,9 +118,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
>
> if (dwz_build_id == nullptr)
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: dwz objfile %s has no build id\n",
> - dwz->filename ());
> + cache_debug ("index cache: dwz objfile %s has no build id\n",
> + dwz->filename ());
> return;
> }
>
> @@ -144,9 +143,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
> return;
> }
>
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: writing index cache for objfile %s\n",
> - objfile_name (obj));
> + cache_debug ("index cache: writing index cache for objfile %s\n",
> + objfile_name (obj));
>
> /* Write the index itself to the directory, using the build id as the
> filename. */
> @@ -156,9 +154,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
> }
> catch (const gdb_exception_error &except)
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: couldn't store index cache for objfile "
> - "%s: %s", objfile_name (obj), except.what ());
> + cache_debug ("index cache: couldn't store index cache for objfile "
> + "%s: %s", objfile_name (obj), except.what ());
> }
> }
>
> @@ -198,9 +195,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
>
> try
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: trying to read %s\n",
> - filename.c_str ());
> + cache_debug ("index cache: trying to read %s\n",
> + filename.c_str ());
>
> /* Try to map that file. */
> index_cache_resource_mmap *mmap_resource
> @@ -215,9 +211,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
> }
> catch (const gdb_exception_error &except)
> {
> - if (debug_index_cache)
> - printf_unfiltered ("index cache: couldn't read %s: %s\n",
> - filename.c_str (), except.what ());
> + cache_debug ("index cache: couldn't read %s: %s\n",
> + filename.c_str (), except.what ());
> }
>
> return {};
> --
> 2.31.1
>
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] Send some logging output to gdb_stdlog
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
` (6 preceding siblings ...)
2021-12-28 22:49 ` [PATCH 7/7] Use gdb_stdlog for MI debugging Tom Tromey
@ 2021-12-29 4:19 ` Joel Brobecker
7 siblings, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2021-12-29 4:19 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker
> I found a few spots where gdb was not sending logging output to
> gdb_stdlog. This patch fixes the ones I found.
>
> Regression tested on x86-64 Fedora 34, though of course I wouldn't
> necessarily expect that to find problems with this patch.
Thanks for those patches, Tom. They look good to me as is.
Perhaps one possible suggestion for patch #6 (index-cache.c).
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache
2021-12-28 22:49 ` [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache Tom Tromey
2021-12-29 4:17 ` Joel Brobecker
@ 2021-12-29 13:51 ` Simon Marchi
2021-12-29 17:56 ` Tom Tromey
1 sibling, 1 reply; 13+ messages in thread
From: Simon Marchi @ 2021-12-29 13:51 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2021-12-28 17:49, Tom Tromey wrote:
> This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
> As a side effect, logs are now written to gdb_stdlog. This is part of
> PR gdb/7233.
Thanks for doing this. I would just suggest naming the macro
"index_cache_debug", just for consistency with the chosen prefix
("index-cache").
Simon
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache
2021-12-29 4:17 ` Joel Brobecker
@ 2021-12-29 17:55 ` Tom Tromey
0 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-29 17:55 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches
Joel> IIUC, the use of debug_prefixed_printf_cond_nofunc allows us to
Joel> avoid having repeat it in the message being passed?
Yep, thanks for noticing this. I've updated the patch.
Tom
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache
2021-12-29 13:51 ` Simon Marchi
@ 2021-12-29 17:56 ` Tom Tromey
0 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2021-12-29 17:56 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>> This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
>> As a side effect, logs are now written to gdb_stdlog. This is part of
>> PR gdb/7233.
Simon> Thanks for doing this. I would just suggest naming the macro
Simon> "index_cache_debug", just for consistency with the chosen prefix
Simon> ("index-cache").
I made this change and the one Joel suggested.
Here's what I'm checking in.
Tom
commit ca78fadba919f2df2913ae893e0d8c587bb105a2
Author: Tom Tromey <tom@tromey.com>
Date: Sun Dec 26 18:36:36 2021 -0700
Use debug_prefixed_printf_cond_nofunc in index-cache
This changes index-cache.c to use debug_prefixed_printf_cond_nofunc.
As a side effect, logs are now written to gdb_stdlog. This is part of
PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index 7cb0fd3d9a1..f0dd4635635 100644
--- a/gdb/dwarf2/index-cache.c
+++ b/gdb/dwarf2/index-cache.c
@@ -37,6 +37,10 @@
/* When set to true, show debug messages about the index cache. */
static bool debug_index_cache = false;
+#define index_cache_debug(FMT, ...) \
+ debug_prefixed_printf_cond_nofunc (debug_index_cache, "index-cache", \
+ FMT, ## __VA_ARGS__)
+
/* The index cache directory, used for "set/show index-cache directory". */
static std::string index_cache_directory;
@@ -59,8 +63,7 @@ index_cache::set_directory (std::string dir)
m_dir = std::move (dir);
- if (debug_index_cache)
- printf_unfiltered ("index cache: now using directory %s\n", m_dir.c_str ());
+ index_cache_debug ("now using directory %s\n", m_dir.c_str ());
}
/* See dwarf-index-cache.h. */
@@ -68,8 +71,7 @@ index_cache::set_directory (std::string dir)
void
index_cache::enable ()
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: enabling (%s)\n", m_dir.c_str ());
+ index_cache_debug ("enabling (%s)\n", m_dir.c_str ());
m_enabled = true;
}
@@ -79,8 +81,7 @@ index_cache::enable ()
void
index_cache::disable ()
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: disabling\n");
+ index_cache_debug ("disabling\n");
m_enabled = false;
}
@@ -99,9 +100,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
if (build_id == nullptr)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: objfile %s has no build id\n",
- objfile_name (obj));
+ index_cache_debug ("objfile %s has no build id\n",
+ objfile_name (obj));
return;
}
@@ -118,9 +118,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
if (dwz_build_id == nullptr)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: dwz objfile %s has no build id\n",
- dwz->filename ());
+ index_cache_debug ("dwz objfile %s has no build id\n",
+ dwz->filename ());
return;
}
@@ -144,9 +143,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
return;
}
- if (debug_index_cache)
- printf_unfiltered ("index cache: writing index cache for objfile %s\n",
- objfile_name (obj));
+ index_cache_debug ("writing index cache for objfile %s\n",
+ objfile_name (obj));
/* Write the index itself to the directory, using the build id as the
filename. */
@@ -156,9 +154,8 @@ index_cache::store (dwarf2_per_objfile *per_objfile)
}
catch (const gdb_exception_error &except)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: couldn't store index cache for objfile "
- "%s: %s", objfile_name (obj), except.what ());
+ index_cache_debug ("couldn't store index cache for objfile "
+ "%s: %s", objfile_name (obj), except.what ());
}
}
@@ -198,9 +195,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
try
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: trying to read %s\n",
- filename.c_str ());
+ index_cache_debug ("trying to read %s\n",
+ filename.c_str ());
/* Try to map that file. */
index_cache_resource_mmap *mmap_resource
@@ -215,9 +211,8 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
}
catch (const gdb_exception_error &except)
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: couldn't read %s: %s\n",
- filename.c_str (), except.what ());
+ index_cache_debug ("couldn't read %s: %s\n",
+ filename.c_str (), except.what ());
}
return {};
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-12-29 17:56 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-28 22:49 [PATCH 0/7] Send some logging output to gdb_stdlog Tom Tromey
2021-12-28 22:49 ` [PATCH 1/7] Send debugging data to gdb_stdlog in mips-linux-nat.c Tom Tromey
2021-12-28 22:49 ` [PATCH 2/7] Use debug_prefixed_printf_cond_nofunc in microblaze.c Tom Tromey
2021-12-28 22:49 ` [PATCH 3/7] Use debug_prefixed_printf_cond_nofunc in machoread Tom Tromey
2021-12-28 22:49 ` [PATCH 4/7] Use gdb_stdlog for separate debug file logging Tom Tromey
2021-12-28 22:49 ` [PATCH 5/7] Send minsym logging to gdb_stdlog Tom Tromey
2021-12-28 22:49 ` [PATCH 6/7] Use debug_prefixed_printf_cond_nofunc in index-cache Tom Tromey
2021-12-29 4:17 ` Joel Brobecker
2021-12-29 17:55 ` Tom Tromey
2021-12-29 13:51 ` Simon Marchi
2021-12-29 17:56 ` Tom Tromey
2021-12-28 22:49 ` [PATCH 7/7] Use gdb_stdlog for MI debugging Tom Tromey
2021-12-29 4:19 ` [PATCH 0/7] Send some logging output to gdb_stdlog Joel Brobecker
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).