[Lldb-commits] [PATCH] D128316: [trace] Add an option to dump instructions in json and to a file

walter erquinigo via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 21 17:49:55 PDT 2022


wallace created this revision.
wallace added a reviewer: jj10306.
Herald added a project: All.
wallace requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In order to provide simple scripting support on top of instruction traces, a simple solution is to enhance the `dump instructions` command and allow printing in json and directly to a file. The format is verbose and not space efficient, but it's not supposed to be used for really large traces, in which case the TraceCursor API is the way to go.

- add a -j option for printing the dump in json
- add a -J option for pretty printing the json output
- add a -F option for specifying an output file
- add a -a option for dumping all the instructions available starting at the initial point configured with the other flags
- add tests for all cases
- refactored the instruction dumper and abstracted the actual "printing" logic. There are two writer implementations: CLI and JSON. This made the dumper itself much more readable and maintanable

sample output:

  (lldb) thread trace dump instructions  -t -a --id 100 -J
  [
    {
      "id": 100,
      "tsc": "43591204528448966"
      "loadAddress": "0x407a91",
      "module": "a.out",
      "symbol": "void std::deque<Foo, std::allocator<Foo>>::_M_push_back_aux<Foo>(Foo&&)",
      "mnemonic": "movq",
      "source": "/usr/include/c++/8/bits/deque.tcc",
      "line": 492,
      "column": 30
    },
    ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128316

Files:
  lldb/include/lldb/Target/TraceCursor.h
  lldb/include/lldb/Target/TraceInstructionDumper.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
  lldb/source/Target/TraceInstructionDumper.cpp
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceTSC.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128316.438883.patch
Type: text/x-patch
Size: 40778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220622/b7bfd3f4/attachment-0001.bin>


More information about the lldb-commits mailing list