Convert 'set/show debug separate-debug-file' to the new debug scheme.
Though I'm not sure if we can really call it "new" any more!
Approved-By: Tom Tromey <tom@tromey.com>
build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
const bfd_byte *build_id)
{
- if (separate_debug_file_debug)
- {
- gdb_printf (gdb_stdlog, _(" Trying %s..."), link.c_str ());
- gdb_flush (gdb_stdlog);
- }
+ separate_debug_file_debug_printf ("Trying %s...", link.c_str ());
/* lrealpath() is expensive even for the usually non-existent files. */
gdb::unique_xmalloc_ptr<char> filename_holder;
if (filename == NULL)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog,
- _(" no, unable to compute real path\n"));
-
+ separate_debug_file_debug_printf ("unable to compute real path");
return {};
}
if (debug_bfd == NULL)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" no, unable to open.\n"));
-
+ separate_debug_file_debug_printf ("unable to open.");
return {};
}
if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" no, build-id does not match.\n"));
-
+ separate_debug_file_debug_printf ("build-id does not match.");
return {};
}
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" yes!\n"));
-
+ separate_debug_file_debug_printf ("found a match");
return debug_bfd;
}
build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
const char *suffix)
{
+ SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT;
+
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
cause "/.build-id/..." lookups. */
build_id = build_id_bfd_get (objfile->obfd.get ());
if (build_id != NULL)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog,
- _("\nLooking for separate debug info (build-id) for "
- "%s\n"), objfile_name (objfile));
+ SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END
+ ("looking for separate debug info (build-id) for %s",
+ objfile_name (objfile));
gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
build_id->data));
&& filename_cmp (bfd_get_filename (abfd.get ()),
objfile_name (objfile)) == 0)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, "\"%s\": separate debug info file has no "
- "debug info", bfd_get_filename (abfd.get ()));
+ separate_debug_file_debug_printf
+ ("\"%s\": separate debug info file has no debug info",
+ bfd_get_filename (abfd.get ()));
warnings->warn (_("\"%ps\": separate debug info file has no "
"debug info"),
styled_string (file_name_style.style (),
struct objfile *parent_objfile,
deferred_warnings *warnings)
{
+ SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT;
+
unsigned long file_crc;
int file_crc_p;
struct stat parent_stat, abfd_stat;
if (filename_cmp (name.c_str (), objfile_name (parent_objfile)) == 0)
return 0;
- if (separate_debug_file_debug)
- {
- gdb_printf (gdb_stdlog, _(" Trying %s..."), name.c_str ());
- gdb_flush (gdb_stdlog);
- }
+ separate_debug_file_debug_printf ("Trying %s...", name.c_str ());
gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget));
if (abfd == NULL)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" no, unable to open.\n"));
-
+ separate_debug_file_debug_printf ("unable to open file");
return 0;
}
if (abfd_stat.st_dev == parent_stat.st_dev
&& abfd_stat.st_ino == parent_stat.st_ino)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog,
- _(" no, same file as the objfile.\n"));
-
+ separate_debug_file_debug_printf ("same file as the objfile");
return 0;
}
verified_as_different = 1;
if (!file_crc_p)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" no, error computing CRC.\n"));
-
+ separate_debug_file_debug_printf ("error computing CRC");
return 0;
}
{
if (!gdb_bfd_crc (parent_objfile->obfd.get (), &parent_crc))
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog,
- _(" no, error computing CRC.\n"));
-
+ separate_debug_file_debug_printf ("error computing CRC");
return 0;
}
}
if (verified_as_different || parent_crc != file_crc)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, "the debug information found in \"%s\""
- " does not match \"%s\" (CRC mismatch).\n",
- name.c_str (), objfile_name (parent_objfile));
+ separate_debug_file_debug_printf
+ ("the debug information found in \"%s\" does not match "
+ "\"%s\" (CRC mismatch).", name.c_str (),
+ objfile_name (parent_objfile));
+
warnings->warn (_("the debug information found in \"%ps\""
" does not match \"%ps\" (CRC mismatch)."),
styled_string (file_name_style.style (),
return 0;
}
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog, _(" yes!\n"));
+ separate_debug_file_debug_printf ("found a match");
return 1;
}
unsigned long crc32, struct objfile *objfile,
deferred_warnings *warnings)
{
- if (separate_debug_file_debug)
- gdb_printf (gdb_stdlog,
- _("\nLooking for separate debug info (debug link) for "
- "%s\n"), objfile_name (objfile));
+ SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END
+ ("looking for separate debug info (debug link) for %s",
+ objfile_name (objfile));
/* First try in the same directory as the original file. */
std::string debugfile = dir;
extern bool separate_debug_file_debug;
+/* Print a "separate-debug-file" debug statement. */
+
+#define separate_debug_file_debug_printf(fmt, ...) \
+ debug_prefixed_printf_cond (separate_debug_file_debug, \
+ "separate-debug-file", \
+ fmt, ##__VA_ARGS__)
+
+/* Print "separate-debug-file" enter/exit debug statements. */
+
+#define SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT \
+ scoped_debug_enter_exit (separate_debug_file_debug, \
+ "separate-debug-file")
+
+/* Print "separate-debug-file" start/end debug statements. */
+
+#define SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END(fmt, ...) \
+ scoped_debug_start_end (separate_debug_file_debug, \
+ "separate-debug-file", fmt, ##__VA_ARGS__)
+
/* Read full symbols immediately. */
extern int readnow_symbol_files;