/* The target structure we are currently using to talk to a process
or file or whatever "inferior" we have. */
-struct target_ops *target_stack;
+static target_ops *g_current_top_target;
+
+target_ops *
+current_top_target ()
+{
+ return g_current_top_target;
+}
/* Command list for target. */
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->has_all_memory ())
return 1;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->has_memory ())
return 1;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->has_stack ())
return 1;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->has_registers ())
return 1;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->has_execution (the_ptid))
return 1;
void
target_kill (void)
{
- target_stack->kill ();
+ current_top_target ()->kill ();
}
void
target_load (const char *arg, int from_tty)
{
target_dcache_invalidate ();
- target_stack->load (arg, from_tty);
+ current_top_target ()->load (arg, from_tty);
}
/* Define it. */
void
target_terminal::init (void)
{
- target_stack->terminal_init ();
+ current_top_target ()->terminal_init ();
m_terminal_state = target_terminal_state::is_ours;
}
if (inf->terminal_state != target_terminal_state::is_inferior)
{
- target_stack->terminal_inferior ();
+ current_top_target ()->terminal_inferior ();
inf->terminal_state = target_terminal_state::is_inferior;
}
if (inf->terminal_state == target_terminal_state::is_ours_for_output)
{
set_current_inferior (inf);
- target_stack->terminal_inferior ();
+ current_top_target ()->terminal_inferior ();
inf->terminal_state = target_terminal_state::is_inferior;
}
}
if (inf->terminal_state == target_terminal_state::is_inferior)
{
set_current_inferior (inf);
- target_stack->terminal_save_inferior ();
+ current_top_target ()->terminal_save_inferior ();
}
}
{
set_current_inferior (inf);
if (desired_state == target_terminal_state::is_ours)
- target_stack->terminal_ours ();
+ current_top_target ()->terminal_ours ();
else if (desired_state == target_terminal_state::is_ours_for_output)
- target_stack->terminal_ours_for_output ();
+ current_top_target ()->terminal_ours_for_output ();
else
gdb_assert_not_reached ("unhandled desired state");
inf->terminal_state = desired_state;
void
target_terminal::info (const char *arg, int from_tty)
{
- target_stack->terminal_info (arg, from_tty);
+ current_top_target ()->terminal_info (arg, from_tty);
}
/* See target.h. */
int
target_supports_terminal_ours (void)
{
- return target_stack->supports_terminal_ours ();
+ return current_top_target ()->supports_terminal_ours ();
}
static void
tcomplain (void)
{
error (_("You can't do that when your target is `%s'"),
- target_stack->shortname ());
+ current_top_target ()->shortname ());
}
void
struct target_ops **cur;
/* Find the proper stratum to install this target in. */
- for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath)
+ for (cur = &g_current_top_target; (*cur) != NULL; cur = &(*cur)->beneath)
{
if ((int) (t->to_stratum) >= (int) (*cur)->to_stratum)
break;
/* Look for the specified target. Note that we assume that a target
can only occur once in the target stack. */
- for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath)
+ for (cur = &g_current_top_target; (*cur) != NULL; cur = &(*cur)->beneath)
{
if ((*cur) == t)
break;
void
pop_all_targets_above (enum strata above_stratum)
{
- while ((int) (target_stack->to_stratum) > (int) above_stratum)
- unpush_target_and_assert (target_stack);
+ while ((int) (current_top_target ()->to_stratum) > (int) above_stratum)
+ unpush_target_and_assert (current_top_target ());
}
/* See target.h. */
void
pop_all_targets_at_and_above (enum strata stratum)
{
- while ((int) (target_stack->to_stratum) >= (int) stratum)
- unpush_target_and_assert (target_stack);
+ while ((int) (current_top_target ()->to_stratum) >= (int) stratum)
+ unpush_target_and_assert (current_top_target ());
}
void
{
struct target_ops *cur;
- for (cur = target_stack; cur != NULL; cur = cur->beneath)
+ for (cur = current_top_target (); cur != NULL; cur = cur->beneath)
if (cur == t)
return 1;
target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
{
volatile CORE_ADDR addr = 0;
- struct target_ops *target = target_stack;
+ struct target_ops *target = current_top_target ();
if (gdbarch_fetch_tls_load_module_address_p (target_gdbarch ()))
{
int
target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- if (target_read (target_stack, TARGET_OBJECT_MEMORY, NULL,
+ if (target_read (current_top_target (), TARGET_OBJECT_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
int
target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- if (target_read (target_stack, TARGET_OBJECT_RAW_MEMORY, NULL,
+ if (target_read (current_top_target (), TARGET_OBJECT_RAW_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
int
target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- if (target_read (target_stack, TARGET_OBJECT_STACK_MEMORY, NULL,
+ if (target_read (current_top_target (), TARGET_OBJECT_STACK_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
int
target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- if (target_read (target_stack, TARGET_OBJECT_CODE_MEMORY, NULL,
+ if (target_read (current_top_target (), TARGET_OBJECT_CODE_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
int
target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
{
- if (target_write (target_stack, TARGET_OBJECT_MEMORY, NULL,
+ if (target_write (current_top_target (), TARGET_OBJECT_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
int
target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
{
- if (target_write (target_stack, TARGET_OBJECT_RAW_MEMORY, NULL,
+ if (target_write (current_top_target (), TARGET_OBJECT_RAW_MEMORY, NULL,
myaddr, memaddr, len) == len)
return 0;
else
std::vector<mem_region>
target_memory_map (void)
{
- std::vector<mem_region> result = target_stack->memory_map ();
+ std::vector<mem_region> result = current_top_target ()->memory_map ();
if (result.empty ())
return result;
void
target_flash_erase (ULONGEST address, LONGEST length)
{
- target_stack->flash_erase (address, length);
+ current_top_target ()->flash_erase (address, length);
}
void
target_flash_done (void)
{
- target_stack->flash_done ();
+ current_top_target ()->flash_done ();
}
static void
return 1;
}
- return target_stack->insert_breakpoint (gdbarch, bp_tgt);
+ return current_top_target ()->insert_breakpoint (gdbarch, bp_tgt);
}
/* See target.h. */
return 1;
}
- return target_stack->remove_breakpoint (gdbarch, bp_tgt, reason);
+ return current_top_target ()->remove_breakpoint (gdbarch, bp_tgt, reason);
}
static void
printf_unfiltered (_("Symbols from \"%s\".\n"),
objfile_name (symfile_objfile));
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
{
if (!t->has_memory ())
continue;
prepare_for_detach ();
- target_stack->detach (inf, from_tty);
+ current_top_target ()->detach (inf, from_tty);
}
void
disconnecting. */
remove_breakpoints ();
- target_stack->disconnect (args, from_tty);
+ current_top_target ()->disconnect (args, from_tty);
}
/* See target/target.h. */
ptid_t
target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
{
- return target_stack->wait (ptid, status, options);
+ return current_top_target ()->wait (ptid, status, options);
}
/* See target.h. */
const char *
target_pid_to_str (ptid_t ptid)
{
- return target_stack->pid_to_str (ptid);
+ return current_top_target ()->pid_to_str (ptid);
}
const char *
target_thread_name (struct thread_info *info)
{
- return target_stack->thread_name (info);
+ return current_top_target ()->thread_name (info);
}
struct thread_info *
int handle_len,
struct inferior *inf)
{
- return target_stack->thread_handle_to_thread_info (thread_handle,
+ return current_top_target ()->thread_handle_to_thread_info (thread_handle,
handle_len, inf);
}
{
target_dcache_invalidate ();
- target_stack->resume (ptid, step, signal);
+ current_top_target ()->resume (ptid, step, signal);
registers_changed_ptid (ptid);
/* We only set the internal executing state here. The user/frontend
if (defer_target_commit_resume)
return;
- target_stack->commit_resume ();
+ current_top_target ()->commit_resume ();
}
/* See target.h. */
void
target_pass_signals (int numsigs, unsigned char *pass_signals)
{
- target_stack->pass_signals (numsigs, pass_signals);
+ current_top_target ()->pass_signals (numsigs, pass_signals);
}
void
target_program_signals (int numsigs, unsigned char *program_signals)
{
- target_stack->program_signals (numsigs, program_signals);
+ current_top_target ()->program_signals (numsigs, program_signals);
}
static int
int
target_follow_fork (int follow_child, int detach_fork)
{
- return target_stack->follow_fork (follow_child, detach_fork);
+ return current_top_target ()->follow_fork (follow_child, detach_fork);
}
/* Target wrapper for follow exec hook. */
void
target_follow_exec (struct inferior *inf, char *execd_pathname)
{
- target_stack->follow_exec (inf, execd_pathname);
+ current_top_target ()->follow_exec (inf, execd_pathname);
}
static void
target_mourn_inferior (ptid_t ptid)
{
gdb_assert (ptid_equal (ptid, inferior_ptid));
- target_stack->mourn_inferior ();
+ current_top_target ()->mourn_inferior ();
/* We no longer need to keep handles on any of the object files.
Make sure to release them to avoid unnecessarily locking any
CORE_ADDR *found_addrp)
{
/* Start over from the top of the target stack. */
- return simple_search_memory (target_stack,
+ return simple_search_memory (current_top_target (),
start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
const gdb_byte *pattern, ULONGEST pattern_len,
CORE_ADDR *found_addrp)
{
- return target_stack->search_memory (start_addr, search_space_len,
+ return current_top_target ()->search_memory (start_addr, search_space_len,
pattern, pattern_len, found_addrp);
}
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
{
/* If this target knows how to create a new program, then
assume we will still be able to after killing the current
find_attach_target (void)
{
/* If a target on the current stack can attach, use it. */
- for (target_ops *t = target_stack; t != NULL; t = t->beneath)
+ for (target_ops *t = current_top_target (); t != NULL; t = t->beneath)
{
if (t->can_attach ())
return t;
find_run_target (void)
{
/* If a target on the current stack can run, use it. */
- for (target_ops *t = target_stack; t != NULL; t = t->beneath)
+ for (target_ops *t = current_top_target (); t != NULL; t = t->beneath)
{
if (t->can_create_inferior ())
return t;
int
target_supports_disable_randomization (void)
{
- return target_stack->supports_disable_randomization ();
+ return current_top_target ()->supports_disable_randomization ();
}
/* See target/target.h. */
int
target_supports_multi_process (void)
{
- return target_stack->supports_multi_process ();
+ return current_top_target ()->supports_multi_process ();
}
/* See target.h. */
{
struct address_space *aspace;
- aspace = target_stack->thread_address_space (ptid);
+ aspace = current_top_target ()->thread_address_space (ptid);
gdb_assert (aspace != NULL);
return aspace;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
{
if (t->can_run ())
return 1;
{
struct target_ops *t;
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
if (t->to_stratum == stratum)
return t;
int
target_thread_alive (ptid_t ptid)
{
- return target_stack->thread_alive (ptid);
+ return current_top_target ()->thread_alive (ptid);
}
void
target_update_thread_list (void)
{
- target_stack->update_thread_list ();
+ current_top_target ()->update_thread_list ();
}
void
return;
}
- target_stack->stop (ptid);
+ current_top_target ()->stop (ptid);
}
void
return;
}
- target_stack->interrupt ();
+ current_top_target ()->interrupt ();
}
/* See target.h. */
void
target_pass_ctrlc (void)
{
- target_stack->pass_ctrlc ();
+ current_top_target ()->pass_ctrlc ();
}
/* See target.h. */
void
target_fetch_registers (struct regcache *regcache, int regno)
{
- target_stack->fetch_registers (regcache, regno);
+ current_top_target ()->fetch_registers (regcache, regno);
if (targetdebug)
regcache->debug_print_register ("target_fetch_registers", regno);
}
if (!may_write_registers)
error (_("Writing to registers is not allowed (regno %d)"), regno);
- target_stack->store_registers (regcache, regno);
+ current_top_target ()->store_registers (regcache, regno);
if (targetdebug)
{
regcache->debug_print_register ("target_store_registers", regno);
int
target_core_of_thread (ptid_t ptid)
{
- return target_stack->core_of_thread (ptid);
+ return current_top_target ()->core_of_thread (ptid);
}
int
const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
{
/* Start over from the top of the target stack. */
- return simple_verify_memory (target_stack,
+ return simple_verify_memory (current_top_target (),
data, memaddr, size);
}
int
target_verify_memory (const gdb_byte *data, CORE_ADDR memaddr, ULONGEST size)
{
- return target_stack->verify_memory (data, memaddr, size);
+ return current_top_target ()->verify_memory (data, memaddr, size);
}
/* The documentation for this function is in its prototype declaration in
target_insert_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask,
enum target_hw_bp_type rw)
{
- return target_stack->insert_mask_watchpoint (addr, mask, rw);
+ return current_top_target ()->insert_mask_watchpoint (addr, mask, rw);
}
/* The documentation for this function is in its prototype declaration in
target_remove_mask_watchpoint (CORE_ADDR addr, CORE_ADDR mask,
enum target_hw_bp_type rw)
{
- return target_stack->remove_mask_watchpoint (addr, mask, rw);
+ return current_top_target ()->remove_mask_watchpoint (addr, mask, rw);
}
/* The documentation for this function is in its prototype declaration
int
target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask)
{
- return target_stack->masked_watch_num_registers (addr, mask);
+ return current_top_target ()->masked_watch_num_registers (addr, mask);
}
/* The documentation for this function is in its prototype declaration
int
target_ranged_break_num_registers (void)
{
- return target_stack->ranged_break_num_registers ();
+ return current_top_target ()->ranged_break_num_registers ();
}
/* See target.h. */
struct btrace_target_info *
target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
{
- return target_stack->enable_btrace (ptid, conf);
+ return current_top_target ()->enable_btrace (ptid, conf);
}
/* See target.h. */
void
target_disable_btrace (struct btrace_target_info *btinfo)
{
- target_stack->disable_btrace (btinfo);
+ current_top_target ()->disable_btrace (btinfo);
}
/* See target.h. */
void
target_teardown_btrace (struct btrace_target_info *btinfo)
{
- target_stack->teardown_btrace (btinfo);
+ current_top_target ()->teardown_btrace (btinfo);
}
/* See target.h. */
struct btrace_target_info *btinfo,
enum btrace_read_type type)
{
- return target_stack->read_btrace (btrace, btinfo, type);
+ return current_top_target ()->read_btrace (btrace, btinfo, type);
}
/* See target.h. */
const struct btrace_config *
target_btrace_conf (const struct btrace_target_info *btinfo)
{
- return target_stack->btrace_conf (btinfo);
+ return current_top_target ()->btrace_conf (btinfo);
}
/* See target.h. */
void
target_stop_recording (void)
{
- target_stack->stop_recording ();
+ current_top_target ()->stop_recording ();
}
/* See target.h. */
void
target_save_record (const char *filename)
{
- target_stack->save_record (filename);
+ current_top_target ()->save_record (filename);
}
/* See target.h. */
int
target_supports_delete_record ()
{
- return target_stack->supports_delete_record ();
+ return current_top_target ()->supports_delete_record ();
}
/* See target.h. */
void
target_delete_record (void)
{
- target_stack->delete_record ();
+ current_top_target ()->delete_record ();
}
/* See target.h. */
enum record_method
target_record_method (ptid_t ptid)
{
- return target_stack->record_method (ptid);
+ return current_top_target ()->record_method (ptid);
}
/* See target.h. */
int
target_record_is_replaying (ptid_t ptid)
{
- return target_stack->record_is_replaying (ptid);
+ return current_top_target ()->record_is_replaying (ptid);
}
/* See target.h. */
int
target_record_will_replay (ptid_t ptid, int dir)
{
- return target_stack->record_will_replay (ptid, dir);
+ return current_top_target ()->record_will_replay (ptid, dir);
}
/* See target.h. */
void
target_record_stop_replaying (void)
{
- target_stack->record_stop_replaying ();
+ current_top_target ()->record_stop_replaying ();
}
/* See target.h. */
void
target_goto_record_begin (void)
{
- target_stack->goto_record_begin ();
+ current_top_target ()->goto_record_begin ();
}
/* See target.h. */
void
target_goto_record_end (void)
{
- target_stack->goto_record_end ();
+ current_top_target ()->goto_record_end ();
}
/* See target.h. */
void
target_goto_record (ULONGEST insn)
{
- target_stack->goto_record (insn);
+ current_top_target ()->goto_record (insn);
}
/* See target.h. */
void
target_insn_history (int size, gdb_disassembly_flags flags)
{
- target_stack->insn_history (size, flags);
+ current_top_target ()->insn_history (size, flags);
}
/* See target.h. */
target_insn_history_from (ULONGEST from, int size,
gdb_disassembly_flags flags)
{
- target_stack->insn_history_from (from, size, flags);
+ current_top_target ()->insn_history_from (from, size, flags);
}
/* See target.h. */
target_insn_history_range (ULONGEST begin, ULONGEST end,
gdb_disassembly_flags flags)
{
- target_stack->insn_history_range (begin, end, flags);
+ current_top_target ()->insn_history_range (begin, end, flags);
}
/* See target.h. */
void
target_call_history (int size, record_print_flags flags)
{
- target_stack->call_history (size, flags);
+ current_top_target ()->call_history (size, flags);
}
/* See target.h. */
void
target_call_history_from (ULONGEST begin, int size, record_print_flags flags)
{
- target_stack->call_history_from (begin, size, flags);
+ current_top_target ()->call_history_from (begin, size, flags);
}
/* See target.h. */
void
target_call_history_range (ULONGEST begin, ULONGEST end, record_print_flags flags)
{
- target_stack->call_history_range (begin, end, flags);
+ current_top_target ()->call_history_range (begin, end, flags);
}
/* See target.h. */
const struct frame_unwind *
target_get_unwinder (void)
{
- return target_stack->get_unwinder ();
+ return current_top_target ()->get_unwinder ();
}
/* See target.h. */
const struct frame_unwind *
target_get_tailcall_unwinder (void)
{
- return target_stack->get_tailcall_unwinder ();
+ return current_top_target ()->get_tailcall_unwinder ();
}
/* See target.h. */
void
target_prepare_to_generate_core (void)
{
- target_stack->prepare_to_generate_core ();
+ current_top_target ()->prepare_to_generate_core ();
}
/* See target.h. */
void
target_done_generating_core (void)
{
- target_stack->done_generating_core ();
+ current_top_target ()->done_generating_core ();
}
\f
printf_filtered (_("The current target stack is:\n"));
- for (t = target_stack; t != NULL; t = t->beneath)
+ for (t = current_top_target (); t != NULL; t = t->beneath)
{
if (t->to_stratum == debug_stratum)
continue;
target_async (int enable)
{
infrun_async (enable);
- target_stack->async (enable);
+ current_top_target ()->async (enable);
}
/* See target.h. */
void
target_thread_events (int enable)
{
- target_stack->thread_events (enable);
+ current_top_target ()->thread_events (enable);
}
/* Controls if targets can report that they can/are async. This is
static int
target_always_non_stop_p (void)
{
- return target_stack->always_non_stop_p ();
+ return current_top_target ()->always_non_stop_p ();
}
/* See target.h. */