]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: split osabi support between gdb/ and gdbsupport/ directories
authorAndrew Burgess <aburgess@redhat.com>
Tue, 8 Oct 2024 09:21:59 +0000 (10:21 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 10 Oct 2024 16:36:21 +0000 (17:36 +0100)
commit67470b3532fd031959169740fa99550fc8a06b84
tree468894259be20f963a22a59bcfc9d7b63d337464
parentcb5997da94752f35bbbc38fe5b1eedc307b0731c
gdb: split osabi support between gdb/ and gdbsupport/ directories

In future commits I want to call set_tdesc_osabi from gdbserver/
code.  Currently the only version of set_tdesc_osabi available to
gdbserver takes a string representing the osabi.

The problem with this is that, having lots of calls to set_tdesc_osabi
which all take a string is an invite for a typo to slip in.  This typo
could potentially go unnoticed until someone tries to debug the wrong
combination of GDB and gdbserver, at which point GDB will fail to find
the correct gdbarch because it doesn't understand the osabi string.

It would be better if the set_tdesc_osabi calls in gdbserver could
take an 'enum gdb_osabi' value and then convert this to the "correct"
string internally.  In this way we are guaranteed to always have a
valid, known, osabi string.

This commit splits the osabi related code, which currently lives
entirely on the GDB side, between gdb/ and gdbsupport/.  I've moved
the enum definition along with the array of osabi names into
gdbsupport/.  Then all the functions that access the names list, and
which convert between names and enum values are also moved.

I've taken the opportunity of this move to add a '.def' file which
contains all the enum names along with the name strings.  This '.def'
file is then used to create 'enum gdb_osabi' as well as the array of
osabi name strings.  By using a '.def' file we know that the enum
order will always match the name string array.

This commit is just a refactor, there are no user visible changes
after this commit.  This commit doesn't change how gdbserver sets the
target description osabi string, that will come in the next commit.

Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/osabi.c
gdb/osabi.h
gdbsupport/Makefile.am
gdbsupport/Makefile.in
gdbsupport/osabi.cc [new file with mode: 0644]
gdbsupport/osabi.def [new file with mode: 0644]
gdbsupport/osabi.h [new file with mode: 0644]