/* 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;
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. */
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;
}
void
index_cache::disable ()
{
- if (debug_index_cache)
- printf_unfiltered ("index cache: disabling\n");
+ index_cache_debug ("disabling\n");
m_enabled = false;
}
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;
}
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;
}
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. */
}
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 ());
}
}
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
}
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 {};