diff options
author | Andrew Burgess <aburgess@redhat.com> | 2025-08-21 13:42:44 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2025-08-26 21:48:35 +0100 |
commit | 1cb99f1398127070de3ad4b354101f640316075c (patch) | |
tree | 09b7b7a2164e6d09e5ff6677211f93d2bd7574c3 | |
parent | 43ed67a290e7679af86395d7b430a71f9e4449ee (diff) | |
download | binutils-1cb99f1398127070de3ad4b354101f640316075c.zip binutils-1cb99f1398127070de3ad4b354101f640316075c.tar.gz binutils-1cb99f1398127070de3ad4b354101f640316075c.tar.bz2 |
gdb: use existing argument more in rename_vmcore_idle_reg_sections
In corelow.c, in the function rename_vmcore_idle_reg_sections, the
argument ABFD holds the core file bfd pointer. When this function is
called current_program_space->core_bfd() is passed as the argument
value.
Within this function, we sometimes use the function argument, and
sometimes access current_program_space->core_bfd() directly.
This is confusing, and unnecessary. Lets not do that.
I've renamed the argument to cbfd (for Core file BFD), and then
updated the function to make use of this argument throughout. This
reduces the number of accesses to global state, which is, I think, a
good thing.
There should be no user visible changes after this commit.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r-- | gdb/corelow.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gdb/corelow.c b/gdb/corelow.c index b376829..af534bf 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -790,10 +790,13 @@ core_file_command (const char *filename, int from_tty) .reg/1, .reg2/1, .reg/2, .reg2/2 After calling this function the rest of the core file handling code can - treat this core file just like any other core file. */ + treat this core file just like any other core file. + + CBFD is the core file being loaded, and INF is the inferior through + which the core file will be examined. */ static void -rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf) +rename_vmcore_idle_reg_sections (bfd *cbfd, inferior *inf) { /* Map from the bfd section to its lwpid (the /NN number). */ std::vector<std::pair<asection *, int>> sections_and_lwpids; @@ -808,7 +811,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf) /* Look for all the .reg sections. Record the section object and the lwpid which is extracted from the section name. Spot if any have an lwpid of zero. */ - for (asection *sect : gdb_bfd_sections (current_program_space->core_bfd ())) + for (asection *sect : gdb_bfd_sections (cbfd)) { if (startswith (bfd_section_name (sect), ".reg/")) { @@ -841,7 +844,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf) std::string replacement_lwpid_str; auto iter = sections_and_lwpids.begin (); int replacement_lwpid = 0; - for (asection *sect : gdb_bfd_sections (current_program_space->core_bfd ())) + for (asection *sect : gdb_bfd_sections (cbfd)) { if (iter != sections_and_lwpids.end () && sect == iter->first) { @@ -879,7 +882,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf) static_cast<int> (len - 2), name, replacement_lwpid); char *name_buf - = static_cast<char *> (bfd_alloc (abfd, name_str.size () + 1)); + = static_cast<char *> (bfd_alloc (cbfd, name_str.size () + 1)); if (name_buf == nullptr) error (_("failed to allocate space for section name '%s'"), name_str.c_str ()); |