diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -185,6 +185,8 @@ void Target::DeleteCurrentProcess() { if (m_process_sp) { + // We dispose any active tracing sessions on the current process + m_trace_sp.reset(); m_section_load_history.Clear(); if (m_process_sp->IsAlive()) m_process_sp->Destroy(false); diff --git a/lldb/test/API/commands/trace/TestTraceStartStop.py b/lldb/test/API/commands/trace/TestTraceStartStop.py --- a/lldb/test/API/commands/trace/TestTraceStartStop.py +++ b/lldb/test/API/commands/trace/TestTraceStartStop.py @@ -166,3 +166,13 @@ self.expect("thread trace stop", error=True, substrs=["error: Process must be launched"]) + + # We should be able to trace the program if we relaunch it + self.expect("r") + self.expect("thread trace start") + # We can reconstruct the single instruction executed in the first line + self.expect("n") + self.expect("thread trace dump instructions -f", + patterns=[f'''thread #1: tid = .* + a.out`main \+ 4 at main.cpp:2 + \[ 0\] {ADDRESS_REGEX} movl'''])