From: Andrew Burgess Date: Thu, 21 Aug 2025 11:58:30 +0000 (+0100) Subject: gdb: use current_program_space->core_bfd() a little less X-Git-Tag: gdb-17-branchpoint~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bd87cef85034dbf39a2817fba4f03828c0ca782;p=thirdparty%2Fbinutils-gdb.git gdb: use current_program_space->core_bfd() a little less The function linux_read_core_file_mappings is passed an argument CBFD, which is the BFD for the core file. In core_target::build_file_mappings, where the function is called, we pass current_program_space->core_bfd() as the argument. However, in linux_read_core_file_mappings, in some places we use the CBFD argument, and in other places we directly use current_program_space->core_bfd(). This is confusing, and unnecessary. Lets not do that. Standardise on just using CBFD. This removes some references to global state in favour of passing the global state in as an argument, I think this is a good thing. There should be no user visible changes after this commit. Approved-By: Simon Marchi --- diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 5c4bbf66563..f57ee855f1d 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1147,8 +1147,8 @@ linux_read_core_file_mappings } gdb::byte_vector contents (note_size); - if (!bfd_get_section_contents (current_program_space->core_bfd (), section, - contents.data (), 0, note_size)) + if (!bfd_get_section_contents (cbfd, section, contents.data (), 0, + note_size)) { warning (_("could not get core note contents")); return; @@ -1163,13 +1163,10 @@ linux_read_core_file_mappings return; } - ULONGEST count = bfd_get (addr_size_bits, current_program_space->core_bfd (), - descdata); + ULONGEST count = bfd_get (addr_size_bits, cbfd, descdata); descdata += addr_size; - ULONGEST page_size = bfd_get (addr_size_bits, - current_program_space->core_bfd (), - descdata); + ULONGEST page_size = bfd_get (addr_size_bits, cbfd, descdata); descdata += addr_size; if (note_size < 2 * addr_size + count * 3 * addr_size) @@ -1216,12 +1213,11 @@ linux_read_core_file_mappings for (int i = 0; i < count; i++) { - ULONGEST start = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata); + ULONGEST start = bfd_get (addr_size_bits, cbfd, descdata); descdata += addr_size; - ULONGEST end = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata); + ULONGEST end = bfd_get (addr_size_bits, cbfd, descdata); descdata += addr_size; - ULONGEST file_ofs - = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata) * page_size; + ULONGEST file_ofs = bfd_get (addr_size_bits, cbfd, descdata) * page_size; descdata += addr_size; char * filename = filenames; filenames += strlen ((char *) filenames) + 1;