[2/5] gdb: add inferior parameter to set_target_gdbarch, rename to set_inferior_gdbarch
Commit Message
From: Simon Marchi <simon.marchi@polymtl.ca>
Add an inferior parameter, so it doesn't depend on the current
inferior. While at it, rename to set_inferior_gdbarch, I think that's a
better name than "target".
The sole observer of the architecture_changed observable,
pyuw_on_new_gdbarch, doesn't seem to depend on the current inferior.
Neither does registers_changed.
Update callers to pass the current inferior, no change in behavior is
expected.
Change-Id: I276e28eafd4740c94bc5233c81a86c01b4a6ae90
---
gdb/arch-utils.c | 16 ++++++++--------
gdb/gdbarch.h | 4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)
Comments
On Thu, Nov 24, 2022 at 11:04:25AM -0500, Simon Marchi via Gdb-patches wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> Add an inferior parameter, so it doesn't depend on the current
> inferior. While at it, rename to set_inferior_gdbarch, I think that's a
> better name than "target".
>
> The sole observer of the architecture_changed observable,
> pyuw_on_new_gdbarch, doesn't seem to depend on the current inferior.
> Neither does registers_changed.
Hi,
I kind of feel that it would make sense to also change the type of the
architecture_changed observable so the observers receive the inferior *
and the gdbarch *. It will not be used at the moment, but makes it
clearer that this observable gets triggerd for a given inferior.
WDYT?
Best,
Lancelot.
>
> Update callers to pass the current inferior, no change in behavior is
> expected.
>
> Change-Id: I276e28eafd4740c94bc5233c81a86c01b4a6ae90
> ---
> gdb/arch-utils.c | 16 ++++++++--------
> gdb/gdbarch.h | 4 ++--
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
> index dc67c632155..92caa5c3c4a 100644
> --- a/gdb/arch-utils.c
> +++ b/gdb/arch-utils.c
> @@ -617,7 +617,7 @@ gdbarch_update_p (struct gdbarch_info info)
> "New architecture %s (%s) selected\n",
> host_address_to_string (new_gdbarch),
> gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
> - set_target_gdbarch (new_gdbarch);
> + set_inferior_gdbarch (current_inferior (), new_gdbarch);
>
> return 1;
> }
> @@ -649,7 +649,7 @@ set_gdbarch_from_file (bfd *abfd)
>
> if (gdbarch == NULL)
> error (_("Architecture of file not recognized."));
> - set_target_gdbarch (gdbarch);
> + set_inferior_gdbarch (current_inferior (), gdbarch);
> }
>
> /* Initialize the current architecture. Update the ``set
> @@ -1427,15 +1427,15 @@ gdbarch_find_by_info (struct gdbarch_info info)
> return new_gdbarch;
> }
>
> -/* Make the specified architecture current. */
> +/* See gdbarch.h. */
>
> void
> -set_target_gdbarch (struct gdbarch *new_gdbarch)
> +set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch)
> {
> - gdb_assert (new_gdbarch != NULL);
> - gdb_assert (new_gdbarch->initialized_p);
> - current_inferior ()->gdbarch = new_gdbarch;
> - gdb::observers::architecture_changed.notify (new_gdbarch);
> + gdb_assert (gdbarch != nullptr);
> + gdb_assert (gdbarch->initialized_p);
> + inf->gdbarch = gdbarch;
> + gdb::observers::architecture_changed.notify (gdbarch);
> registers_changed ();
> }
>
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index f2ba5f97765..76ffddfe0ff 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -342,9 +342,9 @@ extern int gdbarch_update_p (struct gdbarch_info info);
> extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info);
>
>
> -/* Helper function. Set the target gdbarch to "gdbarch". */
> +/* Set INF's the target gdbarch to "gdbarch". */
>
> -extern void set_target_gdbarch (struct gdbarch *gdbarch);
> +extern void set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch);
>
>
> /* A registry adaptor for gdbarch. This arranges to store the
> --
> 2.37.3
>
On 11/24/22 11:42, Lancelot SIX wrote:
> On Thu, Nov 24, 2022 at 11:04:25AM -0500, Simon Marchi via Gdb-patches wrote:
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>
>> Add an inferior parameter, so it doesn't depend on the current
>> inferior. While at it, rename to set_inferior_gdbarch, I think that's a
>> better name than "target".
>>
>> The sole observer of the architecture_changed observable,
>> pyuw_on_new_gdbarch, doesn't seem to depend on the current inferior.
>> Neither does registers_changed.
>
> Hi,
>
> I kind of feel that it would make sense to also change the type of the
> architecture_changed observable so the observers receive the inferior *
> and the gdbarch *. It will not be used at the moment, but makes it
> clearer that this observable gets triggerd for a given inferior.
>
> WDYT?
That's a good idea, I'll add a patch that does that to my next version.
Simon
@@ -617,7 +617,7 @@ gdbarch_update_p (struct gdbarch_info info)
"New architecture %s (%s) selected\n",
host_address_to_string (new_gdbarch),
gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
- set_target_gdbarch (new_gdbarch);
+ set_inferior_gdbarch (current_inferior (), new_gdbarch);
return 1;
}
@@ -649,7 +649,7 @@ set_gdbarch_from_file (bfd *abfd)
if (gdbarch == NULL)
error (_("Architecture of file not recognized."));
- set_target_gdbarch (gdbarch);
+ set_inferior_gdbarch (current_inferior (), gdbarch);
}
/* Initialize the current architecture. Update the ``set
@@ -1427,15 +1427,15 @@ gdbarch_find_by_info (struct gdbarch_info info)
return new_gdbarch;
}
-/* Make the specified architecture current. */
+/* See gdbarch.h. */
void
-set_target_gdbarch (struct gdbarch *new_gdbarch)
+set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch)
{
- gdb_assert (new_gdbarch != NULL);
- gdb_assert (new_gdbarch->initialized_p);
- current_inferior ()->gdbarch = new_gdbarch;
- gdb::observers::architecture_changed.notify (new_gdbarch);
+ gdb_assert (gdbarch != nullptr);
+ gdb_assert (gdbarch->initialized_p);
+ inf->gdbarch = gdbarch;
+ gdb::observers::architecture_changed.notify (gdbarch);
registers_changed ();
}
@@ -342,9 +342,9 @@ extern int gdbarch_update_p (struct gdbarch_info info);
extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info);
-/* Helper function. Set the target gdbarch to "gdbarch". */
+/* Set INF's the target gdbarch to "gdbarch". */
-extern void set_target_gdbarch (struct gdbarch *gdbarch);
+extern void set_inferior_gdbarch (inferior *inf, gdbarch *gdbarch);
/* A registry adaptor for gdbarch. This arranges to store the