Commit
b60cea7 (Make target_wait options use enum flags) broke
deprecated_target_wait_hook usage: there's a commit comment telling
this hook has not been converted.
Rather than trying to mend it, this patch replaces the hook by two
target_wait observers:
target_pre_wait (ptid_t ptid)
target_post_wait (ptid_t event_ptid)
Upon target_wait entry, target_pre_wait is notified with the ptid
passed to target_wait. Upon exit, target_post_wait is notified with
the event ptid returned by target_wait. Should an exception occur,
event_ptid is null_ptid.
This change benefits to Insight (out-of-tree): there's no real use of the
late hook in gdb itself.
static bool stop_print_frame;
/* This is a cached copy of the target/ptid/waitstatus of the last
- event returned by target_wait()/deprecated_target_wait_hook().
+ event returned by target_wait().
This information is returned by get_last_target_status(). */
static process_stratum_target *target_last_proc_target;
static ptid_t target_last_wait_ptid;
do_target_wait_1 (inferior *inf, ptid_t ptid,
target_waitstatus *status, target_wait_flags options)
{
- ptid_t event_ptid;
struct thread_info *tp;
/* We know that we are looking for an event in the target of inferior
if (!target_can_async_p ())
options &= ~TARGET_WNOHANG;
- if (deprecated_target_wait_hook)
- event_ptid = deprecated_target_wait_hook (ptid, status, options);
- else
- event_ptid = target_wait (ptid, status, options);
-
- return event_ptid;
+ return target_wait (ptid, status, options);
}
/* Wrapper for target_wait that first checks whether threads have
don't get any event. */
target_dcache_invalidate ();
- if (deprecated_target_wait_hook)
- event_ptid = deprecated_target_wait_hook (minus_one_ptid, ws, TARGET_WNOHANG);
- else
- event_ptid = target_wait (minus_one_ptid, ws, TARGET_WNOHANG);
+ event_ptid = target_wait (minus_one_ptid, ws, TARGET_WNOHANG);
if (debug_infrun)
print_target_wait_results (minus_one_ptid, event_ptid, *ws);
extern int normal_stop (void);
/* Return the cached copy of the last target/ptid/waitstatus returned
- by target_wait()/deprecated_target_wait_hook(). The data is
- actually cached by handle_inferior_event(), which gets called
- immediately after target_wait()/deprecated_target_wait_hook(). */
+ by target_wait(). The data is actually cached by handle_inferior_event(),
+ which gets called immediately after target_wait(). */
extern void get_last_target_status (process_stratum_target **target,
ptid_t *ptid,
struct target_waitstatus *status);
deprecated_readline_hook = 0;
deprecated_readline_end_hook = 0;
deprecated_context_hook = 0;
- deprecated_target_wait_hook = 0;
deprecated_call_command_hook = 0;
deprecated_error_begin_hook = 0;
}
DEFINE_OBSERVABLE (current_source_symtab_and_line_changed);
DEFINE_OBSERVABLE (gdb_exiting);
DEFINE_OBSERVABLE (connection_removed);
+DEFINE_OBSERVABLE (target_pre_wait);
+DEFINE_OBSERVABLE (target_post_wait);
} /* namespace observers */
} /* namespace gdb */
/* When a connection is removed. */
extern observable<process_stratum_target */* target */> connection_removed;
+/* About to enter target_wait (). */
+extern observable <ptid_t /* ptid */> target_pre_wait;
+
+/* About to leave target_wait (). */
+extern observable <ptid_t /* event_ptid */> target_post_wait;
+
} /* namespace observers */
} /* namespace gdb */
#include "symtab.h"
#include "inferior.h"
#include "infrun.h"
+#include "observable.h"
#include "bfd.h"
#include "symfile.h"
#include "objfiles.h"
if (!target_can_async_p (target))
gdb_assert ((options & TARGET_WNOHANG) == 0);
- return target->wait (ptid, status, options);
+ try
+ {
+ gdb::observers::target_pre_wait.notify (ptid);
+ ptid_t event_ptid = target->wait (ptid, status, options);
+ gdb::observers::target_post_wait.notify (event_ptid);
+ return event_ptid;
+ }
+ catch (...)
+ {
+ gdb::observers::target_post_wait.notify (null_ptid);
+ throw;
+ }
}
/* See target.h. */
void (*deprecated_attach_hook) (void);
void (*deprecated_detach_hook) (void);
-/* Called when going to wait for the target. Usually allows the GUI
- to run while waiting for target events. */
-
-ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
- struct target_waitstatus *status,
- int options);
-
/* Used by UI as a wrapper around command execution. May do various
things like enabling/disabling buttons, etc... */