gdb: remove current_top_target function

The current_top_target function is a hidden dependency on the current
inferior.  Since I'd like to slowly move towards reducing our dependency
on the global current state, remove this function and make callers use

  current_inferior ()->top_target ()

There is no expected change in behavior, but this one step towards
making those callers use the inferior from their context, rather than
refer to the global current inferior.

gdb/ChangeLog:

	* target.h (current_top_target): Remove, make callers use the
	current inferior instead.
	* target.c (current_top_target): Remove.

Change-Id: Iccd457036f84466cdaa3865aa3f9339a24ea001d
This commit is contained in:
Simon Marchi 2021-03-24 18:08:12 -04:00
parent d777bf0df2
commit 328d42d87e
48 changed files with 454 additions and 329 deletions

View File

@ -1,3 +1,9 @@
2021-03-24 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (current_top_target): Remove, make callers use the
current inferior instead.
* target.c (current_top_target): Remove.
2021-03-24 Simon Marchi <simon.marchi@polymtl.ca> 2021-03-24 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (target_shortname): Change to function declaration. * target.h (target_shortname): Change to function declaration.

View File

@ -320,7 +320,8 @@ target_auxv_parse (gdb_byte **readptr,
if (gdbarch_auxv_parse_p (gdbarch)) if (gdbarch_auxv_parse_p (gdbarch))
return gdbarch_auxv_parse (gdbarch, readptr, endptr, typep, valp); return gdbarch_auxv_parse (gdbarch, readptr, endptr, typep, valp);
return current_top_target ()->auxv_parse (readptr, endptr, typep, valp); return current_inferior ()->top_target ()->auxv_parse (readptr, endptr,
typep, valp);
} }
@ -580,7 +581,8 @@ info_auxv_command (const char *cmd, int from_tty)
error (_("The program has no auxiliary information now.")); error (_("The program has no auxiliary information now."));
else else
{ {
int ents = fprint_target_auxv (gdb_stdout, current_top_target ()); int ents = fprint_target_auxv (gdb_stdout,
current_inferior ()->top_target ());
if (ents < 0) if (ents < 0)
error (_("No auxiliary vector found, or failed reading it.")); error (_("No auxiliary vector found, or failed reading it."));

View File

@ -1561,7 +1561,8 @@ avr_io_reg_read_command (const char *args, int from_tty)
/* Find out how many io registers the target has. */ /* Find out how many io registers the target has. */
gdb::optional<gdb::byte_vector> buf gdb::optional<gdb::byte_vector> buf
= target_read_alloc (current_top_target (), TARGET_OBJECT_AVR, "avr.io_reg"); = target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_AVR, "avr.io_reg");
if (!buf) if (!buf)
{ {
@ -1595,7 +1596,8 @@ avr_io_reg_read_command (const char *args, int from_tty)
j = nreg - i; /* last block is less than 8 registers */ j = nreg - i; /* last block is less than 8 registers */
snprintf (query, sizeof (query) - 1, "avr.io_reg:%x,%x", i, j); snprintf (query, sizeof (query) - 1, "avr.io_reg:%x,%x", i, j);
buf = target_read_alloc (current_top_target (), TARGET_OBJECT_AVR, query); buf = target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_AVR, query);
if (!buf) if (!buf)
{ {

View File

@ -3598,8 +3598,8 @@ create_exception_master_breakpoint_hook (objfile *objfile)
} }
addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym); addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym);
addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, addr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (gdbarch, addr, current_inferior ()->top_target ());
b = create_internal_breakpoint (gdbarch, addr, bp_exception_master, b = create_internal_breakpoint (gdbarch, addr, bp_exception_master,
&internal_breakpoint_ops); &internal_breakpoint_ops);
initialize_explicit_location (&explicit_loc); initialize_explicit_location (&explicit_loc);
@ -4869,7 +4869,7 @@ watchpoints_triggered (struct target_waitstatus *ws)
return 0; return 0;
} }
if (!target_stopped_data_address (current_top_target (), &addr)) if (!target_stopped_data_address (current_inferior ()->top_target (), &addr))
{ {
/* We were stopped by a watchpoint, but we don't know where. /* We were stopped by a watchpoint, but we don't know where.
Mark all watchpoints as unknown. */ Mark all watchpoints as unknown. */
@ -4909,8 +4909,8 @@ watchpoints_triggered (struct target_waitstatus *ws)
} }
} }
/* Exact match not required. Within range is sufficient. */ /* Exact match not required. Within range is sufficient. */
else if (target_watchpoint_addr_within_range (current_top_target (), else if (target_watchpoint_addr_within_range
addr, loc->address, (current_inferior ()->top_target (), addr, loc->address,
loc->length)) loc->length))
{ {
w->watchpoint_triggered = watch_triggered_yes; w->watchpoint_triggered = watch_triggered_yes;

View File

@ -218,8 +218,8 @@ read_memory_object (enum target_object object, CORE_ADDR memaddr,
enum target_xfer_status status; enum target_xfer_status status;
ULONGEST xfered_len; ULONGEST xfered_len;
status = target_xfer_partial (current_top_target (), object, NULL, status = target_xfer_partial (current_inferior ()->top_target (), object,
myaddr + xfered, NULL, NULL, myaddr + xfered, NULL,
memaddr + xfered, len - xfered, memaddr + xfered, len - xfered,
&xfered_len); &xfered_len);

View File

@ -863,8 +863,8 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
if (target_read_memory (pointer_address, buf, ptr_size) != 0) if (target_read_memory (pointer_address, buf, ptr_size) != 0)
continue; continue;
addr = extract_typed_address (buf, ptr_type); addr = extract_typed_address (buf, ptr_type);
addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, addr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (gdbarch, addr, current_inferior ()->top_target ());
addr = gdbarch_addr_bits_remove (gdbarch, addr); addr = gdbarch_addr_bits_remove (gdbarch, addr);
if (elf_gnu_ifunc_record_cache (name, addr)) if (elf_gnu_ifunc_record_cache (name, addr))
@ -931,12 +931,13 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
parameter. FUNCTION is the function entry address. ADDRESS may be a parameter. FUNCTION is the function entry address. ADDRESS may be a
function descriptor. */ function descriptor. */
target_auxv_search (current_top_target (), AT_HWCAP, &hwcap); target_auxv_search (current_inferior ()->top_target (), AT_HWCAP, &hwcap);
hwcap_val = value_from_longest (builtin_type (gdbarch) hwcap_val = value_from_longest (builtin_type (gdbarch)
->builtin_unsigned_long, hwcap); ->builtin_unsigned_long, hwcap);
address_val = call_function_by_hand (function, NULL, hwcap_val); address_val = call_function_by_hand (function, NULL, hwcap_val);
address = value_as_address (address_val); address = value_as_address (address_val);
address = gdbarch_convert_from_func_ptr_addr (gdbarch, address, current_top_target ()); address = gdbarch_convert_from_func_ptr_addr
(gdbarch, address, current_inferior ()->top_target ());
address = gdbarch_addr_bits_remove (gdbarch, address); address = gdbarch_addr_bits_remove (gdbarch, address);
if (name_at_pc) if (name_at_pc)
@ -1042,9 +1043,8 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
gdbarch_return_value (gdbarch, func_func, value_type, regcache, gdbarch_return_value (gdbarch, func_func, value_type, regcache,
value_contents_raw (value), NULL); value_contents_raw (value), NULL);
resolved_address = value_as_address (value); resolved_address = value_as_address (value);
resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch, resolved_pc = gdbarch_convert_from_func_ptr_addr
resolved_address, (gdbarch, resolved_address, current_inferior ()->top_target ());
current_top_target ());
resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc); resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc);
gdb_assert (current_program_space == b->pspace || b->pspace == NULL); gdb_assert (current_program_space == b->pspace || b->pspace == NULL);

