This function is just a wrapper around the current inferior's gdbarch.
I find that having that wrapper just obscures where the arch is coming
from, and that it's often used as "I don't know which arch to use so
I'll use this magical target_gdbarch function that gets me an arch" when
the arch should in fact come from something in the context (a thread,
objfile, symbol, etc). I think that removing it and inlining
`current_inferior ()->arch ()` everywhere will make it a bit clearer
where that arch comes from and will trigger people into reflecting
whether this is the right place to get the arch or not.
Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
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);
}
= 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 ())
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)
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
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));
}
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;
}
/* 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;
}
/* 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')
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;
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. */
#include "frame-base.h"
#include "frame-unwind.h"
#include "gdbcore.h"
+#include "inferior.h"
#include "reggroups.h"
#include "gdbcmd.h"
#include "objfiles.h"
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));
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);
}
/* 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: "
if (has_stack_frames ())
return get_frame_arch (get_selected_frame (NULL));
else
- return target_gdbarch ();
+ return current_inferior ()->arch ();
}
int
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 ()
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. */
show_fp_model (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
+ gdbarch *arch = current_inferior ()->arch ();
if (arm_fp_model == ARM_FLOAT_AUTO
- && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
+ && gdbarch_bfd_arch_info (arch)->arch == bfd_arch_arm)
{
- arm_gdbarch_tdep *tdep
- = gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (arch);
gdb_printf (file, _("\
The current ARM floating point model is \"auto\" (currently \"%s\").\n"),
arm_show_abi (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
+ gdbarch *arch = current_inferior ()->arch ();
if (arm_abi_global == ARM_ABI_AUTO
- && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
+ && gdbarch_bfd_arch_info (arch)->arch == bfd_arch_arm)
{
- arm_gdbarch_tdep *tdep
- = gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+ arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (arch);
gdb_printf (file, _("\
The current ARM ABI is \"auto\" (currently \"%s\").\n"),
{
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);
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 ();
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)
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:
{
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"));
}
static int
fprint_target_auxv (struct ui_file *file)
{
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
CORE_ADDR type, val;
int ents = 0;
const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
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;
catch_syscall_split_args (const char *arg)
{
std::vector<int> result;
- struct gdbarch *gdbarch = target_gdbarch ();
+ gdbarch *gdbarch = current_inferior ()->arch ();
while (*arg != '\0')
{
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
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;
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;
/* 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 ();
/* 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
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);
}
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);
}
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;
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)
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);
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);
}
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. */
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 ());
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)
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)
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 ();
#include "gdbsupport/filestuff.h"
#include "gdbsupport/byte-vector.h"
#include "gdbarch.h"
+#include "inferior.h"
static gdb::unique_xmalloc_ptr<char>
scan_expression (const char **cmd, const char *def)
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
#include "exceptions.h"
#include "gdbtypes.h"
#include "dwarf2/loc.h"
+#include "inferior.h"
-\f
/* Compute the name of the pointer representing a local symbol's
address. */
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:
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:
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
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;
}
}
#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
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;
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:
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
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;
}
}
{
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)
{
"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);
}
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
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)
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)));
}
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++)
{
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);
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;
}
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\" "
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);
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);
}
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));
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);
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)
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))
#include "buildsym.h"
#include "language.h"
#include "namespace.h"
+#include "inferior.h"
#include <map>
#include <string>
#include <string.h>
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
#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
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)
{
#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.
struct gdbarch *gdbarch;
if (block == NULL)
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
else
gdbarch = block->gdbarch ();
sym.symbol
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),
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");
{
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",
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++)
{
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;
#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
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)
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);
}
}
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
{
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;
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;
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 ();
{
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' : '-');
#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";
{
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;
#include "gdbarch.h"
#include "dwarf2/frame-tailcall.h"
#include "cli/cli-cmds.h"
+#include "inferior.h"
struct frame_unwind_table_entry
{
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;
gdb::unique_xmalloc_ptr<char> note_data;
int note_size = 0;
asection *note_sec = NULL;
+ gdbarch *arch = current_inferior ()->arch ();
/* An external target method must build the notes section. */
/* FIXME: uweigand/2011-10-06: All architectures that support core file
generation should be converted to gdbarch_make_corefile_notes; at that
point, the target vector method can be removed. */
- if (!gdbarch_make_corefile_notes_p (target_gdbarch ()))
+ if (!gdbarch_make_corefile_notes_p (arch))
note_data = target_make_corefile_notes (obfd, ¬e_size);
else
- note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd,
- ¬e_size);
+ note_data = gdbarch_make_corefile_notes (arch, obfd, ¬e_size);
if (note_data == NULL || note_size == 0)
error (_("Target does not support core file generation."));
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;
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. */
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;
}
}
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);
/* 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)
{
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;
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 (),
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."));
}
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,
using gdbarch_tdep_up = std::unique_ptr<gdbarch_tdep_base>;
-/* The architecture associated with the inferior through the
- connection to the target.
-
- The architecture vector provides some information that is really a
- property of the inferior, accessed through a particular target:
- ptrace operations; the layout of certain RSP packets; the solib_ops
- vector; etc. To differentiate architecture accesses to
- per-inferior/target properties from
- per-thread/per-frame/per-objfile properties, accesses to
- per-inferior/target properties should be made through this
- gdbarch. */
-
-/* This is a convenience wrapper for 'current_inferior ()->gdbarch'. */
-extern struct gdbarch *target_gdbarch (void);
-
/* Callback type for the 'iterate_over_objfiles_in_search_order'
gdbarch method. */
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);
}
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))
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;
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,
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)];
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)];
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 ();
{
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;
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;
/* 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);
}
}
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)
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. */
;
/* 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)
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));
}
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));
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
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
{
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;
}
{
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;
}
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;
#include "cli/cli-utils.h"
#include <algorithm>
#include "gdbarch.h"
+#include "inferior.h"
static std::vector<mem_region> user_mem_region_list, target_mem_region_list;
static std::vector<mem_region> *mem_region_list = &target_mem_region_list;
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");
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";
specifically excluding the generic coprocessor register sets. */
mep_gdbarch_tdep *tdep
- = gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mep_gdbarch_tdep> (current_inferior ()->arch ());
CGEN_CPU_DESC desc = tdep->cpu_desc;
const CGEN_HW_ENTRY *hw;
else
{
mep_gdbarch_tdep *tdep
- = gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mep_gdbarch_tdep> (current_inferior ()->arch ());
return tdep->me_module;
}
}
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");
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);
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
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);
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. */
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"
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)));
}
#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"
{
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;
const char *additional_text = "";
if (mask_address_var == AUTO_BOOLEAN_AUTO)
{
- if (gdbarch_bfd_arch_info (target_gdbarch ())->arch != bfd_arch_mips)
+ if (gdbarch_bfd_arch_info (current_inferior ()->arch ())->arch
+ != bfd_arch_mips)
additional_text = _(" (current architecture is not MIPS)");
else
{
mips_gdbarch_tdep *tdep
- = gdbarch_tdep<mips_gdbarch_tdep> (target_gdbarch ());
+ = gdbarch_tdep<mips_gdbarch_tdep> (current_inferior ()->arch ());
if (mips_mask_address_p (tdep))
additional_text = _(" (currently \"on\")");
{
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 "
return;
}
- switch (mips_get_fpu_type (target_gdbarch ()))
+ switch (mips_get_fpu_type (current_inferior ()->arch ()))
{
case MIPS_FPU_SINGLE:
fpu = "single-precision";
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 "
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)
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;
}
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);
#include "dwarf2/frame.h"
#include "reggroups.h"
#include "gdbarch.h"
+#include "inferior.h"
#include "elf/msp430.h"
#include "opcode/msp430-decode.h"
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;
}
{
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' : '-');
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."));
}
}
"%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";
}
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";
}
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";
}
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";
}
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 *
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);
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)
#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. */
= 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
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. */
{
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"),
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. */
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"),
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);
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
{
/* 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));
}
/* 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
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 ());
}
}
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
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)
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;
}
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;
}
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;
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
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,
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",
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)
{
/* 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;
}
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 ();
}
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;
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);
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 ();
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 ();
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 ();
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 ();
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 ();
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;
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 ();
#include "build-id.h"
#include "symtab.h"
#include "python.h"
+#include "inferior.h"
struct objfile_object
{
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. */
}, 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. */
#include "block.h"
#include "py-event.h"
#include "observable.h"
+#include "inferior.h"
struct pspace_object
{
this is one time when the current program space and current inferior
are not in sync: All inferiors that use PSPACE may no longer exist.
We don't need to do much here, and since "there is always an inferior"
- using target_gdbarch suffices.
+ using the current inferior's arch suffices.
Note: We cannot call get_current_arch because it may try to access
the target, which may involve accessing data in the pspace currently
being deleted. */
- struct gdbarch *arch = target_gdbarch ();
+ gdbarch *arch = current_inferior ()->arch ();
gdbpy_enter enter_py (arch);
gdbpy_ref<pspace_object> object (obj);
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)
{
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
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;
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 ());
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;
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");
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);
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."));
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. */
}
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;
{
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;
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");
#include "reggroups.h"
#include "target.h"
#include "gdbarch.h"
+#include "inferior.h"
/* Dump registers from regcache, used for dumping raw registers and
cooked registers. */
if (target_has_registers ())
gdbarch = get_current_regcache ()->arch ();
else
- gdbarch = target_gdbarch ();
+ gdbarch = current_inferior ()->arch ();
switch (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;
"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)
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. */
};
try
{
- gdbarch_relocate_instruction (target_gdbarch (), &to, from);
+ gdbarch_relocate_instruction (current_inferior ()->arch (),
+ &to, from);
relocated = 1;
}
catch (const gdb_exception &ex)
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;
}
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;
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)
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. */
/* 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 ())
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 ();
&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]);
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.
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,
/* 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))
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);
/* 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 ();
/* 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';
/* 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);
/* 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);
/* 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 ();
/* 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';
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
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);
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 ();
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 ();
}
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. */
/* 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");
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),
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:",
#include "dwarf2/frame.h"
#include "reggroups.h"
#include "gdbarch.h"
+#include "inferior.h"
#include "elf/rl78.h"
#include "elf-bfd.h"
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;
}
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);
#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
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)
#include "value.h"
#include "gdbarch.h"
#include "rust-exp.h"
+#include "inferior.h"
using namespace expr;
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);
#include "remote.h"
#include "target-descriptions.h"
#include "gdbarch.h"
+#include "inferior.h"
#include "elf/rx.h"
#include "elf-bfd.h"
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;
}
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)
{
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)
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);
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);
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);
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);
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. */
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");
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. */
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;
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;
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;
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;
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;
{
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))
/* 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
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 ()));
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)));
}
}
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;
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;
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];
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;
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;
}
#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 };
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;
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];
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;
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)
return 0;
}
- status = frv_fdpic_loadmap_addresses (target_gdbarch (),
+ status = frv_fdpic_loadmap_addresses (current_inferior ()->arch (),
&interp_loadmap_addr, 0);
if (status < 0)
{
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;
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));
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))
(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;
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;
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
static gdb::optional<gdb::byte_vector>
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;
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;
&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 ();
&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 ();
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
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);
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;
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;
{
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);
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;
}
/* 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;
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. */
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
= 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;
}
}
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
{
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 (),
/* 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;
}
{
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;
}
{
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;
}
}
= 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
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 ()));
}
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);
}
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 ();
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);
}
static gdb::unique_xmalloc_ptr<char>
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<char> temp_pathname;
const char *fskind = effective_target_file_system_kind ();
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. */
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 ()),
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<char> filename (tilde_expand (so->so_name));
gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
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;
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);
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;
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)
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;
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 ();
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);
}
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;
}
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 ();
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 ();
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
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
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);
{
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;
{
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;
{
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 */
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 ());
}
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.
}
std::string name = string_printf ("system-supplied DSO at %s",
- paddress (target_gdbarch (),
+ paddress (current_inferior ()->arch (),
vsyscall_range.start));
try
{
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;
}
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;
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");
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,
/* 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,
/* 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
/* 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. */
{
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 "
{
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. */
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
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;
}
|| 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)
{
const ULONGEST offset, const LONGEST len)
{
std::vector<memory_read_result> 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)
|| 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)
/* 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);
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 ();
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
{
/* 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_region> mem_regions = target_memory_map ();
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);
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. */
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)
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;
{
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,
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);
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;
#include "gdbsupport/byte-vector.h"
#include "gdbarch.h"
#include "gdbsupport/buildargv.h"
+#include "inferior.h"
/* Helper macros. */
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. */
: 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;
{
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));
{ /* 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
}
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,
}
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,
{
agent_expr_up aexpr
= gen_trace_for_return_address (tloc->address,
- target_gdbarch (),
- trace_string);
+ arch, trace_string);
finalize_tracepoint_aexpr (aexpr.get ());
(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;
}
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);
const char *name = sym->natural_name ();
collect->collect_symbol (sym,
- target_gdbarch (),
+ arch,
frame_reg,
frame_offset,
tloc->address,
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, ':');
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");
{
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;
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, "</library-list>\n");
buf = (const char *) obstack_finish (&obstack);
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)
{
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;
/* 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. */
int size;
const struct z80_insn_info *info;
std::vector<CORE_ADDR> 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));