diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/build-id.c | 38 | ||||
-rw-r--r-- | gdb/symfile.c | 45 | ||||
-rw-r--r-- | gdb/symfile.h | 19 |
3 files changed, 48 insertions, 54 deletions
diff --git a/gdb/build-id.c b/gdb/build-id.c index fe0494a..8ce94f1 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -81,11 +81,7 @@ static gdb_bfd_ref_ptr 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; @@ -100,10 +96,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, 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 {}; } @@ -112,23 +105,17 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, 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; } @@ -140,6 +127,8 @@ static gdb_bfd_ref_ptr 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. */ @@ -223,10 +212,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile, 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)); @@ -235,9 +223,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile, && 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 (), diff --git a/gdb/symfile.c b/gdb/symfile.c index 6d0cba4..5a03def 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1229,6 +1229,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, 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; @@ -1243,19 +1245,13 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, 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; } @@ -1277,10 +1273,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, 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; @@ -1292,9 +1285,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, 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; } @@ -1310,20 +1301,18 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, { 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 (), @@ -1335,8 +1324,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, return 0; } - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" yes!\n")); + separate_debug_file_debug_printf ("found a match"); return 1; } @@ -1377,10 +1365,9 @@ find_separate_debug_file (const char *dir, 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; diff --git a/gdb/symfile.h b/gdb/symfile.h index a5b0c91..508ba48 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -371,6 +371,25 @@ extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *); 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; |