View File

@ -42,6 +42,7 @@
#include <ctype.h> #include <ctype.h>
#include "expop.h" #include "expop.h"
#include "c-exp.h" #include "c-exp.h"
#include "inferior.h"
/* Parse the string EXP as a C expression, evaluate it, /* Parse the string EXP as a C expression, evaluate it,
@ -1964,8 +1965,8 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
/* The address might point to a function descriptor; /* The address might point to a function descriptor;
resolve it to the actual code address instead. */ resolve it to the actual code address instead. */
addr = gdbarch_convert_from_func_ptr_addr (exp->gdbarch, addr, addr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (exp->gdbarch, addr, current_inferior ()->top_target ());
/* Is it a high_level symbol? */ /* Is it a high_level symbol? */
sym = find_pc_function (addr); sym = find_pc_function (addr);

View File

@ -775,7 +775,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
ULONGEST len, ULONGEST *xfered_len) ULONGEST len, ULONGEST *xfered_len)
{ {
const target_section_table *table const target_section_table *table
= target_get_section_table (current_top_target ()); = target_get_section_table (current_inferior ()->top_target ());
std::vector<mem_range> available_memory std::vector<mem_range> available_memory
= section_table_available_memory (offset, len, *table); = section_table_available_memory (offset, len, *table);

View File

@ -593,7 +593,7 @@ static gdb::optional<gdb::byte_vector>
fbsd_make_note_desc (enum target_object object, uint32_t structsize) fbsd_make_note_desc (enum target_object object, uint32_t structsize)
{ {
gdb::optional<gdb::byte_vector> buf = gdb::optional<gdb::byte_vector> buf =
target_read_alloc (current_top_target (), object, NULL); target_read_alloc (current_inferior ()->top_target (), object, NULL);
if (!buf || buf->empty ()) if (!buf || buf->empty ())
return {}; return {};

View File

@ -2478,9 +2478,8 @@ inside_main_func (frame_info *this_frame)
/* Convert any function descriptor addresses into the actual function /* Convert any function descriptor addresses into the actual function
code address. */ code address. */
sym_addr sym_addr = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (get_frame_arch (this_frame), (get_frame_arch (this_frame), sym_addr, current_inferior ()->top_target ());
sym_addr, current_top_target ());
return sym_addr == get_frame_func (this_frame); return sym_addr == get_frame_func (this_frame);
} }

View File

@ -31,6 +31,7 @@
#include <algorithm> #include <algorithm>
#include "cli/cli-style.h" #include "cli/cli-style.h"
#include "dwarf2/loc.h" #include "dwarf2/loc.h"
#include "inferior.h"
static struct cp_abi_ops gnu_v3_abi_ops; static struct cp_abi_ops gnu_v3_abi_ops;
@ -1243,8 +1244,8 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc)
(powerpc 64 for example). Make sure to retrieve the address (powerpc 64 for example). Make sure to retrieve the address
of the real function from the function descriptor before passing on of the real function from the function descriptor before passing on
the address to other layers of GDB. */ the address to other layers of GDB. */
func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, method_stop_pc, func_addr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (gdbarch, method_stop_pc, current_inferior ()->top_target ());
if (func_addr != 0) if (func_addr != 0)
method_stop_pc = func_addr; method_stop_pc = func_addr;

View File

@ -2653,8 +2653,8 @@ getunwind_table ()
we should find a way to override the corefile layer's we should find a way to override the corefile layer's
xfer_partial method. */ xfer_partial method. */
return target_read_alloc (current_top_target (), TARGET_OBJECT_UNWIND_TABLE, return target_read_alloc (current_inferior ()->top_target (),
NULL); TARGET_OBJECT_UNWIND_TABLE, NULL);
} }
/* Get the kernel unwind table. */ /* Get the kernel unwind table. */

View File

@ -41,7 +41,8 @@ ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip,
CORE_ADDR table_addr; CORE_ADDR table_addr;
unsigned int info_len; unsigned int info_len;
res = target_read (current_top_target (), TARGET_OBJECT_OPENVMS_UIB, res = target_read (current_inferior ()->top_target (),
TARGET_OBJECT_OPENVMS_UIB,
annex + 2, buf, 0, sizeof (buf)); annex + 2, buf, 0, sizeof (buf));
if (res != sizeof (buf)) if (res != sizeof (buf))

View File

@ -269,8 +269,8 @@ find_function_addr (struct value *function,
ftype = check_typedef (TYPE_TARGET_TYPE (ftype)); ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
if (ftype->code () == TYPE_CODE_FUNC if (ftype->code () == TYPE_CODE_FUNC
|| ftype->code () == TYPE_CODE_METHOD) || ftype->code () == TYPE_CODE_METHOD)
funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, funaddr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (gdbarch, funaddr, current_inferior ()->top_target());
} }
if (ftype->code () == TYPE_CODE_FUNC if (ftype->code () == TYPE_CODE_FUNC
|| ftype->code () == TYPE_CODE_METHOD) || ftype->code () == TYPE_CODE_METHOD)
@ -321,9 +321,8 @@ find_function_addr (struct value *function,
funaddr = value_as_address (value_addr (function)); funaddr = value_as_address (value_addr (function));
nfunaddr = funaddr; nfunaddr = funaddr;
funaddr funaddr = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, (gdbarch, funaddr, current_inferior ()->top_target ());
current_top_target ());
if (funaddr != nfunaddr) if (funaddr != nfunaddr)
found_descriptor = 1; found_descriptor = 1;
} }

