]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: use current_program_space->core_bfd() a little less
authorAndrew Burgess <aburgess@redhat.com>
Thu, 21 Aug 2025 11:58:30 +0000 (12:58 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 26 Aug 2025 20:48:34 +0000 (21:48 +0100)
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 <simon.marchi@efficios.com>
gdb/linux-tdep.c

index 5c4bbf665637748ef279870f55f9057b5f0ac5f7..f57ee855f1d845c3a88812e21313d28b88966ff9 100644 (file)
@@ -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;