[trace][intel-pt] Implement trace start and trace stop
authorWalter Erquinigo <a20012251@gmail.com>
Mon, 9 Nov 2020 21:36:26 +0000 (13:36 -0800)
committerWalter Erquinigo <a20012251@gmail.com>
Wed, 31 Mar 2021 00:31:37 +0000 (17:31 -0700)
commit0b69756110db444282c40ea16929186b2910c3b1
tree328177fba14ef2d43aa597e6274f536d4c44caed
parentc23ee7718ea4f9292622af3d80efe2491eb2a506
[trace][intel-pt] Implement trace start and trace stop

This implements the interactive trace start and stop methods.

This diff ended up being much larger than I anticipated because, by doing it, I found that I had implemented in the beginning many things in a non optimal way. In any case, the code is much better now.

There's a lot of boilerplate code due to the gdb-remote protocol, but the main changes are:

- New tracing packets: jLLDBTraceStop, jLLDBTraceStart, jLLDBTraceGetBinaryData. The gdb-remote packet definitions are quite comprehensive.
- Implementation of the "process trace start|stop" and "thread trace start|stop" commands.
- Implementaiton of an API in Trace.h to interact with live traces.
- Created an IntelPTDecoder for live threads, that use the debugger's stop id as checkpoint for its internal cache.
- Added a functionality to stop the process in case "process tracing" is enabled and a new thread can't traced.
- Added tests

I have some ideas to unify the code paths for post mortem and live threads, but I'll do that in another diff.

Differential Revision: https://reviews.llvm.org/D91679
91 files changed:
lldb/docs/lldb-gdb-remote.txt
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Host/common/NativeProcessProtocol.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/ProcessTrace.h
lldb/include/lldb/Target/StopInfo.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Target/ThreadPostMortemTrace.h [moved from lldb/include/lldb/Target/ThreadTrace.h with 77% similarity]
lldb/include/lldb/Target/Trace.h
lldb/include/lldb/Target/TraceSessionFileParser.h
lldb/include/lldb/Utility/StringExtractorGDBRemote.h
lldb/include/lldb/Utility/TraceGDBRemotePackets.h [new file with mode: 0644]
lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h [new file with mode: 0644]
lldb/include/lldb/Utility/TraceOptions.h
lldb/include/lldb/lldb-enumerations.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBThread.cpp
lldb/source/API/SBTrace.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/CommandObjectThreadUtil.cpp
lldb/source/Commands/CommandObjectThreadUtil.h
lldb/source/Commands/CommandObjectTrace.cpp
lldb/source/Commands/CommandObjectTrace.h
lldb/source/Core/PluginManager.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/Process/Linux/CMakeLists.txt
lldb/source/Plugins/Process/Linux/IntelPTManager.cpp [new file with mode: 0644]
lldb/source/Plugins/Process/Linux/IntelPTManager.h [new file with mode: 0644]
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
lldb/source/Plugins/Process/Linux/ProcessorTrace.cpp [deleted file]
lldb/source/Plugins/Process/Linux/ProcessorTrace.h [deleted file]
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.h
lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.cpp
lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionFileParser.h
lldb/source/Plugins/Trace/intel-pt/forward-declarations.h [new file with mode: 0644]
lldb/source/Target/CMakeLists.txt
lldb/source/Target/Process.cpp
lldb/source/Target/ProcessTrace.cpp
lldb/source/Target/StopInfo.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadPostMortemTrace.cpp [moved from lldb/source/Target/ThreadTrace.cpp with 65% similarity]
lldb/source/Target/Trace.cpp
lldb/source/Target/TraceSessionFileParser.cpp
lldb/source/Utility/CMakeLists.txt
lldb/source/Utility/StringExtractorGDBRemote.cpp
lldb/source/Utility/TraceGDBRemotePackets.cpp [new file with mode: 0644]
lldb/source/Utility/TraceIntelPTGDBRemotePackets.cpp [new file with mode: 0644]
lldb/source/Utility/TraceOptions.cpp [deleted file]
lldb/test/API/commands/trace/TestTraceLoad.py
lldb/test/API/commands/trace/TestTraceSchema.py
lldb/test/API/commands/trace/TestTraceStartStop.py
lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json
lldb/test/API/commands/trace/intelpt-trace/trace.json
lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad4.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad5.json
lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json
lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json
lldb/test/API/commands/trace/multiple-threads/Makefile [new file with mode: 0644]
lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py [new file with mode: 0644]
lldb/test/API/commands/trace/multiple-threads/main.cpp [new file with mode: 0644]
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/LLDBUtils.cpp
lldb/unittests/Process/Linux/CMakeLists.txt
lldb/unittests/Process/Linux/IntelPTManagerTests.cpp [moved from lldb/unittests/Process/Linux/ProcessorTraceTest.cpp with 96% similarity]
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp