[prev in list] [next in list] [prev in thread] [next in thread]
List: gdb-cvs
Subject: [binutils-gdb] Use debug_prefixed_printf_cond_nofunc in index-cache
From: Tom Tromey via Gdb-cvs <gdb-cvs () sourceware ! org>
Date: 2021-12-29 18:03:08
Message-ID: 20211229180308.EAAC23858400 () sourceware ! org
[Download RAW message or body]
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ca78fadba919f2df2913ae893e0d8c587bb105a2
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:
---
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..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 {};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic