diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index c50e11b..4a57b51 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1281,9 +1281,8 @@ record_btrace_start_replaying (struct thread_info *tp) { struct btrace_thread_info *btinfo; struct btrace_insn_iterator *replay; - const struct btrace_insn *insn; - struct symtab_and_line sal; - struct frame_info *frame; + volatile struct gdb_exception except; + int executing; btinfo = &tp->btrace; @@ -1291,24 +1290,50 @@ record_btrace_start_replaying (struct thread_info *tp) if (btinfo->begin == NULL) return NULL; - /* We start replaying at the end of the branch trace. This corresponds to the - current instruction. */ - replay = xmalloc (sizeof (*replay)); - btrace_insn_end (replay, btinfo); + executing = is_executing (tp->ptid); + TRY_CATCH (except, RETURN_MASK_ALL) + { + int update_step_frame_id, update_step_stack_frame_id; + struct frame_id frame_id; - /* We're not replaying, yet. */ - gdb_assert (btinfo->replay == NULL); - btinfo->replay = replay; + /* We start replaying at the end of the branch trace. This corresponds to the + current instruction. */ + replay = xmalloc (sizeof (*replay)); + btrace_insn_end (replay, btinfo); - /* Make sure we're not using any stale registers. */ - registers_changed_ptid (tp->ptid); + if (executing) + { + /* get_current_frame would error out otherwise. */ + set_executing (tp->ptid, 0); + } + + frame_id = get_frame_id (get_current_frame ()); - /* We just started replaying. The frame id cached for stepping is based - on unwinding, not on branch tracing. Recompute it. */ - frame = get_current_frame_nocheck (); - insn = btrace_insn_get (replay); - sal = find_pc_line (insn->pc, 0); - set_step_info (frame, sal); + update_step_frame_id = frame_id_eq (frame_id, tp->control.step_frame_id); + update_step_stack_frame_id = frame_id_eq (frame_id, + tp->control.step_stack_frame_id); + + /* We're not replaying, yet. */ + gdb_assert (btinfo->replay == NULL); + btinfo->replay = replay; + + /* Make sure we're not using any stale registers. */ + registers_changed_ptid (tp->ptid); + + /* We just started replaying. The frame id cached for stepping is based + on unwinding, not on branch tracing. Recompute it. */ + + frame_id = get_frame_id (get_current_frame ()); + + if (update_step_frame_id) + tp->control.step_frame_id = frame_id; + if (update_step_stack_frame_id) + tp->control.step_stack_frame_id = frame_id; + } + if (executing) + set_executing (tp->ptid, 1); + if (except.reason < 0) + throw_exception (except); return replay; }