From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC][gdb/symtab] Add DEBUG_DEBUGINFOD_CLIENT in debuginfod-support.c
Date: Wed, 31 Mar 2021 15:56:45 +0200 [thread overview]
Message-ID: <20210331135644.GA13846@delia> (raw)
Hi,
Add an off-by-default debug trace option DEBUG_DEBUGINFOD_CLIENT in
debuginfod-support.c.
By redefining DEBUG_DEBUGINFOD_CLIENT to 1, we get a trace like this:
...
TRYING DEBUGINFO FOR: \
/home/vries/gdb_versions/devel/system-supplied DSO at 0x7ffff7ffa000
BUILDID: 157d01461677175219ab3ccd37454aeb740d2a7e
TOOK: 0.699193 seconds
RESULT fd: -2
warning: Source file is more recent than executable.
TRYING SOURCE: /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/\
obj-x86_64-suse-linux/x86_64-suse-linux/libgcc/../../../libgcc/\
config/i386/sfp-exceptions.c
BUILDID: 97481d83f99d6da01138fe4c61114da27e34d17e
TOOK: 1.724909 seconds
RESULT fd: -2
TRYING SOURCE: /home/abuild/rpmbuild/BUILD/gcc-7.5.0+r278197/\
obj-x86_64-suse-linux/x86_64-suse-linux/libgcc/../../../libgcc/libgcc2.c
BUILDID: 97481d83f99d6da01138fe4c61114da27e34d17e
TOOK: 0.819237 seconds
RESULT fd: -2
...
Any comments?
Thanks,
- Tom
[gdb/symtab] Add DEBUG_DEBUGINFOD_CLIENT in debuginfod-support.c
gdb/ChangeLog:
2021-03-31 Tom de Vries <tdevries@suse.de>
* debuginfod-support.c (DEBUG_DEBUGINFOD_CLIENT): New macro. Define
to 0.
(print_build_id, time_elapsed): New function.
(debuginfod_source_query, debuginfod_debuginfo_query)
[DEBUG_DEBUGINFOD_CLIENT]: Add tracing code.
---
gdb/debuginfod-support.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 9778e2e4cfe..30b9f4ad631 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -23,6 +23,12 @@
#include "debuginfod-support.h"
#include "gdbsupport/gdb_optional.h"
+#define DEBUG_DEBUGINFOD_CLIENT 0
+
+#if DEBUG_DEBUGINFOD_CLIENT
+#include <chrono>
+#endif
+
#ifndef HAVE_LIBDEBUGINFOD
scoped_fd
debuginfod_source_query (const unsigned char *build_id,
@@ -114,6 +120,28 @@ debuginfod_init ()
return c;
}
+#if DEBUG_DEBUGINFOD_CLIENT
+static void
+print_build_id (FILE *stream, const char *prefix, const unsigned char *build_id,
+ int build_id_len, const char *postfix)
+{
+ if (prefix)
+ fprintf (stream, "%s", prefix);
+ for (int i = 0; i < build_id_len; ++i)
+ fprintf (stream, "%02x", build_id[i]);
+ if (postfix)
+ fprintf (stream, "%s", postfix);
+}
+
+static double
+time_elapsed (std::chrono::time_point<std::chrono::high_resolution_clock> start)
+{
+ auto end = std::chrono::high_resolution_clock::now ();
+ std::chrono::duration<double> diff = end - start;
+ return diff.count ();
+}
+#endif
+
/* See debuginfod-support.h */
scoped_fd
@@ -131,14 +159,26 @@ debuginfod_source_query (const unsigned char *build_id,
if (c == nullptr)
return scoped_fd (-ENOMEM);
+#if DEBUG_DEBUGINFOD_CLIENT
+ fprintf (stderr, "TRYING SOURCE: %s\n", srcpath);
+ print_build_id (stderr, "BUILDID: ", build_id, build_id_len, "\n");
+#endif
+
user_data data ("source file", srcpath);
debuginfod_set_user_data (c.get (), &data);
+#if DEBUG_DEBUGINFOD_CLIENT
+ auto start = std::chrono::high_resolution_clock::now ();
+#endif
scoped_fd fd (debuginfod_find_source (c.get (),
build_id,
build_id_len,
srcpath,
nullptr));
+#if DEBUG_DEBUGINFOD_CLIENT
+ fprintf (stderr, "TOOK: %f seconds\n", time_elapsed (start));
+ fprintf (stderr, "RESULT fd: %d\n", fd.get ());
+#endif
/* TODO: Add 'set debug debuginfod' command to control when error messages are shown. */
if (fd.get () < 0 && fd.get () != -ENOENT)
@@ -172,9 +212,21 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
char *dname = nullptr;
user_data data ("separate debug info for", filename);
+#if DEBUG_DEBUGINFOD_CLIENT
+ fprintf (stderr, "TRYING DEBUGINFO FOR: %s\n", filename);
+ print_build_id (stderr, "BUILDID: ", build_id, build_id_len, "\n");
+#endif
+
debuginfod_set_user_data (c.get (), &data);
+#if DEBUG_DEBUGINFOD_CLIENT
+ auto start = std::chrono::high_resolution_clock::now ();
+#endif
scoped_fd fd (debuginfod_find_debuginfo (c.get (), build_id, build_id_len,
&dname));
+#if DEBUG_DEBUGINFOD_CLIENT
+ fprintf (stderr, "TOOK: %f seconds\n", time_elapsed (start));
+ fprintf (stderr, "RESULT fd: %d\n", fd.get ());
+#endif
if (fd.get () < 0 && fd.get () != -ENOENT)
printf_filtered (_("Download failed: %s. Continuing without debug info for %ps.\n"),
next reply other threads:[~2021-03-31 13:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 13:56 Tom de Vries [this message]
2021-04-01 13:38 ` Simon Marchi via Gdb-patches
2021-04-01 16:28 ` Tom Tromey
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=20210331135644.GA13846@delia \
--to=tdevries@suse.de \
--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