aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Johnson <johnsonjakob99@gmail.com>2022-07-26 12:19:54 -0700
committerJakob Johnson <johnsonjakob99@gmail.com>2022-07-27 05:23:59 -0700
commitdde3cf2e83d2a2aec5b46bdac64efbc28a3b2b20 (patch)
tree88c29cc4035e81a2113c966e710b038851c3f9b5
parent1870a8af15b22b48e6840f9bd6d30b5e3113cb1c (diff)
downloadllvm-dde3cf2e83d2a2aec5b46bdac64efbc28a3b2b20.zip
llvm-dde3cf2e83d2a2aec5b46bdac64efbc28a3b2b20.tar.gz
llvm-dde3cf2e83d2a2aec5b46bdac64efbc28a3b2b20.tar.bz2
[trace] Add instruction control flow kind to JSON trace dumper's output
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" }, ``` Differential Revision: https://reviews.llvm.org/D130607
-rw-r--r--lldb/source/Target/TraceDumper.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp
index 5b71e9e..872530b 100644
--- a/lldb/source/Target/TraceDumper.cpp
+++ b/lldb/source/Target/TraceDumper.cpp
@@ -199,6 +199,7 @@ class OutputWriterJSON : public TraceDumper::OutputWriter {
"column"?: decimal,
"source"?: string,
"mnemonic"?: string,
+ "controlFlowKind"?: string,
}
*/
public:
@@ -234,10 +235,18 @@ public:
"symbol",
ToOptionalString(item.symbol_info->sc.GetFunctionName().AsCString()));
- if (item.symbol_info->instruction) {
+ if (lldb::InstructionSP instruction = item.symbol_info->instruction) {
+ ExecutionContext exe_ctx = item.symbol_info->exe_ctx;
m_j.attribute("mnemonic",
- ToOptionalString(item.symbol_info->instruction->GetMnemonic(
- &item.symbol_info->exe_ctx)));
+ ToOptionalString(instruction->GetMnemonic(&exe_ctx)));
+ if (m_options.show_control_flow_kind) {
+ lldb::InstructionControlFlowKind instruction_control_flow_kind =
+ instruction->GetControlFlowKind(&exe_ctx);
+ m_j.attribute("controlFlowKind",
+ ToOptionalString(
+ Instruction::GetNameForInstructionControlFlowKind(
+ instruction_control_flow_kind)));
+ }
}
if (IsLineEntryValid(item.symbol_info->sc.line_entry)) {