btrace: temporarily set inferior_ptid in record_btrace_start_replaying

Get_current_frame uses inferior_ptid.  In record_btrace_start_replaying,
we need to get the current frame of the argument thread.  So far, this
has always been inferior_ptid.  With non-stop, this is not guaranteed.

Temporarily set inferior_ptid to the ptid of the argument thread.

We already temporarily set the argument thread's executing flag to false.

Move both into a new function get_thread_current_frame that does the temporary
adjustments, calls get_current_frame, and restores the previous values.

gdb/
	* record-btrace.c (get_thread_current_frame): New.
	(record_btrace_start_replaying): Call get_thread_current_frame.
This commit is contained in:
Markus Metzger 2015-08-26 15:37:55 +02:00
parent 0ca912dfef
commit ec71cc2fc6
2 changed files with 58 additions and 21 deletions

View File

@ -1,3 +1,8 @@
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (get_thread_current_frame): New.
(record_btrace_start_replaying): Call get_thread_current_frame.
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
* record-btrace.c (record_btrace_resume_thread): A move request

View File

@ -1707,21 +1707,18 @@ record_btrace_resume_thread (struct thread_info *tp,
btinfo->flags |= flag;
}
/* Start replaying a thread. */
/* Get the current frame for TP. */
static struct btrace_insn_iterator *
record_btrace_start_replaying (struct thread_info *tp)
static struct frame_info *
get_thread_current_frame (struct thread_info *tp)
{
struct btrace_insn_iterator *replay;
struct btrace_thread_info *btinfo;
struct frame_info *frame;
ptid_t old_inferior_ptid;
int executing;
btinfo = &tp->btrace;
replay = NULL;
/* We can't start replaying without trace. */
if (btinfo->begin == NULL)
return NULL;
/* Set INFERIOR_PTID, which is implicitly used by get_current_frame. */
old_inferior_ptid = inferior_ptid;
inferior_ptid = tp->ptid;
/* Clear the executing flag to allow changes to the current frame.
We are not actually running, yet. We just started a reverse execution
@ -1730,8 +1727,49 @@ record_btrace_start_replaying (struct thread_info *tp)
For the former, EXECUTING is true and we're in to_wait, about to
move the thread. Since we need to recompute the stack, we temporarily
set EXECUTING to flase. */
executing = is_executing (tp->ptid);
set_executing (tp->ptid, 0);
executing = is_executing (inferior_ptid);
set_executing (inferior_ptid, 0);
frame = NULL;
TRY
{
frame = get_current_frame ();
}
CATCH (except, RETURN_MASK_ALL)
{
/* Restore the previous execution state. */
set_executing (inferior_ptid, executing);
/* Restore the previous inferior_ptid. */
inferior_ptid = old_inferior_ptid;
throw_exception (except);
}
END_CATCH
/* Restore the previous execution state. */
set_executing (inferior_ptid, executing);
/* Restore the previous inferior_ptid. */
inferior_ptid = old_inferior_ptid;
return frame;
}
/* Start replaying a thread. */
static struct btrace_insn_iterator *
record_btrace_start_replaying (struct thread_info *tp)
{
struct btrace_insn_iterator *replay;
struct btrace_thread_info *btinfo;
btinfo = &tp->btrace;
replay = NULL;
/* We can't start replaying without trace. */
if (btinfo->begin == NULL)
return NULL;
/* GDB stores the current frame_id when stepping in order to detects steps
into subroutines.
@ -1745,7 +1783,7 @@ record_btrace_start_replaying (struct thread_info *tp)
int upd_step_frame_id, upd_step_stack_frame_id;
/* The current frame without replaying - computed via normal unwind. */
frame = get_current_frame ();
frame = get_thread_current_frame (tp);
frame_id = get_frame_id (frame);
/* Check if we need to update any stepping-related frame id's. */
@ -1777,7 +1815,7 @@ record_btrace_start_replaying (struct thread_info *tp)
registers_changed_ptid (tp->ptid);
/* The current frame with replaying - computed via btrace unwind. */
frame = get_current_frame ();
frame = get_thread_current_frame (tp);
frame_id = get_frame_id (frame);
/* Replace stepping related frames where necessary. */
@ -1788,9 +1826,6 @@ record_btrace_start_replaying (struct thread_info *tp)
}
CATCH (except, RETURN_MASK_ALL)
{
/* Restore the previous execution state. */
set_executing (tp->ptid, executing);
xfree (btinfo->replay);
btinfo->replay = NULL;
@ -1800,9 +1835,6 @@ record_btrace_start_replaying (struct thread_info *tp)
}
END_CATCH
/* Restore the previous execution state. */
set_executing (tp->ptid, executing);
return replay;
}