diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-05-23 18:11:55 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-06-11 20:41:16 +0100 |
commit | c7e38ee47c9497cf1fc62d7474b619c61dbd7450 (patch) | |
tree | 5401f66007315191b1ccb8ddb93f1177a5feb71d | |
parent | fc240bb143ca808cf67ed94ec8d9c0a4567dc89b (diff) | |
download | gdb-c7e38ee47c9497cf1fc62d7474b619c61dbd7450.zip gdb-c7e38ee47c9497cf1fc62d7474b619c61dbd7450.tar.gz gdb-c7e38ee47c9497cf1fc62d7474b619c61dbd7450.tar.bz2 |
gdb: avoid duplicate search in build_id_to_bfd_suffix
In build_id_to_bfd_suffix we look in each debug-file-directory for a
file matching the required build-id.
If we don't find one then we add the sysroot and perform the search
again.
However, the default sysroot is 'target:', and for a native target
this just means to search on the local machine. So by default, if the
debug information is not present, then we end up searching each
location twice.
I think we only need to perform the "with sysroot" check if either:
1. The sysroot is something other than 'target:'. If the user has
set it to '/some/directory' then we should check this sysroot. Or if
the user has set it to 'target:/some/other_directory', this is also
worth checking.
2. If the sysroot is 'target:', but the target's filesystem is not
local (i.e. the user is connected to a remote target), then we should
check using the sysroot as this will be looking on the remote
machine.
There's no tests for this as the whole point here is that I'm removing
duplicate work. No test regressions were seen though.
There should be no user visible changes after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r-- | gdb/build-id.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gdb/build-id.c b/gdb/build-id.c index 41667d5..fe0494a 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -176,9 +176,15 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, /* Try to look under the sysroot as well. If the sysroot is "/the/sysroot", it will give - "/the/sysroot/usr/lib/debug/.build-id/ab/cdef.debug". */ + "/the/sysroot/usr/lib/debug/.build-id/ab/cdef.debug". - if (!gdb_sysroot.empty ()) + If the sysroot is 'target:' and the target filesystem is local to + GDB then 'target:/path/to/check' becomes '/path/to/check' which + we just checked above. */ + + if (!gdb_sysroot.empty () + && (gdb_sysroot != TARGET_SYSROOT_PREFIX + || !target_filesystem_is_local ())) { link = gdb_sysroot + link; debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id); |