From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 4/8] gdb: convert separate-debug-file to new(ish) debug scheme
Date: Wed, 5 Jun 2024 14:15:11 +0100 [thread overview]
Message-ID: <4efbb2060ea7298f855ee8141f7978ef1f142353.1717592684.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1717592683.git.aburgess@redhat.com>
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!
---
gdb/build-id.c | 38 +++++++++++++-------------------------
gdb/symfile.c | 45 ++++++++++++++++-----------------------------
gdb/symfile.h | 19 +++++++++++++++++++
3 files changed, 48 insertions(+), 54 deletions(-)
diff --git a/gdb/build-id.c b/gdb/build-id.c
index fe0494ae54e..8ce94f1e7a0 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 f7f5be5a39a..2cb1f652867 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 a5b0c91469c..508ba48d161 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;
--
2.25.4
next prev parent reply other threads:[~2024-06-05 13:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 13:15 [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-05 13:15 ` [PATCH 1/8] gdb/fileio: fix errno for packets where an attachment is expected Andrew Burgess
2024-06-06 16:49 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 2/8] gdb: avoid duplicate search in build_id_to_bfd_suffix Andrew Burgess
2024-06-06 16:49 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 3/8] gdb: warn of slow remote file reading only after a successful open Andrew Burgess
2024-06-06 16:58 ` Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` Andrew Burgess [this message]
2024-06-06 16:54 ` [PATCH 4/8] gdb: convert separate-debug-file to new(ish) debug scheme Tom Tromey
2024-06-11 19:52 ` Andrew Burgess
2024-06-05 13:15 ` [PATCH 5/8] gdb: add target_fileio_stat, but no implementations yet Andrew Burgess
2024-06-05 13:15 ` [PATCH 6/8] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-05 14:21 ` Eli Zaretskii
2024-06-05 13:15 ` [PATCH 7/8] gdbserver: add gdbserver support for vFile::stat packet Andrew Burgess
2024-06-05 13:15 ` [PATCH 8/8] gdb: check for multiple matching build-id files Andrew Burgess
2024-06-13 10:29 ` [PATCH 0/8] Extension for looking up debug info by build-id Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 1/4] gdb: add target_fileio_stat, but no implementations yet Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 2/4] gdb: add GDB side target_ops::fileio_stat implementation Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 3/4] gdbserver: add gdbserver support for vFile::stat packet Andrew Burgess
2024-06-13 10:29 ` [PATCHv2 4/4] gdb: check for multiple matching build-id files Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4efbb2060ea7298f855ee8141f7978ef1f142353.1717592684.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).