Use gdb_stdlog for separate debug file logging

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
This commit is contained in:
Tom Tromey 2021-12-26 14:10:05 -07:00
parent 3defe97705
commit 0bc1fe382e
2 changed files with 23 additions and 18 deletions

View file

@ -76,8 +76,8 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
{ {
printf_unfiltered (_(" Trying %s..."), link.c_str ()); fprintf_unfiltered (gdb_stdlog, _(" Trying %s..."), link.c_str ());
gdb_flush (gdb_stdout); gdb_flush (gdb_stdlog);
} }
/* lrealpath() is expensive even for the usually non-existent files. */ /* 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 (filename == NULL)
{ {
if (separate_debug_file_debug) 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 {}; 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 (debug_bfd == NULL)
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_unfiltered (_(" no, unable to open.\n")); fprintf_unfiltered (gdb_stdlog, _(" no, unable to open.\n"));
return {}; 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 (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
{ {
if (separate_debug_file_debug) 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 {}; return {};
} }
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_unfiltered (_(" yes!\n")); fprintf_unfiltered (gdb_stdlog, _(" yes!\n"));
return debug_bfd; return debug_bfd;
} }
@ -209,8 +210,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
if (build_id != NULL) if (build_id != NULL)
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_unfiltered (_("\nLooking for separate debug info (build-id) for " fprintf_unfiltered (gdb_stdlog,
"%s\n"), objfile_name (objfile)); _("\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, gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size,
build_id->data)); build_id->data));

View file

@ -1261,8 +1261,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (separate_debug_file_debug) if (separate_debug_file_debug)
{ {
printf_filtered (_(" Trying %s..."), name.c_str ()); fprintf_filtered (gdb_stdlog, _(" Trying %s..."), name.c_str ());
gdb_flush (gdb_stdout); gdb_flush (gdb_stdlog);
} }
gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget)); 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 (abfd == NULL)
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_filtered (_(" no, unable to open.\n")); fprintf_filtered (gdb_stdlog, _(" no, unable to open.\n"));
return 0; 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) && abfd_stat.st_ino == parent_stat.st_ino)
{ {
if (separate_debug_file_debug) 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; return 0;
} }
@ -1308,7 +1309,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
if (!file_crc_p) if (!file_crc_p)
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_filtered (_(" no, error computing CRC.\n")); fprintf_filtered (gdb_stdlog, _(" no, error computing CRC.\n"));
return 0; 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 (!gdb_bfd_crc (parent_objfile->obfd, &parent_crc))
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_filtered (_(" no, error computing CRC.\n")); fprintf_filtered (gdb_stdlog,
_(" no, error computing CRC.\n"));
return 0; return 0;
} }
@ -1338,13 +1340,13 @@ separate_debug_file_exists (const std::string &name, unsigned long crc,
name.c_str (), objfile_name (parent_objfile)); name.c_str (), objfile_name (parent_objfile));
if (separate_debug_file_debug) 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; return 0;
} }
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_filtered (_(" yes!\n")); fprintf_filtered (gdb_stdlog, _(" yes!\n"));
return 1; return 1;
} }
@ -1379,8 +1381,9 @@ find_separate_debug_file (const char *dir,
unsigned long crc32, struct objfile *objfile) unsigned long crc32, struct objfile *objfile)
{ {
if (separate_debug_file_debug) if (separate_debug_file_debug)
printf_filtered (_("\nLooking for separate debug info (debug link) for " fprintf_filtered (gdb_stdlog,
"%s\n"), objfile_name (objfile)); _("\nLooking for separate debug info (debug link) for "
"%s\n"), objfile_name (objfile));
/* First try in the same directory as the original file. */ /* First try in the same directory as the original file. */
std::string debugfile = dir; std::string debugfile = dir;