[all-commits] [llvm/llvm-project] cfd96f: [trace][intel-pt] Implement the basic decoding fun...

walter erquinigo via All-commits all-commits at lists.llvm.org
Thu Nov 5 18:48:09 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: cfd96f057ba4256fef49518cad43d0a7f591da12
      https://github.com/llvm/llvm-project/commit/cfd96f057ba4256fef49518cad43d0a7f591da12
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2020-11-05 (Thu, 05 Nov 2020)

  Changed paths:
    M lldb/include/lldb/Core/Disassembler.h
    M lldb/include/lldb/Symbol/SymbolContext.h
    M lldb/include/lldb/Target/Trace.h
    M lldb/packages/Python/lldbsuite/test/lldbtest.py
    M lldb/source/Commands/CommandObjectThread.cpp
    M lldb/source/Commands/Options.td
    M lldb/source/Core/Disassembler.cpp
    M lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
    A lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
    A lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
    A lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.cpp
    A lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    M lldb/source/Symbol/SymbolContext.cpp
    M lldb/source/Target/ProcessTrace.cpp
    M lldb/source/Target/Trace.cpp
    M lldb/source/Target/TraceSessionFileParser.cpp
    M lldb/test/API/commands/trace/TestTraceDumpInstructions.py
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/a.out
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/bar.cpp
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/bar.h
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/foo.cpp
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/foo.h
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/libbar.so
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/libfoo.so
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/main.cpp
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json
    A lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file.trace
    A lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json
    A lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json

  Log Message:
  -----------
  [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




More information about the All-commits mailing list