View File

@ -759,7 +759,7 @@ continue_command (const char *args, int from_tty)
ensure_not_running (); ensure_not_running ();
} }
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
if (from_tty) if (from_tty)
printf_filtered (_("Continuing.\n")); printf_filtered (_("Continuing.\n"));
@ -877,7 +877,7 @@ step_1 (int skip_subroutines, int single_inst, const char *count_string)
= strip_bg_char (count_string, &async_exec); = strip_bg_char (count_string, &async_exec);
count_string = stripped.get (); count_string = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
count = count_string ? parse_and_eval_long (count_string) : 1; count = count_string ? parse_and_eval_long (count_string) : 1;
@ -1075,7 +1075,7 @@ jump_command (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec); gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
arg = stripped.get (); arg = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
if (!arg) if (!arg)
error_no_arg (_("starting address")); error_no_arg (_("starting address"));
@ -1155,7 +1155,7 @@ signal_command (const char *signum_exp, int from_tty)
= strip_bg_char (signum_exp, &async_exec); = strip_bg_char (signum_exp, &async_exec);
signum_exp = stripped.get (); signum_exp = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
if (!signum_exp) if (!signum_exp)
error_no_arg (_("signal number")); error_no_arg (_("signal number"));
@ -1400,7 +1400,7 @@ until_command (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec); gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
arg = stripped.get (); arg = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
if (arg) if (arg)
until_break_command (arg, from_tty, 0); until_break_command (arg, from_tty, 0);
@ -1425,7 +1425,7 @@ advance_command (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec); gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
arg = stripped.get (); arg = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
until_break_command (arg, from_tty, 1); until_break_command (arg, from_tty, 1);
} }
@ -1772,7 +1772,7 @@ finish_command (const char *arg, int from_tty)
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec); gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
arg = stripped.get (); arg = stripped.get ();
prepare_execution_command (current_top_target (), async_exec); prepare_execution_command (current_inferior ()->top_target (), async_exec);
if (arg) if (arg)
error (_("The \"finish\" command does not take any arguments.")); error (_("The \"finish\" command does not take any arguments."));

View File

@ -507,7 +507,7 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors)
uiout->field_signed ("number", inf->num); uiout->field_signed ("number", inf->num);
/* Because target_pid_to_str uses current_top_target, /* Because target_pid_to_str uses the current inferior,
switch the inferior. */ switch the inferior. */
switch_to_inferior_no_thread (inf); switch_to_inferior_no_thread (inf);

View File

