From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Cc: Luis Machado <luis.machado@arm.com>
Subject: Re: [PATCH 3/5] gdb: split osabi support between gdb/ and gdbsupport/ directories
Date: Thu, 10 Oct 2024 09:47:32 -0400 [thread overview]
Message-ID: <3e2be9d9-8322-4a29-9b6b-af48262fd9e0@simark.ca> (raw)
In-Reply-To: <63b58681b3abc4ef52c2b17c10bcb26a1a5033ea.1728407374.git.aburgess@redhat.com>
On 2024-10-08 13:11, Andrew Burgess wrote:
> 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 was we are guaranteed to always have a
was -> way
> valid, known, osabi string.
>
> This commit splits the osabi related code, which currently lives
> entirely on the GDB wide, between gdb/ and gdbsupport/. I've moved
wide -> side
> 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.
> ---
> gdb/osabi.c | 91 ----------------------------------
> gdb/osabi.h | 41 +---------------
> gdbsupport/Makefile.am | 1 +
> gdbsupport/Makefile.in | 15 +++---
> gdbsupport/osabi-common.cc | 98 +++++++++++++++++++++++++++++++++++++
> gdbsupport/osabi-common.def | 57 +++++++++++++++++++++
> gdbsupport/osabi-common.h | 54 ++++++++++++++++++++
Naming nit: do we really need / want "common" in the gdbsupport file
names? I think that the file being in gdbsupport already says it's
available to both gdb and gdbserver, so naming "common" seems
redundant (I know we have a bunch of files called "common" already).
> +const char *
> +gdbarch_osabi_name (enum gdb_osabi osabi)
> +{
> + if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
> + return gdb_osabi_names[osabi].pretty;
> +
> + return gdb_osabi_names[GDB_OSABI_INVALID].pretty;
> +}
> +
> +/* See gdbsupport/osabi-commomn.h. */
commomn -> common
Simon
next prev parent reply other threads:[~2024-10-10 13:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-06 18:37 [PATCH 0/3] Set osabi in remote target descriptions Andrew Burgess
2024-10-06 18:37 ` [PATCH 1/3] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char> Andrew Burgess
2024-10-07 17:00 ` Tom Tromey
2024-10-08 19:02 ` Simon Marchi
2024-10-09 11:07 ` Andrew Burgess
2024-10-09 11:45 ` Simon Marchi
2024-10-09 12:17 ` Andrew Burgess
2024-10-09 15:35 ` Simon Marchi
2024-10-09 15:50 ` Andrew Burgess
2024-10-06 18:37 ` [PATCH 2/3] gdb: make use of set_tdesc_osabi overload in features/ files Andrew Burgess
2024-10-07 17:00 ` Tom Tromey
2024-10-08 19:12 ` Simon Marchi
2024-10-09 11:08 ` Andrew Burgess
2024-10-09 11:48 ` Simon Marchi
2024-10-09 12:04 ` Andrew Burgess
2024-10-06 18:37 ` [PATCH 3/3] gdbserver: pass osabi to GDB in target description Andrew Burgess
2024-10-07 9:38 ` Luis Machado
2024-10-07 17:00 ` Tom Tromey
2024-10-08 17:11 ` [PATCH 0/5] Set osabi in remote target descriptions Andrew Burgess
2024-10-08 17:11 ` [PATCH 1/5] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char> Andrew Burgess
2024-10-10 13:37 ` Simon Marchi
2024-10-10 15:31 ` Andrew Burgess
2024-10-08 17:11 ` [PATCH 2/5] gdb: make use of set_tdesc_osabi overload in features/ files Andrew Burgess
2024-10-08 17:11 ` [PATCH 3/5] gdb: split osabi support between gdb/ and gdbsupport/ directories Andrew Burgess
2024-10-09 7:12 ` Luis Machado
2024-10-10 13:47 ` Simon Marchi [this message]
2024-10-08 17:11 ` [PATCH 4/5] gdb/gdbserver: change shared set_tdesc_osabi to take gdb_osabi Andrew Burgess
2024-10-09 7:12 ` Luis Machado
2024-10-10 15:23 ` Simon Marchi
2024-10-08 17:11 ` [PATCH 5/5] gdbserver: pass osabi to GDB in target description Andrew Burgess
2024-10-09 7:14 ` Luis Machado
2024-10-10 15:56 ` Simon Marchi
2024-10-10 20:19 ` Mark Wielaard
2024-10-11 8:31 ` Andrew Burgess
2024-10-10 15:57 ` [PATCH 0/5] Set osabi in remote target descriptions Simon Marchi
2024-10-10 16:41 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e2be9d9-8322-4a29-9b6b-af48262fd9e0@simark.ca \
--to=simark@simark.ca \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox