[binutils-gdb] gdb: remove target_gdbarch
Simon Marchi
simark@sourceware.org
Tue Oct 10 14:48:52 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee
commit 99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Fri Sep 29 14:24:38 2023 -0400
gdb: remove target_gdbarch
This function is just a wrapper around the current inferior's gdbarch.
I find that having that wrapper just obscures where the arch is coming
from, and that it's often used as "I don't know which arch to use so
I'll use this magical target_gdbarch function that gets me an arch" when
the arch should in fact come from something in the context (a thread,
objfile, symbol, etc). I think that removing it and inlining
`current_inferior ()->arch ()` everywhere will make it a bit clearer
where that arch comes from and will trigger people into reflecting
whether this is the right place to get the arch or not.
Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diff:
---
gdb/aarch64-linux-nat.c | 4 +-
gdb/ada-lang.c | 7 +--
gdb/ada-tasks.c | 9 ++--
gdb/aix-thread.c | 5 ++-
gdb/arc-tdep.c | 5 ++-
gdb/arch-utils.c | 12 +----
gdb/arm-tdep.c | 15 ++++---
gdb/auxv.c | 19 ++++----
gdb/break-catch-syscall.c | 2 +-
gdb/breakpoint.c | 16 +++----
gdb/bsd-uthread.c | 15 ++++---
gdb/btrace.c | 3 +-
gdb/cli/cli-dump.c | 5 ++-
gdb/compile/compile-c-symbols.c | 12 ++---
gdb/compile/compile-cplus-symbols.c | 12 +++--
gdb/compile/compile-object-load.c | 52 ++++++++++++----------
gdb/corefile.c | 3 +-
gdb/corelow.c | 2 +-
gdb/cp-namespace.c | 3 +-
gdb/cp-support.c | 3 +-
gdb/d-namespace.c | 3 +-
gdb/darwin-nat-info.c | 12 ++---
gdb/dcache.c | 6 ++-
gdb/disasm.c | 11 +++--
gdb/elfread.c | 4 +-
gdb/fbsd-nat.c | 2 +-
gdb/filesystem.c | 3 +-
gdb/frame-unwind.c | 3 +-
gdb/gcore.c | 49 +++++++++++----------
gdb/gdbarch.h | 15 -------
gdb/gnu-nat.c | 6 +--
gdb/i386-darwin-nat.c | 8 ++--
gdb/i386-tdep.c | 6 ++-
gdb/ia64-vms-tdep.c | 2 +-
gdb/infcmd.c | 8 ++--
gdb/infrun.c | 11 +++--
gdb/jit.c | 3 +-
gdb/linux-nat.c | 10 +++--
gdb/memattr.c | 9 ++--
gdb/mep-tdep.c | 4 +-
gdb/mi/mi-interp.c | 8 ++--
gdb/mi/mi-main.c | 2 +-
gdb/microblaze-tdep.c | 2 +-
gdb/mips-linux-nat.c | 6 +--
gdb/mips-linux-tdep.c | 5 ++-
gdb/mips-tdep.c | 15 ++++---
gdb/moxie-tdep.c | 4 +-
gdb/msp430-tdep.c | 3 +-
gdb/netbsd-nat.c | 2 +-
gdb/nto-procfs.c | 5 ++-
gdb/nto-tdep.c | 29 ++++++------
gdb/ppc-linux-nat.c | 2 +-
gdb/printcmd.c | 66 ++++++++++++++--------------
gdb/process-stratum-target.h | 3 +-
gdb/procfs.c | 24 +++++-----
gdb/progspace.c | 10 +++--
gdb/python/py-finishbreakpoint.c | 2 +-
gdb/python/py-inferior.c | 14 +++---
gdb/python/py-objfile.c | 5 ++-
gdb/python/py-progspace.c | 5 ++-
gdb/python/py-record-btrace.c | 2 +-
gdb/python/python.c | 2 +-
gdb/ravenscar-thread.c | 7 +--
gdb/record-btrace.c | 2 +-
gdb/record-full.c | 19 ++++----
gdb/regcache-dump.c | 6 +--
gdb/remote-sim.c | 2 +-
gdb/remote.c | 69 +++++++++++++++--------------
gdb/rl78-tdep.c | 6 ++-
gdb/rs6000-aix-nat.c | 5 ++-
gdb/rust-parse.c | 5 ++-
gdb/rx-tdep.c | 5 ++-
gdb/s390-linux-nat.c | 2 +-
gdb/sol-thread.c | 13 +++---
gdb/solib-darwin.c | 30 ++++++++-----
gdb/solib-dsbt.c | 26 ++++++-----
gdb/solib-frv.c | 19 ++++----
gdb/solib-svr4.c | 88 +++++++++++++++++++++----------------
gdb/solib.c | 37 ++++++++--------
gdb/sparc64-tdep.c | 14 +++---
gdb/symfile-mem.c | 2 +-
gdb/symfile.c | 11 ++---
gdb/symtab.c | 6 +--
gdb/target-descriptions.c | 4 +-
gdb/target.c | 33 ++++++++------
gdb/target.h | 2 +-
gdb/tracefile-tfile.c | 25 ++++++-----
gdb/tracefile.c | 3 +-
gdb/tracepoint.c | 31 +++++++------
gdb/value.c | 2 +-
gdb/windows-nat.c | 2 +-
gdb/windows-tdep.c | 10 ++---
gdb/z80-tdep.c | 2 +-
93 files changed, 579 insertions(+), 504 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index eb54db4bff4..0e87aaa9b7a 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -836,8 +836,8 @@ ps_err_e
ps_get_thread_area (struct ps_prochandle *ph,
lwpid_t lwpid, int idx, void **base)
{
- int is_64bit_p
- = (gdbarch_bfd_arch_info (target_gdbarch ())->bits_per_word == 64);
+ gdbarch *arch = current_inferior ()->arch ();
+ int is_64bit_p = (gdbarch_bfd_arch_info (arch)->bits_per_word == 64);
return aarch64_ps_get_thread_area (ph, lwpid, idx, base, is_64bit_p);
}
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a37e5637534..9bb649e901d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4914,7 +4914,7 @@ ada_lookup_simple_minsym (const char *name, struct objfile *objfile)
= ada_get_symbol_name_matcher (lookup_name);
gdbarch_iterate_over_objfiles_in_search_order
- (objfile != NULL ? objfile->arch () : target_gdbarch (),
+ (objfile != NULL ? objfile->arch () : current_inferior ()->arch (),
[&result, lookup_name, match_name] (struct objfile *obj)
{
for (minimal_symbol *msymbol : obj->msymbols ())
@@ -6448,7 +6448,8 @@ ada_tag_value_at_base_address (struct value *obj)
struct type *offset_type
= language_lookup_primitive_type (language_def (language_ada),
- target_gdbarch(), "storage_offset");
+ current_inferior ()->arch (),
+ "storage_offset");
ptr_type = lookup_pointer_type (offset_type);
val = value_cast (ptr_type, tag);
if (!val)
@@ -13766,7 +13767,7 @@ public:
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 1de6b0fc930..047566e6228 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -604,8 +604,9 @@ ada_get_tcb_types_info (void)
if (first_id_sym.minsym != nullptr)
{
CORE_ADDR addr = first_id_sym.value_address ();
+ gdbarch *arch = current_inferior ()->arch ();
/* This symbol always has type uint32_t. */
- struct type *u32type = builtin_type (target_gdbarch ())->builtin_uint32;
+ struct type *u32type = builtin_type (arch)->builtin_uint32;
first_id = value_as_long (value_at (u32type, addr));
}
@@ -959,7 +960,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
contains debug information on the task type (due to implicit with of
Ada.Tasking). */
data->known_tasks_element =
- builtin_type (target_gdbarch ())->builtin_data_ptr;
+ builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
data->known_tasks_length = MAX_NUMBER_OF_KNOWN_TASKS;
return;
}
@@ -990,7 +991,7 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
/* Fallback to default values. */
data->known_tasks_element =
- builtin_type (target_gdbarch ())->builtin_data_ptr;
+ builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
data->known_tasks_length = 1;
return;
}
@@ -1253,7 +1254,7 @@ info_task (struct ui_out *uiout, const char *taskno_str, struct inferior *inf)
/* Print the Ada task ID. */
gdb_printf (_("Ada Task: %s\n"),
- paddress (target_gdbarch (), task_info->task_id));
+ paddress (current_inferior ()->arch (), task_info->task_id));
/* Print the name of the task. */
if (task_info->name[0] != '\0')
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 2077491d3cf..945b7f6c697 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1054,7 +1054,7 @@ pd_enable (inferior *inf)
return;
/* Check application word size. */
- data->arch64 = register_size (target_gdbarch (), 0) == 8;
+ data->arch64 = register_size (current_inferior ()->arch (), 0) == 8;
/* Check whether the application is pthreaded. */
stub_name = NULL;
@@ -1069,7 +1069,8 @@ pd_enable (inferior *inf)
if (ms.minsym == NULL)
return;
data->pd_brk_addr = ms.value_address ();
- if (!create_thread_event_breakpoint (target_gdbarch (), data->pd_brk_addr))
+ if (!create_thread_event_breakpoint (current_inferior ()->arch (),
+ data->pd_brk_addr))
return;
/* Prepare for thread debugging. */
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 0b541c6335a..0740eff02e4 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -27,6 +27,7 @@
#include "frame-base.h"
#include "frame-unwind.h"
#include "gdbcore.h"
+#include "inferior.h"
#include "reggroups.h"
#include "gdbcmd.h"
#include "objfiles.h"
@@ -490,7 +491,7 @@ arc_insn_get_branch_target (const struct arc_instruction &insn)
static void
arc_insn_dump (const struct arc_instruction &insn)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ struct gdbarch *gdbarch = current_inferior ()->arch ();
arc_print ("Dumping arc_instruction at %s\n",
paddress (gdbarch, insn.address));
@@ -2441,7 +2442,7 @@ dump_arc_instruction_command (const char *args, int from_tty)
CORE_ADDR address = value_as_address (val);
struct arc_instruction insn;
- struct gdb_non_printing_memory_disassembler dis (target_gdbarch ());
+ gdb_non_printing_memory_disassembler dis (current_inferior ()->arch ());
arc_insn_decode (address, dis.disasm_info (), arc_delayed_print_insn, &insn);
arc_insn_dump (insn);
}
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 5768259d94f..60a50ea5b2c 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -609,7 +609,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 == target_gdbarch ())
+ if (new_gdbarch == current_inferior ()->arch ())
{
if (gdbarch_debug)
gdb_printf (gdb_stdlog, "gdbarch_update_p: "
@@ -850,7 +850,7 @@ get_current_arch (void)
if (has_stack_frames ())
return get_frame_arch (get_selected_frame (NULL));
else
- return target_gdbarch ();
+ return current_inferior ()->arch ();
}
int
@@ -1490,14 +1490,6 @@ gdbarch_initialized_p (gdbarch *arch)
return arch->initialized_p;
}
-/* Return the current inferior's arch. */
-
-struct gdbarch *
-target_gdbarch (void)
-{
- return current_inferior ()->arch ();
-}
-
void _initialize_gdbarch_utils ();
void
_initialize_gdbarch_utils ()
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 7e069d18770..a0ad1fb7a82 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9483,7 +9483,8 @@ static void
arm_update_current_architecture (void)
{
/* If the current architecture is not ARM, we have nothing to do. */
- if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_arm)
+ gdbarch *arch = current_inferior ()->arch ();
+ if (gdbarch_bfd_arch_info (arch)->arch != bfd_arch_arm)
return;
/* Update the architecture. */
@@ -9516,11 +9517,11 @@ static void
show_fp_model (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
+ gdbarch *arch = current_inferior ()->arch ();
if (arm_fp_model == ARM_FLOAT_AUTO
- && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
+ && gdbarch_bfd_arch_info (arch)->arch == bfd_arch_arm)
{
- arm_gdbarch_tdep *tdep
- = gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (arch);
gdb_printf (file, _("\
The current ARM floating point model is \"auto\" (currently \"%s\").\n"),
@@ -9556,11 +9557,11 @@ static void
arm_show_abi (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
+ gdbarch *arch = current_inferior ()->arch ();
if (arm_abi_global == ARM_ABI_AUTO
- && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
+ && gdbarch_bfd_arch_info (arch)->arch == bfd_arch_arm)
{
- arm_gdbarch_tdep *tdep
- = gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (arch);
gdb_printf (file, _("\
The current ARM ABI is \"auto\" (currently \"%s\").\n"),
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 45f3e920d80..61acd48fc98 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -83,7 +83,8 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
{
struct bound_minimal_symbol msym;
CORE_ADDR data_address, pointer_address;
- struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ gdbarch *arch = current_inferior ()->arch ();
+ type *ptr_type = builtin_type (arch)->builtin_data_ptr;
size_t ptr_size = ptr_type->length ();
size_t auxv_pair_size = 2 * ptr_size;
gdb_byte *ptr_buf = (gdb_byte *) alloca (ptr_size);
@@ -284,7 +285,7 @@ int
default_auxv_parse (struct target_ops *ops, const gdb_byte **readptr,
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
const int sizeof_auxv_type = ptr_type->length ();
@@ -428,6 +429,7 @@ fprint_auxv_entry (struct ui_file *file, const char *name,
const char *description, enum auxv_format format,
CORE_ADDR type, CORE_ADDR val)
{
+ gdbarch *arch = current_inferior ()->arch ();
gdb_printf (file, ("%-4s %-20s %-30s "),
plongest (type), name, description);
switch (format)
@@ -436,7 +438,7 @@ fprint_auxv_entry (struct ui_file *file, const char *name,
gdb_printf (file, ("%s\n"), plongest (val));
break;
case AUXV_FORMAT_HEX:
- gdb_printf (file, ("%s\n"), paddress (target_gdbarch (), val));
+ gdb_printf (file, ("%s\n"), paddress (arch, val));
break;
case AUXV_FORMAT_STR:
{
@@ -444,8 +446,8 @@ fprint_auxv_entry (struct ui_file *file, const char *name,
get_user_print_options (&opts);
if (opts.addressprint)
- gdb_printf (file, ("%s "), paddress (target_gdbarch (), val));
- val_print_string (builtin_type (target_gdbarch ())->builtin_char,
+ gdb_printf (file, ("%s "), paddress (arch, val));
+ val_print_string (builtin_type (arch)->builtin_char,
NULL, val, -1, file, &opts);
gdb_printf (file, ("\n"));
}
@@ -567,7 +569,7 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
static int
fprint_target_auxv (struct ui_file *file)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
CORE_ADDR type, val;
int ents = 0;
const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
@@ -579,9 +581,8 @@ fprint_target_auxv (struct ui_file *file)
const gdb_byte *ptr = data;
size_t len = auxv->size ();
- while (parse_auxv (current_inferior ()->top_target (),
- current_inferior ()->arch (),
- &ptr, data + len, &type, &val) > 0)
+ while (parse_auxv (current_inferior ()->top_target (), gdbarch, &ptr,
+ data + len, &type, &val) > 0)
{
gdbarch_print_auxv_entry (gdbarch, file, type, val);
++ents;
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 9bdfcf73efa..a00ecebebbd 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -359,7 +359,7 @@ static std::vector<int>
catch_syscall_split_args (const char *arg)
{
std::vector<int> result;
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
while (*arg != '\0')
{
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index db7d2e6a8e5..2edcbf6d490 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -597,7 +597,7 @@ show_debug_breakpoint (struct ui_file *file, int from_tty,
int
breakpoints_should_be_inserted_now (void)
{
- if (gdbarch_has_global_breakpoints (target_gdbarch ()))
+ if (gdbarch_has_global_breakpoints (current_inferior ()->arch ()))
{
/* If breakpoints are global, they should be inserted even if no
thread under gdb's control is running, or even if there are
@@ -3224,7 +3224,7 @@ update_inserted_breakpoint_locations (void)
to select an inferior to insert breakpoint to. In fact, even
if we aren't attached to any process yet, we should still
insert breakpoints. */
- if (!gdbarch_has_global_breakpoints (target_gdbarch ())
+ if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())
&& (inferior_ptid == null_ptid || !target_has_execution ()))
continue;
@@ -3284,7 +3284,7 @@ insert_breakpoint_locations (void)
to select an inferior to insert breakpoint to. In fact, even
if we aren't attached to any process yet, we should still
insert breakpoints. */
- if (!gdbarch_has_global_breakpoints (target_gdbarch ())
+ if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())
&& (inferior_ptid == null_ptid || !target_has_execution ()))
continue;
@@ -4243,7 +4243,7 @@ breakpoint_init_inferior (enum inf_context context)
/* If breakpoint locations are shared across processes, then there's
nothing to do. */
- if (gdbarch_has_global_breakpoints (target_gdbarch ()))
+ if (gdbarch_has_global_breakpoints (current_inferior ()->arch ()))
return;
mark_breakpoints_out ();
@@ -6615,7 +6615,7 @@ print_one_breakpoint_location (struct breakpoint *b,
/* For backward compatibility, don't display inferiors in CLI unless
there are several. Always display for MI. */
if (allflag
- || (!gdbarch_has_global_breakpoints (target_gdbarch ())
+ || (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())
&& (program_spaces.size () > 1
|| number_of_inferiors () > 1)
/* LOC is for existing B, it cannot be in
@@ -7299,7 +7299,7 @@ int
breakpoint_address_match (const address_space *aspace1, CORE_ADDR addr1,
const address_space *aspace2, CORE_ADDR addr2)
{
- return ((gdbarch_has_global_breakpoints (target_gdbarch ())
+ return ((gdbarch_has_global_breakpoints (current_inferior ()->arch ())
|| aspace1 == aspace2)
&& addr1 == addr2);
}
@@ -7315,7 +7315,7 @@ breakpoint_address_match_range (const address_space *aspace1,
int len1, const address_space *aspace2,
CORE_ADDR addr2)
{
- return ((gdbarch_has_global_breakpoints (target_gdbarch ())
+ return ((gdbarch_has_global_breakpoints (current_inferior ()->arch ())
|| aspace1 == aspace2)
&& addr2 >= addr1 && addr2 < addr1 + len1);
}
@@ -7349,7 +7349,7 @@ breakpoint_location_address_range_overlap (struct bp_location *bl,
const address_space *aspace,
CORE_ADDR addr, int len)
{
- if (gdbarch_has_global_breakpoints (target_gdbarch ())
+ if (gdbarch_has_global_breakpoints (current_inferior ()->arch ())
|| bl->pspace->aspace == aspace)
{
int bl_len = bl->length != 0 ? bl->length : 1;
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index e27e88add86..8765fb77283 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -125,7 +125,7 @@ bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
static void
bsd_uthread_check_magic (CORE_ADDR addr)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
ULONGEST magic = read_memory_unsigned_integer (addr, 4, byte_order);
if (magic != BSD_UTHREAD_PTHREAD_MAGIC)
@@ -169,7 +169,7 @@ bsd_uthread_lookup_address (const char *name, struct objfile *objfile)
static int
bsd_uthread_lookup_offset (const char *name, struct objfile *objfile)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
CORE_ADDR addr;
addr = bsd_uthread_lookup_address (name, objfile);
@@ -182,7 +182,8 @@ bsd_uthread_lookup_offset (const char *name, struct objfile *objfile)
static CORE_ADDR
bsd_uthread_read_memory_address (CORE_ADDR addr)
{
- struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ type *ptr_type
+ = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
return read_memory_typed_address (addr, ptr_type);
}
@@ -193,7 +194,7 @@ bsd_uthread_read_memory_address (CORE_ADDR addr)
static int
bsd_uthread_activate (struct objfile *objfile)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
struct bsd_uthread_ops *ops = get_bsd_uthread (gdbarch);
/* Skip if the thread stratum has already been activated. */
@@ -374,7 +375,7 @@ ptid_t
bsd_uthread_target::wait (ptid_t ptid, struct target_waitstatus *status,
target_wait_flags options)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
CORE_ADDR addr;
process_stratum_target *beneath
= as_process_stratum_target (this->beneath ());
@@ -432,7 +433,7 @@ bsd_uthread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
bool
bsd_uthread_target::thread_alive (ptid_t ptid)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
CORE_ADDR addr = ptid.tid ();
if (addr != 0)
@@ -513,7 +514,7 @@ static const char * const bsd_uthread_state[] =
const char *
bsd_uthread_target::extra_thread_info (thread_info *info)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
CORE_ADDR addr = info->ptid.tid ();
if (addr != 0)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index a7b6e810cdc..3f72b9c91e5 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1058,11 +1058,10 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
switch_to_thread (tp);
struct btrace_thread_info *btinfo;
- struct gdbarch *gdbarch;
unsigned int blk;
int level;
- gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
btinfo = &tp->btrace;
blk = btrace->blocks->size ();
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 08984f6fdf3..28512bd3172 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -33,6 +33,7 @@
#include "gdbsupport/filestuff.h"
#include "gdbsupport/byte-vector.h"
#include "gdbarch.h"
+#include "inferior.h"
static gdb::unique_xmalloc_ptr<char>
scan_expression (const char **cmd, const char *def)
@@ -426,10 +427,10 @@ restore_one_section (bfd *ibfd, asection *isec,
if (load_offset != 0 || load_start != 0 || load_end != 0)
gdb_printf (" into memory (%s to %s)\n",
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
(unsigned long) sec_start
+ sec_offset + load_offset),
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
(unsigned long) sec_start + sec_offset
+ load_offset + sec_load_count));
else
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 617297c3263..5982178170c 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -30,8 +30,8 @@
#include "exceptions.h"
#include "gdbtypes.h"
#include "dwarf2/loc.h"
+#include "inferior.h"
-
/* Compute the name of the pointer representing a local symbol's
address. */
@@ -95,7 +95,7 @@ convert_one_symbol (compile_c_instance *context,
kind = GCC_C_SYMBOL_FUNCTION;
addr = sym.symbol->value_block ()->entry_pc ();
if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
- addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
+ addr = gnu_ifunc_resolve_addr (current_inferior ()->arch (), addr);
break;
case LOC_CONST:
@@ -286,7 +286,7 @@ convert_symbol_bmsym (compile_c_instance *context,
case mst_text_gnu_ifunc:
type = builtin_type (objfile)->nodebug_text_gnu_ifunc_symbol;
kind = GCC_C_SYMBOL_FUNCTION;
- addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
+ addr = gnu_ifunc_resolve_addr (current_inferior ()->arch (), addr);
break;
case mst_data:
@@ -407,7 +407,8 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
identifier);
result = sym->value_block ()->entry_pc ();
if (sym->type ()->is_gnu_ifunc ())
- result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
+ result = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
+ result);
found = 1;
}
else
@@ -424,7 +425,8 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
identifier);
result = msym.value_address ();
if (msym.minsym->type () == mst_text_gnu_ifunc)
- result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
+ result = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
+ result);
found = 1;
}
}
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index ab18e631247..1edbf8f64b5 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -34,6 +34,7 @@
#include "cp-support.h"
#include "gdbcmd.h"
#include "compile-c.h"
+#include "inferior.h"
/* Convert a given symbol, SYM, to the compiler's representation.
INSTANCE is the compiler instance. IS_GLOBAL is true if the
@@ -89,7 +90,8 @@ convert_one_symbol (compile_cplus_instance *instance,
kind = GCC_CP_SYMBOL_FUNCTION;
addr = sym.symbol->value_block()->start ();
if (is_global && sym.symbol->type ()->is_gnu_ifunc ())
- addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
+ addr = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
+ addr);
}
break;
@@ -300,7 +302,7 @@ convert_symbol_bmsym (compile_cplus_instance *instance,
function return type cannot be function */
type = builtin_type (objfile)->nodebug_text_symbol;
kind = GCC_CP_SYMBOL_FUNCTION;
- addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
+ addr = gnu_ifunc_resolve_addr (current_inferior ()->arch (), addr);
break;
case mst_data:
@@ -445,7 +447,8 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
identifier);
result = sym->value_block ()->start ();
if (sym->type ()->is_gnu_ifunc ())
- result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
+ result = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
+ result);
found = 1;
}
else
@@ -462,7 +465,8 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
identifier);
result = msym.value_address ();
if (msym.minsym->type () == mst_text_gnu_ifunc)
- result = gnu_ifunc_resolve_addr (target_gdbarch (), result);
+ result = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
+ result);
found = 1;
}
}
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 013b6a9a427..d1727c30657 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -52,7 +52,8 @@ munmap_list::~munmap_list ()
{
try
{
- gdbarch_infcall_munmap (target_gdbarch (), item.addr, item.size);
+ gdbarch_infcall_munmap (current_inferior ()->arch (),
+ item.addr, item.size);
}
catch (const gdb_exception_error &ex)
{
@@ -130,7 +131,7 @@ setup_sections_data::setup_one_section (asection *sect)
"module \"%s\" section \"%s\" size %s prot %u\n",
bfd_get_filename (m_bfd),
bfd_section_name (sect),
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
bfd_section_size (sect)),
prot);
}
@@ -145,14 +146,14 @@ setup_sections_data::setup_one_section (asection *sect)
if (m_last_size != 0)
{
- addr = gdbarch_infcall_mmap (target_gdbarch (), m_last_size,
- m_last_prot);
+ addr = gdbarch_infcall_mmap (current_inferior ()->arch (),
+ m_last_size, m_last_prot);
munmap_list.add (addr, m_last_size);
if (compile_debug)
gdb_printf (gdb_stdlog,
"allocated %s bytes at %s prot %u\n",
- paddress (target_gdbarch (), m_last_size),
- paddress (target_gdbarch (), addr),
+ paddress (current_inferior ()->arch (), m_last_size),
+ paddress (current_inferior ()->arch (), addr),
m_last_prot);
}
else
@@ -161,8 +162,8 @@ setup_sections_data::setup_one_section (asection *sect)
if ((addr & (m_last_max_alignment - 1)) != 0)
error (_("Inferior compiled module address %s "
"is not aligned to BFD required %s."),
- paddress (target_gdbarch (), addr),
- paddress (target_gdbarch (), m_last_max_alignment));
+ paddress (current_inferior ()->arch (), addr),
+ paddress (current_inferior ()->arch (), m_last_max_alignment));
for (sect_iter = m_last_section_first; sect_iter != sect;
sect_iter = sect_iter->next)
@@ -387,8 +388,8 @@ copy_sections (bfd *abfd, asection *sect, void *data)
error (_("Cannot write compiled module \"%s\" section \"%s\" "
"to inferior memory range %s-%s."),
bfd_get_filename (abfd), bfd_section_name (sect),
- paddress (target_gdbarch (), inferior_addr),
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (), inferior_addr),
+ paddress (current_inferior ()->arch (),
inferior_addr + bfd_section_size (sect)));
}
@@ -546,7 +547,7 @@ get_regs_type (struct symbol *func_sym, struct objfile *objfile)
static void
store_regs (struct type *regs_type, CORE_ADDR regs_base)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
int fieldno;
for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
@@ -666,16 +667,19 @@ compile_object_load (const compile_file_names &file_names,
{
case COMPILE_I_SIMPLE_SCOPE:
expect_parameters = 1;
- expect_return_type = builtin_type (target_gdbarch ())->builtin_void;
+ expect_return_type
+ = builtin_type (current_inferior ()->arch ())->builtin_void;
break;
case COMPILE_I_RAW_SCOPE:
expect_parameters = 0;
- expect_return_type = builtin_type (target_gdbarch ())->builtin_void;
+ expect_return_type
+ = builtin_type (current_inferior ()->arch ())->builtin_void;
break;
case COMPILE_I_PRINT_ADDRESS_SCOPE:
case COMPILE_I_PRINT_VALUE_SCOPE:
expect_parameters = 2;
- expect_return_type = builtin_type (target_gdbarch ())->builtin_void;
+ expect_return_type
+ = builtin_type (current_inferior ()->arch ())->builtin_void;
break;
default:
internal_error (_("invalid scope %d"), scope);
@@ -759,7 +763,7 @@ compile_object_load (const compile_file_names &file_names,
gdb_printf (gdb_stdlog,
"Connecting ELF symbol \"%s\" to the .toc section (%s)\n",
sym->name,
- paddress (target_gdbarch (), sym->value));
+ paddress (current_inferior ()->arch (), sym->value));
continue;
}
@@ -775,17 +779,17 @@ compile_object_load (const compile_file_names &file_names,
gdb_printf (gdb_stdlog,
"ELF mst_text symbol \"%s\" relocated to %s\n",
sym->name,
- paddress (target_gdbarch (), sym->value));
+ paddress (current_inferior ()->arch (), sym->value));
break;
case mst_text_gnu_ifunc:
- sym->value = gnu_ifunc_resolve_addr (target_gdbarch (),
+ sym->value = gnu_ifunc_resolve_addr (current_inferior ()->arch (),
bmsym.value_address ());
if (compile_debug)
gdb_printf (gdb_stdlog,
"ELF mst_text_gnu_ifunc symbol \"%s\" "
"relocated to %s\n",
sym->name,
- paddress (target_gdbarch (), sym->value));
+ paddress (current_inferior ()->arch (), sym->value));
break;
default:
warning (_("Could not find symbol \"%s\" "
@@ -805,7 +809,7 @@ compile_object_load (const compile_file_names &file_names,
else
{
/* Use read-only non-executable memory protection. */
- regs_addr = gdbarch_infcall_mmap (target_gdbarch (),
+ regs_addr = gdbarch_infcall_mmap (current_inferior ()->arch (),
regs_type->length (),
GDB_MMAP_PROT_READ);
gdb_assert (regs_addr != 0);
@@ -813,9 +817,9 @@ compile_object_load (const compile_file_names &file_names,
if (compile_debug)
gdb_printf (gdb_stdlog,
"allocated %s bytes at %s for registers\n",
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
regs_type->length ()),
- paddress (target_gdbarch (), regs_addr));
+ paddress (current_inferior ()->arch (), regs_addr));
store_regs (regs_type, regs_addr);
}
@@ -826,7 +830,7 @@ compile_object_load (const compile_file_names &file_names,
if (out_value_type == NULL)
return NULL;
check_typedef (out_value_type);
- out_value_addr = gdbarch_infcall_mmap (target_gdbarch (),
+ out_value_addr = gdbarch_infcall_mmap (current_inferior ()->arch (),
out_value_type->length (),
(GDB_MMAP_PROT_READ
| GDB_MMAP_PROT_WRITE));
@@ -836,9 +840,9 @@ compile_object_load (const compile_file_names &file_names,
if (compile_debug)
gdb_printf (gdb_stdlog,
"allocated %s bytes at %s for printed value\n",
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
out_value_type->length ()),
- paddress (target_gdbarch (), out_value_addr));
+ paddress (current_inferior ()->arch (), out_value_addr));
}
compile_module_up retval (new struct compile_module);
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 1fbefd2eb8f..c27061a3ae3 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -188,7 +188,8 @@ memory_error (enum target_xfer_status err, CORE_ADDR memaddr)
enum errors exception = GDB_NO_ERROR;
/* Build error string. */
- std::string str = memory_error_message (err, target_gdbarch (), memaddr);
+ std::string str
+ = memory_error_message (err, current_inferior ()->arch (), memaddr);
/* Choose the right error to throw. */
switch (err)
diff --git a/gdb/corelow.c b/gdb/corelow.c
index c0b26239fd9..4da5e4fa5d4 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -1365,7 +1365,7 @@ bool
core_target::fetch_memtags (CORE_ADDR address, size_t len,
gdb::byte_vector &tags, int type)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
/* Make sure we have a way to decode the memory tag notes. */
if (!gdbarch_decode_memtag_section_p (gdbarch))
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index d4a47eaac1f..975e789f18a 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -32,6 +32,7 @@
#include "buildsym.h"
#include "language.h"
#include "namespace.h"
+#include "inferior.h"
#include <map>
#include <string>
#include <string.h>
@@ -196,7 +197,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 2af0218dba0..e02e859b99a 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -43,6 +43,7 @@
#include "event-top.h"
#include "run-on-main-thread.h"
#include "typeprint.h"
+#include "inferior.h"
#define d_left(dc) (dc)->u.s_binary.left
#define d_right(dc) (dc)->u.s_binary.right
@@ -1467,7 +1468,7 @@ add_symbol_overload_list_qualified (const char *func_name,
struct objfile *current_objfile = block ? block->objfile () : nullptr;
gdbarch_iterate_over_objfiles_in_search_order
- (current_objfile ? current_objfile->arch () : target_gdbarch (),
+ (current_objfile ? current_objfile->arch () : current_inferior ()->arch (),
[func_name, surrounding_static_block, &overload_list]
(struct objfile *obj)
{
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index 6153e5b3239..69474ba08d9 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -25,6 +25,7 @@
#include "d-lang.h"
#include "gdbsupport/gdb_obstack.h"
#include "gdbarch.h"
+#include "inferior.h"
/* This returns the length of first component of NAME, which should be
the demangled name of a D variable/function/method/etc.
@@ -92,7 +93,7 @@ d_lookup_symbol (const struct language_defn *langdef,
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index d5f633bccae..07b06b32f76 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -570,9 +570,10 @@ darwin_debug_regions (task_t task, mach_vm_address_t address, int max)
if (print)
{
+ gdbarch *arch = current_inferior ()->arch ();
gdb_printf (_("%s-%s %s/%s %s %s %s"),
- paddress (target_gdbarch (), prev_address),
- paddress (target_gdbarch (), prev_address + prev_size),
+ paddress (arch, prev_address),
+ paddress (arch, prev_address + prev_size),
unparse_protection (prev_info.protection),
unparse_protection (prev_info.max_protection),
unparse_inheritance (prev_info.inheritance),
@@ -618,7 +619,7 @@ darwin_debug_regions_recurse (task_t task)
ui_out_emit_table table_emitter (uiout, 9, -1, "regions");
- if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) <= 32)
{
uiout->table_header (10, ui_left, "start", "Start");
uiout->table_header (10, ui_left, "end", "End");
@@ -654,9 +655,10 @@ darwin_debug_regions_recurse (task_t task)
{
ui_out_emit_tuple tuple_emitter (uiout, "regions-row");
+ gdbarch *arch = current_inferior ()->arch ();
- uiout->field_core_addr ("start", target_gdbarch (), r_start);
- uiout->field_core_addr ("end", target_gdbarch (), r_start + r_size);
+ uiout->field_core_addr ("start", arch, r_start);
+ uiout->field_core_addr ("end", arch, r_start + r_size);
uiout->field_string ("min-prot",
unparse_protection (r_info.protection));
uiout->field_string ("max-prot",
diff --git a/gdb/dcache.c b/gdb/dcache.c
index c075625cb63..8a5fb13acf5 100644
--- a/gdb/dcache.c
+++ b/gdb/dcache.c
@@ -576,7 +576,8 @@ dcache_print_line (DCACHE *dcache, int index)
db = (struct dcache_block *) n->value;
gdb_printf (_("Line %d: address %s [%d hits]\n"),
- index, paddress (target_gdbarch (), db->addr), db->refs);
+ index, paddress (current_inferior ()->arch (), db->addr),
+ db->refs);
for (j = 0; j < dcache->line_size; j++)
{
@@ -636,7 +637,8 @@ dcache_info_1 (DCACHE *dcache, const char *exp)
struct dcache_block *db = (struct dcache_block *) n->value;
gdb_printf (_("Line %d: address %s [%d hits]\n"),
- i, paddress (target_gdbarch (), db->addr), db->refs);
+ i, paddress (current_inferior ()->arch (), db->addr),
+ db->refs);
i++;
refcount += db->refs;
diff --git a/gdb/disasm.c b/gdb/disasm.c
index aa5c6dab690..2e866f6865e 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -33,6 +33,7 @@
#include "valprint.h"
#include "cli/cli-style.h"
#include "objfiles.h"
+#include "inferior.h"
/* Disassemble functions.
FIXME: We should get rid of all the duplicate code in gdb that does
@@ -59,7 +60,8 @@ show_use_libopcodes_styling (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
- gdb_non_printing_memory_disassembler dis (target_gdbarch ());
+ gdbarch *arch = current_inferior ()->arch ();
+ gdb_non_printing_memory_disassembler dis (arch);
bool supported = dis.disasm_info ()->created_styled_output;
if (supported || !use_libopcodes_styling)
@@ -71,7 +73,7 @@ show_use_libopcodes_styling (struct ui_file *file, int from_tty,
turned on! */
gdb_printf (file, _("Use of libopcodes styling support is \"off\""
" (not supported on architecture \"%s\")\n"),
- gdbarch_bfd_arch_info (target_gdbarch ())->printable_name);
+ gdbarch_bfd_arch_info (arch)->printable_name);
}
}
@@ -81,7 +83,8 @@ static void
set_use_libopcodes_styling (const char *args, int from_tty,
struct cmd_list_element *c)
{
- gdb_non_printing_memory_disassembler dis (target_gdbarch ());
+ gdbarch *arch = current_inferior ()->arch ();
+ gdb_non_printing_memory_disassembler dis (arch);
bool supported = dis.disasm_info ()->created_styled_output;
/* If the current architecture doesn't support libopcodes styling then we
@@ -93,7 +96,7 @@ set_use_libopcodes_styling (const char *args, int from_tty,
{
use_libopcodes_styling_option = use_libopcodes_styling;
error (_("Use of libopcodes styling not supported on architecture \"%s\"."),
- gdbarch_bfd_arch_info (target_gdbarch ())->printable_name);
+ gdbarch_bfd_arch_info (arch)->printable_name);
}
else
use_libopcodes_styling = use_libopcodes_styling_option;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 8704b52f35b..7900dfbc388 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -781,7 +781,7 @@ elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
To search other namespaces, we would need to provide context, e.g. in
form of an objfile in that namespace. */
gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
+ (current_inferior ()->arch (),
[name, &addr_p, &found] (struct objfile *objfile)
{
htab_t htab;
@@ -835,7 +835,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
To search other namespaces, we would need to provide context, e.g. in
form of an objfile in that namespace. */
gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
+ (current_inferior ()->arch (),
[name, name_got_plt, &addr_p, &found] (struct objfile *objfile)
{
bfd *obfd = objfile->obfd.get ();
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 55a36f24025..0e0d0cdf621 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -178,7 +178,7 @@ fbsd_nat_target::find_memory_regions (find_memory_region_ftype func,
{
gdb_printf ("Save segment, %ld bytes at %s (%c%c%c)\n",
(long) size,
- paddress (target_gdbarch (), kve->kve_start),
+ paddress (current_inferior ()->arch (), kve->kve_start),
kve->kve_protection & KVME_PROT_READ ? 'r' : '-',
kve->kve_protection & KVME_PROT_WRITE ? 'w' : '-',
kve->kve_protection & KVME_PROT_EXEC ? 'x' : '-');
diff --git a/gdb/filesystem.c b/gdb/filesystem.c
index 27a806e1ba0..a1342442a2c 100644
--- a/gdb/filesystem.c
+++ b/gdb/filesystem.c
@@ -21,6 +21,7 @@
#include "filesystem.h"
#include "gdbarch.h"
#include "gdbcmd.h"
+#include "inferior.h"
const char file_system_kind_auto[] = "auto";
const char file_system_kind_unix[] = "unix";
@@ -39,7 +40,7 @@ effective_target_file_system_kind (void)
{
if (target_file_system_kind == file_system_kind_auto)
{
- if (gdbarch_has_dos_based_file_system (target_gdbarch ()))
+ if (gdbarch_has_dos_based_file_system (current_inferior ()->arch ()))
return file_system_kind_dos_based;
else
return file_system_kind_unix;
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index 866b2e6b4a6..927b6256b0b 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -29,6 +29,7 @@
#include "gdbarch.h"
#include "dwarf2/frame-tailcall.h"
#include "cli/cli-cmds.h"
+#include "inferior.h"
struct frame_unwind_table_entry
{
@@ -344,7 +345,7 @@ frame_unwind_got_address (frame_info_ptr frame, int regnum,
static void
maintenance_info_frame_unwinders (const char *args, int from_tty)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
struct frame_unwind_table *table = get_frame_unwind_table (gdbarch);
ui_out *uiout = current_uiout;
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 05cad94526e..a55b96f08f3 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -71,16 +71,16 @@ write_gcore_file_1 (bfd *obfd)
gdb::unique_xmalloc_ptr<char> note_data;
int note_size = 0;
asection *note_sec = NULL;
+ gdbarch *arch = current_inferior ()->arch ();
/* An external target method must build the notes section. */
/* FIXME: uweigand/2011-10-06: All architectures that support core file
generation should be converted to gdbarch_make_corefile_notes; at that
point, the target vector method can be removed. */
- if (!gdbarch_make_corefile_notes_p (target_gdbarch ()))
+ if (!gdbarch_make_corefile_notes_p (arch))
note_data = target_make_corefile_notes (obfd, ¬e_size);
else
- note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd,
- ¬e_size);
+ note_data = gdbarch_make_corefile_notes (arch, obfd, ¬e_size);
if (note_data == NULL || note_size == 0)
error (_("Target does not support core file generation."));
@@ -166,7 +166,8 @@ gcore_command (const char *args, int from_tty)
static enum bfd_architecture
default_gcore_arch (void)
{
- const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch ());
+ const bfd_arch_info *bfdarch
+ = gdbarch_bfd_arch_info (current_inferior ()->arch ());
if (bfdarch != NULL)
return bfdarch->arch;
@@ -179,9 +180,10 @@ default_gcore_arch (void)
static const char *
default_gcore_target (void)
{
+ gdbarch *arch = current_inferior ()->arch ();
/* The gdbarch may define a target to use for core files. */
- if (gdbarch_gcore_bfd_target_p (target_gdbarch ()))
- return gdbarch_gcore_bfd_target (target_gdbarch ());
+ if (gdbarch_gcore_bfd_target_p (arch))
+ return gdbarch_gcore_bfd_target (arch);
/* Otherwise, try to fall back to the exec target. This will probably
not work for non-ELF targets. */
@@ -394,10 +396,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
if (read == 0 && write == 0 && exec == 0 && modified == 0)
{
if (info_verbose)
- {
- gdb_printf ("Ignore segment, %s bytes at %s\n",
- plongest (size), paddress (target_gdbarch (), vaddr));
- }
+ gdb_printf ("Ignore segment, %s bytes at %s\n",
+ plongest (size), paddress (current_inferior ()->arch (),
+ vaddr));
return 0;
}
@@ -453,10 +454,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
}
if (info_verbose)
- {
- gdb_printf ("Save segment, %s bytes at %s\n",
- plongest (size), paddress (target_gdbarch (), vaddr));
- }
+ gdb_printf ("Save segment, %s bytes at %s\n",
+ plongest (size), paddress (current_inferior ()->arch (),
+ vaddr));
bfd_set_section_size (osec, size);
bfd_set_section_vma (osec, vaddr);
@@ -486,8 +486,9 @@ gcore_create_memtag_section_callback (CORE_ADDR vaddr, unsigned long size,
/* Ask the architecture to create a memory tag section for this particular
memory map entry. It will be populated with contents later, as we can't
start writing the contents before we have all the sections sorted out. */
+ gdbarch *arch = current_inferior ()->arch ();
asection *memtag_section
- = gdbarch_create_memtag_section (target_gdbarch (), obfd, vaddr, size);
+ = gdbarch_create_memtag_section (arch, obfd, vaddr, size);
if (memtag_section == nullptr)
{
@@ -501,7 +502,7 @@ gcore_create_memtag_section_callback (CORE_ADDR vaddr, unsigned long size,
gdb_printf (gdb_stdout, "Saved memory tag segment, %s bytes "
"at %s\n",
plongest (bfd_section_size (memtag_section)),
- paddress (target_gdbarch (), vaddr));
+ paddress (arch, vaddr));
}
return 0;
@@ -594,7 +595,8 @@ gcore_copy_callback (bfd *obfd, asection *osec)
warning (_("Memory read failed for corefile "
"section, %s bytes at %s."),
plongest (size),
- paddress (target_gdbarch (), bfd_section_vma (osec)));
+ paddress (current_inferior ()->arch (),
+ bfd_section_vma (osec)));
break;
}
if (!bfd_set_section_contents (obfd, osec, memhunk.data (),
@@ -620,7 +622,7 @@ gcore_copy_memtag_section_callback (bfd *obfd, asection *osec)
return;
/* Fill the section with memory tag contents. */
- if (!gdbarch_fill_memtag_section (target_gdbarch (), osec))
+ if (!gdbarch_fill_memtag_section (current_inferior ()->arch (), osec))
error (_("Failed to fill memory tag section for core file."));
}
@@ -628,18 +630,17 @@ static int
gcore_memory_sections (bfd *obfd)
{
/* Try gdbarch method first, then fall back to target method. */
- if (!gdbarch_find_memory_regions_p (target_gdbarch ())
- || gdbarch_find_memory_regions (target_gdbarch (),
- gcore_create_callback, obfd) != 0)
+ gdbarch *arch = current_inferior ()->arch ();
+ if (!gdbarch_find_memory_regions_p (arch)
+ || gdbarch_find_memory_regions (arch, gcore_create_callback, obfd) != 0)
{
if (target_find_memory_regions (gcore_create_callback, obfd) != 0)
return 0; /* FIXME: error return/msg? */
}
/* Take care of dumping memory tags, if there are any. */
- if (!gdbarch_find_memory_regions_p (target_gdbarch ())
- || gdbarch_find_memory_regions (target_gdbarch (),
- gcore_create_memtag_section_callback,
+ if (!gdbarch_find_memory_regions_p (arch)
+ || gdbarch_find_memory_regions (arch, gcore_create_memtag_section_callback,
obfd) != 0)
{
if (target_find_memory_regions (gcore_create_memtag_section_callback,
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 5285f29b18b..82d42c9d220 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -72,21 +72,6 @@ struct gdbarch_tdep_base
using gdbarch_tdep_up = std::unique_ptr<gdbarch_tdep_base>;
-/* The architecture associated with the inferior through the
- connection to the target.
-
- The architecture vector provides some information that is really a
- property of the inferior, accessed through a particular target:
- ptrace operations; the layout of certain RSP packets; the solib_ops
- vector; etc. To differentiate architecture accesses to
- per-inferior/target properties from
- per-thread/per-frame/per-objfile properties, accesses to
- per-inferior/target properties should be made through this
- gdbarch. */
-
-/* This is a convenience wrapper for 'current_inferior ()->gdbarch'. */
-extern struct gdbarch *target_gdbarch (void);
-
/* Callback type for the 'iterate_over_objfiles_in_search_order'
gdbarch method. */
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 90caee8a9d4..4608f247806 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2467,14 +2467,14 @@ gnu_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
if (writebuf != NULL)
{
inf_debug (gnu_current_inf, "writing %s[%s] <-- %s",
- paddress (target_gdbarch (), memaddr), pulongest (len),
+ paddress (current_inferior ()->arch (), memaddr), pulongest (len),
host_address_to_string (writebuf));
res = gnu_write_inferior (task, memaddr, writebuf, len);
}
else
{
inf_debug (gnu_current_inf, "reading %s[%s] --> %s",
- paddress (target_gdbarch (), memaddr), pulongest (len),
+ paddress (current_inferior ()->arch (), memaddr), pulongest (len),
host_address_to_string (readbuf));
res = gnu_read_inferior (task, memaddr, readbuf, len);
}
@@ -2529,7 +2529,7 @@ gnu_xfer_auxv (gdb_byte *readbuf, const gdb_byte *writebuf,
auxv[1].a_un.a_val = 0;
inf_debug (gnu_current_inf, "reading auxv %s[%s] --> %s",
- paddress (target_gdbarch (), memaddr), pulongest (len),
+ paddress (current_inferior ()->arch (), memaddr), pulongest (len),
host_address_to_string (readbuf));
if (memaddr + len > sizeof (auxv))
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 284c6771d07..8aeef2049d7 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -475,7 +475,7 @@ i386_darwin_dr_get_control (void)
void
darwin_check_osabi (darwin_inferior *inf, thread_t thread)
{
- if (gdbarch_osabi (target_gdbarch ()) == GDB_OSABI_UNKNOWN)
+ if (gdbarch_osabi (current_inferior ()->arch ()) == GDB_OSABI_UNKNOWN)
{
/* Attaching to a process. Let's figure out what kind it is. */
x86_thread_state_t gp_regs;
@@ -492,7 +492,7 @@ darwin_check_osabi (darwin_inferior *inf, thread_t thread)
gdbarch_info info;
gdbarch_info_fill (&info);
- info.byte_order = gdbarch_byte_order (target_gdbarch ());
+ info.byte_order = gdbarch_byte_order (current_inferior ()->arch ());
info.osabi = GDB_OSABI_DARWIN;
if (gp_regs.tsh.flavor == x86_THREAD_STATE64)
info.bfd_arch_info = bfd_lookup_arch (bfd_arch_i386,
@@ -516,7 +516,7 @@ darwin_check_osabi (darwin_inferior *inf, thread_t thread)
static int
i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
static const gdb_byte darwin_syscall[] = { 0xcd, 0x80 }; /* int 0x80 */
gdb_byte buf[sizeof (darwin_syscall)];
@@ -549,7 +549,7 @@ i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
static int
amd64_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
static const gdb_byte darwin_syscall[] = { 0x0f, 0x05 }; /* syscall */
gdb_byte buf[sizeof (darwin_syscall)];
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index d5423681802..560f16aa0e3 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3451,7 +3451,8 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
result_value->mark_bytes_unavailable (0, 16);
else
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order
+ = gdbarch_byte_order (current_inferior ()->arch ());
LONGEST upper, lower;
int size = builtin_type (gdbarch)->builtin_data_ptr->length ();
@@ -3635,7 +3636,8 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
{
ULONGEST upper, lower;
int size = builtin_type (gdbarch)->builtin_data_ptr->length ();
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order
+ = gdbarch_byte_order (current_inferior ()->arch ());
/* New values from input value. */
regnum -= tdep->bnd0_regnum;
diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c
index 1ed0d2dfb71..000052fcbf9 100644
--- a/gdb/ia64-vms-tdep.c
+++ b/gdb/ia64-vms-tdep.c
@@ -34,7 +34,7 @@ ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t *pi,
int need_unwind_info, void *arg)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
gdb_byte buf[32];
const char *annex = core_addr_to_string (ip);
LONGEST res;
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index fd85d27466a..cf8cd527955 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -287,7 +287,7 @@ post_create_inferior (int from_tty)
/* If the solist is global across processes, there's no need to
refetch it here. */
- if (!gdbarch_has_global_solist (target_gdbarch ()))
+ if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
solib_add (nullptr, 0, auto_solib_add);
}
}
@@ -2015,7 +2015,7 @@ info_program_command (const char *args, int from_tty)
target_files_info ();
gdb_printf (_("Program stopped at %s.\n"),
- paddress (target_gdbarch (), tp->stop_pc ()));
+ paddress (current_inferior ()->arch (), tp->stop_pc ()));
if (tp->control.stop_step)
gdb_printf (_("It stopped after being stepped.\n"));
else if (stat != 0)
@@ -2661,7 +2661,7 @@ attach_command (const char *args, int from_tty)
scoped_disable_commit_resumed disable_commit_resumed ("attaching");
- if (gdbarch_has_global_solist (target_gdbarch ()))
+ if (gdbarch_has_global_solist (current_inferior ()->arch ()))
/* Don't complain if all processes share the same symbol
space. */
;
@@ -2873,7 +2873,7 @@ detach_command (const char *args, int from_tty)
/* If the solist is global across inferiors, don't clear it when we
detach from a single inferior. */
- if (!gdbarch_has_global_solist (target_gdbarch ()))
+ if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
no_shared_libraries (nullptr, from_tty);
if (deprecated_detach_hook)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 784f0b96ebf..4fde96800fb 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5300,7 +5300,8 @@ handle_one (const wait_one_event &event)
infrun_debug_printf ("saved stop_pc=%s for %s "
"(currently_stepping=%d)",
- paddress (target_gdbarch (), t->stop_pc ()),
+ paddress (current_inferior ()->arch (),
+ t->stop_pc ()),
t->ptid.to_string ().c_str (),
currently_stepping (t));
}
@@ -6334,7 +6335,8 @@ finish_step_over (struct execution_control_state *ecs)
infrun_debug_printf ("saved stop_pc=%s for %s "
"(currently_stepping=%d)",
- paddress (target_gdbarch (), tp->stop_pc ()),
+ paddress (current_inferior ()->arch (),
+ tp->stop_pc ()),
tp->ptid.to_string ().c_str (),
currently_stepping (tp));
@@ -8018,8 +8020,9 @@ keep_going_stepped_thread (struct thread_info *tp)
ptid_t resume_ptid;
infrun_debug_printf ("expected thread advanced also (%s -> %s)",
- paddress (target_gdbarch (), tp->prev_pc),
- paddress (target_gdbarch (), tp->stop_pc ()));
+ paddress (current_inferior ()->arch (), tp->prev_pc),
+ paddress (current_inferior ()->arch (),
+ tp->stop_pc ()));
/* Clear the info of the previous step-over, as it's no longer
valid (if the thread was trying to step over a breakpoint, it
diff --git a/gdb/jit.c b/gdb/jit.c
index 1997be77b83..9e8325ab803 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1229,7 +1229,8 @@ jit_inferior_execd_hook (inferior *exec_inf, inferior *follow_inf)
void
jit_breakpoint_re_set (void)
{
- jit_breakpoint_re_set_internal (target_gdbarch (), current_program_space);
+ jit_breakpoint_re_set_internal (current_inferior ()->arch (),
+ current_program_space);
}
/* This function cleans up any code entries left over when the
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 7e36ced6292..9148dda4aad 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2448,8 +2448,9 @@ status_callback (struct lwp_info *lp)
{
linux_nat_debug_printf ("PC of %s changed. was=%s, now=%s",
lp->ptid.to_string ().c_str (),
- paddress (target_gdbarch (), lp->stop_pc),
- paddress (target_gdbarch (), pc));
+ paddress (current_inferior ()->arch (),
+ lp->stop_pc),
+ paddress (current_inferior ()->arch (), pc));
discard = 1;
}
@@ -2458,7 +2459,8 @@ status_callback (struct lwp_info *lp)
{
linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
lp->ptid.to_string ().c_str (),
- paddress (target_gdbarch (), lp->stop_pc));
+ paddress (current_inferior ()->arch (),
+ lp->stop_pc));
discard = 1;
}
@@ -3725,7 +3727,7 @@ linux_nat_target::xfer_partial (enum target_object object,
by linux_proc_xfer_partial.
Compare ADDR_BIT first to avoid a compiler warning on shift overflow. */
- int addr_bit = gdbarch_addr_bit (target_gdbarch ());
+ int addr_bit = gdbarch_addr_bit (current_inferior ()->arch ());
if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
offset &= ((ULONGEST) 1 << addr_bit) - 1;
diff --git a/gdb/memattr.c b/gdb/memattr.c
index fafd909a714..8b0e3ef7b7e 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -29,6 +29,7 @@
#include "cli/cli-utils.h"
#include <algorithm>
#include "gdbarch.h"
+#include "inferior.h"
static std::vector<mem_region> user_mem_region_list, target_mem_region_list;
static std::vector<mem_region> *mem_region_list = &target_mem_region_list;
@@ -354,10 +355,10 @@ info_mem_command (const char *args, int from_tty)
gdb_printf ("Num ");
gdb_printf ("Enb ");
gdb_printf ("Low Addr ");
- if (gdbarch_addr_bit (target_gdbarch ()) > 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) > 32)
gdb_printf (" ");
gdb_printf ("High Addr ");
- if (gdbarch_addr_bit (target_gdbarch ()) > 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) > 32)
gdb_printf (" ");
gdb_printf ("Attrs ");
gdb_printf ("\n");
@@ -369,14 +370,14 @@ info_mem_command (const char *args, int from_tty)
gdb_printf ("%-3d %-3c\t",
m.number,
m.enabled_p ? 'y' : 'n');
- if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) <= 32)
tmp = hex_string_custom (m.lo, 8);
else
tmp = hex_string_custom (m.lo, 16);
gdb_printf ("%s ", tmp);
- if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) <= 32)
{
if (m.hi == 0)
tmp = "0x100000000";
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 85c2e229a5c..a84df4e1f53 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -263,7 +263,7 @@ me_module_register_set (CONFIG_ATTR me_module,
specifically excluding the generic coprocessor register sets. */
mep_gdbarch_tdep *tdep
- = gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mep_gdbarch_tdep> (current_inferior ()->arch ());
CGEN_CPU_DESC desc = tdep->cpu_desc;
const CGEN_HW_ENTRY *hw;
@@ -859,7 +859,7 @@ current_me_module (void)
else
{
mep_gdbarch_tdep *tdep
- = gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mep_gdbarch_tdep> (current_inferior ()->arch ());
return tdep->me_module;
}
}
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index b3b0f5bb1f5..0d3c8235c2c 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -726,13 +726,13 @@ mi_interp::on_target_resumed (ptid_t ptid)
void
mi_output_solib_attribs (ui_out *uiout, struct so_list *solib)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
uiout->field_string ("id", solib->so_original_name);
uiout->field_string ("target-name", solib->so_original_name);
uiout->field_string ("host-name", solib->so_name);
uiout->field_signed ("symbols-loaded", solib->symbols_loaded);
- if (!gdbarch_has_global_solist (target_gdbarch ()))
+ if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num);
ui_out_emit_list list_emitter (uiout, "ranges");
@@ -776,7 +776,7 @@ mi_interp::on_solib_unloaded (so_list *solib)
uiout->field_string ("id", solib->so_original_name);
uiout->field_string ("target-name", solib->so_original_name);
uiout->field_string ("host-name", solib->so_name);
- if (!gdbarch_has_global_solist (target_gdbarch ()))
+ if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num);
gdb_flush (this->event_channel);
@@ -821,7 +821,7 @@ mi_interp::on_memory_changed (inferior *inferior, CORE_ADDR memaddr,
ui_out_redirect_pop redir (mi_uiout, this->event_channel);
mi_uiout->field_fmt ("thread-group", "i%d", inferior->num);
- mi_uiout->field_core_addr ("addr", target_gdbarch (), memaddr);
+ mi_uiout->field_core_addr ("addr", current_inferior ()->arch (), memaddr);
mi_uiout->field_string ("len", hex_string (len));
/* Append 'type=code' into notification if MEMADDR falls in the range of
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 4f18ef7db25..944c9116731 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2714,7 +2714,7 @@ mi_cmd_trace_frame_collected (const char *command, const char *const *argv,
for (const mem_range &r : available_memory)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
ui_out_emit_tuple tuple_emitter (uiout, NULL);
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index f254a54305c..74e70405b3a 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -115,7 +115,7 @@ microblaze_register_type (struct gdbarch *gdbarch, int regnum)
static unsigned long
microblaze_fetch_instruction (CORE_ADDR pc)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
gdb_byte buf[4];
/* If we can't read the instruction at PC, return zero. */
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 8a7cc95f2a4..8d21049b8cf 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -516,7 +516,7 @@ mips_show_dr (const char *func, CORE_ADDR addr,
if (addr || len)
gdb_printf (gdb_stdlog,
" (addr=%s, len=%d, type=%s)",
- paddress (target_gdbarch (), addr), len,
+ paddress (current_inferior ()->arch (), addr), len,
type == hw_write ? "data-write"
: (type == hw_read ? "data-read"
: (type == hw_access ? "data-read/write"
@@ -526,10 +526,10 @@ mips_show_dr (const char *func, CORE_ADDR addr,
for (i = 0; i < MAX_DEBUG_REGISTER; i++)
gdb_printf (gdb_stdlog, "\tDR%d: lo=%s, hi=%s\n", i,
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
mips_linux_watch_get_watchlo (&watch_mirror,
i)),
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
mips_linux_watch_get_watchhi (&watch_mirror,
i)));
}
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 9f5d5b32408..371bc73c9b2 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -39,6 +39,7 @@
#include "linux-tdep.h"
#include "xml-syscall.h"
#include "gdbsupport/gdb_signals.h"
+#include "inferior.h"
#include "features/mips-linux.c"
#include "features/mips-dsp-linux.c"
@@ -599,8 +600,8 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc)
{
gdb_byte buf[28], *p;
ULONGEST insn, insn1;
- int n64 = (mips_abi (target_gdbarch ()) == MIPS_ABI_N64);
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ int n64 = (mips_abi (current_inferior ()->arch ()) == MIPS_ABI_N64);
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
if (in_mips_stubs_section (pc))
return 1;
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 4044daa2413..d40d28e85de 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -1183,12 +1183,13 @@ show_mask_address (struct ui_file *file, int from_tty,
const char *additional_text = "";
if (mask_address_var == AUTO_BOOLEAN_AUTO)
{
- if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
+ if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
+ != bfd_arch_mips)
additional_text = _(" (current architecture is not MIPS)");
else
{
mips_gdbarch_tdep *tdep
- = gdbarch_tdep<mips_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mips_gdbarch_tdep> (current_inferior ()->arch ());
if (mips_mask_address_p (tdep))
additional_text = _(" (currently \"on\")");
@@ -6926,7 +6927,8 @@ show_mipsfpu_command (const char *args, int from_tty)
{
const char *fpu;
- if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
+ if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
+ != bfd_arch_mips)
{
gdb_printf
("The MIPS floating-point coprocessor is unknown "
@@ -6934,7 +6936,7 @@ show_mipsfpu_command (const char *args, int from_tty)
return;
}
- switch (mips_get_fpu_type (target_gdbarch ()))
+ switch (mips_get_fpu_type (current_inferior ()->arch ()))
{
case MIPS_FPU_SINGLE:
fpu = "single-precision";
@@ -8850,7 +8852,8 @@ show_mips_abi (struct ui_file *file,
struct cmd_list_element *ignored_cmd,
const char *ignored_value)
{
- if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
+ if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
+ != bfd_arch_mips)
gdb_printf
(file,
"The MIPS ABI is unknown because the current architecture "
@@ -8858,7 +8861,7 @@ show_mips_abi (struct ui_file *file,
else
{
enum mips_abi global_abi = global_mips_abi ();
- enum mips_abi actual_abi = mips_abi (target_gdbarch ());
+ enum mips_abi actual_abi = mips_abi (current_inferior ()->arch ());
const char *actual_abi_str = mips_abi_strings[actual_abi];
if (global_abi == MIPS_ABI_UNKNOWN)
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 9154d488499..600fb060b1e 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -279,7 +279,7 @@ moxie_process_readu (CORE_ADDR addr, gdb_byte *buf,
gdb_printf (gdb_stderr,
_("Process record: error reading memory at "
"addr 0x%s len = %d.\n"),
- paddress (target_gdbarch (), addr), length);
+ paddress (current_inferior ()->arch (), addr), length);
return -1;
}
@@ -628,7 +628,7 @@ moxie_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
if (record_debug > 1)
gdb_printf (gdb_stdlog, "Process record: moxie_process_record "
"addr = 0x%s\n",
- paddress (target_gdbarch (), addr));
+ paddress (current_inferior ()->arch (), addr));
inst = (uint16_t) moxie_process_readu (addr, buf, 2, byte_order);
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index 2768e4e3a21..97d9073efbb 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -35,6 +35,7 @@
#include "dwarf2/frame.h"
#include "reggroups.h"
#include "gdbarch.h"
+#include "inferior.h"
#include "elf/msp430.h"
#include "opcode/msp430-decode.h"
@@ -328,7 +329,7 @@ check_for_saved (void *result_untyped, pv_t addr, CORE_ADDR size, pv_t value)
if (value.kind == pvk_register
&& value.k == 0
&& pv_is_register (addr, MSP430_SP_REGNUM)
- && size == register_size (target_gdbarch (), value.reg))
+ && size == register_size (current_inferior ()->arch (), value.reg))
result->reg_offset[value.reg] = addr.k;
}
diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c
index d1614ec0783..0cfcb45038c 100644
--- a/gdb/netbsd-nat.c
+++ b/gdb/netbsd-nat.c
@@ -250,7 +250,7 @@ nbsd_nat_target::find_memory_regions (find_memory_region_ftype func,
{
gdb_printf ("Save segment, %ld bytes at %s (%c%c%c)\n",
(long) size,
- paddress (target_gdbarch (), kve->kve_start),
+ paddress (current_inferior ()->arch (), kve->kve_start),
kve->kve_protection & KVME_PROT_READ ? 'r' : '-',
kve->kve_protection & KVME_PROT_WRITE ? 'w' : '-',
kve->kve_protection & KVME_PROT_EXEC ? 'x' : '-');
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 61c18fdc825..08bb8699b7c 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -275,8 +275,9 @@ nto_procfs_target::open (const char *arg, int from_tty)
else
{
if (sysinfo->type !=
- nto_map_arch_to_cputype (gdbarch_bfd_arch_info
- (target_gdbarch ())->arch_name))
+ nto_map_arch_to_cputype
+ (gdbarch_bfd_arch_info
+ (current_inferior ()->arch ())->arch_name))
error (_("Invalid target CPU."));
}
}
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 1ad0f012969..9ece8b5fb39 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -102,14 +102,15 @@ nto_find_and_open_solib (const char *solib, unsigned o_flags,
"%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
nto_root = nto_target ();
- if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
+ gdbarch *gdbarch = current_inferior ()->arch ();
+ if (strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name, "i386") == 0)
{
arch = "x86";
endian = "";
}
- else if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name,
+ else if (strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name,
"rs6000") == 0
- || strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name,
+ || strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name,
"powerpc") == 0)
{
arch = "ppc";
@@ -117,8 +118,8 @@ nto_find_and_open_solib (const char *solib, unsigned o_flags,
}
else
{
- arch = gdbarch_bfd_arch_info (target_gdbarch ())->arch_name;
- endian = gdbarch_byte_order (target_gdbarch ())
+ arch = gdbarch_bfd_arch_info (gdbarch)->arch_name;
+ endian = gdbarch_byte_order (gdbarch)
== BFD_ENDIAN_BIG ? "be" : "le";
}
@@ -162,14 +163,15 @@ nto_init_solib_absolute_prefix (void)
const char *arch;
nto_root = nto_target ();
- if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name, "i386") == 0)
+ gdbarch *gdbarch = current_inferior ()->arch ();
+ if (strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name, "i386") == 0)
{
arch = "x86";
endian = "";
}
- else if (strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name,
+ else if (strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name,
"rs6000") == 0
- || strcmp (gdbarch_bfd_arch_info (target_gdbarch ())->arch_name,
+ || strcmp (gdbarch_bfd_arch_info (gdbarch)->arch_name,
"powerpc") == 0)
{
arch = "ppc";
@@ -177,8 +179,8 @@ nto_init_solib_absolute_prefix (void)
}
else
{
- arch = gdbarch_bfd_arch_info (target_gdbarch ())->arch_name;
- endian = gdbarch_byte_order (target_gdbarch ())
+ arch = gdbarch_bfd_arch_info (gdbarch)->arch_name;
+ endian = gdbarch_byte_order (gdbarch)
== BFD_ENDIAN_BIG ? "be" : "le";
}
@@ -253,12 +255,13 @@ lm_addr (struct so_list *so)
static CORE_ADDR
nto_truncate_ptr (CORE_ADDR addr)
{
- if (gdbarch_ptr_bit (target_gdbarch ()) == sizeof (CORE_ADDR) * 8)
+ gdbarch *gdbarch = current_inferior ()->arch ();
+ if (gdbarch_ptr_bit (gdbarch) == sizeof (CORE_ADDR) * 8)
/* We don't need to truncate anything, and the bit twiddling below
will fail due to overflow problems. */
return addr;
else
- return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch ())) - 1);
+ return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (gdbarch)) - 1);
}
static Elf_Internal_Phdr *
@@ -455,7 +458,7 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf,
if (target_read_memory (initial_stack + data_ofs, targ32, 4) != 0)
return 0;
- byte_order = gdbarch_byte_order (target_gdbarch ());
+ byte_order = gdbarch_byte_order (current_inferior ()->arch ());
anint = extract_unsigned_integer (targ32, sizeof (targ32), byte_order);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index d14aba694e5..a0205119f00 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1920,7 +1920,7 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
const gdb_byte *ptr = *readptr;
if (endptr == ptr)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index d29a57f89b5..5e9c8a5b222 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -55,6 +55,7 @@
#include "gdbsupport/gdb_optional.h"
#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/rsp-low.h"
+#include "inferior.h"
/* Chain containing all defined memory-tag subcommands. */
@@ -1132,7 +1133,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
= value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr,
tag_laddr);
- if (gdbarch_tagged_address_p (target_gdbarch (), v_addr))
+ if (gdbarch_tagged_address_p (current_inferior ()->arch (), v_addr))
{
/* Fetch the allocation tag. */
struct value *tag
@@ -1287,7 +1288,7 @@ should_validate_memtags (struct value *value)
return false;
/* We do. Check whether it includes any tags. */
- return gdbarch_tagged_address_p (target_gdbarch (), value);
+ return gdbarch_tagged_address_p (current_inferior ()->arch (), value);
}
/* Helper for parsing arguments for print_command_1. */
@@ -1342,21 +1343,20 @@ print_command_1 (const char *args, int voidprint)
{
try
{
+ gdbarch *arch = current_inferior ()->arch ();
+
if (should_validate_memtags (val)
- && !gdbarch_memtag_matches_p (target_gdbarch (), val))
+ && !gdbarch_memtag_matches_p (arch, val))
{
/* Fetch the logical tag. */
struct value *tag
- = gdbarch_get_memtag (target_gdbarch (), val,
- memtag_type::logical);
- std::string ltag
- = gdbarch_memtag_to_string (target_gdbarch (), tag);
+ = gdbarch_get_memtag (arch, val, memtag_type::logical);
+ std::string ltag = gdbarch_memtag_to_string (arch, tag);
/* Fetch the allocation tag. */
- tag = gdbarch_get_memtag (target_gdbarch (), val,
+ tag = gdbarch_get_memtag (arch, val,
memtag_type::allocation);
- std::string atag
- = gdbarch_memtag_to_string (target_gdbarch (), tag);
+ std::string atag = gdbarch_memtag_to_string (arch, tag);
gdb_printf (_("Logical tag (%s) does not match the "
"allocation tag (%s).\n"),
@@ -2977,7 +2977,7 @@ static void
show_addr_not_tagged (CORE_ADDR address)
{
error (_("Address %s not in a region mapped with a memory tagging flag."),
- paddress (target_gdbarch (), address));
+ paddress (current_inferior ()->arch (), address));
}
/* Convenience function for error checking in memory-tag commands. */
@@ -3010,18 +3010,18 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
value_print_options print_opts;
struct value *val = process_print_command_args (args, &print_opts, true);
+ gdbarch *arch = current_inferior ()->arch ();
/* If the address is not in a region memory mapped with a memory tagging
flag, it is no use trying to access/manipulate its allocation tag.
It is OK to manipulate the logical tag though. */
if (tag_type == memtag_type::allocation
- && !gdbarch_tagged_address_p (target_gdbarch (), val))
+ && !gdbarch_tagged_address_p (arch, val))
show_addr_not_tagged (value_as_address (val));
- struct value *tag_value
- = gdbarch_get_memtag (target_gdbarch (), val, tag_type);
- std::string tag = gdbarch_memtag_to_string (target_gdbarch (), tag_value);
+ value *tag_value = gdbarch_get_memtag (arch, val, tag_type);
+ std::string tag = gdbarch_memtag_to_string (arch, tag_value);
if (tag.empty ())
gdb_printf (_("%s tag unavailable.\n"),
@@ -3099,6 +3099,7 @@ memory_tag_with_logical_tag_command (const char *args, int from_tty)
gdb::byte_vector tags;
struct value *val;
value_print_options print_opts;
+ gdbarch *arch = current_inferior ()->arch ();
/* Parse the input. */
parse_with_logical_tag_input (args, &val, tags, &print_opts);
@@ -3116,12 +3117,11 @@ memory_tag_with_logical_tag_command (const char *args, int from_tty)
length. */
/* Cast to (void *). */
- val = value_cast (builtin_type (target_gdbarch ())->builtin_data_ptr,
+ val = value_cast (builtin_type (current_inferior ()->arch ())->builtin_data_ptr,
val);
/* Length doesn't matter for a logical tag. Pass 0. */
- if (!gdbarch_set_memtags (target_gdbarch (), val, 0, tags,
- memtag_type::logical))
+ if (!gdbarch_set_memtags (arch, val, 0, tags, memtag_type::logical))
gdb_printf (_("Could not update the logical tag data.\n"));
else
{
@@ -3174,7 +3174,7 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
/* If the address is not in a region memory mapped with a memory tagging
flag, it is no use trying to access/manipulate its allocation tag. */
- if (!gdbarch_tagged_address_p (target_gdbarch (), *val))
+ if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val))
show_addr_not_tagged (value_as_address (*val));
}
@@ -3197,7 +3197,7 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
/* Parse the input. */
parse_set_allocation_tag_input (args, &val, &length, tags);
- if (!gdbarch_set_memtags (target_gdbarch (), val, length, tags,
+ if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags,
memtag_type::allocation))
gdb_printf (_("Could not update the allocation tag(s).\n"));
else
@@ -3220,41 +3220,39 @@ memory_tag_check_command (const char *args, int from_tty)
value_print_options print_opts;
struct value *val = process_print_command_args (args, &print_opts, true);
+ gdbarch *arch = current_inferior ()->arch ();
/* If the address is not in a region memory mapped with a memory tagging
flag, it is no use trying to access/manipulate its allocation tag. */
- if (!gdbarch_tagged_address_p (target_gdbarch (), val))
+ if (!gdbarch_tagged_address_p (arch, val))
show_addr_not_tagged (value_as_address (val));
CORE_ADDR addr = value_as_address (val);
/* Check if the tag is valid. */
- if (!gdbarch_memtag_matches_p (target_gdbarch (), val))
+ if (!gdbarch_memtag_matches_p (arch, val))
{
- struct value *tag
- = gdbarch_get_memtag (target_gdbarch (), val, memtag_type::logical);
- std::string ltag
- = gdbarch_memtag_to_string (target_gdbarch (), tag);
+ value *tag = gdbarch_get_memtag (arch, val, memtag_type::logical);
+ std::string ltag = gdbarch_memtag_to_string (arch, tag);
- tag = gdbarch_get_memtag (target_gdbarch (), val,
- memtag_type::allocation);
- std::string atag
- = gdbarch_memtag_to_string (target_gdbarch (), tag);
+ tag = gdbarch_get_memtag (arch, val, memtag_type::allocation);
+ std::string atag = gdbarch_memtag_to_string (arch, tag);
gdb_printf (_("Logical tag (%s) does not match"
" the allocation tag (%s) for address %s.\n"),
ltag.c_str (), atag.c_str (),
- paddress (target_gdbarch (), addr));
+ paddress (current_inferior ()->arch (), addr));
}
else
{
struct value *tag
- = gdbarch_get_memtag (target_gdbarch (), val, memtag_type::logical);
+ = gdbarch_get_memtag (current_inferior ()->arch (), val,
+ memtag_type::logical);
std::string ltag
- = gdbarch_memtag_to_string (target_gdbarch (), tag);
+ = gdbarch_memtag_to_string (current_inferior ()->arch (), tag);
gdb_printf (_("Memory tags for address %s match (%s).\n"),
- paddress (target_gdbarch (), addr), ltag.c_str ());
+ paddress (current_inferior ()->arch (), addr), ltag.c_str ());
}
}
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 35cfd9c1cca..f4968ec4701 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -55,7 +55,8 @@ public:
space. */
struct address_space *thread_address_space (ptid_t ptid) override;
- /* This default implementation always returns target_gdbarch (). */
+ /* This default implementation always returns the current inferior's
+ gdbarch. */
struct gdbarch *thread_architecture (ptid_t ptid) override;
/* Default implementations for process_stratum targets. Return true
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 48e9f3dd4b5..0e8a08f99d3 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -174,7 +174,7 @@ procfs_target::auxv_parse (const gdb_byte **readptr,
const gdb_byte *endptr, CORE_ADDR *typep,
CORE_ADDR *valp)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+ bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
const gdb_byte *ptr = *readptr;
if (endptr == ptr)
@@ -711,9 +711,10 @@ proc_watchpoint_address (procinfo *pi, CORE_ADDR *addr)
if (!proc_get_status (pi))
return 0;
- *addr = (CORE_ADDR) gdbarch_pointer_to_address (target_gdbarch (),
- builtin_type (target_gdbarch ())->builtin_data_ptr,
- (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr);
+ gdbarch *arch = current_inferior ()->arch ();
+ *addr = gdbarch_pointer_to_address
+ (arch, builtin_type (arch)->builtin_data_ptr,
+ (gdb_byte *) &pi->prstatus.pr_lwp.pr_info.si_addr);
return 1;
}
@@ -1517,12 +1518,12 @@ proc_parent_pid (procinfo *pi)
static void *
procfs_address_to_host_pointer (CORE_ADDR addr)
{
- struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ gdbarch *arch = current_inferior ()->arch ();
+ type *ptr_type = builtin_type (arch)->builtin_data_ptr;
void *ptr;
gdb_assert (sizeof (ptr) == ptr_type->length ());
- gdbarch_address_to_pointer (target_gdbarch (), ptr_type,
- (gdb_byte *) &ptr, addr);
+ gdbarch_address_to_pointer (arch, ptr_type, (gdb_byte *) &ptr, addr);
return ptr;
}
@@ -3013,7 +3014,8 @@ procfs_target::can_use_hw_breakpoint (enum bptype type, int cnt, int othertype)
procfs_address_to_host_pointer will reveal that an internal error
will be generated when the host and target pointer sizes are
different. */
- struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ type *ptr_type
+ = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
if (sizeof (void *) != ptr_type->length ())
return 0;
@@ -3061,7 +3063,7 @@ procfs_target::insert_watchpoint (CORE_ADDR addr, int len,
struct expression *cond)
{
if (!target_have_steppable_watchpoint ()
- && !gdbarch_have_nonsteppable_watchpoint (target_gdbarch ()))
+ && !gdbarch_have_nonsteppable_watchpoint (current_inferior ()->arch ()))
/* When a hardware watchpoint fires off the PC will be left at
the instruction following the one which caused the
watchpoint. It will *NOT* be necessary for GDB to step over
@@ -3224,7 +3226,7 @@ info_mappings_callback (struct prmap *map, find_memory_region_ftype ignore,
pr_off = (unsigned int) map->pr_offset;
- if (gdbarch_addr_bit (target_gdbarch ()) == 32)
+ if (gdbarch_addr_bit (current_inferior ()->arch ()) == 32)
gdb_printf ("\t%#10lx %#10lx %#10lx %#10x %7s\n",
(unsigned long) map->pr_vaddr,
(unsigned long) map->pr_vaddr + map->pr_size - 1,
@@ -3251,7 +3253,7 @@ info_proc_mappings (procinfo *pi, int summary)
return; /* No output for summary mode. */
gdb_printf (_("Mapped address spaces:\n\n"));
- if (gdbarch_ptr_bit (target_gdbarch ()) == 32)
+ if (gdbarch_ptr_bit (current_inferior ()->arch ()) == 32)
gdb_printf ("\t%10s %10s %10s %10s %7s\n",
"Start Addr",
" End Addr",
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 1dbcd5875dd..555fa79ccce 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -58,7 +58,8 @@ address_space::address_space ()
struct address_space *
maybe_new_address_space (void)
{
- int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
+ int shared_aspace
+ = gdbarch_has_shared_address_space (current_inferior ()->arch ());
if (shared_aspace)
{
@@ -121,7 +122,7 @@ program_space::~program_space ()
/* Defer breakpoint re-set because we don't want to create new
locations for this pspace which we're tearing down. */
clear_symtab_users (SYMFILE_DEFER_BP_RESET);
- if (!gdbarch_has_shared_address_space (target_gdbarch ()))
+ if (!gdbarch_has_shared_address_space (current_inferior ()->arch ()))
delete this->aspace;
}
@@ -402,7 +403,8 @@ maintenance_info_program_spaces_command (const char *args, int from_tty)
void
update_address_spaces (void)
{
- int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch ());
+ int shared_aspace
+ = gdbarch_has_shared_address_space (current_inferior ()->arch ());
init_address_spaces ();
@@ -422,7 +424,7 @@ update_address_spaces (void)
}
for (inferior *inf : all_inferiors ())
- if (gdbarch_has_global_solist (target_gdbarch ()))
+ if (gdbarch_has_global_solist (current_inferior ()->arch ()))
inf->aspace = maybe_new_address_space ();
else
inf->aspace = inf->pspace->aspace;
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 42a7e0706d2..627eb297542 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -427,7 +427,7 @@ bpfinishpy_handle_stop (struct bpstat *bs, int print_frame)
static void
bpfinishpy_handle_exit (struct inferior *inf)
{
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
for (breakpoint &bp : all_breakpoints_safe ())
bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 50d20c33b9d..c0bd6a69895 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -107,7 +107,7 @@ python_on_resume (ptid_t ptid)
if (!gdb_python_initialized)
return;
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_continue_event (ptid) < 0)
gdbpy_print_stack ();
@@ -119,7 +119,7 @@ python_on_resume (ptid_t ptid)
static void
python_on_inferior_call_pre (ptid_t thread, CORE_ADDR address)
{
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_inferior_call_event (INFERIOR_CALL_PRE, thread, address) < 0)
gdbpy_print_stack ();
@@ -131,7 +131,7 @@ python_on_inferior_call_pre (ptid_t thread, CORE_ADDR address)
static void
python_on_inferior_call_post (ptid_t thread, CORE_ADDR address)
{
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_inferior_call_event (INFERIOR_CALL_POST, thread, address) < 0)
gdbpy_print_stack ();
@@ -144,7 +144,7 @@ python_on_inferior_call_post (ptid_t thread, CORE_ADDR address)
static void
python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len, const bfd_byte *data)
{
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_memory_changed_event (addr, len) < 0)
gdbpy_print_stack ();
@@ -157,7 +157,7 @@ python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len,
static void
python_on_register_change (frame_info_ptr frame, int regnum)
{
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_register_changed_event (frame, regnum) < 0)
gdbpy_print_stack ();
@@ -171,7 +171,7 @@ python_inferior_exit (struct inferior *inf)
if (!gdb_python_initialized)
return;
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (inf->has_exit_code)
exit_code = &inf->exit_code;
@@ -202,7 +202,7 @@ python_all_objfiles_removed (program_space *pspace)
if (!gdb_python_initialized)
return;
- gdbpy_enter enter_py (target_gdbarch ());
+ gdbpy_enter enter_py (current_inferior ()->arch ());
if (emit_clear_objfiles_event (pspace) < 0)
gdbpy_print_stack ();
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index ad72f3f0423..bb5d0d92aba 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -25,6 +25,7 @@
#include "build-id.h"
#include "symtab.h"
#include "python.h"
+#include "inferior.h"
struct objfile_object
{
@@ -618,7 +619,7 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
struct objfile *objfile = nullptr;
if (by_build_id)
gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
+ (current_inferior ()->arch (),
[&objfile, name] (struct objfile *obj)
{
/* Don't return separate debug files. */
@@ -641,7 +642,7 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
}, gdbpy_current_objfile);
else
gdbarch_iterate_over_objfiles_in_search_order
- (target_gdbarch (),
+ (current_inferior ()->arch (),
[&objfile, name] (struct objfile *obj)
{
/* Don't return separate debug files. */
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 72a5d4f4c62..f636ffd0460 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -28,6 +28,7 @@
#include "block.h"
#include "py-event.h"
#include "observable.h"
+#include "inferior.h"
struct pspace_object
{
@@ -69,11 +70,11 @@ struct pspace_deleter
this is one time when the current program space and current inferior
are not in sync: All inferiors that use PSPACE may no longer exist.
We don't need to do much here, and since "there is always an inferior"
- using target_gdbarch suffices.
+ using the current inferior's arch suffices.
Note: We cannot call get_current_arch because it may try to access
the target, which may involve accessing data in the pspace currently
being deleted. */
- struct gdbarch *arch = target_gdbarch ();
+ gdbarch *arch = current_inferior ()->arch ();
gdbpy_enter enter_py (arch);
gdbpy_ref<pspace_object> object (obj);
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 7978f3332c6..822ae18e25e 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -302,7 +302,7 @@ recpy_bt_insn_decoded (PyObject *self, void *closure)
try
{
- gdb_print_insn (target_gdbarch (), insn->pc, &strfile, NULL);
+ gdb_print_insn (current_inferior ()->arch (), insn->pc, &strfile, NULL);
}
catch (const gdb_exception &except)
{
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e56d2463d59..d3dea088c3b 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -254,7 +254,7 @@ gdbpy_enter::get_gdbarch ()
void
gdbpy_enter::finalize ()
{
- python_gdbarch = target_gdbarch ();
+ python_gdbarch = current_inferior ()->arch ();
}
/* A helper class to save and restore the GIL, but without touching
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 68d336bee99..3558cfd3875 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -383,7 +383,7 @@ get_running_thread_id (int cpu)
gdb_byte *buf;
CORE_ADDR object_addr;
struct type *builtin_type_void_data_ptr
- = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
if (!object_msym.minsym)
return 0;
@@ -648,7 +648,8 @@ ravenscar_thread_target::get_fpu_state (struct regcache *regcache,
if (fpu_context.minsym == nullptr)
return NO_FP_REGISTERS;
- struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ type *ptr_type
+ = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
ptr_type = lookup_pointer_type (ptr_type);
value *val = value_from_pointer (ptr_type, fpu_context.value_address ());
@@ -874,7 +875,7 @@ ravenscar_inferior_created (inferior *inf)
const char *err_msg;
if (!ravenscar_task_support
- || gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
+ || gdbarch_ravenscar_ops (current_inferior ()->arch ()) == NULL
|| !has_ravenscar_runtime ())
return;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 97447d3e8f8..abab79f3132 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -793,7 +793,7 @@ btrace_insn_history (struct ui_out *uiout,
flags |= DISASSEMBLY_SPECULATIVE;
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
btrace_line_range last_lines = btrace_mk_line_range (NULL, 0, 0);
ui_out_emit_list list_emitter (uiout, "asm_insns");
diff --git a/gdb/record-full.c b/gdb/record-full.c
index faf8b595d22..f072bdd7f88 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -640,14 +640,14 @@ record_full_arch_list_add_mem (CORE_ADDR addr, int len)
gdb_printf (gdb_stdlog,
"Process record: add mem addr = %s len = %d to "
"record list.\n",
- paddress (target_gdbarch (), addr), len);
+ paddress (current_inferior ()->arch (), addr), len);
if (!addr) /* FIXME: Why? Some arch must permit it... */
return 0;
rec = record_full_mem_alloc (addr, len);
- if (record_read_memory (target_gdbarch (), addr,
+ if (record_read_memory (current_inferior ()->arch (), addr,
record_full_get_loc (rec), len))
{
record_full_mem_release (rec);
@@ -945,7 +945,7 @@ record_full_open_1 (const char *name, int from_tty)
error (_("Process record target can't debug inferior in non-stop mode "
"(non-stop)."));
- if (!gdbarch_process_record_p (target_gdbarch ()))
+ if (!gdbarch_process_record_p (current_inferior ()->arch ()))
error (_("Process record: the current architecture doesn't support "
"record function."));
@@ -1650,7 +1650,7 @@ record_full_target::xfer_partial (enum target_object object,
if (!query (_("Because GDB is in replay mode, writing to memory "
"will make the execution log unusable from this "
"point onward. Write memory at address %s?"),
- paddress (target_gdbarch (), offset)))
+ paddress (current_inferior ()->arch (), offset)))
error (_("Process record canceled the operation."));
/* Destroy the record from here forward. */
@@ -2810,6 +2810,8 @@ maintenance_print_record_instruction (const char *args, int from_tty)
}
gdb_assert (to_print != nullptr);
+ gdbarch *arch = current_inferior ()->arch ();
+
/* Go back to the start of the instruction. */
while (to_print->prev != nullptr && to_print->prev->type != record_full_end)
to_print = to_print->prev;
@@ -2825,14 +2827,12 @@ maintenance_print_record_instruction (const char *args, int from_tty)
{
case record_full_reg:
{
- type *regtype = gdbarch_register_type (target_gdbarch (),
- to_print->u.reg.num);
+ type *regtype = gdbarch_register_type (arch, to_print->u.reg.num);
value *val
= value_from_contents (regtype,
record_full_get_loc (to_print));
gdb_printf ("Register %s changed: ",
- gdbarch_register_name (target_gdbarch (),
- to_print->u.reg.num));
+ gdbarch_register_name (arch, to_print->u.reg.num));
struct value_print_options opts;
get_user_print_options (&opts);
opts.raw = true;
@@ -2845,8 +2845,7 @@ maintenance_print_record_instruction (const char *args, int from_tty)
gdb_byte *b = record_full_get_loc (to_print);
gdb_printf ("%d bytes of memory at address %s changed from:",
to_print->u.mem.len,
- print_core_address (target_gdbarch (),
- to_print->u.mem.addr));
+ print_core_address (arch, to_print->u.mem.addr));
for (int i = 0; i < to_print->u.mem.len; i++)
gdb_printf (" %02x", b[i]);
gdb_printf ("\n");
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index 9387cfd44f1..5f438950256 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -24,6 +24,7 @@
#include "reggroups.h"
#include "target.h"
#include "gdbarch.h"
+#include "inferior.h"
/* Dump registers from regcache, used for dumping raw registers and
[...]
[diff truncated at 100000 bytes]
More information about the Gdb-cvs
mailing list