From 99d9c3b92ca96a7425cbb6b1bf453ede9477a2ee Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 29 Sep 2023 14:24:38 -0400 Subject: 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 Approved-By: Andrew Burgess --- 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 eb54db4..0e87aaa 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 a37e563..9bb649e 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 1de6b0f..047566e 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 2077491..945b7f6 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 0b541c6..0740eff 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 5768259..60a50ea 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 7e069d1..a0ad1fb 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 (target_gdbarch ()); + arm_gdbarch_tdep *tdep = 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 (target_gdbarch ()); + arm_gdbarch_tdep *tdep = 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 45f3e92..61acd48 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 &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 9bdfcf7..a00eceb 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -359,7 +359,7 @@ static std::vector catch_syscall_split_args (const char *arg) { std::vector 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 db7d2e6..2edcbf6 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 e27e88a..8765fb7 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 a7b6e81..3f72b9c 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 08984f6..28512bd 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 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 617297c..5982178 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 ab18e63..1edbf8f 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 013b6a9..d1727c3 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 1fbefd2..c27061a 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 c0b2623..4da5e4f 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 d4a47ea..975e789 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 #include #include @@ -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 2af0218..e02e859 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 6153e5b..69474ba 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 d5f633b..07b06b3 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 c075625..8a5fb13 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 aa5c6da..2e866f6 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 8704b52..7900dfb 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 55a36f2..0e0d0cd 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 27a806e..a134244 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 866b2e6..927b625 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 05cad94..a55b96f 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -71,16 +71,16 @@ write_gcore_file_1 (bfd *obfd) gdb::unique_xmalloc_ptr 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 5285f29..82d42c9 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -72,21 +72,6 @@ struct gdbarch_tdep_base using gdbarch_tdep_up = std::unique_ptr; -/* 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 90caee8..4608f24 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 284c677..8aeef20 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 d542368..560f16a 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 1ed0d2d..000052f 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 fd85d27..cf8cd52 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 784f0b9..4fde968 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 1997be7..9e8325a 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 7e36ced..9148dda 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 fafd909..8b0e3ef 100644 --- a/gdb/memattr.c +++ b/gdb/memattr.c @@ -29,6 +29,7 @@ #include "cli/cli-utils.h" #include #include "gdbarch.h" +#include "inferior.h" static std::vector user_mem_region_list, target_mem_region_list; static std::vector *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 85c2e22..a84df4e 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 (target_gdbarch ()); + = 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 (target_gdbarch ()); + = gdbarch_tdep (current_inferior ()->arch ()); return tdep->me_module; } } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index b3b0f5b..0d3c823 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 4f18ef7..944c911 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 f254a54..74e7040 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 8a7cc95..8d21049 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 9f5d5b3..371bc73 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 4044daa..d40d28e 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 (target_gdbarch ()); + = 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 9154d48..600fb06 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 2768e4e..97d9073 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 d1614ec..0cfcb45 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 61c18fd..08bb869 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 1ad0f01..9ece8b5 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 d14aba6..a020511 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 d29a57f..5e9c8a5 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 35cfd9c..f4968ec 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 48e9f3d..0e8a08f 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 1dbcd58..555fa79 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 42a7e07..627eb29 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 50d20c3..c0bd6a6 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 ad72f3f..bb5d0d9 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 72a5d4f..f636ffd 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 object (obj); diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 7978f33..822ae18 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 e56d246..d3dea08 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 68d336b..3558cfd 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 97447d3..abab79f 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 faf8b59..f072bdd 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 9387cfd..5f43895 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 cooked registers. */ @@ -234,7 +235,7 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump) if (target_has_registers ()) gdbarch = get_current_regcache ()->arch (); else - gdbarch = target_gdbarch (); + gdbarch = current_inferior ()->arch (); switch (what_to_dump) { @@ -260,8 +261,7 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump) /* For the benefit of "maint print registers" & co when debugging an executable, allow dumping a regcache even when there is no thread selected / no registers. */ - dump.reset (new register_dump_reg_buffer (target_gdbarch (), - dump_pseudo)); + dump.reset (new register_dump_reg_buffer (gdbarch, dump_pseudo)); } } break; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index e49375d..518f7c9 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -1053,7 +1053,7 @@ gdbsim_xfer_memory (struct target_ops *target, "memaddr %s, len %s\n", host_address_to_string (readbuf), host_address_to_string (writebuf), - paddress (target_gdbarch (), memaddr), + paddress (current_inferior ()->arch (), memaddr), pulongest (len)); if (writebuf) diff --git a/gdb/remote.c b/gdb/remote.c index ff3f55d..ffe42e4 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -369,9 +369,9 @@ struct packet_reg long regnum; /* GDB's internal register number. */ LONGEST pnum; /* Remote protocol register number. */ int in_g_packet; /* Always part of G packet. */ - /* long size in bytes; == register_size (target_gdbarch (), regnum); + /* long size in bytes; == register_size (arch, regnum); at present. */ - /* char *name; == gdbarch_register_name (target_gdbarch (), regnum); + /* char *name; == gdbarch_register_name (arch, regnum); at present. */ }; @@ -1584,7 +1584,8 @@ remote_target::remote_get_noisy_reply () try { - gdbarch_relocate_instruction (target_gdbarch (), &to, from); + gdbarch_relocate_instruction (current_inferior ()->arch (), + &to, from); relocated = 1; } catch (const gdb_exception &ex) @@ -1657,7 +1658,7 @@ remote_target::get_remote_state () function which calls getpkt also needs to be mindful of changes to rs->buf, but this call limits the number of places which run into trouble. */ - m_remote_state.get_remote_arch_state (target_gdbarch ()); + m_remote_state.get_remote_arch_state (current_inferior ()->arch ()); return &m_remote_state; } @@ -1823,7 +1824,8 @@ long remote_target::get_remote_packet_size () { struct remote_state *rs = get_remote_state (); - remote_arch_state *rsa = rs->get_remote_arch_state (target_gdbarch ()); + remote_arch_state *rsa + = rs->get_remote_arch_state (current_inferior ()->arch ()); if (rs->explicit_packet_size) return rs->explicit_packet_size; @@ -1975,7 +1977,8 @@ long remote_target::get_memory_packet_size (struct memory_packet_config *config) { struct remote_state *rs = get_remote_state (); - remote_arch_state *rsa = rs->get_remote_arch_state (target_gdbarch ()); + remote_arch_state *rsa + = rs->get_remote_arch_state (current_inferior ()->arch ()); long what_they_get; if (config->fixed_p) @@ -2665,7 +2668,7 @@ remote_target::remote_add_inferior (bool fake_pid_p, int pid, int attached, if (attached == -1) attached = remote_query_attached (pid); - if (gdbarch_has_global_solist (target_gdbarch ())) + if (gdbarch_has_global_solist (current_inferior ()->arch ())) { /* If the target shares code across all inferiors, then every attach adds a new inferior. */ @@ -5012,7 +5015,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p) /* On OSs where the list of libraries is global to all processes, we fetch them early. */ - if (gdbarch_has_global_solist (target_gdbarch ())) + if (gdbarch_has_global_solist (current_inferior ()->arch ())) solib_add (NULL, from_tty, auto_solib_add); if (target_is_non_stop_p ()) @@ -5138,7 +5141,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p) supported for non-stop; it could be, but it is tricky if there are no stopped threads when we connect. */ if (remote_read_description_p (this) - && gdbarch_target_desc (target_gdbarch ()) == NULL) + && gdbarch_target_desc (current_inferior ()->arch ()) == NULL) { target_clear_description (); target_find_description (); @@ -5343,13 +5346,14 @@ remote_target::remote_check_symbols () &reply[8]); else { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; CORE_ADDR sym_addr = sym.value_address (); /* If this is a function address, return the start of code instead of any data function descriptor. */ sym_addr = gdbarch_convert_from_func_ptr_addr - (target_gdbarch (), sym_addr, current_inferior ()->top_target ()); + (current_inferior ()->arch (), sym_addr, + current_inferior ()->top_target ()); xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol:%s:%s", phex_nz (sym_addr, addr_size), &reply[8]); @@ -6143,7 +6147,7 @@ remote_target::remote_detach_1 (inferior *inf, int from_tty) target_announce_detach (from_tty); - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) { /* If we're in breakpoints-always-inserted mode, or the inferior is running, we have to remove breakpoints before detaching. @@ -6504,7 +6508,7 @@ remote_target::append_resumption (char *p, char *endp, if (tp->control.may_range_step) { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; p += xsnprintf (p, endp - p, ";r%s,%s", phex_nz (tp->control.step_range_start, @@ -9024,7 +9028,7 @@ remote_address_masked (CORE_ADDR addr) /* If "remoteaddresssize" was not set, default to target address size. */ if (!address_size) - address_size = gdbarch_addr_bit (target_gdbarch ()); + address_size = gdbarch_addr_bit (current_inferior ()->arch ()); if (address_size > 0 && address_size < (sizeof (ULONGEST) * 8)) @@ -9537,7 +9541,7 @@ static const int remote_flash_timeout = 1000; void remote_target::flash_erase (ULONGEST address, LONGEST length) { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; enum packet_result ret; scoped_restore restore_timeout = make_scoped_restore (&remote_timeout, remote_flash_timeout); @@ -10709,7 +10713,7 @@ remote_target::insert_breakpoint (struct gdbarch *gdbarch, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); rs = get_remote_state (); @@ -10767,7 +10771,7 @@ remote_target::remove_breakpoint (struct gdbarch *gdbarch, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); *(p++) = 'z'; @@ -10821,7 +10825,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); xsnprintf (rs->buf.data (), endbuf - rs->buf.data (), "Z%x,", packet); @@ -10871,7 +10875,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); xsnprintf (rs->buf.data (), endbuf - rs->buf.data (), "z%x,", packet); @@ -11021,7 +11025,7 @@ remote_target::insert_hw_breakpoint (struct gdbarch *gdbarch, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); rs = get_remote_state (); @@ -11078,7 +11082,7 @@ remote_target::remove_hw_breakpoint (struct gdbarch *gdbarch, /* Make sure the remote is pointing at the right process, if necessary. */ - if (!gdbarch_has_global_breakpoints (target_gdbarch ())) + if (!gdbarch_has_global_breakpoints (current_inferior ()->arch ())) set_general_process (); *(p++) = 'z'; @@ -11202,12 +11206,12 @@ compare_sections_command (const char *args, int from_tty) if (res == -1) error (_("target memory fault, section %s, range %s -- %s"), sectname, - paddress (target_gdbarch (), lma), - paddress (target_gdbarch (), lma + size)); + paddress (current_inferior ()->arch (), lma), + paddress (current_inferior ()->arch (), lma + size)); gdb_printf ("Section %s, range %s -- %s: ", sectname, - paddress (target_gdbarch (), lma), - paddress (target_gdbarch (), lma + size)); + paddress (current_inferior ()->arch (), lma), + paddress (current_inferior ()->arch (), lma + size)); if (res) gdb_printf ("matched.\n"); else @@ -11365,7 +11369,8 @@ remote_target::xfer_partial (enum target_object object, int i; char *p2; char query_type; - int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + int unit_size + = gdbarch_addressable_memory_unit_size (current_inferior ()->arch ()); set_remote_traceframe (); set_general_thread (inferior_ptid); @@ -11561,7 +11566,7 @@ remote_target::search_memory (CORE_ADDR start_addr, ULONGEST search_space_len, const gdb_byte *pattern, ULONGEST pattern_len, CORE_ADDR *found_addrp) { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; struct remote_state *rs = get_remote_state (); int max_size = get_memory_write_packet_size (); @@ -12151,7 +12156,7 @@ register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes, static bool remote_read_description_p (struct target_ops *target) { - struct remote_g_packet_data *data = get_g_packet_data (target_gdbarch ()); + remote_g_packet_data *data = get_g_packet_data (current_inferior ()->arch ()); return !data->guesses.empty (); } @@ -12159,7 +12164,7 @@ remote_read_description_p (struct target_ops *target) const struct target_desc * remote_target::read_description () { - struct remote_g_packet_data *data = get_g_packet_data (target_gdbarch ()); + remote_g_packet_data *data = get_g_packet_data (current_inferior ()->arch ()); /* Do not try this during initial connection, when we do not know whether there is a running but stopped thread. */ @@ -13637,7 +13642,7 @@ remote_target::get_trace_status (struct trace_status *ts) /* FIXME we need to get register block size some other way. */ trace_regblock_size - = rs->get_remote_arch_state (target_gdbarch ())->sizeof_g_packet; + = rs->get_remote_arch_state (current_inferior ()->arch ())->sizeof_g_packet; putpkt ("qTStatus"); @@ -15142,7 +15147,7 @@ static void create_fetch_memtags_request (gdb::char_vector &packet, CORE_ADDR address, size_t len, int type) { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; std::string request = string_printf ("qMemTags:%s,%s:%s", phex_nz (address, addr_size), @@ -15176,7 +15181,7 @@ create_store_memtags_request (gdb::char_vector &packet, CORE_ADDR address, size_t len, int type, const gdb::byte_vector &tags) { - int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; + int addr_size = gdbarch_addr_bit (current_inferior ()->arch ()) / 8; /* Put together the main packet, address and length. */ std::string request = string_printf ("QMemTags:%s,%s:%s:", diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index d01d1fd..2f40fbd 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -35,6 +35,7 @@ #include "dwarf2/frame.h" #include "reggroups.h" #include "gdbarch.h" +#include "inferior.h" #include "elf/rl78.h" #include "elf-bfd.h" @@ -897,7 +898,7 @@ check_for_saved (void *result_untyped, pv_t addr, CORE_ADDR size, if (value.kind == pvk_register && value.k == 0 && pv_is_register (addr, RL78_SP_REGNUM) - && size == register_size (target_gdbarch (), value.reg)) + && size == register_size (current_inferior ()->arch (), value.reg)) result->reg_offset[value.reg] = addr.k; } @@ -922,7 +923,8 @@ rl78_analyze_prologue (CORE_ADDR start_pc, result->reg_offset[rn] = 1; } - pv_area stack (RL78_SP_REGNUM, gdbarch_addr_bit (target_gdbarch ())); + pv_area stack (RL78_SP_REGNUM, + gdbarch_addr_bit (current_inferior ()->arch ())); /* The call instruction has saved the return address on the stack. */ reg[RL78_SP_REGNUM] = pv_add_constant (reg[RL78_SP_REGNUM], -4); diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c index e28a0e7..b7a34e0 100644 --- a/gdb/rs6000-aix-nat.c +++ b/gdb/rs6000-aix-nat.c @@ -77,7 +77,7 @@ #ifndef ARCH3264 # define ARCH64() 0 #else -# define ARCH64() (register_size (target_gdbarch (), 0) == 8) +# define ARCH64() (register_size (current_inferior ()->arch (), 0) == 8) #endif class rs6000_nat_target final : public inf_ptrace_target @@ -1040,7 +1040,8 @@ rs6000_nat_target::xfer_shared_libraries return TARGET_XFER_E_IO; gdb::byte_vector ldi_buf = rs6000_ptrace_ldinfo (inferior_ptid); - result = rs6000_aix_ld_info_to_xml (target_gdbarch (), ldi_buf.data (), + result = rs6000_aix_ld_info_to_xml (current_inferior ()->arch (), + ldi_buf.data (), readbuf, offset, len, 1); if (result == 0) diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 4b3348d..d2f6008 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -30,6 +30,7 @@ #include "value.h" #include "gdbarch.h" #include "rust-exp.h" +#include "inferior.h" using namespace expr; @@ -2309,8 +2310,8 @@ static void rust_lex_tests (void) { /* Set up dummy "parser", so that rust_type works. */ - struct parser_state ps (language_def (language_rust), target_gdbarch (), - nullptr, 0, 0, nullptr, 0, nullptr); + parser_state ps (language_def (language_rust), current_inferior ()->arch (), + nullptr, 0, 0, nullptr, 0, nullptr); rust_parser parser (&ps); rust_lex_test_one (&parser, "", 0); diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 7bd469d..87f1afd 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -36,6 +36,7 @@ #include "remote.h" #include "target-descriptions.h" #include "gdbarch.h" +#include "inferior.h" #include "elf/rx.h" #include "elf-bfd.h" @@ -142,7 +143,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, RX_SP_REGNUM) - && size == register_size (target_gdbarch (), value.reg)) + && size == register_size (current_inferior ()->arch (), value.reg)) result->reg_offset[value.reg] = addr.k; } @@ -198,7 +199,7 @@ rx_analyze_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc, result->reg_offset[rn] = 1; } - pv_area stack (RX_SP_REGNUM, gdbarch_addr_bit (target_gdbarch ())); + pv_area stack (RX_SP_REGNUM, gdbarch_addr_bit (current_inferior ()->arch ())); if (frame_type == RX_FRAME_TYPE_FAST_INTERRUPT) { diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index 8f54e9f..0aa3ede 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -966,7 +966,7 @@ s390_linux_nat_target::auxv_parse (const gdb_byte **readptr, CORE_ADDR *valp) { int sizeof_auxv_field = s390_target_wordsize (); - 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/sol-thread.c b/gdb/sol-thread.c index c152b44..537acdb 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -847,7 +847,7 @@ ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset) ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0); struct regcache *regcache = get_thread_arch_regcache (current_inferior ()->process_target (), - ptid, target_gdbarch ()); + ptid, current_inferior ()->arch ()); target_fetch_registers (regcache, -1); fill_gregset (regcache, (gdb_gregset_t *) gregset, -1); @@ -864,7 +864,7 @@ ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid, ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0); struct regcache *regcache = get_thread_arch_regcache (current_inferior ()->process_target (), - ptid, target_gdbarch ()); + ptid, current_inferior ()->arch ()); supply_gregset (regcache, (const gdb_gregset_t *) gregset); target_store_registers (regcache, -1); @@ -917,7 +917,7 @@ ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0); struct regcache *regcache = get_thread_arch_regcache (current_inferior ()->process_target (), - ptid, target_gdbarch ()); + ptid, current_inferior ()->arch ()); target_fetch_registers (regcache, -1); fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1); @@ -934,7 +934,7 @@ ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0); struct regcache *regcache = get_thread_arch_regcache (current_inferior ()->process_target (), - ptid, target_gdbarch ()); + ptid, current_inferior ()->arch ()); supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset); target_store_registers (regcache, -1); @@ -1079,7 +1079,8 @@ info_cb (const td_thrhandle_t *th, void *s) gdb_printf (" startfunc=%s", msym.minsym ? msym.minsym->print_name () - : paddress (target_gdbarch (), ti.ti_startfunc)); + : paddress (current_inferior ()->arch (), + ti.ti_startfunc)); } /* If thread is asleep, print function that went to sleep. */ @@ -1091,7 +1092,7 @@ info_cb (const td_thrhandle_t *th, void *s) gdb_printf (" sleepfunc=%s", msym.minsym ? msym.minsym->print_name () - : paddress (target_gdbarch (), ti.ti_pc)); + : paddress (current_inferior ()->arch (), ti.ti_pc)); } gdb_printf ("\n"); diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 1dacc7b..98c81bb 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -105,8 +105,9 @@ static void darwin_load_image_infos (struct darwin_info *info) { gdb_byte buf[24]; - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; int len; /* If the structure address is not known, don't continue. */ @@ -216,7 +217,8 @@ open_symbol_file_object (int from_tty) static struct so_list * darwin_current_sos (void) { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; enum bfd_endian byte_order = type_byte_order (ptr_type); int ptr_len = ptr_type->length (); unsigned int image_info_size; @@ -299,7 +301,7 @@ darwin_current_sos (void) static CORE_ADDR darwin_validate_exec_header (CORE_ADDR load_addr) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); struct mach_o_header_external hdr; unsigned long hdr_val; @@ -329,7 +331,8 @@ darwin_validate_exec_header (CORE_ADDR load_addr) static CORE_ADDR darwin_read_exec_load_addr_from_dyld (struct darwin_info *info) { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; int ptr_len = ptr_type->length (); unsigned int image_info_size = ptr_len * 3; int i; @@ -359,7 +362,7 @@ darwin_read_exec_load_addr_from_dyld (struct darwin_info *info) static CORE_ADDR darwin_read_exec_load_addr_at_init (struct darwin_info *info) { - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int addr_size = gdbarch_addr_bit (gdbarch) / 8; ULONGEST load_ptr_addr; @@ -432,8 +435,9 @@ darwin_get_dyld_bfd () if (dyld_bfd != NULL) { gdb_bfd_ref_ptr sub - (gdb_bfd_mach_o_fat_extract (dyld_bfd.get (), bfd_object, - gdbarch_bfd_arch_info (target_gdbarch ()))); + (gdb_bfd_mach_o_fat_extract + (dyld_bfd.get (), bfd_object, + gdbarch_bfd_arch_info (current_inferior ()->arch ()))); dyld_bfd = sub; } return dyld_bfd; @@ -475,7 +479,8 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info) { gdb_byte buf[8]; LONGEST len; - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; /* Sanity check. */ if (ptr_type->length () > sizeof (buf)) @@ -592,7 +597,7 @@ darwin_solib_create_inferior_hook (int from_tty) /* Add the breakpoint which is hit by dyld when the list of solib is modified. */ if (notifier != 0) - create_solib_event_breakpoint (target_gdbarch (), notifier); + create_solib_event_breakpoint (current_inferior ()->arch (), notifier); } static void @@ -652,8 +657,9 @@ darwin_bfd_open (const char *pathname) gdb_bfd_ref_ptr abfd (solib_bfd_fopen (found_pathname.get (), found_file)); gdb_bfd_ref_ptr res - (gdb_bfd_mach_o_fat_extract (abfd.get (), bfd_object, - gdbarch_bfd_arch_info (target_gdbarch ()))); + (gdb_bfd_mach_o_fat_extract + (abfd.get (), bfd_object, + gdbarch_bfd_arch_info (current_inferior ()->arch ()))); if (res == NULL) error (_("`%s': not a shared-library: %s"), bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ())); diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index e0aa7f1..c29b2b8 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -197,14 +197,16 @@ dsbt_print_loadmap (struct int_elf32_dsbt_loadmap *map) for (i = 0; i < map->nsegs; i++) gdb_printf ("%s:%s -> %s:%s\n", - print_core_address (target_gdbarch (), + print_core_address (current_inferior ()->arch (), map->segs[i].p_vaddr), - print_core_address (target_gdbarch (), - map->segs[i].p_vaddr - + map->segs[i].p_memsz), - print_core_address (target_gdbarch (), map->segs[i].addr), - print_core_address (target_gdbarch (), map->segs[i].addr - + map->segs[i].p_memsz)); + print_core_address (current_inferior ()->arch (), + (map->segs[i].p_vaddr + + map->segs[i].p_memsz)), + print_core_address (current_inferior ()->arch (), + map->segs[i].addr), + print_core_address (current_inferior ()->arch (), + (map->segs[i].addr + + map->segs[i].p_memsz))); } } @@ -213,7 +215,7 @@ dsbt_print_loadmap (struct int_elf32_dsbt_loadmap *map) static struct int_elf32_dsbt_loadmap * decode_loadmap (const gdb_byte *buf) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); const struct ext_elf32_dsbt_loadmap *ext_ldmbuf; struct int_elf32_dsbt_loadmap *int_ldmbuf; @@ -313,7 +315,7 @@ dsbt_get_initial_loadmaps (void) static struct int_elf32_dsbt_loadmap * fetch_loadmap (CORE_ADDR ldmaddr) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); struct ext_elf32_dsbt_loadmap ext_ldmbuf_partial; struct ext_elf32_dsbt_loadmap *ext_ldmbuf; struct int_elf32_dsbt_loadmap *int_ldmbuf; @@ -436,7 +438,7 @@ displacement_from_map (struct int_elf32_dsbt_loadmap *map, static CORE_ADDR lm_base (void) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); struct bound_minimal_symbol got_sym; CORE_ADDR addr; gdb_byte buf[TIC6X_PTR_SIZE]; @@ -518,7 +520,7 @@ lm_base (void) static struct so_list * dsbt_current_sos (void) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); CORE_ADDR lm_addr; struct so_list *sos_head = NULL; struct so_list **sos_next_ptr = &sos_head; @@ -771,7 +773,7 @@ enable_break (void) hex_string_custom (addr, 8)); /* Now (finally!) create the solib breakpoint. */ - create_solib_event_breakpoint (target_gdbarch (), addr); + create_solib_event_breakpoint (current_inferior ()->arch (), addr); ret = 1; } diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 152168c..d4e84a1 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -26,6 +26,7 @@ #include "symtab.h" #include "elf/frv.h" #include "gdb_bfd.h" +#include "inferior.h" /* FR-V pointers are four bytes wide. */ enum { FRV_PTR_SIZE = 4 }; @@ -89,7 +90,7 @@ struct int_elf32_fdpic_loadmap { static struct int_elf32_fdpic_loadmap * fetch_loadmap (CORE_ADDR ldmaddr) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); struct ext_elf32_fdpic_loadmap ext_ldmbuf_partial; struct ext_elf32_fdpic_loadmap *ext_ldmbuf; struct int_elf32_fdpic_loadmap *int_ldmbuf; @@ -262,7 +263,7 @@ static CORE_ADDR main_lm_addr = 0; static CORE_ADDR lm_base (void) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); struct bound_minimal_symbol got_sym; CORE_ADDR addr; gdb_byte buf[FRV_PTR_SIZE]; @@ -308,7 +309,7 @@ lm_base (void) static struct so_list * frv_current_sos (void) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); CORE_ADDR lm_addr, mgot; struct so_list *sos_head = NULL; struct so_list **sos_next_ptr = &sos_head; @@ -495,7 +496,7 @@ static int enable_break2_done = 0; static int enable_break2 (void) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); asection *interp_sect; if (enable_break2_done) @@ -548,7 +549,7 @@ enable_break2 (void) return 0; } - status = frv_fdpic_loadmap_addresses (target_gdbarch (), + status = frv_fdpic_loadmap_addresses (current_inferior ()->arch (), &interp_loadmap_addr, 0); if (status < 0) { @@ -665,7 +666,7 @@ enable_break2 (void) remove_solib_event_breakpoints (); /* Now (finally!) create the solib breakpoint. */ - create_solib_event_breakpoint (target_gdbarch (), addr); + create_solib_event_breakpoint (current_inferior ()->arch (), addr); enable_break2_done = 1; @@ -709,7 +710,7 @@ enable_break (void) return 0; } - create_solib_event_breakpoint (target_gdbarch (), entry_point); + create_solib_event_breakpoint (current_inferior ()->arch (), entry_point); solib_debug_printf ("solib event breakpoint placed at entry point: %s", hex_string_custom (entry_point, 8)); @@ -724,7 +725,7 @@ frv_relocate_main_executable (void) struct int_elf32_fdpic_loadmap *ldm; int changed; - status = frv_fdpic_loadmap_addresses (target_gdbarch (), + status = frv_fdpic_loadmap_addresses (current_inferior ()->arch (), &interp_addr, &exec_addr); if (status < 0 || (exec_addr == 0 && interp_addr == 0)) @@ -943,7 +944,7 @@ find_canonical_descriptor_in_load_object (CORE_ADDR entry_point, CORE_ADDR got_value, const char *name, bfd *abfd, lm_info_frv *lm) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); arelent *rel; unsigned int i; CORE_ADDR addr = 0; diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 521e08c..7bc6ca4 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -197,10 +197,11 @@ lm_info_read (CORE_ADDR lm_addr) if (target_read_memory (lm_addr, lm.data (), lmo->link_map_size) != 0) warning (_("Error reading shared library list entry at %s"), - paddress (target_gdbarch (), lm_addr)); + paddress (current_inferior ()->arch (), lm_addr)); else { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; lm_info.reset (new lm_info_svr4); lm_info->lm_addr = lm_addr; @@ -304,7 +305,7 @@ lm_addr_check (const struct so_list *so, bfd *abfd) if (info_verbose) gdb_printf (_("Using PIC (Position Independent Code) " "prelink displacement %s for \"%s\".\n"), - paddress (target_gdbarch (), l_addr), + paddress (current_inferior ()->arch (), l_addr), so->so_name); } else @@ -455,7 +456,7 @@ static int match_main (const char *); static gdb::optional read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); CORE_ADDR at_phdr, at_phent, at_phnum, pt_phdr = 0; int arch_size, sect_size; CORE_ADDR sect_addr; @@ -623,7 +624,7 @@ static int scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr, CORE_ADDR *ptr_addr) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); int arch_size, step; long current_dyntag; CORE_ADDR dyn_ptr; @@ -706,7 +707,8 @@ elf_locate_base (void) &dyn_ptr, NULL) || scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr, NULL)) { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; gdb_byte *pbuf; int pbuf_size = ptr_type->length (); @@ -726,7 +728,8 @@ elf_locate_base (void) &dyn_ptr, &dyn_ptr_addr) || scan_dyntag_auxv (DT_MIPS_RLD_MAP_REL, &dyn_ptr, &dyn_ptr_addr)) { - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; gdb_byte *pbuf; int pbuf_size = ptr_type->length (); @@ -767,7 +770,8 @@ static CORE_ADDR solib_svr4_r_map (CORE_ADDR debug_base) { struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; CORE_ADDR addr = 0; try @@ -789,7 +793,8 @@ static CORE_ADDR solib_svr4_r_brk (struct svr4_info *info) { struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - 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 (info->debug_base + lmo->r_brk_offset, ptr_type); @@ -802,7 +807,8 @@ static CORE_ADDR solib_svr4_r_ldsomap (struct svr4_info *info) { struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; enum bfd_endian byte_order = type_byte_order (ptr_type); ULONGEST version = 0; @@ -832,7 +838,8 @@ static CORE_ADDR solib_svr4_r_next (CORE_ADDR debug_base) { link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; bfd_endian byte_order = type_byte_order (ptr_type); ULONGEST version = 0; @@ -892,7 +899,8 @@ open_symbol_file_object (int from_tty) { CORE_ADDR lm, l_name; struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); - struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + type *ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; int l_name_size = ptr_type->length (); gdb::byte_vector l_name_buf (l_name_size); struct svr4_info *info = get_svr4_info (current_program_space); @@ -1287,8 +1295,8 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, if (li->l_prev != prev_lm) { warning (_("Corrupted shared library list: %s != %s"), - paddress (target_gdbarch (), prev_lm), - paddress (target_gdbarch (), li->l_prev)); + paddress (current_inferior ()->arch (), prev_lm), + paddress (current_inferior ()->arch (), li->l_prev)); return 0; } @@ -1516,7 +1524,7 @@ svr4_current_sos (void) /* Filter out the vDSO module, if present. Its symbol file would not be found on disk. The vDSO/vsyscall's OBJFILE is instead managed by symfile-mem.c:add_vsyscall_page. */ - if (gdbarch_vsyscall_range (target_gdbarch (), &vsyscall_range) + if (gdbarch_vsyscall_range (current_inferior ()->arch (), &vsyscall_range) && vsyscall_range.length != 0) { struct so_list **sop; @@ -1663,10 +1671,10 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ) gdbarch_convert_from_func_ptr_addr(). The method gdbarch_convert_from_func_ptr_addr() is the merely the identify function for targets which don't use function descriptors. */ - addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), + addr = gdbarch_convert_from_func_ptr_addr (current_inferior ()->arch (), bfd_get_start_address (abfd), targ); - return gdbarch_addr_bits_remove (target_gdbarch (), addr); + return gdbarch_addr_bits_remove (current_inferior ()->arch (), addr); } /* A probe and its associated action. */ @@ -2358,9 +2366,10 @@ enable_break (struct svr4_info *info, int from_tty) struct obj_section *os; sym_addr = gdbarch_addr_bits_remove - (target_gdbarch (), + (current_inferior ()->arch (), gdbarch_convert_from_func_ptr_addr - (target_gdbarch (), sym_addr, current_inferior ()->top_target ())); + (current_inferior ()->arch (), sym_addr, + current_inferior ()->top_target ())); /* On at least some versions of Solaris there's a dynamic relocation on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if @@ -2409,7 +2418,8 @@ enable_break (struct svr4_info *info, int from_tty) = info->interp_plt_sect_low + bfd_section_size (interp_sect); } - svr4_create_solib_event_breakpoints (info, target_gdbarch (), sym_addr); + svr4_create_solib_event_breakpoints + (info, current_inferior ()->arch (), sym_addr); return 1; } } @@ -2471,7 +2481,7 @@ enable_break (struct svr4_info *info, int from_tty) if (!load_addr_found) if (target_auxv_search (AT_BASE, &load_addr) > 0) { - int addr_bit = gdbarch_addr_bit (target_gdbarch ()); + int addr_bit = gdbarch_addr_bit (current_inferior ()->arch ()); /* Ensure LOAD_ADDR has proper sign in its possible upper bits so that `+ load_addr' will overflow CORE_ADDR width not creating @@ -2508,7 +2518,8 @@ enable_break (struct svr4_info *info, int from_tty) { struct regcache *regcache = get_thread_arch_regcache (current_inferior ()->process_target (), - inferior_ptid, target_gdbarch ()); + inferior_ptid, + current_inferior ()->arch ()); load_addr = (regcache_read_pc (regcache) - exec_entry_point (tmp_bfd.get (), @@ -2562,13 +2573,14 @@ enable_break (struct svr4_info *info, int from_tty) /* Convert 'sym_addr' from a function pointer to an address. Because we pass tmp_bfd_target instead of the current target, this will always produce an unrelocated value. */ - sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), - sym_addr, - tmp_bfd_target.get ()); + sym_addr = gdbarch_convert_from_func_ptr_addr + (current_inferior ()->arch (), sym_addr, + tmp_bfd_target.get ()); if (sym_addr != 0) { - svr4_create_solib_event_breakpoints (info, target_gdbarch (), + svr4_create_solib_event_breakpoints (info, + current_inferior ()->arch (), load_addr + sym_addr); return 1; } @@ -2593,8 +2605,10 @@ enable_break (struct svr4_info *info, int from_tty) { sym_addr = msymbol.value_address (); sym_addr = gdbarch_convert_from_func_ptr_addr - (target_gdbarch (), sym_addr, current_inferior ()->top_target ()); - svr4_create_solib_event_breakpoints (info, target_gdbarch (), + (current_inferior ()->arch (), sym_addr, + current_inferior ()->top_target ()); + svr4_create_solib_event_breakpoints (info, + current_inferior ()->arch (), sym_addr); return 1; } @@ -2610,10 +2624,10 @@ enable_break (struct svr4_info *info, int from_tty) { sym_addr = msymbol.value_address (); sym_addr = gdbarch_convert_from_func_ptr_addr - (target_gdbarch (), sym_addr, + (current_inferior ()->arch (), sym_addr, current_inferior ()->top_target ()); - svr4_create_solib_event_breakpoints (info, target_gdbarch (), - sym_addr); + svr4_create_solib_event_breakpoints + (info, current_inferior ()->arch (), sym_addr); return 1; } } @@ -2742,7 +2756,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp) = read_program_headers_from_bfd (current_program_space->exec_bfd ()); if (phdrs_target && phdrs_binary) { - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); /* We are dealing with three different addresses. EXEC_BFD represents current address in on-disk file. target memory content @@ -3050,7 +3064,7 @@ svr4_exec_displacement (CORE_ADDR *displacementp) gdb_printf (_("Using PIE (Position Independent Executable) " "displacement %s for \"%s\".\n"), - paddress (target_gdbarch (), exec_displacement), + paddress (current_inferior ()->arch (), exec_displacement), bfd_get_filename (current_program_space->exec_bfd ())); } @@ -3192,12 +3206,12 @@ svr4_clear_solib (void) static CORE_ADDR svr4_truncate_ptr (CORE_ADDR addr) { - if (gdbarch_ptr_bit (target_gdbarch ()) == sizeof (CORE_ADDR) * 8) + if (gdbarch_ptr_bit (current_inferior ()->arch ()) == 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 (current_inferior ()->arch ())) - 1); } @@ -3256,7 +3270,7 @@ set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch, static struct link_map_offsets * svr4_fetch_link_map_offsets (void) { - struct solib_svr4_ops *ops = get_ops (target_gdbarch ()); + struct solib_svr4_ops *ops = get_ops (current_inferior ()->arch ()); gdb_assert (ops->fetch_link_map_offsets); return ops->fetch_link_map_offsets (); @@ -3267,7 +3281,7 @@ svr4_fetch_link_map_offsets (void) static int svr4_have_link_map_offsets (void) { - struct solib_svr4_ops *ops = get_ops (target_gdbarch ()); + struct solib_svr4_ops *ops = get_ops (current_inferior ()->arch ()); return (ops->fetch_link_map_offsets != NULL); } diff --git a/gdb/solib.c b/gdb/solib.c index 5280e5f..a2a8a03 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -111,7 +111,7 @@ show_solib_search_path (struct ui_file *file, int from_tty, static gdb::unique_xmalloc_ptr solib_find_1 (const char *in_pathname, int *fd, bool is_solib) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); int found_file = -1; gdb::unique_xmalloc_ptr temp_pathname; const char *fskind = effective_target_file_system_kind (); @@ -384,7 +384,7 @@ gdb::unique_xmalloc_ptr solib_find (const char *in_pathname, int *fd) { const char *solib_symbols_extension - = gdbarch_solib_symbols_extension (target_gdbarch ()); + = gdbarch_solib_symbols_extension (current_inferior ()->arch ()); /* If solib_symbols_extension is set, replace the file's extension. */ @@ -464,7 +464,7 @@ solib_bfd_open (const char *pathname) bfd_get_filename (abfd.get ()), bfd_errmsg (bfd_get_error ())); /* Check bfd arch. */ - b = gdbarch_bfd_arch_info (target_gdbarch ()); + b = gdbarch_bfd_arch_info (current_inferior ()->arch ()); if (!b->compatible (b, bfd_get_arch_info (abfd.get ()))) error (_("`%s': Shared library architecture %s is not compatible " "with target architecture %s."), bfd_get_filename (abfd.get ()), @@ -539,7 +539,7 @@ get_cbfd_soname_build_id (gdb_bfd_ref_ptr abfd, const char *soname) static int solib_map_sections (struct so_list *so) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); gdb::unique_xmalloc_ptr filename (tilde_expand (so->so_name)); gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ())); @@ -633,7 +633,7 @@ solib_map_sections (struct so_list *so) static void clear_so (struct so_list *so) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); delete so->sections; so->sections = NULL; @@ -670,7 +670,7 @@ clear_so (struct so_list *so) void free_so (struct so_list *so) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); clear_so (so); ops->free_so (so); @@ -774,7 +774,7 @@ notify_solib_unloaded (program_space *pspace, so_list *so) void update_solib_list (int from_tty) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); struct so_list *inferior = ops->current_sos(); struct so_list *gdb, **gdb_link; @@ -1077,7 +1077,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty) bool so_missing_debug_info = false; int addr_width; int nr_libs; - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); struct ui_out *uiout = current_uiout; if (pattern) @@ -1213,7 +1213,7 @@ solib_name_from_address (struct program_space *pspace, CORE_ADDR address) bool solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); if (ops->keep_data_in_core) return ops->keep_data_in_core (vaddr, size) != 0; @@ -1226,7 +1226,7 @@ solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) void clear_solib (void) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); disable_breakpoints_in_shlibs (); @@ -1251,7 +1251,7 @@ clear_solib (void) void solib_create_inferior_hook (int from_tty) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); ops->solib_create_inferior_hook (from_tty); } @@ -1261,7 +1261,7 @@ solib_create_inferior_hook (int from_tty) bool in_solib_dynsym_resolve_code (CORE_ADDR pc) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); return ops->in_dynsym_resolve_code (pc) != 0; } @@ -1297,7 +1297,7 @@ no_shared_libraries (const char *ignored, int from_tty) void update_solib_breakpoints (void) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); if (ops->update_breakpoints != NULL) ops->update_breakpoints (); @@ -1308,7 +1308,7 @@ update_solib_breakpoints (void) void handle_solib_event (void) { - const struct target_so_ops *ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); if (ops->handle_event != NULL) ops->handle_event (); @@ -1392,11 +1392,9 @@ static void reload_shared_libraries (const char *ignored, int from_tty, struct cmd_list_element *e) { - const struct target_so_ops *ops; - reload_shared_libraries_1 (from_tty); - ops = gdbarch_so_ops (target_gdbarch ()); + const target_so_ops *ops = gdbarch_so_ops (current_inferior ()->arch ()); /* Creating inferior hooks here has two purposes. First, if we reload shared libraries then the address of solib breakpoint we've computed @@ -1506,7 +1504,7 @@ gdb_bfd_lookup_symbol_from_symtab if (match_sym (sym)) { - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); symaddr = sym->value; /* Some ELF targets fiddle with addresses of symbols they @@ -1622,7 +1620,8 @@ gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd, CORE_ADDR *ptr, gdb_byte ptr_buf[8]; CORE_ADDR ptr_addr_1; - ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; + ptr_type + = builtin_type (current_inferior ()->arch ())->builtin_data_ptr; ptr_addr_1 = dyn_addr + (buf - bufstart) + arch_size / 8; if (target_read_memory (ptr_addr_1, ptr_buf, arch_size / 8) == 0) dyn_ptr = extract_typed_address (ptr_buf, ptr_type); diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 19534fc..5cf384f 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -345,7 +345,7 @@ adi_read_versions (CORE_ADDR vaddr, size_t size, gdb_byte *tags) { adi_stat_t ast = get_adi_info (inferior_ptid.pid ()); error(_("Address at %s is not in ADI maps"), - paddress (target_gdbarch (), vaddr * ast.blksize)); + paddress (current_inferior ()->arch (), vaddr * ast.blksize)); } fileio_error target_errno; @@ -366,7 +366,7 @@ adi_write_versions (CORE_ADDR vaddr, size_t size, unsigned char *tags) { adi_stat_t ast = get_adi_info (inferior_ptid.pid ()); error(_("Address at %s is not in ADI maps"), - paddress (target_gdbarch (), vaddr * ast.blksize)); + paddress (current_inferior ()->arch (), vaddr * ast.blksize)); } fileio_error target_errno; @@ -388,7 +388,8 @@ adi_print_versions (CORE_ADDR vaddr, size_t cnt, gdb_byte *tags) { QUIT; gdb_printf ("%s:\t", - paddress (target_gdbarch (), vaddr * adi_stat.blksize)); + paddress (current_inferior ()->arch (), + vaddr * adi_stat.blksize)); for (int i = maxelts; i > 0 && cnt > 0; i--, cnt--) { if (tags[v_idx] == 0xff) /* no version tag */ @@ -416,7 +417,8 @@ do_examine (CORE_ADDR start, int bcnt) if (read_cnt == -1) error (_("No ADI information")); else if (read_cnt < cnt) - error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr)); + error(_("No ADI information at %s"), + paddress (current_inferior ()->arch (), vaddr)); adi_print_versions (vstart, cnt, buf.data ()); } @@ -434,8 +436,8 @@ do_assign (CORE_ADDR start, size_t bcnt, int version) if (set_cnt == -1) error (_("No ADI information")); else if (set_cnt < cnt) - error(_("No ADI information at %s"), paddress (target_gdbarch (), vaddr)); - + error(_("No ADI information at %s"), + paddress (current_inferior ()->arch (), vaddr)); } /* ADI examine version tag command. diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 956f10e..8ec6119 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -184,7 +184,7 @@ add_vsyscall_page (inferior *inf) } std::string name = string_printf ("system-supplied DSO at %s", - paddress (target_gdbarch (), + paddress (current_inferior ()->arch (), vsyscall_range.start)); try { diff --git a/gdb/symfile.c b/gdb/symfile.c index dc2f625..5eb1638 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1959,7 +1959,8 @@ load_progress (ULONGEST bytes, void *untyped_arg) current_uiout->message ("Loading section %s, size %s lma %s\n", args->section_name, hex_string (args->section_size), - paddress (target_gdbarch (), args->lma)); + paddress (current_inferior ()->arch (), + args->lma)); return; } @@ -1976,10 +1977,10 @@ load_progress (ULONGEST bytes, void *untyped_arg) if (target_read_memory (args->lma, check.data (), bytes) != 0) error (_("Download verify read failed at %s"), - paddress (target_gdbarch (), args->lma)); + paddress (current_inferior ()->arch (), args->lma)); if (memcmp (args->buffer, check.data (), bytes) != 0) error (_("Download verify compare failed at %s"), - paddress (target_gdbarch (), args->lma)); + paddress (current_inferior ()->arch (), args->lma)); } totals->data_count += bytes; args->lma += bytes; @@ -2091,9 +2092,9 @@ generic_load (const char *args, int from_tty) steady_clock::time_point end_time = steady_clock::now (); CORE_ADDR entry = bfd_get_start_address (loadfile_bfd.get ()); - entry = gdbarch_addr_bits_remove (target_gdbarch (), entry); + entry = gdbarch_addr_bits_remove (current_inferior ()->arch (), entry); uiout->text ("Start address "); - uiout->field_core_addr ("address", target_gdbarch (), entry); + uiout->field_core_addr ("address", current_inferior ()->arch (), entry); uiout->text (", load size "); uiout->field_unsigned ("load-size", total_progress.data_count); uiout->text ("\n"); diff --git a/gdb/symtab.c b/gdb/symtab.c index e9bc7b2..46547f8 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2460,7 +2460,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, struct gdbarch *gdbarch; if (block == NULL) - gdbarch = target_gdbarch (); + gdbarch = current_inferior ()->arch (); else gdbarch = block->gdbarch (); result.symbol = language_lookup_primitive_type_as_symbol (this, @@ -2582,7 +2582,7 @@ lookup_global_or_static_symbol (const char *name, /* Do a global search (of global blocks, heh). */ if (result.symbol == NULL) gdbarch_iterate_over_objfiles_in_search_order - (objfile != NULL ? objfile->arch () : target_gdbarch (), + (objfile != NULL ? objfile->arch () : current_inferior ()->arch (), [&result, block_index, name, domain] (struct objfile *objfile_iter) { result = lookup_symbol_in_objfile (objfile_iter, block_index, @@ -6296,7 +6296,7 @@ find_main_name (void) /* Try to find language for main in psymtabs. */ bool symbol_found_p = false; gdbarch_iterate_over_objfiles_in_search_order - (target_gdbarch (), + (current_inferior ()->arch (), [&symbol_found_p, pspace] (objfile *obj) { language lang diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 9f6e8d2..d882544 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -475,7 +475,7 @@ target_find_description (void) /* The current architecture should not have any target description specified. It should have been cleared, e.g. when we disconnected from the previous target. */ - gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL); + gdb_assert (gdbarch_target_desc (current_inferior ()->arch ()) == NULL); /* First try to fetch an XML description from the user-specified file. */ @@ -510,7 +510,7 @@ target_find_description (void) { struct tdesc_arch_data *data; - data = get_arch_data (target_gdbarch ()); + data = get_arch_data (current_inferior ()->arch ()); if (tdesc_has_registers (tdesc_info->tdesc) && data->arch_regs.empty ()) warning (_("Target-supplied registers are not supported " diff --git a/gdb/target.c b/gdb/target.c index 8cb4fa1..6853c14 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1281,7 +1281,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) { volatile CORE_ADDR addr = 0; struct target_ops *target = current_inferior ()->top_target (); - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); /* If OBJFILE is a separate debug object file, look for the original object file. */ @@ -1631,7 +1631,8 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object, if (len == 0) return TARGET_XFER_EOF; - memaddr = gdbarch_remove_non_address_bits (target_gdbarch (), memaddr); + memaddr = gdbarch_remove_non_address_bits (current_inferior ()->arch (), + memaddr); /* Fill in READBUF with breakpoint shadows, or WRITEBUF with breakpoint insns, thus hiding out from higher layers whether @@ -1803,8 +1804,9 @@ target_read_uint32 (CORE_ADDR memaddr, uint32_t *result) r = target_read_memory (memaddr, buf, sizeof buf); if (r != 0) return r; - *result = extract_unsigned_integer (buf, sizeof buf, - gdbarch_byte_order (target_gdbarch ())); + *result = extract_unsigned_integer + (buf, sizeof buf, + gdbarch_byte_order (current_inferior ()->arch ())); return 0; } @@ -1981,7 +1983,8 @@ target_read (struct target_ops *ops, || object == TARGET_OBJECT_STACK_MEMORY || object == TARGET_OBJECT_CODE_MEMORY || object == TARGET_OBJECT_RAW_MEMORY) - unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + unit_size = gdbarch_addressable_memory_unit_size + (current_inferior ()->arch ()); while (xfered_total < len) { @@ -2140,7 +2143,8 @@ read_memory_robust (struct target_ops *ops, const ULONGEST offset, const LONGEST len) { std::vector result; - int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + int unit_size + = gdbarch_addressable_memory_unit_size (current_inferior ()->arch ()); LONGEST xfered_total = 0; while (xfered_total < len) @@ -2215,7 +2219,8 @@ target_write_with_progress (struct target_ops *ops, || object == TARGET_OBJECT_STACK_MEMORY || object == TARGET_OBJECT_CODE_MEMORY || object == TARGET_OBJECT_RAW_MEMORY) - unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ()); + unit_size = gdbarch_addressable_memory_unit_size + (current_inferior ()->arch ()); /* Give the progress callback a chance to set up. */ if (progress) @@ -2468,7 +2473,7 @@ target_pre_inferior (int from_tty) /* In some OSs, the shared library list is the same/global/shared across inferiors. If code is shared between processes, so are memory regions and features. */ - if (!gdbarch_has_global_solist (target_gdbarch ())) + if (!gdbarch_has_global_solist (current_inferior ()->arch ())) { no_shared_libraries (NULL, from_tty); @@ -2539,10 +2544,9 @@ target_detach (inferior *inf, int from_tty) ptid_t save_pid_ptid = ptid_t (inf->pid); /* As long as some to_detach implementations rely on the current_inferior - (either directly, or indirectly, like through target_gdbarch or by - reading memory), INF needs to be the current inferior. When that - requirement will become no longer true, then we can remove this - assertion. */ + (either directly, or indirectly, like through reading memory), INF needs + to be the current inferior. When that requirement will become no longer + true, then we can remove this assertion. */ gdb_assert (inf == current_inferior ()); prepare_for_detach (); @@ -3582,7 +3586,8 @@ static int default_region_ok_for_hw_watchpoint (struct target_ops *self, CORE_ADDR addr, int len) { - return (len <= gdbarch_ptr_bit (target_gdbarch ()) / TARGET_CHAR_BIT); + gdbarch *arch = current_inferior ()->arch (); + return (len <= gdbarch_ptr_bit (arch) / TARGET_CHAR_BIT); } static int @@ -4284,7 +4289,7 @@ flash_erase_command (const char *cmd, int from_tty) { /* Used to communicate termination of flash operations to the target. */ bool found_flash_region = false; - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); std::vector mem_regions = target_memory_map (); diff --git a/gdb/target.h b/gdb/target.h index 936ae79..446c0a9 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -934,7 +934,7 @@ struct target_ops the target is currently stopped at. The architecture information is used to perform decr_pc_after_break adjustment, and also to determine the frame architecture of the innermost frame. ptrace operations need to - operate according to target_gdbarch (). */ + operate according to the current inferior's gdbarch. */ virtual struct gdbarch *thread_architecture (ptid_t) TARGET_DEFAULT_RETURN (NULL); diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 478f2f0..b698b40 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -659,7 +659,7 @@ tfile_get_traceframe_address (off_t tframe_offset) tfile_read ((gdb_byte *) &tpnum, 2); tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); tp = get_tracepoint_by_number_on_target (tpnum); /* FIXME this is a poor heuristic if multiple locations. */ @@ -703,14 +703,15 @@ tfile_target::trace_find (enum trace_find_type type, int num, tfile_read ((gdb_byte *) &tpnum, 2); tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); offset += 2; if (tpnum == 0) break; tfile_read ((gdb_byte *) &data_size, 4); data_size = (unsigned int) extract_unsigned_integer - ((gdb_byte *) &data_size, 4, - gdbarch_byte_order (target_gdbarch ())); + ((gdb_byte *) &data_size, 4, + gdbarch_byte_order + (current_inferior ()->arch ())); offset += 4; if (type == tfind_number) @@ -811,7 +812,7 @@ traceframe_walk_blocks (gdb::function_view callback, int pos) mlen = (unsigned short) extract_unsigned_integer ((gdb_byte *) &mlen, 2, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); lseek (trace_fd, mlen, SEEK_CUR); pos += (8 + 2 + mlen); break; @@ -947,7 +948,8 @@ tfile_target::xfer_partial (enum target_object object, { ULONGEST maddr, amt; unsigned short mlen; - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order + = gdbarch_byte_order (current_inferior ()->arch ()); tfile_read ((gdb_byte *) &maddr, 8); maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8, @@ -1027,13 +1029,13 @@ tfile_target::get_trace_state_variable_value (int tsvnum, LONGEST *val) tfile_read ((gdb_byte *) &vnum, 4); vnum = (int) extract_signed_integer ((gdb_byte *) &vnum, 4, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); if (tsvnum == vnum) { tfile_read ((gdb_byte *) val, 8); *val = extract_signed_integer ((gdb_byte *) val, 8, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); found = true; } pos += (4 + 8); @@ -1058,12 +1060,13 @@ build_traceframe_info (char blocktype, struct traceframe_info *info) tfile_read ((gdb_byte *) &maddr, 8); maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8, gdbarch_byte_order - (target_gdbarch ())); + (current_inferior ()->arch ())); tfile_read ((gdb_byte *) &mlen, 2); mlen = (unsigned short) extract_unsigned_integer ((gdb_byte *) &mlen, - 2, gdbarch_byte_order - (target_gdbarch ())); + 2, + gdbarch_byte_order + (current_inferior ()->arch ())); info->memory.emplace_back (maddr, mlen); break; diff --git a/gdb/tracefile.c b/gdb/tracefile.c index 5a26419..12ea7fa 100644 --- a/gdb/tracefile.c +++ b/gdb/tracefile.c @@ -25,6 +25,7 @@ #include "gdbsupport/byte-vector.h" #include "gdbarch.h" #include "gdbsupport/buildargv.h" +#include "inferior.h" /* Helper macros. */ @@ -71,7 +72,7 @@ trace_save (const char *filename, struct trace_file_writer *writer, ULONGEST offset = 0; #define MAX_TRACE_UPLOAD 2000 gdb::byte_vector buf (std::max (MAX_TRACE_UPLOAD, trace_regblock_size)); - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); /* If the target is to save the data to a file on its own, then just send the command and be done with it. */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 626fd87..2c54868 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1097,10 +1097,10 @@ collection_list::collection_list () : m_strace_data (false) { int max_remote_regno = 0; - for (int i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++) + for (int i = 0; i < gdbarch_num_regs (current_inferior ()->arch ()); i++) { int remote_regno = (gdbarch_remote_register_number - (target_gdbarch (), i)); + (current_inferior ()->arch (), i)); if (remote_regno >= 0 && remote_regno > max_remote_regno) max_remote_regno = remote_regno; @@ -1173,7 +1173,7 @@ collection_list::stringify () { gdb_printf ("(%d, %s, %ld)\n", m_memranges[i].type, - paddress (target_gdbarch (), + paddress (current_inferior ()->arch (), m_memranges[i].start), (long) (m_memranges[i].end - m_memranges[i].start)); @@ -1281,14 +1281,15 @@ encode_actions_1 (struct command_line *action, { /* Repeat over a comma-separated list. */ QUIT; /* Allow user to bail out with ^C. */ action_exp = skip_spaces (action_exp); + gdbarch *arch = current_inferior ()->arch (); if (0 == strncasecmp ("$reg", action_exp, 4)) { - for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); + for (i = 0; i < gdbarch_num_regs (arch); i++) { int remote_regno = (gdbarch_remote_register_number - (target_gdbarch (), i)); + (arch, i)); /* Ignore arch regnos without a corresponding remote regno. This can happen for regnos not @@ -1300,7 +1301,7 @@ encode_actions_1 (struct command_line *action, } else if (0 == strncasecmp ("$arg", action_exp, 4)) { - collect->add_local_symbols (target_gdbarch (), + collect->add_local_symbols (arch, tloc->address, frame_reg, frame_offset, @@ -1310,7 +1311,7 @@ encode_actions_1 (struct command_line *action, } else if (0 == strncasecmp ("$loc", action_exp, 4)) { - collect->add_local_symbols (target_gdbarch (), + collect->add_local_symbols (arch, tloc->address, frame_reg, frame_offset, @@ -1322,8 +1323,7 @@ encode_actions_1 (struct command_line *action, { agent_expr_up aexpr = gen_trace_for_return_address (tloc->address, - target_gdbarch (), - trace_string); + arch, trace_string); finalize_tracepoint_aexpr (aexpr.get ()); @@ -1356,15 +1356,14 @@ encode_actions_1 (struct command_line *action, (exp->op.get ())); const char *name = regop->get_name (); - i = user_reg_map_name_to_regnum (target_gdbarch (), + i = user_reg_map_name_to_regnum (arch, name, strlen (name)); if (i == -1) internal_error (_("Register $%s not available"), name); if (info_verbose) gdb_printf ("OP_REGISTER: "); - collect->add_local_register (target_gdbarch (), - i, tloc->address); + collect->add_local_register (arch, i, tloc->address); break; } @@ -1379,7 +1378,7 @@ encode_actions_1 (struct command_line *action, struct type *type = memop->get_type (); /* Initialize the TYPE_LENGTH if it is a typedef. */ check_typedef (type); - collect->add_memrange (target_gdbarch (), + collect->add_memrange (arch, memrange_absolute, addr, type->length (), tloc->address); @@ -1397,7 +1396,7 @@ encode_actions_1 (struct command_line *action, const char *name = sym->natural_name (); collect->collect_symbol (sym, - target_gdbarch (), + arch, frame_reg, frame_offset, tloc->address, @@ -3553,7 +3552,7 @@ parse_static_tracepoint_marker_definition (const char *line, const char **pp, p = unpack_varlen_hex (p, &addr); p++; /* skip a colon */ - marker->gdbarch = target_gdbarch (); + marker->gdbarch = current_inferior ()->arch (); marker->address = (CORE_ADDR) addr; endp = strchr (p, ':'); @@ -3706,7 +3705,7 @@ info_static_tracepoint_markers_command (const char *arg, int from_tty) uiout->table_header (40, ui_left, "marker-id", "ID"); uiout->table_header (3, ui_left, "enabled", "Enb"); - if (gdbarch_addr_bit (target_gdbarch ()) <= 32) + if (gdbarch_addr_bit (current_inferior ()->arch ()) <= 32) uiout->table_header (10, ui_left, "addr", "Address"); else uiout->table_header (18, ui_left, "addr", "Address"); diff --git a/gdb/value.c b/gdb/value.c index 1908874..17b7c53 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2515,7 +2515,7 @@ value::from_xmethod (xmethod_worker_up &&worker) { struct value *v; - v = value::allocate (builtin_type (target_gdbarch ())->xmethod); + v = value::allocate (builtin_type (current_inferior ()->arch ())->xmethod); v->m_lval = lval_xcallable; v->m_location.xm_worker = worker.release (); v->m_modifiable = false; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 7a139c8..b446afd 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2920,7 +2920,7 @@ windows_xfer_shared_libraries (struct target_ops *ops, windows_xfer_shared_library (so.name.c_str (), (CORE_ADDR) (uintptr_t) so.load_addr, &so.text_offset, - target_gdbarch (), &obstack); + current_inferior ()->arch (), &obstack); obstack_grow_str0 (&obstack, "\n"); buf = (const char *) obstack_finish (&obstack); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 0414aea..29aec5a 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -451,8 +451,8 @@ display_one_tib (ptid_t ptid) gdb_byte *index; CORE_ADDR thread_local_base; ULONGEST i, val, max, max_name, size, tib_size; - ULONGEST sizeof_ptr = gdbarch_ptr_bit (target_gdbarch ()); - enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); + ULONGEST sizeof_ptr = gdbarch_ptr_bit (current_inferior ()->arch ()); + bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ()); if (sizeof_ptr == 64) { @@ -490,13 +490,13 @@ display_one_tib (ptid_t ptid) gdb_printf (_("Unable to read thread information " "block for %s at address %s\n"), target_pid_to_str (ptid).c_str (), - paddress (target_gdbarch (), thread_local_base)); + paddress (current_inferior ()->arch (), thread_local_base)); return -1; } gdb_printf (_("Thread Information Block %s at %s\n"), target_pid_to_str (ptid).c_str (), - paddress (target_gdbarch (), thread_local_base)); + paddress (current_inferior ()->arch (), thread_local_base)); index = (gdb_byte *) tib; @@ -872,7 +872,7 @@ windows_solib_create_inferior_hook (int from_tty) /* Find base address of main executable in TIB->process_environment_block->image_base_address. */ - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int ptr_bytes; int peb_offset; /* Offset of process_environment_block in TIB. */ diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index d9ba207..ae32855 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -778,7 +778,7 @@ z80_software_single_step (struct regcache *regcache) int size; const struct z80_insn_info *info; std::vector ret (1); - struct gdbarch *gdbarch = target_gdbarch (); + gdbarch *gdbarch = current_inferior ()->arch (); regcache->cooked_read (Z80_PC_REGNUM, &addr); read_memory (addr, buf, sizeof(buf)); -- cgit v1.1