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:
parent
0ca912dfef
commit
ec71cc2fc6
|
@ -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>
|
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
|
||||||
|
|
||||||
* record-btrace.c (record_btrace_resume_thread): A move request
|
* record-btrace.c (record_btrace_resume_thread): A move request
|
||||||
|
|
|
@ -1707,21 +1707,18 @@ record_btrace_resume_thread (struct thread_info *tp,
|
||||||
btinfo->flags |= flag;
|
btinfo->flags |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start replaying a thread. */
|
/* Get the current frame for TP. */
|
||||||
|
|
||||||
static struct btrace_insn_iterator *
|
static struct frame_info *
|
||||||
record_btrace_start_replaying (struct thread_info *tp)
|
get_thread_current_frame (struct thread_info *tp)
|
||||||
{
|
{
|
||||||
struct btrace_insn_iterator *replay;
|
struct frame_info *frame;
|
||||||
struct btrace_thread_info *btinfo;
|
ptid_t old_inferior_ptid;
|
||||||
int executing;
|
int executing;
|
||||||
|
|
||||||
btinfo = &tp->btrace;
|
/* Set INFERIOR_PTID, which is implicitly used by get_current_frame. */
|
||||||
replay = NULL;
|
old_inferior_ptid = inferior_ptid;
|
||||||
|
inferior_ptid = tp->ptid;
|
||||||
/* We can't start replaying without trace. */
|
|
||||||
if (btinfo->begin == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Clear the executing flag to allow changes to the current frame.
|
/* Clear the executing flag to allow changes to the current frame.
|
||||||
We are not actually running, yet. We just started a reverse execution
|
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
|
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
|
move the thread. Since we need to recompute the stack, we temporarily
|
||||||
set EXECUTING to flase. */
|
set EXECUTING to flase. */
|
||||||
executing = is_executing (tp->ptid);
|
executing = is_executing (inferior_ptid);
|
||||||
set_executing (tp->ptid, 0);
|
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
|
/* GDB stores the current frame_id when stepping in order to detects steps
|
||||||
into subroutines.
|
into subroutines.
|
||||||
|
@ -1745,7 +1783,7 @@ record_btrace_start_replaying (struct thread_info *tp)
|
||||||
int upd_step_frame_id, upd_step_stack_frame_id;
|
int upd_step_frame_id, upd_step_stack_frame_id;
|
||||||
|
|
||||||
/* The current frame without replaying - computed via normal unwind. */
|
/* 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);
|
frame_id = get_frame_id (frame);
|
||||||
|
|
||||||
/* Check if we need to update any stepping-related frame id's. */
|
/* 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);
|
registers_changed_ptid (tp->ptid);
|
||||||
|
|
||||||
/* The current frame with replaying - computed via btrace unwind. */
|
/* 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);
|
frame_id = get_frame_id (frame);
|
||||||
|
|
||||||
/* Replace stepping related frames where necessary. */
|
/* Replace stepping related frames where necessary. */
|
||||||
|
@ -1788,9 +1826,6 @@ record_btrace_start_replaying (struct thread_info *tp)
|
||||||
}
|
}
|
||||||
CATCH (except, RETURN_MASK_ALL)
|
CATCH (except, RETURN_MASK_ALL)
|
||||||
{
|
{
|
||||||
/* Restore the previous execution state. */
|
|
||||||
set_executing (tp->ptid, executing);
|
|
||||||
|
|
||||||
xfree (btinfo->replay);
|
xfree (btinfo->replay);
|
||||||
btinfo->replay = NULL;
|
btinfo->replay = NULL;
|
||||||
|
|
||||||
|
@ -1800,9 +1835,6 @@ record_btrace_start_replaying (struct thread_info *tp)
|
||||||
}
|
}
|
||||||
END_CATCH
|
END_CATCH
|
||||||
|
|
||||||
/* Restore the previous execution state. */
|
|
||||||
set_executing (tp->ptid, executing);
|
|
||||||
|
|
||||||
return replay;
|
return replay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue