gdb: add a new 'maint info target-sections' command
We already have a command 'maint info sections', this command prints
all sections from all known object files.
However, GDB maintains a second section table internally. This
section table is used when GDB wants to read directly from an object
file rather than actually reading memory on the target. As such only
some sections (the allocatable ones) are added to this secondary
section table.
I recently ran into a situation where some of GDB's optimisations for
reading directly from the files were not working. In 'maint info
sections' I could see that GDB knew about the object file, and did
know about the sections that it _should_ have been reading from. But
I couldn't ask GDB which sections it had copied into its secondary
section table.
This commit adds a new command 'maint info target-sections' that fills
this gap. This command lists only those sections that GDB has copied
into its secondary table.
You'll notice that the testsuite includes a comment indicating that
there's a bug in GDB. Normally this is not something I would add to
the testsuite, instead we should raise an actual bugzilla bug and then
mark an xfail, however, a later patch in this series will remove this
comment once the actual bug in GDB is fixed.
gdb/ChangeLog:
* NEWS: Mention new 'maint info target-sections' command.
* maint.c (maintenance_info_target_sections): New function.
(_initialize_maint_cmds): Register new command.
gdb/doc/ChangeLog:
* gdb.texinfo (Files): Document new 'maint info target-sections'
command.
gdb/testsuite/ChangeLog:
* gdb.base/maint-info-sections.exp: Add new tests.
(check_maint_info_target_sections_output): New proc.