[trace] clear any existing tracing sessions before relaunching the binary
authorWalter Erquinigo <wallace@fb.com>
Mon, 21 Mar 2022 20:26:57 +0000 (13:26 -0700)
committerWalter Erquinigo <wallace@fb.com>
Mon, 21 Mar 2022 23:03:37 +0000 (16:03 -0700)
commita80c6c7d36d25999a28cfad32e1f461db95ba4dc
tree5a14fc589b676bc0a9cb7c1fe93e840fb2f2e241
parent31e44c01e3b5cc2cc7a9f1dc49806b3f050efb82
[trace] clear any existing tracing sessions before relaunching the binary

There's a bug caused when a process is relaunched: the target, which
doesn't change, keeps the Trace object from the previous process, which
is already defunct, and causes segmentation faults when it's attempted
to be used.
A fix is to clean up the Trace object when the target is disposing of
the previous process during relaunches.

A way to reproduce this:
```
lldb a.out
b main
r
process trace start
c
r
process trace start
```

Differential Revision: https://reviews.llvm.org/D122176
lldb/source/Target/Target.cpp
lldb/test/API/commands/trace/TestTraceStartStop.py