static void debug_to_open (char *, int);
-static void debug_to_resume (ptid_t, int, enum target_signal);
-
-static void debug_to_fetch_registers (struct regcache *, int);
-
-static void debug_to_store_registers (struct regcache *, int);
-
static void debug_to_prepare_to_store (struct regcache *);
static void debug_to_files_info (struct target_ops *);
static void debug_to_terminal_info (char *, int);
-static void debug_to_kill (void);
-
static void debug_to_load (char *, int);
static int debug_to_lookup_symbol (char *, CORE_ADDR *);
static void debug_to_notice_signals (ptid_t);
-static int debug_to_thread_alive (ptid_t);
-
static void debug_to_stop (ptid_t);
/* NOTE: cagney/2004-09-29: Many targets reference this variable in
{
}
+void
+target_kill (void)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_kill != NULL)
+ {
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
+
+ t->to_kill (t);
+ return;
+ }
+
+ noprocess ();
+}
+
void
target_load (char *arg, int from_tty)
{
{
printf_unfiltered (_("You are already running a program:\n"));
target_files_info ();
- if (query ("Kill it? "))
+ if (query (_("Kill it? ")))
{
target_kill ();
if (target_has_execution)
INHERIT (to_attach_no_wait, t);
/* Do not inherit to_detach. */
/* Do not inherit to_disconnect. */
- INHERIT (to_resume, t);
+ /* Do not inherit to_resume. */
/* Do not inherit to_wait. */
- INHERIT (to_fetch_registers, t);
- INHERIT (to_store_registers, t);
+ /* Do not inherit to_fetch_registers. */
+ /* Do not inherit to_store_registers. */
INHERIT (to_prepare_to_store, t);
INHERIT (deprecated_xfer_memory, t);
INHERIT (to_files_info, t);
INHERIT (to_terminal_ours, t);
INHERIT (to_terminal_save_ours, t);
INHERIT (to_terminal_info, t);
- INHERIT (to_kill, t);
+ /* Do not inherit to_kill. */
INHERIT (to_load, t);
INHERIT (to_lookup_symbol, t);
/* Do no inherit to_create_inferior. */
/* Do not inherit to_mourn_inferiour. */
INHERIT (to_can_run, t);
INHERIT (to_notice_signals, t);
- INHERIT (to_thread_alive, t);
- INHERIT (to_find_new_threads, t);
+ /* Do not inherit to_thread_alive. */
+ /* Do not inherit to_find_new_threads. */
/* Do not inherit to_pid_to_str. */
INHERIT (to_extra_thread_info, t);
INHERIT (to_stop, t);
de_fault (to_post_attach,
(void (*) (int))
target_ignore);
- de_fault (to_resume,
- (void (*) (ptid_t, int, enum target_signal))
- noprocess);
- de_fault (to_fetch_registers,
- (void (*) (struct regcache *, int))
- target_ignore);
- de_fault (to_store_registers,
- (void (*) (struct regcache *, int))
- noprocess);
de_fault (to_prepare_to_store,
(void (*) (struct regcache *))
noprocess);
target_ignore);
de_fault (to_terminal_info,
default_terminal_info);
- de_fault (to_kill,
- (void (*) (void))
- noprocess);
de_fault (to_load,
(void (*) (char *, int))
tcomplain);
de_fault (to_notice_signals,
(void (*) (ptid_t))
target_ignore);
- de_fault (to_thread_alive,
- (int (*) (ptid_t))
- return_zero);
- de_fault (to_find_new_threads,
- (void (*) (void))
- target_ignore);
de_fault (to_extra_thread_info,
(char *(*) (struct thread_info *))
return_zero);
void
target_resume (ptid_t ptid, int step, enum target_signal signal)
{
+ struct target_ops *t;
+
dcache_invalidate (target_dcache);
- (*current_target.to_resume) (ptid, step, signal);
- set_executing (ptid, 1);
- set_running (ptid, 1);
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_resume != NULL)
+ {
+ t->to_resume (t, ptid, step, signal);
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n",
+ PIDGET (ptid),
+ step ? "step" : "continue",
+ target_signal_to_name (signal));
+
+ set_executing (ptid, 1);
+ set_running (ptid, 1);
+ return;
+ }
+ }
+
+ noprocess ();
}
/* Look through the list of possible targets for a target that can
follow forks. */
t->to_mourn_inferior (t);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
+
+ /* We no longer need to keep handles on any of the object files.
+ Make sure to release them to avoid unnecessarily locking any
+ of them while we're not actually debugging. */
+ bfd_cache_close_all ();
+
return;
}
}
"could not find a target to attach");
}
-static void
-debug_to_post_attach (int pid)
+int
+target_thread_alive (ptid_t ptid)
{
- debug_target.to_post_attach (pid);
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_thread_alive != NULL)
+ {
+ int retval;
- fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
+ retval = t->to_thread_alive (t, ptid);
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
+ PIDGET (ptid), retval);
+
+ return retval;
+ }
+ }
+
+ return 0;
+}
+
+void
+target_find_new_threads (void)
+{
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_find_new_threads != NULL)
+ {
+ t->to_find_new_threads (t);
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_find_new_threads ()\n");
+
+ return;
+ }
+ }
}
static void
-debug_to_resume (ptid_t ptid, int step, enum target_signal siggnal)
+debug_to_post_attach (int pid)
{
- debug_target.to_resume (ptid, step, siggnal);
+ debug_target.to_post_attach (pid);
- fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", PIDGET (ptid),
- step ? "step" : "continue",
- target_signal_to_name (siggnal));
+ fprintf_unfiltered (gdb_stdlog, "target_post_attach (%d)\n", pid);
}
/* Return a pretty printed form of target_waitstatus.
fprintf_unfiltered (gdb_stdlog, "\n");
}
-static void
-debug_to_fetch_registers (struct regcache *regcache, int regno)
+void
+target_fetch_registers (struct regcache *regcache, int regno)
{
- debug_target.to_fetch_registers (regcache, regno);
- debug_print_register ("target_fetch_registers", regcache, regno);
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_fetch_registers != NULL)
+ {
+ t->to_fetch_registers (t, regcache, regno);
+ if (targetdebug)
+ debug_print_register ("target_fetch_registers", regcache, regno);
+ return;
+ }
+ }
}
-static void
-debug_to_store_registers (struct regcache *regcache, int regno)
+void
+target_store_registers (struct regcache *regcache, int regno)
{
- debug_target.to_store_registers (regcache, regno);
- debug_print_register ("target_store_registers", regcache, regno);
- fprintf_unfiltered (gdb_stdlog, "\n");
+
+ struct target_ops *t;
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ {
+ if (t->to_store_registers != NULL)
+ {
+ t->to_store_registers (t, regcache, regno);
+ if (targetdebug)
+ {
+ debug_print_register ("target_store_registers", regcache, regno);
+ }
+ return;
+ }
+ }
+
+ noprocess ();
}
static void
from_tty);
}
-static void
-debug_to_kill (void)
-{
- debug_target.to_kill ();
-
- fprintf_unfiltered (gdb_stdlog, "target_kill ()\n");
-}
-
static void
debug_to_load (char *args, int from_tty)
{
PIDGET (ptid));
}
-static int
-debug_to_thread_alive (ptid_t ptid)
-{
- int retval;
-
- retval = debug_target.to_thread_alive (ptid);
-
- fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
- PIDGET (ptid), retval);
-
- return retval;
-}
-
-static void
-debug_to_find_new_threads (void)
-{
- debug_target.to_find_new_threads ();
-
- fputs_unfiltered ("target_find_new_threads ()\n", gdb_stdlog);
-}
-
static void
debug_to_stop (ptid_t ptid)
{
current_target.to_open = debug_to_open;
current_target.to_post_attach = debug_to_post_attach;
- current_target.to_resume = debug_to_resume;
- current_target.to_fetch_registers = debug_to_fetch_registers;
- current_target.to_store_registers = debug_to_store_registers;
current_target.to_prepare_to_store = debug_to_prepare_to_store;
current_target.deprecated_xfer_memory = deprecated_debug_xfer_memory;
current_target.to_files_info = debug_to_files_info;
current_target.to_terminal_ours = debug_to_terminal_ours;
current_target.to_terminal_save_ours = debug_to_terminal_save_ours;
current_target.to_terminal_info = debug_to_terminal_info;
- current_target.to_kill = debug_to_kill;
current_target.to_load = debug_to_load;
current_target.to_lookup_symbol = debug_to_lookup_symbol;
current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
current_target.to_has_exited = debug_to_has_exited;
current_target.to_can_run = debug_to_can_run;
current_target.to_notice_signals = debug_to_notice_signals;
- current_target.to_thread_alive = debug_to_thread_alive;
- current_target.to_find_new_threads = debug_to_find_new_threads;
current_target.to_stop = debug_to_stop;
current_target.to_rcmd = debug_to_rcmd;
current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;