diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2024-07-28 23:25:58 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2024-08-12 11:10:02 -0400 |
commit | 91f378ddd0f3c51a29190b337abd9ebd06726f0b (patch) | |
tree | 61241a2cf93ce75b111f47f140c64b1aa7bab374 | |
parent | 74e39223b5e7cb645720a81f2c6ec25f9f40998c (diff) | |
download | binutils-91f378ddd0f3c51a29190b337abd9ebd06726f0b.zip binutils-91f378ddd0f3c51a29190b337abd9ebd06726f0b.tar.gz binutils-91f378ddd0f3c51a29190b337abd9ebd06726f0b.tar.bz2 |
gdb: pass inferior to gdbarch_update_p
Make the current inferior reference bubble up one level. I think this
makes it clearer what gdbarch_update_p, which is update the passed
inferior's architecture (although the function name could probably be
better).
When gdbarch_find_by_info, it is possible for the new architecture's
init callback to be called. I have not audited all of them (there are
just too many), it's possible that some of them do care about the
current inferior, for some reason (for instance, if one of them makes a
target call). If so, they should be changed too.
Change-Id: I89f012188d7fdca395a830f4b013743565f26847
-rw-r--r-- | gdb/arch-utils.c | 29 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 2 | ||||
-rw-r--r-- | gdb/cris-tdep.c | 6 | ||||
-rw-r--r-- | gdb/gdbarch.h | 5 | ||||
-rw-r--r-- | gdb/i386-darwin-nat.c | 2 | ||||
-rw-r--r-- | gdb/mips-tdep.c | 10 | ||||
-rw-r--r-- | gdb/osabi.c | 3 | ||||
-rw-r--r-- | gdb/rs6000-aix-nat.c | 2 | ||||
-rw-r--r-- | gdb/rs6000-tdep.c | 4 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 4 |
10 files changed, 34 insertions, 33 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 9110f0e..6ffa410 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -405,13 +405,13 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c) if (set_endian_string == endian_auto) { target_byte_order_user = BFD_ENDIAN_UNKNOWN; - if (! gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("set_endian: architecture update failed")); } else if (set_endian_string == endian_little) { info.byte_order = BFD_ENDIAN_LITTLE; - if (! gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) gdb_printf (gdb_stderr, _("Little endian target not supported by GDB\n")); else @@ -420,7 +420,7 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c) else if (set_endian_string == endian_big) { info.byte_order = BFD_ENDIAN_BIG; - if (! gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) gdb_printf (gdb_stderr, _("Big endian target not supported by GDB\n")); else @@ -562,7 +562,7 @@ set_architecture (const char *ignore_args, if (strcmp (set_architecture_string, "auto") == 0) { target_architecture_user = NULL; - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("could not select an architecture automatically")); } else @@ -570,7 +570,7 @@ set_architecture (const char *ignore_args, info.bfd_arch_info = bfd_scan_arch (set_architecture_string); if (info.bfd_arch_info == NULL) internal_error (_("set_architecture: bfd_scan_arch failed")); - if (gdbarch_update_p (info)) + if (gdbarch_update_p (current_inferior (), info)) target_architecture_user = info.bfd_arch_info; else gdb_printf (gdb_stderr, @@ -580,22 +580,23 @@ set_architecture (const char *ignore_args, show_architecture (gdb_stdout, from_tty, NULL, NULL); } -/* Try to select a global architecture that matches "info". Return - non-zero if the attempt succeeds. */ +/* See arch-utils.h. */ + int -gdbarch_update_p (struct gdbarch_info info) +gdbarch_update_p (inferior *inf, struct gdbarch_info info) { struct gdbarch *new_gdbarch; /* Check for the current file. */ if (info.abfd == NULL) - info.abfd = current_program_space->exec_bfd (); + info.abfd = inf->pspace->exec_bfd (); + if (info.abfd == NULL) - info.abfd = current_program_space->core_bfd (); + info.abfd = inf->pspace->core_bfd (); /* Check for the current target description. */ if (info.target_desc == NULL) - info.target_desc = target_current_description (current_inferior ()); + info.target_desc = target_current_description (inf); new_gdbarch = gdbarch_find_by_info (info); @@ -610,7 +611,7 @@ gdbarch_update_p (struct gdbarch_info info) /* If it is the same old architecture, accept the request (but don't swap anything). */ - if (new_gdbarch == current_inferior ()->arch ()) + if (new_gdbarch == inf->arch ()) { if (gdbarch_debug) gdb_printf (gdb_stdlog, "gdbarch_update_p: " @@ -627,7 +628,7 @@ gdbarch_update_p (struct gdbarch_info info) host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); - current_inferior ()->set_arch (new_gdbarch); + inf->set_arch (new_gdbarch); return 1; } @@ -752,7 +753,7 @@ initialize_current_architecture (void) info.byte_order = default_byte_order; info.byte_order_for_code = info.byte_order; - if (! gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("initialize_current_architecture: Selection of " "initial architecture failed")); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index d126908..6b235a0 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9504,7 +9504,7 @@ arm_update_current_architecture (void) /* Update the architecture. */ gdbarch_info info; - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("could not update architecture")); } diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 692aa9a..769b930 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -3883,7 +3883,7 @@ set_cris_version (const char *ignore_args, int from_tty, usr_cmd_cris_version_valid = 1; /* Update the current architecture, if needed. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("cris_gdbarch_update: failed to update architecture.")); } @@ -3894,7 +3894,7 @@ set_cris_mode (const char *ignore_args, int from_tty, struct gdbarch_info info; /* Update the current architecture, if needed. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error ("cris_gdbarch_update: failed to update architecture."); } @@ -3905,7 +3905,7 @@ set_cris_dwarf2_cfi (const char *ignore_args, int from_tty, struct gdbarch_info info; /* Update the current architecture, if needed. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("cris_gdbarch_update: failed to update architecture.")); } diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 5175ef7..60a0f60 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -316,7 +316,7 @@ extern obstack *gdbarch_obstack (gdbarch *arch); extern char *gdbarch_obstack_strdup (struct gdbarch *arch, const char *string); -/* Helper function. Force an update of the current architecture. +/* Helper function. Force an update of INF's architecture. The actual architecture selected is determined by INFO, ``(gdb) set architecture'' et.al., the existing architecture and BFD's default @@ -325,8 +325,7 @@ extern char *gdbarch_obstack_strdup (struct gdbarch *arch, const char *string); Returns non-zero if the update succeeds. */ -extern int gdbarch_update_p (struct gdbarch_info info); - +extern int gdbarch_update_p (inferior *inf, gdbarch_info info); /* Helper function. Find an architecture matching info. diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c index 5965599..55c6123 100644 --- a/gdb/i386-darwin-nat.c +++ b/gdb/i386-darwin-nat.c @@ -499,7 +499,7 @@ darwin_check_osabi (darwin_inferior *inf, thread_t thread) else info.bfd_arch_info = bfd_lookup_arch (bfd_arch_i386, bfd_mach_i386_i386); - gdbarch_update_p (info); + gdbarch_update_p (current_inferior (), info); } } diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index e935e26..f000d2f 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -896,7 +896,7 @@ set_mips64_transfers_32bit_regs (const char *args, int from_tty, /* FIXME: cagney/2003-11-15: Should be setting a field in "info" instead of relying on globals. Doing that would let generic code handle the search for this specific architecture. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) { mips64_transfers_32bit_regs_p = 0; error (_("32-bit compatibility mode not supported")); @@ -6968,7 +6968,7 @@ set_mipsfpu_single_command (const char *args, int from_tty) /* FIXME: cagney/2003-11-15: Should be setting a field in "info" instead of relying on globals. Doing that would let generic code handle the search for this specific architecture. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("set mipsfpu failed")); } @@ -6981,7 +6981,7 @@ set_mipsfpu_double_command (const char *args, int from_tty) /* FIXME: cagney/2003-11-15: Should be setting a field in "info" instead of relying on globals. Doing that would let generic code handle the search for this specific architecture. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("set mipsfpu failed")); } @@ -6994,7 +6994,7 @@ set_mipsfpu_none_command (const char *args, int from_tty) /* FIXME: cagney/2003-11-15: Should be setting a field in "info" instead of relying on globals. Doing that would let generic code handle the search for this specific architecture. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("set mipsfpu failed")); } @@ -8840,7 +8840,7 @@ mips_abi_update (const char *ignore_args, /* Force the architecture to update, and (if it's a MIPS architecture) mips_gdbarch_init will take care of the rest. */ - gdbarch_update_p (info); + gdbarch_update_p (current_inferior (), info); } /* Print out which MIPS ABI is in use. */ diff --git a/gdb/osabi.c b/gdb/osabi.c index 92f8f26..8a1efce 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -25,6 +25,7 @@ #include "gdb_bfd.h" #include "elf-bfd.h" +#include "inferior.h" #ifndef GDB_OSABI_DEFAULT #define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN @@ -644,7 +645,7 @@ set_osabi (const char *args, int from_tty, struct cmd_list_element *c) /* NOTE: At some point (true multiple architectures) we'll need to be more graceful here. */ gdbarch_info info; - if (! gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("Updating OS ABI failed.")); } diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c index 908671a..6a20f61 100644 --- a/gdb/rs6000-aix-nat.c +++ b/gdb/rs6000-aix-nat.c @@ -993,7 +993,7 @@ rs6000_nat_target::create_inferior (const char *exec_file, info.bfd_arch_info = bfd_get_arch_info (&abfd); info.abfd = current_program_space->exec_bfd (); - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("rs6000_create_inferior: failed " "to select architecture")); } diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index a5b1249..ed6a21b 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -8603,7 +8603,7 @@ powerpc_set_soft_float (const char *args, int from_tty, struct gdbarch_info info; /* Update the architecture. */ - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("could not update architecture")); } @@ -8629,7 +8629,7 @@ powerpc_set_vector_abi (const char *args, int from_tty, /* Update the architecture. */ gdbarch_info info; - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("could not update architecture")); } diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 23b5b10..4bb48fc 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -500,7 +500,7 @@ target_find_description (void) struct gdbarch_info info; info.target_desc = tdesc_info->tdesc; - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) { warning (_("Architecture rejected target-supplied description")); tdesc_info->tdesc = nullptr; @@ -537,7 +537,7 @@ target_clear_description (void) tdesc_info->tdesc = nullptr; gdbarch_info info; - if (!gdbarch_update_p (info)) + if (!gdbarch_update_p (current_inferior (), info)) internal_error (_("Could not remove target-supplied description")); } |