@ -1777,7 +1777,7 @@ displaced_step_finish (thread_info *event_thread, enum gdb_signal signal)
/* Fixup may need to read memory/registers. Switch to the thread /* Fixup may need to read memory/registers. Switch to the thread
that we're fixing up. Also, target_stopped_by_watchpoint checks that we're fixing up. Also, target_stopped_by_watchpoint checks
the current thread, and displaced_step_restore performs ptid-dependent the current thread, and displaced_step_restore performs ptid-dependent
memory accesses using current_inferior() and current_top_target(). */ memory accesses using current_inferior(). */
switch_to_thread (event_thread); switch_to_thread (event_thread);
displaced_step_reset_cleanup cleanup (displaced); displaced_step_reset_cleanup cleanup (displaced);
@ -5813,7 +5813,8 @@ handle_signal_stop (struct execution_control_state *ecs)
infrun_debug_printf ("stopped by watchpoint"); infrun_debug_printf ("stopped by watchpoint");
if (target_stopped_data_address (current_top_target (), &addr)) if (target_stopped_data_address (current_inferior ()->top_target (),
&addr))
infrun_debug_printf ("stopped data address=%s", infrun_debug_printf ("stopped data address=%s",
paddress (reg_gdbarch, addr)); paddress (reg_gdbarch, addr));
else else
@ -8835,7 +8836,8 @@ siginfo_value_read (struct value *v)
validate_registers_access (); validate_registers_access ();
transferred = transferred =
target_read (current_top_target (), TARGET_OBJECT_SIGNAL_INFO, target_read (current_inferior ()->top_target (),
TARGET_OBJECT_SIGNAL_INFO,
NULL, NULL,
value_contents_all_raw (v), value_contents_all_raw (v),
value_offset (v), value_offset (v),
@ -8857,7 +8859,7 @@ siginfo_value_write (struct value *v, struct value *fromval)
vice versa. */ vice versa. */
validate_registers_access (); validate_registers_access ();
transferred = target_write (current_top_target (), transferred = target_write (current_inferior ()->top_target (),
TARGET_OBJECT_SIGNAL_INFO, TARGET_OBJECT_SIGNAL_INFO,
NULL, NULL,
value_contents_all_raw (fromval), value_contents_all_raw (fromval),
@ -8921,7 +8923,8 @@ public:
siginfo_data.reset ((gdb_byte *) xmalloc (len)); siginfo_data.reset ((gdb_byte *) xmalloc (len));
if (target_read (current_top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, if (target_read (current_inferior ()->top_target (),
TARGET_OBJECT_SIGNAL_INFO, NULL,
siginfo_data.get (), 0, len) != len) siginfo_data.get (), 0, len) != len)
{ {
/* Errors ignored. */ /* Errors ignored. */
@ -8956,7 +8959,8 @@ public:
struct type *type = gdbarch_get_siginfo_type (gdbarch); struct type *type = gdbarch_get_siginfo_type (gdbarch);
/* Errors ignored. */ /* Errors ignored. */
target_write (current_top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, target_write (current_inferior ()->top_target (),
TARGET_OBJECT_SIGNAL_INFO, NULL,
m_siginfo_data.get (), 0, TYPE_LENGTH (type)); m_siginfo_data.get (), 0, TYPE_LENGTH (type));
} }

View File

@ -47,6 +47,7 @@
#include "gdbsupport/function-view.h" #include "gdbsupport/function-view.h"
#include "gdbsupport/def-vector.h" #include "gdbsupport/def-vector.h"
#include <algorithm> #include <algorithm>
#include "inferior.h"
/* An enumeration of the various things a user might attempt to /* An enumeration of the various things a user might attempt to
complete for a linespec location. */ complete for a linespec location. */
@ -2314,7 +2315,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
= (gdbarch_convert_from_func_ptr_addr = (gdbarch_convert_from_func_ptr_addr
(gdbarch, (gdbarch,
msym_addr, msym_addr,
current_top_target ())); current_inferior ()->top_target ()));
} }
if (msym_addr == addr) if (msym_addr == addr)

View File

@ -410,9 +410,10 @@ int
linux_is_uclinux (void) linux_is_uclinux (void)
{ {
CORE_ADDR dummy; CORE_ADDR dummy;
target_ops *target = current_inferior ()->top_target ();
return (target_auxv_search (current_top_target (), AT_NULL, &dummy) > 0 return (target_auxv_search (target, AT_NULL, &dummy) > 0
&& target_auxv_search (current_top_target (), AT_PAGESZ, &dummy) == 0); && target_auxv_search (target, AT_PAGESZ, &dummy) == 0);
} }
static int static int
@ -1735,7 +1736,8 @@ linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch)
gdb::byte_vector buf (TYPE_LENGTH (siginfo_type)); gdb::byte_vector buf (TYPE_LENGTH (siginfo_type));
bytes_read = target_read (current_top_target (), TARGET_OBJECT_SIGNAL_INFO, NULL, bytes_read = target_read (current_inferior ()->top_target (),
TARGET_OBJECT_SIGNAL_INFO, NULL,
buf.data (), 0, TYPE_LENGTH (siginfo_type)); buf.data (), 0, TYPE_LENGTH (siginfo_type));
if (bytes_read != TYPE_LENGTH (siginfo_type)) if (bytes_read != TYPE_LENGTH (siginfo_type))
buf.clear (); buf.clear ();
@ -2037,7 +2039,8 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
/* Auxillary vector. */ /* Auxillary vector. */
gdb::optional<gdb::byte_vector> auxv = gdb::optional<gdb::byte_vector> auxv =
target_read_alloc (current_top_target (), TARGET_OBJECT_AUXV, NULL); target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_AUXV, NULL);
if (auxv && !auxv->empty ()) if (auxv && !auxv->empty ())
{ {
note_data.reset (elfcore_write_note (obfd, note_data.release (), note_data.reset (elfcore_write_note (obfd, note_data.release (),
@ -2317,7 +2320,8 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
char filename[100]; char filename[100];
long pid; long pid;
if (target_auxv_search (current_top_target (), AT_SYSINFO_EHDR, &range->start) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_SYSINFO_EHDR, &range->start) <= 0)
return 0; return 0;
/* It doesn't make sense to access the host's /proc when debugging a /* It doesn't make sense to access the host's /proc when debugging a
@ -2507,14 +2511,15 @@ linux_displaced_step_location (struct gdbarch *gdbarch)
local-store address and is thus not usable as displaced stepping local-store address and is thus not usable as displaced stepping
location. The auxiliary vector gets us the PowerPC-side entry location. The auxiliary vector gets us the PowerPC-side entry
point address instead. */ point address instead. */
if (target_auxv_search (current_top_target (), AT_ENTRY, &addr) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_ENTRY, &addr) <= 0)
throw_error (NOT_SUPPORTED_ERROR, throw_error (NOT_SUPPORTED_ERROR,
_("Cannot find AT_ENTRY auxiliary vector entry.")); _("Cannot find AT_ENTRY auxiliary vector entry."));
/* Make certain that the address points at real code, and not a /* Make certain that the address points at real code, and not a
function descriptor. */ function descriptor. */
addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, addr = gdbarch_convert_from_func_ptr_addr
current_top_target ()); (gdbarch, addr, current_inferior ()->top_target ());
/* Inferior calls also use the entry point as a breakpoint location. /* Inferior calls also use the entry point as a breakpoint location.
We don't want displaced stepping to interfere with those We don't want displaced stepping to interfere with those

View File

@ -40,6 +40,7 @@
#include "top.h" #include "top.h"
#include "maint.h" #include "maint.h"
#include "gdbsupport/selftest.h" #include "gdbsupport/selftest.h"
#include "inferior.h"
#include "cli/cli-decode.h" #include "cli/cli-decode.h"
#include "cli/cli-utils.h" #include "cli/cli-utils.h"
@ -472,7 +473,7 @@ maintenance_info_target_sections (const char *arg, int from_tty)
bfd *abfd = nullptr; bfd *abfd = nullptr;
int digits = 0; int digits = 0;
const target_section_table *table const target_section_table *table
= target_get_section_table (current_top_target ()); = target_get_section_table (current_inferior ()->top_target ());
if (table == nullptr) if (table == nullptr)
return; return;

View File

@ -264,7 +264,7 @@ proceed_thread_callback (struct thread_info *thread, void *arg)
static void static void
exec_continue (char **argv, int argc) exec_continue (char **argv, int argc)
{ {
prepare_execution_command (current_top_target (), mi_async_p ()); prepare_execution_command (current_inferior ()->top_target (), mi_async_p ());
if (non_stop) if (non_stop)
{ {
@ -1328,7 +1328,8 @@ mi_cmd_data_read_memory (const char *command, char **argv, int argc)
gdb::byte_vector mbuf (total_bytes); gdb::byte_vector mbuf (total_bytes);
nr_bytes = target_read (current_top_target (), TARGET_OBJECT_MEMORY, NULL, nr_bytes = target_read (current_inferior ()->top_target (),
TARGET_OBJECT_MEMORY, NULL,
mbuf.data (), addr, total_bytes); mbuf.data (), addr, total_bytes);
if (nr_bytes <= 0) if (nr_bytes <= 0)
error (_("Unable to read memory.")); error (_("Unable to read memory."));
@ -1448,7 +1449,7 @@ mi_cmd_data_read_memory_bytes (const char *command, char **argv, int argc)
length = atol (argv[1]); length = atol (argv[1]);
std::vector<memory_read_result> result std::vector<memory_read_result> result
= read_memory_robust (current_top_target (), addr, length); = read_memory_robust (current_inferior ()->top_target (), addr, length);
if (result.size () == 0) if (result.size () == 0)
error (_("Unable to read memory.")); error (_("Unable to read memory."));

View File

@ -54,6 +54,7 @@
#include <algorithm> #include <algorithm>
#include "safe-ctype.h" #include "safe-ctype.h"
#include "gdbsupport/parallel-for.h" #include "gdbsupport/parallel-for.h"
#include "inferior.h"
#if CXX_STD_THREAD #if CXX_STD_THREAD
#include <mutex> #include <mutex>
@ -78,9 +79,8 @@ msymbol_is_function (struct objfile *objfile, minimal_symbol *minsym,
case mst_data_gnu_ifunc: case mst_data_gnu_ifunc:
{ {
struct gdbarch *gdbarch = objfile->arch (); struct gdbarch *gdbarch = objfile->arch ();
CORE_ADDR pc CORE_ADDR pc = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (gdbarch, msym_addr, (gdbarch, msym_addr, current_inferior ()->top_target ());
current_top_target ());
if (pc != msym_addr) if (pc != msym_addr)
{ {
if (func_address_p != NULL) if (func_address_p != NULL)

View File

@ -1967,8 +1967,8 @@ ppc_linux_nat_target::read_description ()
features.wordsize = ppc_linux_target_wordsize (tid); features.wordsize = ppc_linux_target_wordsize (tid);
CORE_ADDR hwcap = linux_get_hwcap (current_top_target ()); CORE_ADDR hwcap = linux_get_hwcap (current_inferior ()->top_target ());
CORE_ADDR hwcap2 = linux_get_hwcap2 (current_top_target ()); CORE_ADDR hwcap2 = linux_get_hwcap2 (current_inferior ()->top_target ());
if (have_ptrace_getsetvsxregs if (have_ptrace_getsetvsxregs
&& (hwcap & PPC_FEATURE_HAS_VSX)) && (hwcap & PPC_FEATURE_HAS_VSX))
@ -2125,7 +2125,8 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
takes two hardware watchpoints though. */ takes two hardware watchpoints though. */
if (len > 1 if (len > 1
&& hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE && hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE
&& linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE) && (linux_get_hwcap (current_inferior ()->top_target ())
& PPC_FEATURE_BOOKE))
return 2; return 2;
/* Check if the processor provides DAWR interface. */ /* Check if the processor provides DAWR interface. */
if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR) if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
@ -2153,7 +2154,8 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
{ {
gdb_assert (m_dreg_interface.debugreg_p ()); gdb_assert (m_dreg_interface.debugreg_p ());
if (((linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE) if (((linux_get_hwcap (current_inferior ()->top_target ())
& PPC_FEATURE_BOOKE)
&& (addr + len) > (addr & ~3) + 4) && (addr + len) > (addr & ~3) + 4)
|| (addr + len) > (addr & ~7) + 8) || (addr + len) > (addr & ~7) + 8)
return 0; return 0;
@ -2640,7 +2642,8 @@ ppc_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
long wp_value; long wp_value;
long read_mode, write_mode; long read_mode, write_mode;
if (linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE) if (linux_get_hwcap (current_inferior ()->top_target ())
& PPC_FEATURE_BOOKE)
{ {
/* PowerPC 440 requires only the read/write flags to be passed /* PowerPC 440 requires only the read/write flags to be passed
to the kernel. */ to the kernel. */
@ -3013,9 +3016,11 @@ ppc_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
int mask; int mask;
if (m_dreg_interface.hwdebug_p () if (m_dreg_interface.hwdebug_p ()
&& linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE) && (linux_get_hwcap (current_inferior ()->top_target ())
& PPC_FEATURE_BOOKE))
return start <= addr && start + length >= addr; return start <= addr && start + length >= addr;
else if (linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE) else if (linux_get_hwcap (current_inferior ()->top_target ())
& PPC_FEATURE_BOOKE)
mask = 3; mask = 3;
else else
mask = 7; mask = 7;

View File

@ -3643,7 +3643,8 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
&thread_args); &thread_args);
gdb::optional<gdb::byte_vector> auxv = gdb::optional<gdb::byte_vector> auxv =
target_read_alloc (current_top_target (), TARGET_OBJECT_AUXV, NULL); target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_AUXV, NULL);
if (auxv && !auxv->empty ()) if (auxv && !auxv->empty ())
note_data.reset (elfcore_write_note (obfd, note_data.release (), note_size, note_data.reset (elfcore_write_note (obfd, note_data.release (), note_size,
"CORE", NT_AUXV, auxv->data (), "CORE", NT_AUXV, auxv->data (),

View File

@ -1916,7 +1916,7 @@ cooked_write_test (struct gdbarch *gdbarch)
{ {
/* Error out if debugging something, because we're going to push the /* Error out if debugging something, because we're going to push the
test target, which would pop any existing target. */ test target, which would pop any existing target. */
if (current_top_target ()->stratum () >= process_stratum) if (current_inferior ()->top_target ()->stratum () >= process_stratum)
error (_("target already pushed")); error (_("target already pushed"));
/* Create a mock environment. A process_stratum target pushed. */ /* Create a mock environment. A process_stratum target pushed. */

View File

@ -5079,9 +5079,8 @@ remote_target::remote_check_symbols ()
/* If this is a function address, return the start of code /* If this is a function address, return the start of code
instead of any data function descriptor. */ instead of any data function descriptor. */
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr = gdbarch_convert_from_func_ptr_addr
sym_addr, (target_gdbarch (), sym_addr, current_inferior ()->top_target ());
current_top_target ());
xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol:%s:%s", xsnprintf (msg.data (), get_remote_packet_size (), "qSymbol:%s:%s",
phex_nz (sym_addr, addr_size), &reply[8]); phex_nz (sym_addr, addr_size), &reply[8]);
@ -11463,7 +11462,8 @@ remote_target::memory_map ()
{ {
std::vector<mem_region> result; std::vector<mem_region> result;
gdb::optional<gdb::char_vector> text gdb::optional<gdb::char_vector> text
= target_read_stralloc (current_top_target (), TARGET_OBJECT_MEMORY_MAP, NULL); = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_MEMORY_MAP, NULL);
if (text) if (text)
result = parse_memory_map (text->data ()); result = parse_memory_map (text->data ());
@ -13694,7 +13694,8 @@ traceframe_info_up
remote_target::traceframe_info () remote_target::traceframe_info ()
{ {
gdb::optional<gdb::char_vector> text gdb::optional<gdb::char_vector> text
= target_read_stralloc (current_top_target (), TARGET_OBJECT_TRACEFRAME_INFO, = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_TRACEFRAME_INFO,
NULL); NULL);
if (text) if (text)
return parse_traceframe_info (text->data ()); return parse_traceframe_info (text->data ());
@ -13923,7 +13924,8 @@ static void
btrace_read_config (struct btrace_config *conf) btrace_read_config (struct btrace_config *conf)
{ {
gdb::optional<gdb::char_vector> xml gdb::optional<gdb::char_vector> xml
= target_read_stralloc (current_top_target (), TARGET_OBJECT_BTRACE_CONF, ""); = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_BTRACE_CONF, "");
if (xml) if (xml)
parse_xml_btrace_conf (conf, xml->data ()); parse_xml_btrace_conf (conf, xml->data ());
} }
@ -14124,7 +14126,8 @@ remote_target::read_btrace (struct btrace_data *btrace,
} }
gdb::optional<gdb::char_vector> xml gdb::optional<gdb::char_vector> xml
= target_read_stralloc (current_top_target (), TARGET_OBJECT_BTRACE, annex); = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_BTRACE, annex);
if (!xml) if (!xml)
return BTRACE_ERR_UNKNOWN; return BTRACE_ERR_UNKNOWN;
@ -14180,7 +14183,7 @@ remote_target::pid_to_exec_file (int pid)
xsnprintf (annex, annex_size, "%x", pid); xsnprintf (annex, annex_size, "%x", pid);
} }
filename = target_read_stralloc (current_top_target (), filename = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_EXEC_FILE, annex); TARGET_OBJECT_EXEC_FILE, annex);
return filename ? filename->data () : nullptr; return filename ? filename->data () : nullptr;

View File

@ -5077,7 +5077,8 @@ ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache,
return 0; return 0;
case 1014: /* Data Cache Block set to Zero */ case 1014: /* Data Cache Block set to Zero */
if (target_auxv_search (current_top_target (), AT_DCACHEBSIZE, &at_dcsz) <= 0 if (target_auxv_search (current_inferior ()->top_target (),
AT_DCACHEBSIZE, &at_dcsz) <= 0
|| at_dcsz == 0) || at_dcsz == 0)
at_dcsz = 128; /* Assume 128-byte cache line size (POWER8) */ at_dcsz = 128; /* Assume 128-byte cache line size (POWER8) */

View File

@ -1002,7 +1002,7 @@ s390_linux_nat_target::read_description ()
that mode, report s390 architecture with 64-bit GPRs. */ that mode, report s390 architecture with 64-bit GPRs. */
#ifdef __s390x__ #ifdef __s390x__
{ {
CORE_ADDR hwcap = linux_get_hwcap (current_top_target ()); CORE_ADDR hwcap = linux_get_hwcap (current_inferior ()->top_target ());
have_regset_tdb = (hwcap & HWCAP_S390_TE) have_regset_tdb = (hwcap & HWCAP_S390_TE)
&& check_regset (tid, NT_S390_TDB, s390_sizeof_tdbregset); && check_regset (tid, NT_S390_TDB, s390_sizeof_tdbregset);

View File

@ -39,6 +39,7 @@
#include "target-descriptions.h" #include "target-descriptions.h"
#include "trad-frame.h" #include "trad-frame.h"
#include "value.h" #include "value.h"
#include "inferior.h"
#include "features/s390-linux32.c" #include "features/s390-linux32.c"
#include "features/s390x-linux64.c" #include "features/s390x-linux64.c"
@ -685,7 +686,7 @@ s390_load (struct s390_prologue_data *data,
if (pv_is_constant (addr)) if (pv_is_constant (addr))
{ {
const struct target_section *secp const struct target_section *secp
= target_section_by_addr (current_top_target (), addr.k); = target_section_by_addr (current_inferior ()->top_target (), addr.k);
if (secp != NULL if (secp != NULL
&& (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY)) && (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
return pv_constant (read_memory_integer (addr.k, size, return pv_constant (read_memory_integer (addr.k, size,

View File

@ -246,7 +246,8 @@ solib_aix_get_library_list (struct inferior *inf, const char *warning_msg)
return data->library_list; return data->library_list;
gdb::optional<gdb::char_vector> library_document gdb::optional<gdb::char_vector> library_document
= target_read_stralloc (current_top_target (), TARGET_OBJECT_LIBRARIES_AIX, = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_LIBRARIES_AIX,
NULL); NULL);
if (!library_document && warning_msg != NULL) if (!library_document && warning_msg != NULL)
{ {

View File

@ -488,7 +488,8 @@ darwin_solib_read_all_image_info_addr (struct darwin_info *info)
if (TYPE_LENGTH (ptr_type) > sizeof (buf)) if (TYPE_LENGTH (ptr_type) > sizeof (buf))
return; return;
len = target_read (current_top_target (), TARGET_OBJECT_DARWIN_DYLD_INFO, len = target_read (current_inferior ()->top_target (),
TARGET_OBJECT_DARWIN_DYLD_INFO,
NULL, buf, 0, TYPE_LENGTH (ptr_type)); NULL, buf, 0, TYPE_LENGTH (ptr_type));
if (len <= 0) if (len <= 0)
return; return;

View File

@ -280,7 +280,8 @@ dsbt_get_initial_loadmaps (void)
{ {
struct dsbt_info *info = get_dsbt_info (); struct dsbt_info *info = get_dsbt_info ();
gdb::optional<gdb::byte_vector> buf gdb::optional<gdb::byte_vector> buf
= target_read_alloc (current_top_target (), TARGET_OBJECT_FDPIC, "exec"); = target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_FDPIC, "exec");
if (!buf || buf->empty ()) if (!buf || buf->empty ())
{ {
@ -291,7 +292,8 @@ dsbt_get_initial_loadmaps (void)
if (solib_dsbt_debug) if (solib_dsbt_debug)
dsbt_print_loadmap (info->exec_loadmap); dsbt_print_loadmap (info->exec_loadmap);
buf = target_read_alloc (current_top_target (), TARGET_OBJECT_FDPIC, "exec"); buf = target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_FDPIC, "exec");
if (!buf || buf->empty ()) if (!buf || buf->empty ())
{ {
info->interp_loadmap = NULL; info->interp_loadmap = NULL;

View File

@ -428,11 +428,14 @@ read_program_header (int type, int *p_arch_size, CORE_ADDR *base_addr)
int pt_phdr_p = 0; int pt_phdr_p = 0;
/* Get required auxv elements from target. */ /* Get required auxv elements from target. */
if (target_auxv_search (current_top_target (), AT_PHDR, &at_phdr) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_PHDR, &at_phdr) <= 0)
return {}; return {};
if (target_auxv_search (current_top_target (), AT_PHENT, &at_phent) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_PHENT, &at_phent) <= 0)
return {}; return {};
if (target_auxv_search (current_top_target (), AT_PHNUM, &at_phnum) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_PHNUM, &at_phnum) <= 0)
return {}; return {};
if (!at_phdr || !at_phnum) if (!at_phdr || !at_phnum)
return {}; return {};
@ -1239,7 +1242,8 @@ svr4_current_sos_via_xfer_libraries (struct svr4_library_list *list,
/* Fetch the list of shared libraries. */ /* Fetch the list of shared libraries. */
gdb::optional<gdb::char_vector> svr4_library_document gdb::optional<gdb::char_vector> svr4_library_document
= target_read_stralloc (current_top_target (), TARGET_OBJECT_LIBRARIES_SVR4, = target_read_stralloc (current_inferior ()->top_target (),
TARGET_OBJECT_LIBRARIES_SVR4,
annex); annex);
if (!svr4_library_document) if (!svr4_library_document)
return 0; return 0;
@ -2242,9 +2246,8 @@ enable_break (struct svr4_info *info, int from_tty)
sym_addr = gdbarch_addr_bits_remove sym_addr = gdbarch_addr_bits_remove
(target_gdbarch (), (target_gdbarch (),
gdbarch_convert_from_func_ptr_addr (target_gdbarch (), gdbarch_convert_from_func_ptr_addr
sym_addr, (target_gdbarch (), sym_addr, current_inferior ()->top_target ()));
current_top_target ()));
/* On at least some versions of Solaris there's a dynamic relocation /* 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 on _r_debug.r_brk and SYM_ADDR may not be relocated yet, e.g., if
@ -2353,7 +2356,8 @@ enable_break (struct svr4_info *info, int from_tty)
/* If we were not able to find the base address of the loader /* If we were not able to find the base address of the loader
from our so_list, then try using the AT_BASE auxilliary entry. */ from our so_list, then try using the AT_BASE auxilliary entry. */
if (!load_addr_found) if (!load_addr_found)
if (target_auxv_search (current_top_target (), AT_BASE, &load_addr) > 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_BASE, &load_addr) > 0)
{ {
int addr_bit = gdbarch_addr_bit (target_gdbarch ()); int addr_bit = gdbarch_addr_bit (target_gdbarch ());
@ -2474,9 +2478,8 @@ enable_break (struct svr4_info *info, int from_tty)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{ {
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr = gdbarch_convert_from_func_ptr_addr
sym_addr, (target_gdbarch (), sym_addr, current_inferior ()->top_target ());
current_top_target ());
svr4_create_solib_event_breakpoints (info, target_gdbarch (), svr4_create_solib_event_breakpoints (info, target_gdbarch (),
sym_addr); sym_addr);
return 1; return 1;
@ -2492,9 +2495,9 @@ enable_break (struct svr4_info *info, int from_tty)
&& (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0)) && (BMSYMBOL_VALUE_ADDRESS (msymbol) != 0))
{ {
sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol); sym_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr = gdbarch_convert_from_func_ptr_addr
sym_addr, (target_gdbarch (), sym_addr,
current_top_target ()); current_inferior ()->top_target ());
svr4_create_solib_event_breakpoints (info, target_gdbarch (), svr4_create_solib_event_breakpoints (info, target_gdbarch (),
sym_addr); sym_addr);
return 1; return 1;
@ -2582,7 +2585,8 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
if ((bfd_get_file_flags (current_program_space->exec_bfd ()) & DYNAMIC) == 0) if ((bfd_get_file_flags (current_program_space->exec_bfd ()) & DYNAMIC) == 0)
return 0; return 0;
if (target_auxv_search (current_top_target (), AT_ENTRY, &entry_point) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_ENTRY, &entry_point) <= 0)
return 0; return 0;
exec_displacement exec_displacement

View File

@ -25,6 +25,7 @@
#include "target.h" #include "target.h"
#include "solib-target.h" #include "solib-target.h"
#include <vector> #include <vector>
#include "inferior.h"
/* Private data for each loaded library. */ /* Private data for each loaded library. */
struct lm_info_target : public lm_info_base struct lm_info_target : public lm_info_base
@ -233,8 +234,8 @@ solib_target_current_sos (void)
/* Fetch the list of shared libraries. */ /* Fetch the list of shared libraries. */
gdb::optional<gdb::char_vector> library_document gdb::optional<gdb::char_vector> library_document
= target_read_stralloc (current_top_target (), TARGET_OBJECT_LIBRARIES, = target_read_stralloc (current_inferior ()->top_target (),
NULL); TARGET_OBJECT_LIBRARIES, NULL);
if (!library_document) if (!library_document)
return NULL; return NULL;

View File

@ -189,7 +189,7 @@ ULONGEST
sparc_fetch_wcookie (struct gdbarch *gdbarch) sparc_fetch_wcookie (struct gdbarch *gdbarch)
{ {
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct target_ops *ops = current_top_target (); struct target_ops *ops = current_inferior ()->top_target ();
gdb_byte buf[8]; gdb_byte buf[8];
int len; int len;

View File

@ -214,10 +214,12 @@ adi_available (void)
return proc->stat.is_avail; return proc->stat.is_avail;
proc->stat.checked_avail = true; proc->stat.checked_avail = true;
if (target_auxv_search (current_top_target (), AT_ADI_BLKSZ, &value) <= 0) if (target_auxv_search (current_inferior ()->top_target (),
AT_ADI_BLKSZ, &value) <= 0)
return false; return false;
proc->stat.blksize = value; proc->stat.blksize = value;
target_auxv_search (current_top_target (), AT_ADI_NBITS, &value); target_auxv_search (current_inferior ()->top_target (),
AT_ADI_NBITS, &value);
proc->stat.nbits = value; proc->stat.nbits = value;
proc->stat.max_version = (1 << proc->stat.nbits) - 2; proc->stat.max_version = (1 << proc->stat.nbits) - 2;
proc->stat.is_avail = true; proc->stat.is_avail = true;

View File

@ -838,10 +838,8 @@ init_entry_point_info (struct objfile *objfile)
/* Make certain that the address points at real code, and not a /* Make certain that the address points at real code, and not a
function descriptor. */ function descriptor. */
entry_point entry_point = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (objfile->arch (), (objfile->arch (), entry_point, current_inferior ()->top_target ());
entry_point,
current_top_target ());
/* Remove any ISA markers, so that this matches entries in the /* Remove any ISA markers, so that this matches entries in the
symbol table. */ symbol table. */

View File

@ -5564,10 +5564,8 @@ find_gnu_ifunc (const symbol *sym)
if (MSYMBOL_TYPE (minsym) == mst_data_gnu_ifunc) if (MSYMBOL_TYPE (minsym) == mst_data_gnu_ifunc)
{ {
struct gdbarch *gdbarch = objfile->arch (); struct gdbarch *gdbarch = objfile->arch ();
msym_addr msym_addr = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (gdbarch, (gdbarch, msym_addr, current_inferior ()->top_target ());
msym_addr,
current_top_target ());
} }
if (msym_addr == address) if (msym_addr == address)
{ {

View File

@ -553,11 +553,13 @@ target_find_description (void)
/* Next try to read the description from the current target using /* Next try to read the description from the current target using
target objects. */ target objects. */
if (current_target_desc == NULL) if (current_target_desc == NULL)
current_target_desc = target_read_description_xml (current_top_target ()); current_target_desc = target_read_description_xml
(current_inferior ()->top_target ());
/* If that failed try a target-specific hook. */ /* If that failed try a target-specific hook. */
if (current_target_desc == NULL) if (current_target_desc == NULL)
current_target_desc = target_read_description (current_top_target ()); current_target_desc = target_read_description
(current_inferior ()->top_target ());
/* If a non-NULL description was returned, then update the current /* If a non-NULL description was returned, then update the current
architecture. */ architecture. */

View File

@ -21,6 +21,7 @@
#include "defs.h" #include "defs.h"
#include "target.h" #include "target.h"
#include "memory-map.h" #include "memory-map.h"
#include "inferior.h"
#include "gdbsupport/gdb_sys_time.h" #include "gdbsupport/gdb_sys_time.h"
#include <algorithm> #include <algorithm>
@ -335,7 +336,7 @@ target_write_memory_blocks (const std::vector<memory_write_request> &requests,
{ {
LONGEST len; LONGEST len;
len = target_write_with_progress (current_top_target (), len = target_write_with_progress (current_inferior ()->top_target (),
TARGET_OBJECT_MEMORY, NULL, TARGET_OBJECT_MEMORY, NULL,
iter.data, iter.begin, iter.data, iter.begin,
iter.end - iter.begin, iter.end - iter.begin,
@ -358,7 +359,7 @@ target_write_memory_blocks (const std::vector<memory_write_request> &requests,
{ {
LONGEST len; LONGEST len;
len = target_write_with_progress (current_top_target (), len = target_write_with_progress (current_inferior ()->top_target (),
TARGET_OBJECT_FLASH, NULL, TARGET_OBJECT_FLASH, NULL,
iter.data, iter.begin, iter.data, iter.begin,
iter.end - iter.begin, iter.end - iter.begin,

File diff suppressed because it is too large Load Diff

View File

@ -1385,11 +1385,6 @@ private:
target_ops *m_stack[(int) debug_stratum + 1] {}; target_ops *m_stack[(int) debug_stratum + 1] {};
}; };
/* The ops structure for our "current" target process. This should
never be NULL. If there is no target, it points to the dummy_target. */
extern target_ops *current_top_target ();
/* Return the dummy target. */ /* Return the dummy target. */
extern target_ops *get_dummy_target (); extern target_ops *get_dummy_target ();

View File

@ -310,7 +310,7 @@ tfile_write_tdesc (struct trace_file_writer *self)
= (struct tfile_trace_file_writer *) self; = (struct tfile_trace_file_writer *) self;
gdb::optional<std::string> tdesc gdb::optional<std::string> tdesc
= target_fetch_description_xml (current_top_target ()); = target_fetch_description_xml (current_inferior ()->top_target ());
if (!tdesc) if (!tdesc)
return; return;

View File

@ -3812,7 +3812,8 @@ sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
{ {
/* We need to read the whole object before we know its size. */ /* We need to read the whole object before we know its size. */
gdb::optional<gdb::byte_vector> buf gdb::optional<gdb::byte_vector> buf
= target_read_alloc (current_top_target (), TARGET_OBJECT_STATIC_TRACE_DATA, = target_read_alloc (current_inferior ()->top_target (),
TARGET_OBJECT_STATIC_TRACE_DATA,
NULL); NULL);
if (buf) if (buf)
{ {

View File

@ -1040,7 +1040,7 @@ read_value_memory (struct value *val, LONGEST bit_offset,
enum target_xfer_status status; enum target_xfer_status status;
ULONGEST xfered_partial; ULONGEST xfered_partial;
status = target_xfer_partial (current_top_target (), status = target_xfer_partial (current_inferior ()->top_target (),
object, NULL, object, NULL,
buffer + xfered_total * unit_size, NULL, buffer + xfered_total * unit_size, NULL,
memaddr + xfered_total, memaddr + xfered_total,
@ -1286,7 +1286,8 @@ value_assign (struct value *toval, struct value *fromval)
case lval_register: case lval_register:
case lval_computed: case lval_computed:
gdb::observers::target_changed.notify (current_top_target ()); gdb::observers::target_changed.notify
(current_inferior ()->top_target ());
/* Having destroyed the frame cache, restore the selected /* Having destroyed the frame cache, restore the selected
frame. */ frame. */

View File

@ -42,6 +42,7 @@
#include "count-one-bits.h" #include "count-one-bits.h"
#include "c-lang.h" #include "c-lang.h"
#include "cp-abi.h" #include "cp-abi.h"
#include "inferior.h"
/* Maximum number of wchars returned from wchar_iterate. */ /* Maximum number of wchars returned from wchar_iterate. */
#define MAX_WCHARS 4 #define MAX_WCHARS 4
@ -1848,9 +1849,8 @@ print_function_pointer_address (const struct value_print_options *options,
CORE_ADDR address, CORE_ADDR address,
struct ui_file *stream) struct ui_file *stream)
{ {
CORE_ADDR func_addr CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr
= gdbarch_convert_from_func_ptr_addr (gdbarch, address, (gdbarch, address, current_inferior ()->top_target ());
current_top_target ());
/* If the function pointer is represented by a description, print /* If the function pointer is represented by a description, print
the address of the description. */ the address of the description. */

View File

@ -45,6 +45,7 @@
#include "gdbsupport/array-view.h" #include "gdbsupport/array-view.h"
#include "cli/cli-style.h" #include "cli/cli-style.h"
#include "expop.h" #include "expop.h"
#include "inferior.h"
/* Definition of a user function. */ /* Definition of a user function. */
struct internal_function struct internal_function
@ -3159,7 +3160,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
set_value_address (v, set_value_address (v,
gdbarch_convert_from_func_ptr_addr gdbarch_convert_from_func_ptr_addr
(gdbarch, BMSYMBOL_VALUE_ADDRESS (msym), current_top_target ())); (gdbarch, BMSYMBOL_VALUE_ADDRESS (msym),
current_inferior ()->top_target ()));
} }
if (arg1p) if (arg1p)

View File

@ -487,7 +487,7 @@ display_one_tib (ptid_t ptid)
return -1; return -1;
} }
if (target_read (current_top_target (), TARGET_OBJECT_MEMORY, if (target_read (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY,
NULL, tib, thread_local_base, tib_size) != tib_size) NULL, tib, thread_local_base, tib_size) != tib_size)
{ {
printf_filtered (_("Unable to read thread information " printf_filtered (_("Unable to read thread information "