From ae20e79ae852fee8f7d42701a54a95de3b79ecea Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Tue, 2 May 2017 11:35:54 +0200 Subject: 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. --- gdb/btrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gdb/btrace.c') diff --git a/gdb/btrace.c b/gdb/btrace.c index 238df0a..3801086 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -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) -- cgit v1.1