diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h --- a/lldb/include/lldb/Core/Disassembler.h +++ b/lldb/include/lldb/Core/Disassembler.h @@ -223,6 +223,9 @@ virtual bool IsCall() { return false; } + static const char *GetNameForInstructionControlFlowKind( + lldb::InstructionControlFlowKind instruction_control_flow_kind); + protected: Address m_address; // The section offset address of this instruction // We include an address class in the Instruction class to diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -972,6 +972,8 @@ /// control flow of a trace. /// /// A single instruction can match one or more of these categories. +/// The enum -> string conversion is in Disassembler.cpp, don't change +/// this enum without updating that code as well. enum InstructionControlFlowKind { /// The instruction could not be classified. eInstructionControlFlowKindUnknown = 0, diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -905,6 +905,30 @@ return m_address_class; } +const char *Instruction::GetNameForInstructionControlFlowKind( + lldb::InstructionControlFlowKind instruction_control_flow_kind) { + switch (instruction_control_flow_kind) { + case eInstructionControlFlowKindUnknown: + return "unknown"; + case eInstructionControlFlowKindOther: + return "other"; + case eInstructionControlFlowKindCall: + return "call"; + case eInstructionControlFlowKindReturn: + return "return"; + case eInstructionControlFlowKindJump: + return "jump"; + case eInstructionControlFlowKindCondJump: + return "cond jump"; + case eInstructionControlFlowKindFarCall: + return "far call"; + case eInstructionControlFlowKindFarReturn: + return "far return"; + case eInstructionControlFlowKindFarJump: + return "far jump"; + } +} + void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size, bool show_address, bool show_bytes, bool show_control_flow_kind, @@ -946,35 +970,10 @@ } if (show_control_flow_kind) { - switch (GetControlFlowKind(exe_ctx->GetTargetRef().GetArchitecture())) { - case eInstructionControlFlowKindUnknown: - ss.Printf("%-12s", "unknown"); - break; - case eInstructionControlFlowKindOther: - ss.Printf("%-12s", "other"); - break; - case eInstructionControlFlowKindCall: - ss.Printf("%-12s", "call"); - break; - case eInstructionControlFlowKindReturn: - ss.Printf("%-12s", "return"); - break; - case eInstructionControlFlowKindJump: - ss.Printf("%-12s", "jump"); - break; - case eInstructionControlFlowKindCondJump: - ss.Printf("%-12s", "cond jump"); - break; - case eInstructionControlFlowKindFarCall: - ss.Printf("%-12s", "far call"); - break; - case eInstructionControlFlowKindFarReturn: - ss.Printf("%-12s", "far return"); - break; - case eInstructionControlFlowKindFarJump: - ss.Printf("%-12s", "far jump"); - break; - } + lldb::InstructionControlFlowKind instruction_control_flow_kind = + GetControlFlowKind(exe_ctx->GetTargetRef().GetArchitecture()); + ss.Printf("%-12s", GetNameForInstructionControlFlowKind( + instruction_control_flow_kind)); } const size_t opcode_pos = ss.GetSizeOfLastLine(); diff --git a/lldb/source/Target/TraceDumper.cpp b/lldb/source/Target/TraceDumper.cpp --- a/lldb/source/Target/TraceDumper.cpp +++ b/lldb/source/Target/TraceDumper.cpp @@ -218,6 +218,11 @@ m_j.attribute("mnemonic", ToOptionalString(item.symbol_info->instruction->GetMnemonic( &item.symbol_info->exe_ctx))); + + m_j.attribute( + "mnemonic", + ToOptionalString(item.symbol_info->instruction->GetMnemonic( + &item.symbol_info->exe_ctx))); } if (IsLineEntryValid(item.symbol_info->sc.line_entry)) {