]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: remove some dead code from core_target_open
authorAndrew Burgess <aburgess@redhat.com>
Wed, 27 Aug 2025 18:51:56 +0000 (19:51 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 4 Sep 2025 15:07:10 +0000 (16:07 +0100)
commit9cede382cb96b08bff9dcdb18aa959ec6f18f04f
tree75e48f8e6b02c99bbb51d1516fe7ad4403902ddb
parent9463d3e7563186ea9800ff2ba8ae909c31e5e854
gdb: remove some dead code from core_target_open

In core_target_open we call target_preopen which pops all targets
above the file_stratum, this will include the core_target, if the core
target is currently loaded.

Currently, the core file BFD is stored in the program_space of an
inferior.  The only way to set the core file BFD is by creating a
core_target (in core_target_open).  And when a core_target is closed
the core file BFD within the program_space is reset to nullptr (see
core_target::close and core_target::clear_core, both in corelow.c).

What this means is that, if there is no core_target loaded then there
will be no core file BFD in the program_space.  And in
core_target_open, after the call to target_preopen, there will be no
core_target loaded, and thus, no core file BFD in the program_space.

There is currently code in core_target_open which checks to see if
there is a core file BFD set in the current program space.  For the
reasons given above, I believe this is dead code and can be removed.

I've added some asserts to validate my assumptions.

There should be no user visible changes after this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/corelow.c