Python: Use correct ptid in btrace recording

The user would always get the instruction_history and function_call_history
objects of the current thread, not the thread for which the gdb.Record object
was created.

The attached testcase fails without this patch and passes with the patch.
This commit is contained in:
Tim Wiederhake
2017-05-02 11:35:54 +02:00
parent 8d0050ea19
commit ae20e79ae8
8 changed files with 224 additions and 29 deletions

View File

@@ -1802,11 +1802,17 @@ btrace_fetch (struct thread_info *tp)
if (btinfo->replay != NULL)
return;
/* With CLI usage, TP->PTID always equals INFERIOR_PTID here. Now that we
can store a gdb.Record object in Python referring to a different thread
than the current one, temporarily set INFERIOR_PTID. */
cleanup = save_inferior_ptid ();
inferior_ptid = tp->ptid;
/* We should not be called on running or exited threads. */
gdb_assert (can_access_registers_ptid (tp->ptid));
btrace_data_init (&btrace);
cleanup = make_cleanup_btrace_data (&btrace);
make_cleanup_btrace_data (&btrace);
/* Let's first try to extend the trace we already have. */
if (btinfo->end != NULL)