target, record: add PTID argument to to_record_is_replaying

The to_record_is_replaying target method is used to query record targets if
they are replaying.  This is currently interpreted as "is any thread being
replayed".

Add a PTID argument and change the interpretation to "is any thread matching
PTID being replayed".

Change all users to pass minus_one_ptid to preserve the old meaning.

The record full target does not really support multi-threading and ignores
the PTID argument.

gdb/
	* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
	Update users to pass minus_one_ptid.
	* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
	* record.c (cmd_record_delete): Pass inferior_ptid to
	target_record_is_replaying.
	* target-delegates.c: Regenerated.
	* target.c (target_record_is_replaying): Add ptid argument.
	* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
	argument.
	(target_record_is_replaying): Add ptid argument.
This commit is contained in:
Markus Metzger 2015-09-08 08:26:16 +02:00
parent cbb55fa7a1
commit a52eab4808
7 changed files with 46 additions and 26 deletions

View File

@ -1,3 +1,16 @@
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (record_btrace_is_replaying): Add ptid argument.
Update users to pass minus_one_ptid.
* record-full.c (record_full_is_replaying): Add ptid argument (ignored).
* record.c (cmd_record_delete): Pass inferior_ptid to
target_record_is_replaying.
* target-delegates.c: Regenerated.
* target.c (target_record_is_replaying): Add ptid argument.
* target.h (struct target_ops) <to_record_is_replaying>: Add ptid
argument.
(target_record_is_replaying): Add ptid argument.
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (record_btrace_open): Remove non_stop check.

View File

@ -1136,12 +1136,12 @@ record_btrace_call_history_from (struct target_ops *self,
/* The to_record_is_replaying method of target record-btrace. */
static int
record_btrace_is_replaying (struct target_ops *self)
record_btrace_is_replaying (struct target_ops *self, ptid_t ptid)
{
struct thread_info *tp;
ALL_NON_EXITED_THREADS (tp)
if (btrace_is_replaying (tp))
if (ptid_match (tp->ptid, ptid) && btrace_is_replaying (tp))
return 1;
return 0;
@ -1160,7 +1160,7 @@ record_btrace_xfer_partial (struct target_ops *ops, enum target_object object,
/* Filter out requests that don't make sense during replay. */
if (replay_memory_access == replay_memory_access_read_only
&& !record_btrace_generating_corefile
&& record_btrace_is_replaying (ops))
&& record_btrace_is_replaying (ops, minus_one_ptid))
{
switch (object)
{
@ -1313,7 +1313,8 @@ record_btrace_store_registers (struct target_ops *ops,
{
struct target_ops *t;
if (!record_btrace_generating_corefile && record_btrace_is_replaying (ops))
if (!record_btrace_generating_corefile
&& record_btrace_is_replaying (ops, minus_one_ptid))
error (_("This record target does not allow writing registers."));
gdb_assert (may_write_registers != 0);
@ -1330,7 +1331,8 @@ record_btrace_prepare_to_store (struct target_ops *ops,
{
struct target_ops *t;
if (!record_btrace_generating_corefile && record_btrace_is_replaying (ops))
if (!record_btrace_generating_corefile
&& record_btrace_is_replaying (ops, minus_one_ptid))
return;
t = ops->beneath;
@ -1917,7 +1919,8 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
For non-stop targets this means that no thread is replaying. In order to
make progress, we may need to explicitly move replaying threads to the end
of their execution history. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
if ((execution_direction != EXEC_REVERSE)
&& !record_btrace_is_replaying (ops, minus_one_ptid))
{
ops = ops->beneath;
return ops->to_resume (ops, orig_ptid, step, signal);
@ -2273,7 +2276,8 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
DEBUG ("wait %s (0x%x)", target_pid_to_str (ptid), options);
/* As long as we're not replaying, just forward the request. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
if ((execution_direction != EXEC_REVERSE)
&& !record_btrace_is_replaying (ops, minus_one_ptid))
{
ops = ops->beneath;
return ops->to_wait (ops, ptid, status, options);
@ -2401,7 +2405,8 @@ record_btrace_stop (struct target_ops *ops, ptid_t ptid)
DEBUG ("stop %s", target_pid_to_str (ptid));
/* As long as we're not replaying, just forward the request. */
if (!record_btrace_is_replaying (ops) && execution_direction != EXEC_REVERSE)
if ((execution_direction != EXEC_REVERSE)
&& !record_btrace_is_replaying (ops, minus_one_ptid))
{
ops = ops->beneath;
ops->to_stop (ops, ptid);
@ -2432,7 +2437,7 @@ record_btrace_can_execute_reverse (struct target_ops *self)
static int
record_btrace_stopped_by_sw_breakpoint (struct target_ops *ops)
{
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
{
struct thread_info *tp = inferior_thread ();
@ -2448,7 +2453,7 @@ record_btrace_stopped_by_sw_breakpoint (struct target_ops *ops)
static int
record_btrace_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
{
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
return 1;
return ops->beneath->to_supports_stopped_by_sw_breakpoint (ops->beneath);
@ -2459,7 +2464,7 @@ record_btrace_supports_stopped_by_sw_breakpoint (struct target_ops *ops)
static int
record_btrace_stopped_by_hw_breakpoint (struct target_ops *ops)
{
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
{
struct thread_info *tp = inferior_thread ();
@ -2475,7 +2480,7 @@ record_btrace_stopped_by_hw_breakpoint (struct target_ops *ops)
static int
record_btrace_supports_stopped_by_hw_breakpoint (struct target_ops *ops)
{
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
return 1;
return ops->beneath->to_supports_stopped_by_hw_breakpoint (ops->beneath);
@ -2487,7 +2492,7 @@ static void
record_btrace_update_thread_list (struct target_ops *ops)
{
/* We don't add or remove threads during replay. */
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
return;
/* Forward the request. */
@ -2501,7 +2506,7 @@ static int
record_btrace_thread_alive (struct target_ops *ops, ptid_t ptid)
{
/* We don't add or remove threads during replay. */
if (record_btrace_is_replaying (ops))
if (record_btrace_is_replaying (ops, minus_one_ptid))
return find_thread_ptid (ptid) != NULL;
/* Forward the request. */

View File

@ -1840,7 +1840,7 @@ record_full_delete (struct target_ops *self)
/* The "to_record_is_replaying" target method. */
static int
record_full_is_replaying (struct target_ops *self)
record_full_is_replaying (struct target_ops *self, ptid_t ptid)
{
return RECORD_FULL_IS_REPLAY;
}

View File

@ -234,7 +234,7 @@ cmd_record_delete (char *args, int from_tty)
{
require_record_target ();
if (!target_record_is_replaying ())
if (!target_record_is_replaying (inferior_ptid))
{
printf_unfiltered (_("Already at end of record list.\n"));
return;

View File

@ -3602,26 +3602,28 @@ debug_delete_record (struct target_ops *self)
}
static int
delegate_record_is_replaying (struct target_ops *self)
delegate_record_is_replaying (struct target_ops *self, ptid_t arg1)
{
self = self->beneath;
return self->to_record_is_replaying (self);
return self->to_record_is_replaying (self, arg1);
}
static int
tdefault_record_is_replaying (struct target_ops *self)
tdefault_record_is_replaying (struct target_ops *self, ptid_t arg1)
{
return 0;
}
static int
debug_record_is_replaying (struct target_ops *self)
debug_record_is_replaying (struct target_ops *self, ptid_t arg1)
{
int result;
fprintf_unfiltered (gdb_stdlog, "-> %s->to_record_is_replaying (...)\n", debug_target.to_shortname);
result = debug_target.to_record_is_replaying (&debug_target);
result = debug_target.to_record_is_replaying (&debug_target, arg1);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_record_is_replaying (", debug_target.to_shortname);
target_debug_print_struct_target_ops_p (&debug_target);
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_ptid_t (arg1);
fputs_unfiltered (") = ", gdb_stdlog);
target_debug_print_int (result);
fputs_unfiltered ("\n", gdb_stdlog);

View File

@ -3656,9 +3656,9 @@ target_delete_record (void)
/* See target.h. */
int
target_record_is_replaying (void)
target_record_is_replaying (ptid_t ptid)
{
return current_target.to_record_is_replaying (&current_target);
return current_target.to_record_is_replaying (&current_target, ptid);
}
/* See target.h. */

View File

@ -1153,8 +1153,8 @@ struct target_ops
void (*to_delete_record) (struct target_ops *)
TARGET_DEFAULT_NORETURN (tcomplain ());
/* Query if the record target is currently replaying. */
int (*to_record_is_replaying) (struct target_ops *)
/* Query if the record target is currently replaying PTID. */
int (*to_record_is_replaying) (struct target_ops *, ptid_t ptid)
TARGET_DEFAULT_RETURN (0);
/* Go to the begin of the execution trace. */
@ -2440,7 +2440,7 @@ extern int target_supports_delete_record (void);
extern void target_delete_record (void);
/* See to_record_is_replaying in struct target_ops. */
extern int target_record_is_replaying (void);
extern int target_record_is_replaying (ptid_t ptid);
/* See to_goto_record_begin in struct target_ops. */
extern void target_goto_record_begin (void);