From: Bruno Larsen <blarsen@redhat.com>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Use enum for gdbarch's call_dummy_location
Date: Wed, 26 Oct 2022 13:57:44 +0200 [thread overview]
Message-ID: <8f667a30-676f-ed43-9cd3-ce44c81f52a9@redhat.com> (raw)
In-Reply-To: <20221018161533.3089756-3-tromey@adacore.com>
On 18/10/2022 18:15, Tom Tromey via Gdb-patches wrote:
> This changes gdbarch to use an enum for call_dummy_location, providing
> a little more type safety.
No regressions introduced, and the type safety is always welcome!
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
Cheers,
Bruno
> ---
> gdb/gdbarch-components.py | 2 +-
> gdb/gdbarch-gen.h | 4 ++--
> gdb/gdbarch.c | 6 +++---
> gdb/gdbarch.h | 7 +++++++
> gdb/inferior.h | 3 ---
> 5 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py
> index c997a709cbb..b2c7b784761 100644
> --- a/gdb/gdbarch-components.py
> +++ b/gdb/gdbarch-components.py
> @@ -647,7 +647,7 @@ Method(
> )
>
> Value(
> - type="int",
> + type="enum call_dummy_location_type",
> name="call_dummy_location",
> predefault="AT_ENTRY_POINT",
> invalid=False,
> diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
> index 840de585869..e0d7a08ff6a 100644
> --- a/gdb/gdbarch-gen.h
> +++ b/gdb/gdbarch-gen.h
> @@ -331,8 +331,8 @@ typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, stru
> extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr);
> extern void set_gdbarch_push_dummy_call (struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call);
>
> -extern int gdbarch_call_dummy_location (struct gdbarch *gdbarch);
> -extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, int call_dummy_location);
> +extern enum call_dummy_location_type gdbarch_call_dummy_location (struct gdbarch *gdbarch);
> +extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, enum call_dummy_location_type call_dummy_location);
>
> extern bool gdbarch_push_dummy_code_p (struct gdbarch *gdbarch);
>
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index 5545cfdad8e..6d6e61006f5 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -97,7 +97,7 @@ struct gdbarch
> gdbarch_dummy_id_ftype *dummy_id = default_dummy_id;
> int deprecated_fp_regnum = -1;
> gdbarch_push_dummy_call_ftype *push_dummy_call = nullptr;
> - int call_dummy_location = AT_ENTRY_POINT;
> + enum call_dummy_location_type call_dummy_location = AT_ENTRY_POINT;
> gdbarch_push_dummy_code_ftype *push_dummy_code = nullptr;
> gdbarch_code_of_frame_writable_ftype *code_of_frame_writable = default_code_of_frame_writable;
> gdbarch_print_registers_info_ftype *print_registers_info = default_print_registers_info;
> @@ -2230,7 +2230,7 @@ set_gdbarch_push_dummy_call (struct gdbarch *gdbarch,
> gdbarch->push_dummy_call = push_dummy_call;
> }
>
> -int
> +enum call_dummy_location_type
> gdbarch_call_dummy_location (struct gdbarch *gdbarch)
> {
> gdb_assert (gdbarch != NULL);
> @@ -2242,7 +2242,7 @@ gdbarch_call_dummy_location (struct gdbarch *gdbarch)
>
> void
> set_gdbarch_call_dummy_location (struct gdbarch *gdbarch,
> - int call_dummy_location)
> + enum call_dummy_location_type call_dummy_location)
> {
> gdbarch->call_dummy_location = call_dummy_location;
> }
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index 2f1c7399d78..f2ba5f97765 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -149,6 +149,13 @@ using read_core_file_mappings_loop_ftype =
> const char *filename,
> const bfd_build_id *build_id)>;
>
> +/* Possible values for gdbarch_call_dummy_location. */
> +enum call_dummy_location_type
> +{
> + ON_STACK,
> + AT_ENTRY_POINT,
> +};
> +
> #include "gdbarch-gen.h"
>
> /* An internal function that should _only_ be called from gdbarch_tdep.
> diff --git a/gdb/inferior.h b/gdb/inferior.h
> index 8877be38e36..69525a2e053 100644
> --- a/gdb/inferior.h
> +++ b/gdb/inferior.h
> @@ -282,9 +282,6 @@ enum stop_kind
> };
>
> \f
> -/* Possible values for gdbarch_call_dummy_location. */
> -#define ON_STACK 1
> -#define AT_ENTRY_POINT 4
>
> /* Base class for target-specific inferior data. */
>
next prev parent reply other threads:[~2022-10-26 11:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 16:15 [PATCH 0/2] Use enum for call_dummy_location Tom Tromey
2022-10-18 16:15 ` [PATCH 1/2] Inline initialization of gdbarch members Tom Tromey
2022-10-26 9:33 ` Bruno Larsen
2022-10-31 15:03 ` Tom Tromey
2022-10-18 16:15 ` [PATCH 2/2] Use enum for gdbarch's call_dummy_location Tom Tromey
2022-10-26 11:57 ` Bruno Larsen [this message]
2022-10-26 11:25 ` [PATCH 0/2] Use enum for call_dummy_location Luis Machado
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=8f667a30-676f-ed43-9cd3-ce44c81f52a9@redhat.com \
--to=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).