This is an archive of the discontinued LLVM Phabricator instance.

[trace] Add instruction control flow kind to JSON trace dumper's output
ClosedPublic

Authored by jj10306 on Jul 26 2022, 4:26 PM.

Details

Summary

D128477 adds a '-k' flag which displays each instruction's control flow in the thread trace dump instructions command's non-json output (ie no '-j' or '-J' flag)
This diff adds the instruction control flow kind to the thread trace dump instructions command's JSON output (ie '-j' or '-J' flag)

Test Plan:
Confirm "controlFlowKind" is present in JSON when '-k' is provided

(lldb) thread trace dump instructions -J -k
[
  {                                                                                                                                                                                                                                                                                 [141/1952]
    "id": 7755,
    "loadAddress": "0x400868",
    "module": "test.out",
    "symbol": "main",
    "mnemonic": "jmp",
    "controlFlowKind": "jump",
    "source": "/home/jakobjohnson/jakob-dev/test.cpp",
    "line": 41,
    "column": 29
  },
  {
    "id": 7753,
    "loadAddress": "0x7ffff7b54dab",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "retq",
    "controlFlowKind": "return"
  },
  {
    "id": 7752,
    "loadAddress": "0x7ffff7b54daa",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "popq",
    "controlFlowKind": "other"
  },
  ...
]

Confirm "controlFlowKind" is not present when '-k' isn't provided

(lldb) thread trace dump instructions -J
[
  {
    "id": 7755,
    "loadAddress": "0x400868",
    "module": "test.out",
    "symbol": "main",
    "mnemonic": "jmp",
    "source": "/home/jakobjohnson/jakob-dev/test.cpp",
    "line": 41,
    "column": 29
  },
  {
    "id": 7753,
    "loadAddress": "0x7ffff7b54dab",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "retq"
  },
  {
    "id": 7752,
    "loadAddress": "0x7ffff7b54daa",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "popq"
  },

Diff Detail

Event Timeline

jj10306 created this revision.Jul 26 2022, 4:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 4:26 PM
jj10306 requested review of this revision.Jul 26 2022, 4:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2022, 4:26 PM
This revision is now accepted and ready to land.Jul 26 2022, 4:59 PM
wallace accepted this revision.Jul 26 2022, 5:26 PM