diff options
author | Walter Erquinigo <wallace@fb.com> | 2022-06-18 15:44:37 -0700 |
---|---|---|
committer | Walter Erquinigo <wallace@fb.com> | 2022-06-22 11:14:22 -0700 |
commit | efbfde0dd0f92d89767df53cbfb883ecf93ffa83 (patch) | |
tree | b26140b16f9c2561fd6e3bd81ded057aa65f73b8 /llvm/lib/IR/Function.cpp | |
parent | 89a1d03e2b379e325daa5249411e414bbd995b5e (diff) | |
download | llvm-efbfde0dd0f92d89767df53cbfb883ecf93ffa83.zip llvm-efbfde0dd0f92d89767df53cbfb883ecf93ffa83.tar.gz llvm-efbfde0dd0f92d89767df53cbfb883ecf93ffa83.tar.bz2 |
[trace] Add an option to dump instructions in json and to a file
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
},
...
```
Differential Revision: https://reviews.llvm.org/D128316
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
0 files changed, 0 insertions, 0 deletions