llvm-project/lldb/source/Core
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
..
Address.cpp [lldb] Switch Section-dumping code to raw_ostream 2020-05-14 11:59:18 +02:00
AddressRange.cpp
AddressResolver.cpp
AddressResolverFileLine.cpp
AddressResolverName.cpp
CMakeLists.txt [CMake] Use find_library for ncurses 2020-08-31 20:06:21 -07:00
Communication.cpp [lldb] Don't use static locals for return value storage in some *AsCString functions 2020-07-30 12:17:42 +02:00
CoreProperties.td [lldb] Display autosuggestion part in gray if there is one possible suggestion 2020-08-14 11:37:49 +02:00
Debugger.cpp [TargetList] Simplify dummy target creation 2020-11-05 16:04:02 -08:00
Disassembler.cpp [trace][intel-pt] Implement the basic decoding functionality 2020-11-05 18:38:03 -08:00
DumpDataExtractor.cpp [lldb] Refactor character printing in DumpDataExtractor 2020-07-14 14:22:03 +02:00
DumpRegisterValue.cpp
DynamicLoader.cpp [lldb] Delete copy operations on PluginInterface class 2020-10-09 10:37:09 +02:00
EmulateInstruction.cpp
FileLineResolver.cpp
FileSpecList.cpp
FormatEntity.cpp
Highlighter.cpp
IOHandler.cpp [lldb] Return FileSP and StreamFileSP by value in IOHandler (NFC) 2020-09-16 21:15:05 -07:00
IOHandlerCursesGUI.cpp [lldb/Gui] zero-initialize children_stop_id 2020-09-02 20:05:17 -07:00
Mangled.cpp [lldb][Core] Remove dead codepath in Mangled 2020-05-26 17:12:20 -07:00
Module.cpp [lldb/Module] Allow for the creation of memory-only modules 2020-07-14 08:45:44 -07:00
ModuleChild.cpp
ModuleList.cpp [lldb] Report old modules from ModuleList::ReplaceEquivalent 2020-10-30 15:14:32 -04:00
Opcode.cpp
PluginManager.cpp [intel pt] Refactor parsing 2020-10-09 17:32:04 -07:00
RichManglingContext.cpp
SearchFilter.cpp [lldb] Remove redundant WithFormat suffixes (NFC) 2020-07-20 23:00:32 -07:00
Section.cpp [lldb][NFC] Overload raw_ostream operator << for ConstString 2020-05-22 11:24:48 +02:00
SourceManager.cpp [lldb] Modernize away some snprintf calls 2020-07-27 14:27:54 +02:00
StreamAsynchronousIO.cpp
StreamFile.cpp
UserSettingsController.cpp
Value.cpp [lldb][NFC] Fix compiler warnings after removal of eValueTypeVector 2020-11-05 17:17:33 +01:00
ValueObject.cpp [lldb] Delete Value::Vector class 2020-11-04 10:21:56 +01:00
ValueObjectCast.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectChild.cpp [lldb][NFC] Fix compiler warnings after removal of eValueTypeVector 2020-11-05 17:17:33 +01:00
ValueObjectConstResult.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectConstResultCast.cpp
ValueObjectConstResultChild.cpp
ValueObjectConstResultImpl.cpp
ValueObjectDynamicValue.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectList.cpp
ValueObjectMemory.cpp [lldb][NFC] Fix compiler warnings after removal of eValueTypeVector 2020-11-05 17:17:33 +01:00
ValueObjectRegister.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectSyntheticFilter.cpp [lldb] Add missings moves where appropiate (NFC) 2020-08-10 21:02:11 -07:00
ValueObjectVariable.cpp [lldb] Delete Value::Vector class 2020-11-04 10:21:56 +01:00