llvm-project/lldb/source/Commands
Walter Erquinigo cfd96f057b [trace][intel-pt] Implement the basic decoding functionality
Depends on D89408.

This diff finally implements trace decoding!

The current interface is

  $ trace load /path/to/trace/session/file.json
  $ thread trace dump instructions

  thread #1: tid = 3842849, total instructions = 22
    [ 0] 0x40052d
    [ 1] 0x40052d
    ...
    [19] 0x400521

  $ # simply enter, which is a repeat command
    [20] 0x40052d
    [21] 0x400529
    ...

This doesn't do any disassembly, which will be done in the next diff.

Changes:
- Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding.
- Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step.
- Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces.
- Added basic APIs for accessing the trace in Trace.h:
  - GetInstructionCount, which counts the number of instructions traced for a given thread
  - IsTraceFailed, which returns an Error if decoding a thread failed
  - ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do.
- DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible.
- Tests included

Differential Revision: https://reviews.llvm.org/D89283
2020-11-05 18:38:03 -08:00
..
CMakeLists.txt Add a "Trace" plug-in to LLDB to add process trace support in stages. 2020-09-21 17:13:18 -07:00
CommandCompletions.cpp [lldb] type category name common completion 2020-08-24 19:54:23 +02:00
CommandObjectApropos.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
CommandObjectApropos.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectBreakpoint.cpp Add `breakpoint delete --disabled`: deletes all disabled breakpoints. 2020-09-23 11:35:11 -07:00
CommandObjectBreakpoint.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectBreakpointCommand.cpp [lldb/Commands] Fix outdated `breakpoint command add` help string 2020-09-21 10:15:34 -07:00
CommandObjectBreakpointCommand.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectCommands.cpp [lldb] Support Python imports relative the to the current file being sourced 2020-10-27 09:20:45 -07:00
CommandObjectCommands.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectDisassemble.cpp Recommit "[lldb] Don't dissasemble large functions by default" 2020-05-15 11:57:48 +02:00
CommandObjectDisassemble.h Recommit "[lldb] Don't dissasemble large functions by default" 2020-05-15 11:57:48 +02:00
CommandObjectExpression.cpp [lldb/Interpreter] Support color in CommandReturnObject 2020-06-09 10:45:45 -07:00
CommandObjectExpression.h [lldb] Mark expressions that couldn't be parsed or executed as failed expressions 2020-03-23 15:28:17 +01:00
CommandObjectFrame.cpp [lldb] move the frame index completion into a common completion and apply it to `thread backtrace -s` 2020-08-11 12:25:39 +02:00
CommandObjectFrame.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectGUI.cpp Fix typo in error message 2020-05-14 07:23:59 +02:00
CommandObjectGUI.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectHelp.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
CommandObjectHelp.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectLanguage.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
CommandObjectLanguage.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectLog.cpp [lldb] Fixing the bug that the "log timer" has no tab completion 2020-04-09 08:58:52 +02:00
CommandObjectLog.h [lldb] NFC remove DISALLOW_COPY_AND_ASSIGN 2020-06-02 13:23:53 -04:00
CommandObjectMemory.cpp [lldb] Remove [US]IntValueIsValidForSize from CommandObjectMemory 2020-11-04 16:28:10 +01:00
CommandObjectMemory.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectMultiword.cpp [lldb] Remove unnecessary c_str() in OutputFormattedHelpText calls (NFC) 2020-06-12 21:13:21 -07:00
CommandObjectPlatform.cpp [lldb/Target] Add custom interpreter option to `platform shell` 2020-09-02 16:36:10 +02:00
CommandObjectPlatform.h [lldb] NFC remove DISALLOW_COPY_AND_ASSIGN 2020-06-02 13:23:53 -04:00
CommandObjectPlugin.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
CommandObjectPlugin.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectProcess.cpp [lldb] common completion for process pids and process names 2020-08-24 17:30:43 +02:00
CommandObjectProcess.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectQuit.cpp [lldb/interpreter] Fix formatting in CommandInterpreter.cpp (NFC) 2020-07-22 11:48:07 +02:00
CommandObjectQuit.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectRegexCommand.cpp [lldb] Move ScriptCommand and RegexCommand under Commands (NFC) 2020-09-01 17:33:39 -07:00
CommandObjectRegexCommand.h [lldb] Move ScriptCommand and RegexCommand under Commands (NFC) 2020-09-01 17:33:39 -07:00
CommandObjectRegister.cpp tab completion for register read/write 2020-05-07 18:14:27 +02:00
CommandObjectRegister.h [lldb] NFC remove DISALLOW_COPY_AND_ASSIGN 2020-06-02 13:23:53 -04:00
CommandObjectReproducer.cpp [lldb] Move copying of files into reproducer out of process 2020-10-23 12:33:54 -07:00
CommandObjectReproducer.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectScript.cpp [lldb] Add -l/--language option to script command 2020-09-15 09:40:17 -07:00
CommandObjectScript.h [lldb] Add -l/--language option to script command 2020-09-15 09:40:17 -07:00
CommandObjectSession.cpp [lldb/interpreter] Move the history subcommand to session (NFCI) 2020-07-23 13:05:45 +02:00
CommandObjectSession.h [lldb/interpreter] Add ability to save lldb session to a file 2020-07-22 11:43:16 +02:00
CommandObjectSettings.cpp Convert for loops to entry-based iteration 2020-04-02 18:56:29 +02:00
CommandObjectSettings.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectSource.cpp Add an option (-y) to "break set" and "source list" that uses the same 2020-07-20 17:40:36 -07:00
CommandObjectSource.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectStats.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
CommandObjectStats.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectTarget.cpp Revert "Revert "Add the ability to write target stop-hooks using the ScriptInterpreter."" 2020-09-29 12:01:14 -07:00
CommandObjectTarget.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectThread.cpp [trace][intel-pt] Implement the basic decoding functionality 2020-11-05 18:38:03 -08:00
CommandObjectThread.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectTrace.cpp [intel pt] Refactor parsing 2020-10-09 17:32:04 -07:00
CommandObjectTrace.h Add a "Trace" plug-in to LLDB to add process trace support in stages. 2020-09-21 17:13:18 -07:00
CommandObjectType.cpp [lldb] tab completion for class `CommandObjectTypeFormatterDelete` 2020-08-31 14:18:07 +02:00
CommandObjectType.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectVersion.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
CommandObjectVersion.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectWatchpoint.cpp [lldb] watchpoint ID common completion for commands `watchpoint delete/enable/disable/modify/ignore` 2020-08-11 14:25:09 +02:00
CommandObjectWatchpoint.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
CommandObjectWatchpointCommand.cpp [lldb/Interpreter] Support color in CommandReturnObject 2020-06-09 10:45:45 -07:00
CommandObjectWatchpointCommand.h [lldb] Update header guards to be consistent and compliant with LLVM (NFC) 2020-02-17 23:15:40 -08:00
Options.td [trace][intel-pt] Implement the basic decoding functionality 2020-11-05 18:38:03 -08:00
OptionsBase.td [lldb] Don't dynamically allocate the posix option validator. 2019-07-26 11:46:21 +00:00