aboutsummaryrefslogtreecommitdiff
path: root/gdb/alpha-linux-nat.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-05-06 19:01:40 +0100
committerAndrew Burgess <aburgess@redhat.com>2024-09-07 20:28:57 +0100
commit8358d39b4f0c5c9d29714676bcccb1d59014997f (patch)
tree84022337d5aef29623da4e801f471c01d55a0b8a /gdb/alpha-linux-nat.c
parentfa826a4bbe98563d1ee98278c3ff0f52b77c413d (diff)
downloadbinutils-8358d39b4f0c5c9d29714676bcccb1d59014997f.zip
binutils-8358d39b4f0c5c9d29714676bcccb1d59014997f.tar.gz
binutils-8358d39b4f0c5c9d29714676bcccb1d59014997f.tar.bz2
gdb: unify build-id to objfile lookup code
There are 3 places where we currently call debuginfod_exec_query to lookup an objfile for a given build-id. In one of these places we first call build_id_to_exec_bfd which also looks up an objfile given a build-id, but this function looks on disk for a symlink in the .build-id/ sub-directory (within the debug-file-directory). I can't think of any reason why we shouldn't call build_id_to_exec_bfd before every call to debuginfod_exec_query. So, in this commit I have added a new function in build-id.c, find_objfile_by_build_id, this function calls build_id_to_exec_bfd, and if that fails, then calls debuginfod_exec_query. Everywhere we call debuginfod_exec_query is updated to call the new function, and in locate_exec_from_corefile_build_id, the existing call to build_id_to_exec_bfd is removed as calling find_objfile_by_build_id does this for us. One slight weird thing is in core_target::build_file_mappings, here we call find_objfile_by_build_id which returns a gdb_bfd_ref_ptr for the opened file, however we immediately reopen the file as "binary". The reason for this is that all the bfds opened in ::build_file_mappings need to be opened as "binary" (see the function comments for why). I did consider passing a target type into find_objfile_by_build_id, which could then be forwarded to build_id_to_exec_bfd and used to open the BFD as "binary", however, if you follow the call chain you'll end up in build_id_to_debug_bfd_1, where we actually open the bfd. Notice in here that we call build_id_verify to double check the build-id of the file we found, this requires that the bfd not be opened as "binary". What this means is that we always have to first open the bfd using the gnutarget target type (for the build-id check), and then we would have to reopen it as "binary". There seems little point pushing the reopen logic into find_objfile_by_build_id, so we just do this in the ::build_file_mappings function. I've extended the tests to cover the two cases which actually changed in this commit.
Diffstat (limited to 'gdb/alpha-linux-nat.c')
0 files changed, 0 insertions, 0 deletions