[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h (original)
+++ lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h Tue Sep 6 15:57:50 2016
@@ -16,81 +16,65 @@
#include "lldb/Core/Opcode.h"
class EmulationStateARM {
-public:
-
- EmulationStateARM ();
-
- virtual
- ~EmulationStateARM ();
-
- bool
- StorePseudoRegisterValue (uint32_t reg_num, uint64_t value);
-
- uint64_t
- ReadPseudoRegisterValue (uint32_t reg_num, bool &success);
-
- bool
- StoreToPseudoAddress (lldb::addr_t p_address, uint32_t value);
-
- uint32_t
- ReadFromPseudoAddress (lldb::addr_t p_address, bool &success);
-
- void
- ClearPseudoRegisters ();
-
- void
- ClearPseudoMemory ();
-
- bool
- LoadPseudoRegistersFromFrame (lldb_private::StackFrame &frame);
-
- bool
- LoadStateFromDictionary (lldb_private::OptionValueDictionary *test_data);
+public:
+ EmulationStateARM();
- bool
- CompareState (EmulationStateARM &other_state);
+ virtual ~EmulationStateARM();
- static size_t
- ReadPseudoMemory (lldb_private::EmulateInstruction *instruction,
+ bool StorePseudoRegisterValue(uint32_t reg_num, uint64_t value);
+
+ uint64_t ReadPseudoRegisterValue(uint32_t reg_num, bool &success);
+
+ bool StoreToPseudoAddress(lldb::addr_t p_address, uint32_t value);
+
+ uint32_t ReadFromPseudoAddress(lldb::addr_t p_address, bool &success);
+
+ void ClearPseudoRegisters();
+
+ void ClearPseudoMemory();
+
+ bool LoadPseudoRegistersFromFrame(lldb_private::StackFrame &frame);
+
+ bool LoadStateFromDictionary(lldb_private::OptionValueDictionary *test_data);
+
+ bool CompareState(EmulationStateARM &other_state);
+
+ static size_t
+ ReadPseudoMemory(lldb_private::EmulateInstruction *instruction, void *baton,
+ const lldb_private::EmulateInstruction::Context &context,
+ lldb::addr_t addr, void *dst, size_t length);
+
+ static size_t
+ WritePseudoMemory(lldb_private::EmulateInstruction *instruction, void *baton,
+ const lldb_private::EmulateInstruction::Context &context,
+ lldb::addr_t addr, const void *dst, size_t length);
+
+ static bool ReadPseudoRegister(lldb_private::EmulateInstruction *instruction,
+ void *baton,
+ const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value);
+
+ static bool
+ WritePseudoRegister(lldb_private::EmulateInstruction *instruction,
void *baton,
const lldb_private::EmulateInstruction::Context &context,
- lldb::addr_t addr,
- void *dst,
- size_t length);
-
- static size_t
- WritePseudoMemory (lldb_private::EmulateInstruction *instruction,
- void *baton,
- const lldb_private::EmulateInstruction::Context &context,
- lldb::addr_t addr,
- const void *dst,
- size_t length);
-
- static bool
- ReadPseudoRegister (lldb_private::EmulateInstruction *instruction,
- void *baton,
- const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue ®_value);
-
- static bool
- WritePseudoRegister (lldb_private::EmulateInstruction *instruction,
- void *baton,
- const lldb_private::EmulateInstruction::Context &context,
- const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue ®_value);
+ const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value);
+
private:
- uint32_t m_gpr[17];
- struct _sd_regs
- {
- uint32_t s_regs[32]; // sregs 0 - 31 & dregs 0 - 15
-
- uint64_t d_regs[16]; // dregs 16-31
-
- } m_vfp_regs;
-
- std::map<lldb::addr_t, uint32_t> m_memory; // Eventually will want to change uint32_t to a data buffer heap type.
-
- DISALLOW_COPY_AND_ASSIGN (EmulationStateARM);
+ uint32_t m_gpr[17];
+ struct _sd_regs {
+ uint32_t s_regs[32]; // sregs 0 - 31 & dregs 0 - 15
+
+ uint64_t d_regs[16]; // dregs 16-31
+
+ } m_vfp_regs;
+
+ std::map<lldb::addr_t, uint32_t> m_memory; // Eventually will want to change
+ // uint32_t to a data buffer heap
+ // type.
+
+ DISALLOW_COPY_AND_ASSIGN(EmulationStateARM);
};
-#endif // lldb_EmulationStateARM_h_
+#endif // lldb_EmulationStateARM_h_
Modified: lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- EmulateInstructionARM64.cpp -------------------------------*- C++ -*-===//
+//===-- EmulateInstructionARM64.cpp -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,8 +12,8 @@
#include <stdlib.h>
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Address.h"
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h"
@@ -31,15 +32,15 @@
using namespace lldb;
using namespace lldb_private;
-#define No_VFP 0
-#define VFPv1 (1u << 1)
-#define VFPv2 (1u << 2)
-#define VFPv3 (1u << 3)
+#define No_VFP 0
+#define VFPv1 (1u << 1)
+#define VFPv2 (1u << 2)
+#define VFPv3 (1u << 3)
#define AdvancedSIMD (1u << 4)
#define VFPv1_ABOVE (VFPv1 | VFPv2 | VFPv3 | AdvancedSIMD)
#define VFPv2_ABOVE (VFPv2 | VFPv3 | AdvancedSIMD)
-#define VFPv2v3 (VFPv2 | VFPv3)
+#define VFPv2v3 (VFPv2 | VFPv3)
#define UInt(x) ((uint64_t)x)
#define SInt(x) ((int64_t)x)
@@ -47,17 +48,9 @@ using namespace lldb_private;
#define boolean bool
#define integer int64_t
-static inline bool
-IsZero(uint64_t x)
-{
- return x == 0;
-}
+static inline bool IsZero(uint64_t x) { return x == 0; }
-static inline uint64_t
-NOT(uint64_t x)
-{
- return ~x;
-}
+static inline uint64_t NOT(uint64_t x) { return ~x; }
#if 0
// LSL_C()
@@ -75,354 +68,447 @@ LSL_C (uint64_t x, integer shift, bool &
// LSL()
// =====
-static inline uint64_t
-LSL(uint64_t x, integer shift)
-{
- if (shift == 0)
- return x;
- return x << shift;
+static inline uint64_t LSL(uint64_t x, integer shift) {
+ if (shift == 0)
+ return x;
+ return x << shift;
}
// AddWithCarry()
// ===============
static inline uint64_t
-AddWithCarry (uint32_t N, uint64_t x, uint64_t y, bit carry_in, EmulateInstructionARM64::ProcState &proc_state)
-{
- uint64_t unsigned_sum = UInt(x) + UInt(y) + UInt(carry_in);
- int64_t signed_sum = SInt(x) + SInt(y) + UInt(carry_in);
- uint64_t result = unsigned_sum;
- if (N < 64)
- result = Bits64 (result, N-1, 0);
- proc_state.N = Bit64(result, N-1);
- proc_state.Z = IsZero(result);
- proc_state.C = UInt(result) == unsigned_sum;
- proc_state.V = SInt(result) == signed_sum;
- return result;
+AddWithCarry(uint32_t N, uint64_t x, uint64_t y, bit carry_in,
+ EmulateInstructionARM64::ProcState &proc_state) {
+ uint64_t unsigned_sum = UInt(x) + UInt(y) + UInt(carry_in);
+ int64_t signed_sum = SInt(x) + SInt(y) + UInt(carry_in);
+ uint64_t result = unsigned_sum;
+ if (N < 64)
+ result = Bits64(result, N - 1, 0);
+ proc_state.N = Bit64(result, N - 1);
+ proc_state.Z = IsZero(result);
+ proc_state.C = UInt(result) == unsigned_sum;
+ proc_state.V = SInt(result) == signed_sum;
+ return result;
}
// ConstrainUnpredictable()
// ========================
EmulateInstructionARM64::ConstraintType
-ConstrainUnpredictable (EmulateInstructionARM64::Unpredictable which)
-{
- EmulateInstructionARM64::ConstraintType result = EmulateInstructionARM64::Constraint_UNKNOWN;
- switch (which)
- {
- case EmulateInstructionARM64::Unpredictable_WBOVERLAP:
- case EmulateInstructionARM64::Unpredictable_LDPOVERLAP:
- // TODO: don't know what to really do here? Pseudo code says:
- // set result to one of above Constraint behaviours or UNDEFINED
- break;
- }
- return result;
+ConstrainUnpredictable(EmulateInstructionARM64::Unpredictable which) {
+ EmulateInstructionARM64::ConstraintType result =
+ EmulateInstructionARM64::Constraint_UNKNOWN;
+ switch (which) {
+ case EmulateInstructionARM64::Unpredictable_WBOVERLAP:
+ case EmulateInstructionARM64::Unpredictable_LDPOVERLAP:
+ // TODO: don't know what to really do here? Pseudo code says:
+ // set result to one of above Constraint behaviours or UNDEFINED
+ break;
+ }
+ return result;
}
-
-
//----------------------------------------------------------------------
//
// EmulateInstructionARM implementation
//
//----------------------------------------------------------------------
-void
-EmulateInstructionARM64::Initialize ()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic (),
- GetPluginDescriptionStatic (),
- CreateInstance);
+void EmulateInstructionARM64::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
}
-void
-EmulateInstructionARM64::Terminate ()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
+void EmulateInstructionARM64::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-ConstString
-EmulateInstructionARM64::GetPluginNameStatic ()
-{
- ConstString g_plugin_name ("lldb.emulate-instruction.arm64");
- return g_plugin_name;
+ConstString EmulateInstructionARM64::GetPluginNameStatic() {
+ ConstString g_plugin_name("lldb.emulate-instruction.arm64");
+ return g_plugin_name;
}
-lldb_private::ConstString
-EmulateInstructionARM64::GetPluginName()
-{
- static ConstString g_plugin_name ("EmulateInstructionARM64");
- return g_plugin_name;
+lldb_private::ConstString EmulateInstructionARM64::GetPluginName() {
+ static ConstString g_plugin_name("EmulateInstructionARM64");
+ return g_plugin_name;
}
-const char *
-EmulateInstructionARM64::GetPluginDescriptionStatic ()
-{
- return "Emulate instructions for the ARM64 architecture.";
+const char *EmulateInstructionARM64::GetPluginDescriptionStatic() {
+ return "Emulate instructions for the ARM64 architecture.";
}
EmulateInstruction *
-EmulateInstructionARM64::CreateInstance (const ArchSpec &arch, InstructionType inst_type)
-{
- if (EmulateInstructionARM64::SupportsEmulatingInstructionsOfTypeStatic(inst_type))
- {
- if (arch.GetTriple().getArch() == llvm::Triple::aarch64)
- {
- std::auto_ptr<EmulateInstructionARM64> emulate_insn_ap (new EmulateInstructionARM64 (arch));
- if (emulate_insn_ap.get())
- return emulate_insn_ap.release();
- }
+EmulateInstructionARM64::CreateInstance(const ArchSpec &arch,
+ InstructionType inst_type) {
+ if (EmulateInstructionARM64::SupportsEmulatingInstructionsOfTypeStatic(
+ inst_type)) {
+ if (arch.GetTriple().getArch() == llvm::Triple::aarch64) {
+ std::auto_ptr<EmulateInstructionARM64> emulate_insn_ap(
+ new EmulateInstructionARM64(arch));
+ if (emulate_insn_ap.get())
+ return emulate_insn_ap.release();
}
-
- return NULL;
+ }
+
+ return NULL;
}
-bool
-EmulateInstructionARM64::SetTargetTriple (const ArchSpec &arch)
-{
- if (arch.GetTriple().getArch () == llvm::Triple::arm)
- return true;
- else if (arch.GetTriple().getArch () == llvm::Triple::thumb)
- return true;
+bool EmulateInstructionARM64::SetTargetTriple(const ArchSpec &arch) {
+ if (arch.GetTriple().getArch() == llvm::Triple::arm)
+ return true;
+ else if (arch.GetTriple().getArch() == llvm::Triple::thumb)
+ return true;
- return false;
+ return false;
}
-bool
-EmulateInstructionARM64::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo ®_info)
-{
- if (reg_kind == eRegisterKindGeneric)
- {
- switch (reg_num)
- {
- case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = arm64_dwarf::pc; break;
- case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = arm64_dwarf::sp; break;
- case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = arm64_dwarf::fp; break;
- case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = arm64_dwarf::lr; break;
- case LLDB_REGNUM_GENERIC_FLAGS:
- // There is no DWARF register number for the CPSR right now...
- reg_info.name = "cpsr";
- reg_info.alt_name = NULL;
- reg_info.byte_size = 4;
- reg_info.byte_offset = 0;
- reg_info.encoding = eEncodingUint;
- reg_info.format = eFormatHex;
- for (uint32_t i=0; i<lldb::kNumRegisterKinds; ++i)
- reg_info.kinds[reg_kind] = LLDB_INVALID_REGNUM;
- reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
- return true;
-
- default: return false;
- }
- }
-
- if (reg_kind == eRegisterKindDWARF)
- return arm64_dwarf::GetRegisterInfo(reg_num, reg_info);
+bool EmulateInstructionARM64::GetRegisterInfo(RegisterKind reg_kind,
+ uint32_t reg_num,
+ RegisterInfo ®_info) {
+ if (reg_kind == eRegisterKindGeneric) {
+ switch (reg_num) {
+ case LLDB_REGNUM_GENERIC_PC:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = arm64_dwarf::pc;
+ break;
+ case LLDB_REGNUM_GENERIC_SP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = arm64_dwarf::sp;
+ break;
+ case LLDB_REGNUM_GENERIC_FP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = arm64_dwarf::fp;
+ break;
+ case LLDB_REGNUM_GENERIC_RA:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = arm64_dwarf::lr;
+ break;
+ case LLDB_REGNUM_GENERIC_FLAGS:
+ // There is no DWARF register number for the CPSR right now...
+ reg_info.name = "cpsr";
+ reg_info.alt_name = NULL;
+ reg_info.byte_size = 4;
+ reg_info.byte_offset = 0;
+ reg_info.encoding = eEncodingUint;
+ reg_info.format = eFormatHex;
+ for (uint32_t i = 0; i < lldb::kNumRegisterKinds; ++i)
+ reg_info.kinds[reg_kind] = LLDB_INVALID_REGNUM;
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ if (reg_kind == eRegisterKindDWARF)
+ return arm64_dwarf::GetRegisterInfo(reg_num, reg_info);
+ return false;
+}
+
+EmulateInstructionARM64::Opcode *
+EmulateInstructionARM64::GetOpcodeForInstruction(const uint32_t opcode) {
+ static EmulateInstructionARM64::Opcode g_opcodes[] = {
+ //----------------------------------------------------------------------
+ // Prologue instructions
+ //----------------------------------------------------------------------
+
+ // push register(s)
+ {0xff000000, 0xd1000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "SUB <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}"},
+ {0xff000000, 0xf1000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "SUBS <Xd>, <Xn|SP>, #<imm> {, <shift>}"},
+ {0xff000000, 0x91000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "ADD <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}"},
+ {0xff000000, 0xb1000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "ADDS <Xd>, <Xn|SP>, #<imm> {, <shift>}"},
+
+ {0xff000000, 0x51000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "SUB <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}"},
+ {0xff000000, 0x71000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "SUBS <Wd>, <Wn|WSP>, #<imm> {, <shift>}"},
+ {0xff000000, 0x11000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "ADD <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}"},
+ {0xff000000, 0x31000000, No_VFP,
+ &EmulateInstructionARM64::EmulateADDSUBImm,
+ "ADDS <Wd>, <Wn|WSP>, #<imm> {, <shift>}"},
+
+ {0xffc00000, 0x29000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "STP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0xa9000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "STP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0x2d000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "STP <St>, <St2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0x6d000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "STP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0xad000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "STP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]"},
+
+ {0xffc00000, 0x29800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xa9800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x2d800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "STP <St>, <St2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x6d800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xad800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!"},
+
+ {0xffc00000, 0x28800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xa8800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x2c800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "STP <St>, <St2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x6c800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xac800000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!"},
+
+ {0xffc00000, 0x29400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "LDP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0xa9400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "LDP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0x2d400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "LDP <St>, <St2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0x6d400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "LDP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]"},
+ {0xffc00000, 0xad400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>,
+ "LDP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]"},
+
+ {0xffc00000, 0x29c00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xa9c00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x2dc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x6dc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xadc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>,
+ "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!"},
+
+ {0xffc00000, 0x28c00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xa8c00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x2cc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0x6cc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!"},
+ {0xffc00000, 0xacc00000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>,
+ "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!"},
+
+ {0xffe00c00, 0xb8000400, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>,
+ "STR <Wt>, [<Xn|SP>], #<simm>"},
+ {0xffe00c00, 0xf8000400, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>,
+ "STR <Xt>, [<Xn|SP>], #<simm>"},
+ {0xffe00c00, 0xb8000c00, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>,
+ "STR <Wt>, [<Xn|SP>, #<simm>]!"},
+ {0xffe00c00, 0xf8000c00, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>,
+ "STR <Xt>, [<Xn|SP>, #<simm>]!"},
+ {0xffc00000, 0xb9000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>,
+ "STR <Wt>, [<Xn|SP>{, #<pimm>}]"},
+ {0xffc00000, 0xf9000000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>,
+ "STR <Xt>, [<Xn|SP>{, #<pimm>}]"},
+
+ {0xffe00c00, 0xb8400400, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>,
+ "LDR <Wt>, [<Xn|SP>], #<simm>"},
+ {0xffe00c00, 0xf8400400, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>,
+ "LDR <Xt>, [<Xn|SP>], #<simm>"},
+ {0xffe00c00, 0xb8400c00, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>,
+ "LDR <Wt>, [<Xn|SP>, #<simm>]!"},
+ {0xffe00c00, 0xf8400c00, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>,
+ "LDR <Xt>, [<Xn|SP>, #<simm>]!"},
+ {0xffc00000, 0xb9400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>,
+ "LDR <Wt>, [<Xn|SP>{, #<pimm>}]"},
+ {0xffc00000, 0xf9400000, No_VFP,
+ &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>,
+ "LDR <Xt>, [<Xn|SP>{, #<pimm>}]"},
+
+ {0xfc000000, 0x14000000, No_VFP, &EmulateInstructionARM64::EmulateB,
+ "B <label>"},
+ {0xff000010, 0x54000000, No_VFP, &EmulateInstructionARM64::EmulateBcond,
+ "B.<cond> <label>"},
+ {0x7f000000, 0x34000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ,
+ "CBZ <Wt>, <label>"},
+ {0x7f000000, 0x35000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ,
+ "CBNZ <Wt>, <label>"},
+ {0x7f000000, 0x36000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ,
+ "TBZ <R><t>, #<imm>, <label>"},
+ {0x7f000000, 0x37000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ,
+ "TBNZ <R><t>, #<imm>, <label>"},
+
+ };
+ static const size_t k_num_arm_opcodes = llvm::array_lengthof(g_opcodes);
+
+ for (size_t i = 0; i < k_num_arm_opcodes; ++i) {
+ if ((g_opcodes[i].mask & opcode) == g_opcodes[i].value)
+ return &g_opcodes[i];
+ }
+ return nullptr;
+}
+
+bool EmulateInstructionARM64::ReadInstruction() {
+ bool success = false;
+ m_addr = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC,
+ LLDB_INVALID_ADDRESS, &success);
+ if (success) {
+ Context read_inst_context;
+ read_inst_context.type = eContextReadOpcode;
+ read_inst_context.SetNoArgs();
+ m_opcode.SetOpcode32(
+ ReadMemoryUnsigned(read_inst_context, m_addr, 4, 0, &success),
+ GetByteOrder());
+ }
+ if (!success)
+ m_addr = LLDB_INVALID_ADDRESS;
+ return success;
+}
+
+bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) {
+ const uint32_t opcode = m_opcode.GetOpcode32();
+ Opcode *opcode_data = GetOpcodeForInstruction(opcode);
+ if (opcode_data == NULL)
return false;
-}
-EmulateInstructionARM64::Opcode*
-EmulateInstructionARM64::GetOpcodeForInstruction (const uint32_t opcode)
-{
- static EmulateInstructionARM64::Opcode
- g_opcodes[] =
- {
- //----------------------------------------------------------------------
- // Prologue instructions
- //----------------------------------------------------------------------
-
- // push register(s)
- { 0xff000000, 0xd1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUB <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0xf1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUBS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x91000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADD <Xd|SP>, <Xn|SP>, #<imm> {, <shift>}" },
- { 0xff000000, 0xb1000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADDS <Xd>, <Xn|SP>, #<imm> {, <shift>}" },
-
- { 0xff000000, 0x51000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUB <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x71000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "SUBS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x11000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADD <Wd|WSP>, <Wn|WSP>, #<imm> {, <shift>}" },
- { 0xff000000, 0x31000000, No_VFP, &EmulateInstructionARM64::EmulateADDSUBImm, "ADDS <Wd>, <Wn|WSP>, #<imm> {, <shift>}" },
-
- { 0xffc00000, 0x29000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xa9000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x2d000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x6d000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xad000000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "STP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
-
- { 0xffc00000, 0x29800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa9800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2d800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6d800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xad800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x28800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa8800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2c800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6c800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xac800000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "STP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x29400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Wt>, <Wt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xa9400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Xt>, <Xt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x2d400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <St>, <St2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0x6d400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Dt>, <Dt2>, [<Xn|SP>{, #<imm>}]" },
- { 0xffc00000, 0xad400000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_OFF>, "LDP <Qt>, <Qt2>, [<Xn|SP>{, #<imm>}]" },
-
- { 0xffc00000, 0x29c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa9c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2dc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6dc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xadc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_PRE>, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffc00000, 0x28c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Wt>, <Wt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xa8c00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Xt>, <Xt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x2cc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <St>, <St2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0x6cc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Dt>, <Dt2>, [<Xn|SP>, #<imm>]!" },
- { 0xffc00000, 0xacc00000, No_VFP, &EmulateInstructionARM64::EmulateLDPSTP<AddrMode_POST>, "LDP <Qt>, <Qt2>, [<Xn|SP>, #<imm>]!" },
-
- { 0xffe00c00, 0xb8000400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "STR <Wt>, [<Xn|SP>], #<simm>" },
- { 0xffe00c00, 0xf8000400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "STR <Xt>, [<Xn|SP>], #<simm>" },
- { 0xffe00c00, 0xb8000c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "STR <Wt>, [<Xn|SP>, #<simm>]!" },
- { 0xffe00c00, 0xf8000c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "STR <Xt>, [<Xn|SP>, #<simm>]!" },
- { 0xffc00000, 0xb9000000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "STR <Wt>, [<Xn|SP>{, #<pimm>}]" },
- { 0xffc00000, 0xf9000000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "STR <Xt>, [<Xn|SP>{, #<pimm>}]" },
-
- { 0xffe00c00, 0xb8400400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "LDR <Wt>, [<Xn|SP>], #<simm>" },
- { 0xffe00c00, 0xf8400400, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_POST>, "LDR <Xt>, [<Xn|SP>], #<simm>" },
- { 0xffe00c00, 0xb8400c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "LDR <Wt>, [<Xn|SP>, #<simm>]!" },
- { 0xffe00c00, 0xf8400c00, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_PRE>, "LDR <Xt>, [<Xn|SP>, #<simm>]!" },
- { 0xffc00000, 0xb9400000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "LDR <Wt>, [<Xn|SP>{, #<pimm>}]" },
- { 0xffc00000, 0xf9400000, No_VFP, &EmulateInstructionARM64::EmulateLDRSTRImm<AddrMode_OFF>, "LDR <Xt>, [<Xn|SP>{, #<pimm>}]" },
-
- { 0xfc000000, 0x14000000, No_VFP, &EmulateInstructionARM64::EmulateB, "B <label>" },
- { 0xff000010, 0x54000000, No_VFP, &EmulateInstructionARM64::EmulateBcond, "B.<cond> <label>" },
- { 0x7f000000, 0x34000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBZ <Wt>, <label>" },
- { 0x7f000000, 0x35000000, No_VFP, &EmulateInstructionARM64::EmulateCBZ, "CBNZ <Wt>, <label>" },
- { 0x7f000000, 0x36000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBZ <R><t>, #<imm>, <label>" },
- { 0x7f000000, 0x37000000, No_VFP, &EmulateInstructionARM64::EmulateTBZ, "TBNZ <R><t>, #<imm>, <label>" },
-
- };
- static const size_t k_num_arm_opcodes = llvm::array_lengthof(g_opcodes);
-
- for (size_t i=0; i<k_num_arm_opcodes; ++i)
- {
- if ((g_opcodes[i].mask & opcode) == g_opcodes[i].value)
- return &g_opcodes[i];
- }
- return nullptr;
-}
+ // printf ("opcode template for 0x%8.8x: %s\n", opcode, opcode_data->name);
+ const bool auto_advance_pc =
+ evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
+ m_ignore_conditions =
+ evaluate_options & eEmulateInstructionOptionIgnoreConditions;
+
+ bool success = false;
+ // if (m_opcode_cpsr == 0 || m_ignore_conditions == false)
+ // {
+ // m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindGeneric,
+ // // use eRegisterKindDWARF is we ever get a cpsr DWARF register
+ // number
+ // LLDB_REGNUM_GENERIC_FLAGS,
+ // // use arm64_dwarf::cpsr if we
+ // ever get one
+ // 0,
+ // &success);
+ // }
+
+ // Only return false if we are unable to read the CPSR if we care about
+ // conditions
+ if (success == false && m_ignore_conditions == false)
+ return false;
-bool
-EmulateInstructionARM64::ReadInstruction ()
-{
- bool success = false;
- m_addr = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success);
- if (success)
- {
- Context read_inst_context;
- read_inst_context.type = eContextReadOpcode;
- read_inst_context.SetNoArgs ();
- m_opcode.SetOpcode32 (ReadMemoryUnsigned (read_inst_context, m_addr, 4, 0, &success), GetByteOrder());
- }
+ uint32_t orig_pc_value = 0;
+ if (auto_advance_pc) {
+ orig_pc_value =
+ ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::pc, 0, &success);
if (!success)
- m_addr = LLDB_INVALID_ADDRESS;
- return success;
-}
+ return false;
+ }
+ // Call the Emulate... function.
+ success = (this->*opcode_data->callback)(opcode);
+ if (!success)
+ return false;
-bool
-EmulateInstructionARM64::EvaluateInstruction (uint32_t evaluate_options)
-{
- const uint32_t opcode = m_opcode.GetOpcode32();
- Opcode *opcode_data = GetOpcodeForInstruction(opcode);
- if (opcode_data == NULL)
- return false;
-
- //printf ("opcode template for 0x%8.8x: %s\n", opcode, opcode_data->name);
- const bool auto_advance_pc = evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
- m_ignore_conditions = evaluate_options & eEmulateInstructionOptionIgnoreConditions;
-
- bool success = false;
-// if (m_opcode_cpsr == 0 || m_ignore_conditions == false)
-// {
-// m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindGeneric, // use eRegisterKindDWARF is we ever get a cpsr DWARF register number
-// LLDB_REGNUM_GENERIC_FLAGS, // use arm64_dwarf::cpsr if we ever get one
-// 0,
-// &success);
-// }
+ if (auto_advance_pc) {
+ uint32_t new_pc_value =
+ ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::pc, 0, &success);
+ if (!success)
+ return false;
- // Only return false if we are unable to read the CPSR if we care about conditions
- if (success == false && m_ignore_conditions == false)
+ if (auto_advance_pc && (new_pc_value == orig_pc_value)) {
+ EmulateInstruction::Context context;
+ context.type = eContextAdvancePC;
+ context.SetNoArgs();
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, arm64_dwarf::pc,
+ orig_pc_value + 4))
return false;
-
- uint32_t orig_pc_value = 0;
- if (auto_advance_pc)
- {
- orig_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::pc, 0, &success);
- if (!success)
- return false;
}
-
- // Call the Emulate... function.
- success = (this->*opcode_data->callback) (opcode);
- if (!success)
- return false;
-
- if (auto_advance_pc)
- {
- uint32_t new_pc_value = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::pc, 0, &success);
- if (!success)
- return false;
-
- if (auto_advance_pc && (new_pc_value == orig_pc_value))
- {
- EmulateInstruction::Context context;
- context.type = eContextAdvancePC;
- context.SetNoArgs();
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, arm64_dwarf::pc, orig_pc_value + 4))
- return false;
- }
- }
- return true;
+ }
+ return true;
}
-bool
-EmulateInstructionARM64::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
-{
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind (eRegisterKindDWARF);
+bool EmulateInstructionARM64::CreateFunctionEntryUnwind(
+ UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
- UnwindPlan::RowSP row(new UnwindPlan::Row);
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
- // Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(arm64_dwarf::sp, 0);
+ // Our previous Call Frame Address is the stack pointer
+ row->GetCFAValue().SetIsRegisterPlusOffset(arm64_dwarf::sp, 0);
- unwind_plan.AppendRow (row);
- unwind_plan.SetSourceName ("EmulateInstructionARM64");
- unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolYes);
- unwind_plan.SetReturnAddressRegister (arm64_dwarf::lr);
- return true;
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName("EmulateInstructionARM64");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolYes);
+ unwind_plan.SetReturnAddressRegister(arm64_dwarf::lr);
+ return true;
}
-uint32_t
-EmulateInstructionARM64::GetFramePointerRegisterNumber () const
-{
- if (m_arch.GetTriple().isAndroid())
- return LLDB_INVALID_REGNUM; // Don't use frame pointer on android
+uint32_t EmulateInstructionARM64::GetFramePointerRegisterNumber() const {
+ if (m_arch.GetTriple().isAndroid())
+ return LLDB_INVALID_REGNUM; // Don't use frame pointer on android
- return arm64_dwarf::sp;
+ return arm64_dwarf::sp;
}
-bool
-EmulateInstructionARM64::UsingAArch32()
-{
- bool aarch32 = m_opcode_pstate.RW == 1;
- // if !HaveAnyAArch32() then assert !aarch32;
- // if HighestELUsingAArch32() then assert aarch32;
- return aarch32;
+bool EmulateInstructionARM64::UsingAArch32() {
+ bool aarch32 = m_opcode_pstate.RW == 1;
+ // if !HaveAnyAArch32() then assert !aarch32;
+ // if HighestELUsingAArch32() then assert aarch32;
+ return aarch32;
}
-bool
-EmulateInstructionARM64::BranchTo (const Context &context, uint32_t N, addr_t target)
-{
+bool EmulateInstructionARM64::BranchTo(const Context &context, uint32_t N,
+ addr_t target) {
#if 0
// Set program counter to a new address, with a branch reason hint
// for possible use by hardware fetching the next instruction.
@@ -450,603 +536,577 @@ EmulateInstructionARM64::BranchTo (const
return;
#endif
- addr_t addr;
-
- //Hint_Branch(branch_type);
- if (N == 32)
- {
- if (!UsingAArch32())
- return false;
- addr = target;
- }
- else if (N == 64)
- {
- if (UsingAArch32())
- return false;
- // TODO: Remove the tag bits from a tagged target
- addr = target;
- }
- else
- return false;
-
- if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, addr))
- return false;
+ addr_t addr;
- return true;
-}
-
-bool
-EmulateInstructionARM64::ConditionHolds (const uint32_t cond)
-{
- // If we are ignoring conditions, then always return true.
- // this allows us to iterate over disassembly code and still
- // emulate an instruction even if we don't have all the right
- // bits set in the CPSR register...
- if (m_ignore_conditions)
- return true;
+ // Hint_Branch(branch_type);
+ if (N == 32) {
+ if (!UsingAArch32())
+ return false;
+ addr = target;
+ } else if (N == 64) {
+ if (UsingAArch32())
+ return false;
+ // TODO: Remove the tag bits from a tagged target
+ addr = target;
+ } else
+ return false;
- bool result = false;
- switch (UnsignedBits(cond, 3, 1))
- {
- case 0:
- result = (m_opcode_pstate.Z == 1);
- break;
- case 1:
- result = (m_opcode_pstate.C == 1);
- break;
- case 2:
- result = (m_opcode_pstate.N == 1);
- break;
- case 3:
- result = (m_opcode_pstate.V == 1);
- break;
- case 4:
- result = (m_opcode_pstate.C == 1 && m_opcode_pstate.Z == 0);
- break;
- case 5:
- result = (m_opcode_pstate.N == m_opcode_pstate.V);
- break;
- case 6:
- result = (m_opcode_pstate.N == m_opcode_pstate.V && m_opcode_pstate.Z == 0);
- break;
- case 7:
- // Always execute (cond == 0b1110, or the special 0b1111 which gives
- // opcodes different meanings, but always means execution happens.
- return true;
- }
+ if (!WriteRegisterUnsigned(context, eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC, addr))
+ return false;
- if (cond & 1)
- result = !result;
- return result;
+ return true;
}
-bool
-EmulateInstructionARM64::EmulateADDSUBImm (const uint32_t opcode)
-{
- // integer d = UInt(Rd);
- // integer n = UInt(Rn);
- // integer datasize = if sf == 1 then 64 else 32;
- // boolean sub_op = (op == 1);
- // boolean setflags = (S == 1);
- // bits(datasize) imm;
- //
- // case shift of
- // when '00' imm = ZeroExtend(imm12, datasize);
- // when '01' imm = ZeroExtend(imm12 : Zeros(12), datasize);
- // when '1x' UNDEFINED;
- //
- //
- // bits(datasize) result;
- // bits(datasize) operand1 = if n == 31 then SP[] else X[n];
- // bits(datasize) operand2 = imm;
- // bits(4) nzcv;
- // bit carry_in;
- //
- // if sub_op then
- // operand2 = NOT(operand2);
- // carry_in = 1;
- // else
- // carry_in = 0;
- //
- // (result, nzcv) = AddWithCarry(operand1, operand2, carry_in);
- //
- // if setflags then
- // PSTATE.NZCV = nzcv;
- //
- // if d == 31 && !setflags then
- // SP[] = result;
- // else
- // X[d] = result;
-
- const uint32_t sf = Bit32(opcode, 31);
- const uint32_t op = Bit32(opcode, 30);
- const uint32_t S = Bit32(opcode, 29);
- const uint32_t shift = Bits32(opcode, 23, 22);
- const uint32_t imm12 = Bits32(opcode, 21, 10);
- const uint32_t Rn = Bits32(opcode, 9, 5);
- const uint32_t Rd = Bits32(opcode, 4, 0);
-
- bool success = false;
-
- const uint32_t d = UInt(Rd);
- const uint32_t n = UInt(Rn);
- const uint32_t datasize = (sf == 1) ? 64 : 32;
- boolean sub_op = op == 1;
- boolean setflags = S == 1;
- uint64_t imm;
-
- switch (shift)
- {
- case 0: imm = imm12; break;
- case 1: imm = imm12 << 12; break;
- default: return false; // UNDEFINED;
- }
- uint64_t result;
- uint64_t operand1 = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::x0 + n, 0, &success);
- uint64_t operand2 = imm;
- bit carry_in;
-
- if (sub_op)
- {
- operand2 = NOT(operand2);
- carry_in = 1;
- imm = -imm; // For the Register plug offset context below
- }
- else
- {
- carry_in = 0;
- }
-
- ProcState proc_state;
-
- result = AddWithCarry (datasize, operand1, operand2, carry_in, proc_state);
-
- if (setflags)
- {
- m_emulated_pstate.N = proc_state.N;
- m_emulated_pstate.Z = proc_state.Z;
- m_emulated_pstate.C = proc_state.C;
- m_emulated_pstate.V = proc_state.V;
- }
-
- Context context;
- RegisterInfo reg_info_Rn;
- if (arm64_dwarf::GetRegisterInfo (n, reg_info_Rn))
- context.SetRegisterPlusOffset (reg_info_Rn, imm);
-
- if ((n == arm64_dwarf::sp || n == GetFramePointerRegisterNumber()) &&
- d == arm64_dwarf::sp &&
- !setflags)
- {
- context.type = EmulateInstruction::eContextAdjustStackPointer;
- }
- else if (d == GetFramePointerRegisterNumber() &&
- n == arm64_dwarf::sp &&
- !setflags)
- {
- context.type = EmulateInstruction::eContextSetFramePointer;
- }
- else
- {
- context.type = EmulateInstruction::eContextImmediate;
- }
+bool EmulateInstructionARM64::ConditionHolds(const uint32_t cond) {
+ // If we are ignoring conditions, then always return true.
+ // this allows us to iterate over disassembly code and still
+ // emulate an instruction even if we don't have all the right
+ // bits set in the CPSR register...
+ if (m_ignore_conditions)
+ return true;
- // If setflags && d == arm64_dwarf::sp then d = WZR/XZR. See CMN, CMP
- if (!setflags || d != arm64_dwarf::sp)
- WriteRegisterUnsigned (context, eRegisterKindDWARF, arm64_dwarf::x0 + d, result);
+ bool result = false;
+ switch (UnsignedBits(cond, 3, 1)) {
+ case 0:
+ result = (m_opcode_pstate.Z == 1);
+ break;
+ case 1:
+ result = (m_opcode_pstate.C == 1);
+ break;
+ case 2:
+ result = (m_opcode_pstate.N == 1);
+ break;
+ case 3:
+ result = (m_opcode_pstate.V == 1);
+ break;
+ case 4:
+ result = (m_opcode_pstate.C == 1 && m_opcode_pstate.Z == 0);
+ break;
+ case 5:
+ result = (m_opcode_pstate.N == m_opcode_pstate.V);
+ break;
+ case 6:
+ result = (m_opcode_pstate.N == m_opcode_pstate.V && m_opcode_pstate.Z == 0);
+ break;
+ case 7:
+ // Always execute (cond == 0b1110, or the special 0b1111 which gives
+ // opcodes different meanings, but always means execution happens.
+ return true;
+ }
+ if (cond & 1)
+ result = !result;
+ return result;
+}
+
+bool EmulateInstructionARM64::EmulateADDSUBImm(const uint32_t opcode) {
+ // integer d = UInt(Rd);
+ // integer n = UInt(Rn);
+ // integer datasize = if sf == 1 then 64 else 32;
+ // boolean sub_op = (op == 1);
+ // boolean setflags = (S == 1);
+ // bits(datasize) imm;
+ //
+ // case shift of
+ // when '00' imm = ZeroExtend(imm12, datasize);
+ // when '01' imm = ZeroExtend(imm12 : Zeros(12), datasize);
+ // when '1x' UNDEFINED;
+ //
+ //
+ // bits(datasize) result;
+ // bits(datasize) operand1 = if n == 31 then SP[] else X[n];
+ // bits(datasize) operand2 = imm;
+ // bits(4) nzcv;
+ // bit carry_in;
+ //
+ // if sub_op then
+ // operand2 = NOT(operand2);
+ // carry_in = 1;
+ // else
+ // carry_in = 0;
+ //
+ // (result, nzcv) = AddWithCarry(operand1, operand2, carry_in);
+ //
+ // if setflags then
+ // PSTATE.NZCV = nzcv;
+ //
+ // if d == 31 && !setflags then
+ // SP[] = result;
+ // else
+ // X[d] = result;
+
+ const uint32_t sf = Bit32(opcode, 31);
+ const uint32_t op = Bit32(opcode, 30);
+ const uint32_t S = Bit32(opcode, 29);
+ const uint32_t shift = Bits32(opcode, 23, 22);
+ const uint32_t imm12 = Bits32(opcode, 21, 10);
+ const uint32_t Rn = Bits32(opcode, 9, 5);
+ const uint32_t Rd = Bits32(opcode, 4, 0);
+
+ bool success = false;
+
+ const uint32_t d = UInt(Rd);
+ const uint32_t n = UInt(Rn);
+ const uint32_t datasize = (sf == 1) ? 64 : 32;
+ boolean sub_op = op == 1;
+ boolean setflags = S == 1;
+ uint64_t imm;
+
+ switch (shift) {
+ case 0:
+ imm = imm12;
+ break;
+ case 1:
+ imm = imm12 << 12;
+ break;
+ default:
+ return false; // UNDEFINED;
+ }
+ uint64_t result;
+ uint64_t operand1 = ReadRegisterUnsigned(eRegisterKindDWARF,
+ arm64_dwarf::x0 + n, 0, &success);
+ uint64_t operand2 = imm;
+ bit carry_in;
+
+ if (sub_op) {
+ operand2 = NOT(operand2);
+ carry_in = 1;
+ imm = -imm; // For the Register plug offset context below
+ } else {
+ carry_in = 0;
+ }
+
+ ProcState proc_state;
+
+ result = AddWithCarry(datasize, operand1, operand2, carry_in, proc_state);
+
+ if (setflags) {
+ m_emulated_pstate.N = proc_state.N;
+ m_emulated_pstate.Z = proc_state.Z;
+ m_emulated_pstate.C = proc_state.C;
+ m_emulated_pstate.V = proc_state.V;
+ }
+
+ Context context;
+ RegisterInfo reg_info_Rn;
+ if (arm64_dwarf::GetRegisterInfo(n, reg_info_Rn))
+ context.SetRegisterPlusOffset(reg_info_Rn, imm);
+
+ if ((n == arm64_dwarf::sp || n == GetFramePointerRegisterNumber()) &&
+ d == arm64_dwarf::sp && !setflags) {
+ context.type = EmulateInstruction::eContextAdjustStackPointer;
+ } else if (d == GetFramePointerRegisterNumber() && n == arm64_dwarf::sp &&
+ !setflags) {
+ context.type = EmulateInstruction::eContextSetFramePointer;
+ } else {
+ context.type = EmulateInstruction::eContextImmediate;
+ }
+
+ // If setflags && d == arm64_dwarf::sp then d = WZR/XZR. See CMN, CMP
+ if (!setflags || d != arm64_dwarf::sp)
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, arm64_dwarf::x0 + d,
+ result);
+
+ return false;
+}
+
+template <EmulateInstructionARM64::AddrMode a_mode>
+bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
+ uint32_t opc = Bits32(opcode, 31, 30);
+ uint32_t V = Bit32(opcode, 26);
+ uint32_t L = Bit32(opcode, 22);
+ uint32_t imm7 = Bits32(opcode, 21, 15);
+ uint32_t Rt2 = Bits32(opcode, 14, 10);
+ uint32_t Rn = Bits32(opcode, 9, 5);
+ uint32_t Rt = Bits32(opcode, 4, 0);
+
+ integer n = UInt(Rn);
+ integer t = UInt(Rt);
+ integer t2 = UInt(Rt2);
+ uint64_t idx;
+
+ MemOp memop = L == 1 ? MemOp_LOAD : MemOp_STORE;
+ boolean vector = (V == 1);
+ // AccType acctype = AccType_NORMAL;
+ boolean is_signed = false;
+ boolean wback = a_mode != AddrMode_OFF;
+ boolean wb_unknown = false;
+ boolean rt_unknown = false;
+ integer scale;
+ integer size;
+
+ if (opc == 3)
+ return false; // UNDEFINED
+
+ if (vector) {
+ scale = 2 + UInt(opc);
+ } else {
+ scale = (opc & 2) ? 3 : 2;
+ is_signed = (opc & 1) != 0;
+ if (is_signed && memop == MemOp_STORE)
+ return false; // UNDEFINED
+ }
+
+ if (!vector && wback && ((t == n) || (t2 == n))) {
+ switch (ConstrainUnpredictable(Unpredictable_WBOVERLAP)) {
+ case Constraint_UNKNOWN:
+ wb_unknown = true; // writeback is UNKNOWN
+ break;
+
+ case Constraint_SUPPRESSWB:
+ wback = false; // writeback is suppressed
+ break;
+
+ case Constraint_NOP:
+ memop = MemOp_NOP; // do nothing
+ wback = false;
+ break;
+
+ case Constraint_NONE:
+ break;
+ }
+ }
+
+ if (memop == MemOp_LOAD && t == t2) {
+ switch (ConstrainUnpredictable(Unpredictable_LDPOVERLAP)) {
+ case Constraint_UNKNOWN:
+ rt_unknown = true; // result is UNKNOWN
+ break;
+
+ case Constraint_NOP:
+ memop = MemOp_NOP; // do nothing
+ wback = false;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ idx = LSL(llvm::SignExtend64<7>(imm7), scale);
+ size = (integer)1 << scale;
+ uint64_t datasize = size * 8;
+ uint64_t address;
+ uint64_t wb_address;
+
+ RegisterValue data_Rt;
+ RegisterValue data_Rt2;
+
+ // if (vector)
+ // CheckFPEnabled(false);
+
+ RegisterInfo reg_info_base;
+ RegisterInfo reg_info_Rt;
+ RegisterInfo reg_info_Rt2;
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::x0 + n, reg_info_base))
return false;
-}
-template <EmulateInstructionARM64::AddrMode a_mode> bool
-EmulateInstructionARM64::EmulateLDPSTP (const uint32_t opcode)
-{
- uint32_t opc = Bits32(opcode, 31, 30);
- uint32_t V = Bit32(opcode, 26);
- uint32_t L = Bit32(opcode, 22);
- uint32_t imm7 = Bits32(opcode, 21, 15);
- uint32_t Rt2 = Bits32(opcode, 14, 10);
- uint32_t Rn = Bits32(opcode, 9, 5);
- uint32_t Rt = Bits32(opcode, 4, 0);
-
- integer n = UInt(Rn);
- integer t = UInt(Rt);
- integer t2 = UInt(Rt2);
- uint64_t idx;
-
- MemOp memop = L == 1 ? MemOp_LOAD : MemOp_STORE;
- boolean vector = (V == 1);
- //AccType acctype = AccType_NORMAL;
- boolean is_signed = false;
- boolean wback = a_mode != AddrMode_OFF;
- boolean wb_unknown = false;
- boolean rt_unknown = false;
- integer scale;
- integer size;
-
- if (opc == 3)
- return false; // UNDEFINED
-
- if (vector)
- {
- scale = 2 + UInt(opc);
- }
- else
- {
- scale = (opc & 2) ? 3 : 2;
- is_signed = (opc & 1) != 0;
- if (is_signed && memop == MemOp_STORE)
- return false; // UNDEFINED
- }
-
- if (!vector && wback && ((t == n) || (t2 == n)))
- {
- switch (ConstrainUnpredictable(Unpredictable_WBOVERLAP))
- {
- case Constraint_UNKNOWN:
- wb_unknown = true; // writeback is UNKNOWN
- break;
-
- case Constraint_SUPPRESSWB:
- wback = false; // writeback is suppressed
- break;
-
- case Constraint_NOP:
- memop = MemOp_NOP; // do nothing
- wback = false;
- break;
-
- case Constraint_NONE:
- break;
- }
+ if (vector) {
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + n, reg_info_Rt))
+ return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::v0 + n, reg_info_Rt2))
+ return false;
+ } else {
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::x0 + t, reg_info_Rt))
+ return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::x0 + t2,
+ reg_info_Rt2))
+ return false;
+ }
+
+ bool success = false;
+ if (n == 31) {
+ // CheckSPAlignment();
+ address =
+ ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::sp, 0, &success);
+ } else
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::x0 + n, 0,
+ &success);
+
+ wb_address = address + idx;
+ if (a_mode != AddrMode_POST)
+ address = wb_address;
+
+ Context context_t;
+ Context context_t2;
+
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ Error error;
+
+ switch (memop) {
+ case MemOp_STORE: {
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is
+ // based off of the sp
+ // or fp register
+ {
+ context_t.type = eContextPushRegisterOnStack;
+ context_t2.type = eContextPushRegisterOnStack;
+ } else {
+ context_t.type = eContextRegisterStore;
+ context_t2.type = eContextRegisterStore;
+ }
+ context_t.SetRegisterToRegisterPlusOffset(reg_info_Rt, reg_info_base, 0);
+ context_t2.SetRegisterToRegisterPlusOffset(reg_info_Rt2, reg_info_base,
+ size);
+
+ if (!ReadRegister(®_info_Rt, data_Rt))
+ return false;
+
+ if (data_Rt.GetAsMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context_t, address + 0, buffer, reg_info_Rt.byte_size))
+ return false;
+
+ if (!ReadRegister(®_info_Rt2, data_Rt2))
+ return false;
+
+ if (data_Rt2.GetAsMemoryData(®_info_Rt2, buffer, reg_info_Rt2.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context_t2, address + size, buffer,
+ reg_info_Rt2.byte_size))
+ return false;
+ } break;
+
+ case MemOp_LOAD: {
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this load is
+ // based off of the sp
+ // or fp register
+ {
+ context_t.type = eContextPopRegisterOffStack;
+ context_t2.type = eContextPopRegisterOffStack;
+ } else {
+ context_t.type = eContextRegisterLoad;
+ context_t2.type = eContextRegisterLoad;
+ }
+ context_t.SetAddress(address);
+ context_t2.SetAddress(address + size);
+
+ if (rt_unknown)
+ memset(buffer, 'U', reg_info_Rt.byte_size);
+ else {
+ if (!ReadMemory(context_t, address, buffer, reg_info_Rt.byte_size))
+ return false;
}
- if (memop == MemOp_LOAD && t == t2)
- {
- switch (ConstrainUnpredictable(Unpredictable_LDPOVERLAP))
- {
- case Constraint_UNKNOWN:
- rt_unknown = true; // result is UNKNOWN
- break;
-
- case Constraint_NOP:
- memop = MemOp_NOP; // do nothing
- wback = false;
- break;
-
- default:
- break;
- }
- }
-
- idx = LSL(llvm::SignExtend64<7>(imm7), scale);
- size = (integer)1 << scale;
- uint64_t datasize = size * 8;
- uint64_t address;
- uint64_t wb_address;
-
- RegisterValue data_Rt;
- RegisterValue data_Rt2;
-
- // if (vector)
- // CheckFPEnabled(false);
-
- RegisterInfo reg_info_base;
- RegisterInfo reg_info_Rt;
- RegisterInfo reg_info_Rt2;
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + n, reg_info_base))
+ if (data_Rt.SetFromMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!vector && is_signed && !data_Rt.SignExtend(datasize))
+ return false;
+
+ if (!WriteRegister(context_t, ®_info_Rt, data_Rt))
+ return false;
+
+ if (!rt_unknown) {
+ if (!ReadMemory(context_t2, address + size, buffer,
+ reg_info_Rt2.byte_size))
return false;
-
- if (vector)
- {
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::v0 + n, reg_info_Rt))
- return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::v0 + n, reg_info_Rt2))
- return false;
}
- else
- {
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + t, reg_info_Rt))
- return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + t2, reg_info_Rt2))
- return false;
- }
-
- bool success = false;
+
+ if (data_Rt2.SetFromMemoryData(®_info_Rt2, buffer,
+ reg_info_Rt2.byte_size, eByteOrderLittle,
+ error) == 0)
+ return false;
+
+ if (!vector && is_signed && !data_Rt2.SignExtend(datasize))
+ return false;
+
+ if (!WriteRegister(context_t2, ®_info_Rt2, data_Rt2))
+ return false;
+ } break;
+
+ default:
+ break;
+ }
+
+ if (wback) {
+ if (wb_unknown)
+ wb_address = LLDB_INVALID_ADDRESS;
+ Context context;
+ context.SetImmediateSigned(idx);
if (n == 31)
- {
- //CheckSPAlignment();
- address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::sp, 0, &success);
- }
+ context.type = eContextAdjustStackPointer;
else
- address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::x0 + n, 0, &success);
-
- wb_address = address + idx;
- if (a_mode != AddrMode_POST)
- address = wb_address;
-
- Context context_t;
- Context context_t2;
-
- uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
- Error error;
+ context.type = eContextAdjustBaseRegister;
+ WriteRegisterUnsigned(context, ®_info_base, wb_address);
+ }
+ return true;
+}
+
+template <EmulateInstructionARM64::AddrMode a_mode>
+bool EmulateInstructionARM64::EmulateLDRSTRImm(const uint32_t opcode) {
+ uint32_t size = Bits32(opcode, 31, 30);
+ uint32_t opc = Bits32(opcode, 23, 22);
+ uint32_t n = Bits32(opcode, 9, 5);
+ uint32_t t = Bits32(opcode, 4, 0);
+
+ bool wback;
+ bool postindex;
+ uint64_t offset;
+
+ switch (a_mode) {
+ case AddrMode_POST:
+ wback = true;
+ postindex = true;
+ offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
+ break;
+ case AddrMode_PRE:
+ wback = true;
+ postindex = false;
+ offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
+ break;
+ case AddrMode_OFF:
+ wback = false;
+ postindex = false;
+ offset = LSL(Bits32(opcode, 21, 10), size);
+ break;
+ }
+
+ MemOp memop;
+
+ if (Bit32(opc, 1) == 0) {
+ memop = Bit32(opc, 0) == 1 ? MemOp_LOAD : MemOp_STORE;
+ } else {
+ memop = MemOp_LOAD;
+ if (size == 2 && Bit32(opc, 0) == 1)
+ return false;
+ }
+
+ Error error;
+ bool success = false;
+ uint64_t address;
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ RegisterValue data_Rt;
+
+ if (n == 31)
+ address =
+ ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::sp, 0, &success);
+ else
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::x0 + n, 0,
+ &success);
- switch (memop)
- {
- case MemOp_STORE:
- {
- if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is based off of the sp or fp register
- {
- context_t.type = eContextPushRegisterOnStack;
- context_t2.type = eContextPushRegisterOnStack;
- }
- else
- {
- context_t.type = eContextRegisterStore;
- context_t2.type = eContextRegisterStore;
- }
- context_t.SetRegisterToRegisterPlusOffset (reg_info_Rt, reg_info_base, 0);
- context_t2.SetRegisterToRegisterPlusOffset (reg_info_Rt2, reg_info_base, size);
-
- if (!ReadRegister (®_info_Rt, data_Rt))
- return false;
-
- if (data_Rt.GetAsMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!WriteMemory(context_t, address + 0, buffer, reg_info_Rt.byte_size))
- return false;
-
- if (!ReadRegister (®_info_Rt2, data_Rt2))
- return false;
-
- if (data_Rt2.GetAsMemoryData(®_info_Rt2, buffer, reg_info_Rt2.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!WriteMemory(context_t2, address + size, buffer, reg_info_Rt2.byte_size))
- return false;
- }
- break;
-
- case MemOp_LOAD:
- {
- if (n == 31 || n == GetFramePointerRegisterNumber()) // if this load is based off of the sp or fp register
- {
- context_t.type = eContextPopRegisterOffStack;
- context_t2.type = eContextPopRegisterOffStack;
- }
- else
- {
- context_t.type = eContextRegisterLoad;
- context_t2.type = eContextRegisterLoad;
- }
- context_t.SetAddress(address);
- context_t2.SetAddress(address + size);
-
- if (rt_unknown)
- memset (buffer, 'U', reg_info_Rt.byte_size);
- else
- {
- if (!ReadMemory (context_t, address, buffer, reg_info_Rt.byte_size))
- return false;
- }
-
- if (data_Rt.SetFromMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!vector && is_signed && !data_Rt.SignExtend (datasize))
- return false;
-
- if (!WriteRegister (context_t, ®_info_Rt, data_Rt))
- return false;
-
- if (!rt_unknown)
- {
- if (!ReadMemory (context_t2, address + size, buffer, reg_info_Rt2.byte_size))
- return false;
- }
-
- if (data_Rt2.SetFromMemoryData(®_info_Rt2, buffer, reg_info_Rt2.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!vector && is_signed && !data_Rt2.SignExtend (datasize))
- return false;
-
- if (!WriteRegister (context_t2, ®_info_Rt2, data_Rt2))
- return false;
- }
- break;
-
- default:
- break;
- }
-
- if (wback)
- {
- if (wb_unknown)
- wb_address = LLDB_INVALID_ADDRESS;
- Context context;
- context.SetImmediateSigned (idx);
- if (n == 31)
- context.type = eContextAdjustStackPointer;
- else
- context.type = eContextAdjustBaseRegister;
- WriteRegisterUnsigned (context, ®_info_base, wb_address);
- }
- return true;
-}
+ if (!success)
+ return false;
-template <EmulateInstructionARM64::AddrMode a_mode> bool
-EmulateInstructionARM64::EmulateLDRSTRImm (const uint32_t opcode)
-{
- uint32_t size = Bits32(opcode, 31, 30);
- uint32_t opc = Bits32(opcode, 23, 22);
- uint32_t n = Bits32(opcode, 9, 5);
- uint32_t t = Bits32(opcode, 4, 0);
-
- bool wback;
- bool postindex;
- uint64_t offset;
+ if (!postindex)
+ address += offset;
- switch (a_mode)
- {
- case AddrMode_POST:
- wback = true;
- postindex = true;
- offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
- break;
- case AddrMode_PRE:
- wback = true;
- postindex = false;
- offset = llvm::SignExtend64<9>(Bits32(opcode, 20, 12));
- break;
- case AddrMode_OFF:
- wback = false;
- postindex = false;
- offset = LSL(Bits32(opcode, 21, 10), size);
- break;
- }
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::x0 + n, reg_info_base))
+ return false;
- MemOp memop;
+ RegisterInfo reg_info_Rt;
+ if (!GetRegisterInfo(eRegisterKindDWARF, arm64_dwarf::x0 + t, reg_info_Rt))
+ return false;
- if (Bit32(opc, 1) == 0)
- {
- memop = Bit32(opc, 0) == 1 ? MemOp_LOAD : MemOp_STORE;
- }
+ Context context;
+ switch (memop) {
+ case MemOp_STORE:
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is
+ // based off of the sp
+ // or fp register
+ context.type = eContextPushRegisterOnStack;
else
- {
- memop = MemOp_LOAD;
- if (size == 2 && Bit32(opc, 0) == 1)
- return false;
- }
-
- Error error;
- bool success = false;
- uint64_t address;
- uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
- RegisterValue data_Rt;
-
- if (n == 31)
- address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::sp, 0, &success);
+ context.type = eContextRegisterStore;
+ context.SetRegisterToRegisterPlusOffset(reg_info_Rt, reg_info_base,
+ postindex ? 0 : offset);
+
+ if (!ReadRegister(®_info_Rt, data_Rt))
+ return false;
+
+ if (data_Rt.GetAsMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context, address, buffer, reg_info_Rt.byte_size))
+ return false;
+ break;
+
+ case MemOp_LOAD:
+ if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is
+ // based off of the sp
+ // or fp register
+ context.type = eContextPopRegisterOffStack;
else
- address = ReadRegisterUnsigned (eRegisterKindDWARF, arm64_dwarf::x0 + n, 0, &success);
-
- if (!success)
- return false;
-
- if (!postindex)
- address += offset;
+ context.type = eContextRegisterLoad;
+ context.SetAddress(address);
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + n, reg_info_base))
- return false;
+ if (!ReadMemory(context, address, buffer, reg_info_Rt.byte_size))
+ return false;
- RegisterInfo reg_info_Rt;
- if (!GetRegisterInfo (eRegisterKindDWARF, arm64_dwarf::x0 + t, reg_info_Rt))
- return false;
-
- Context context;
- switch (memop)
- {
- case MemOp_STORE:
- if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is based off of the sp or fp register
- context.type = eContextPushRegisterOnStack;
- else
- context.type = eContextRegisterStore;
- context.SetRegisterToRegisterPlusOffset (reg_info_Rt, reg_info_base, postindex ? 0 : offset);
-
- if (!ReadRegister (®_info_Rt, data_Rt))
- return false;
-
- if (data_Rt.GetAsMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!WriteMemory(context, address, buffer, reg_info_Rt.byte_size))
- return false;
- break;
-
- case MemOp_LOAD:
- if (n == 31 || n == GetFramePointerRegisterNumber()) // if this store is based off of the sp or fp register
- context.type = eContextPopRegisterOffStack;
- else
- context.type = eContextRegisterLoad;
- context.SetAddress(address);
-
- if (!ReadMemory (context, address, buffer, reg_info_Rt.byte_size))
- return false;
-
- if (data_Rt.SetFromMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size, eByteOrderLittle, error) == 0)
- return false;
-
- if (!WriteRegister (context, ®_info_Rt, data_Rt))
- return false;
- break;
- default:
- return false;
- }
+ if (data_Rt.SetFromMemoryData(®_info_Rt, buffer, reg_info_Rt.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteRegister(context, ®_info_Rt, data_Rt))
+ return false;
+ break;
+ default:
+ return false;
+ }
- if (wback)
- {
- if (postindex)
- address += offset;
+ if (wback) {
+ if (postindex)
+ address += offset;
- if (n == 31)
- context.type = eContextAdjustStackPointer;
- else
- context.type = eContextAdjustBaseRegister;
- context.SetImmediateSigned (offset);
+ if (n == 31)
+ context.type = eContextAdjustStackPointer;
+ else
+ context.type = eContextAdjustBaseRegister;
+ context.SetImmediateSigned(offset);
- if (!WriteRegisterUnsigned (context, ®_info_base, address))
- return false;
- }
- return true;
+ if (!WriteRegisterUnsigned(context, ®_info_base, address))
+ return false;
+ }
+ return true;
}
-bool
-EmulateInstructionARM64::EmulateB (const uint32_t opcode)
-{
+bool EmulateInstructionARM64::EmulateB(const uint32_t opcode) {
#if 0
// ARM64 pseudo code...
if branch_type == BranchType_CALL then X[30] = PC[] + 4;
BranchTo(PC[] + offset, branch_type);
#endif
- bool success = false;
+ bool success = false;
- EmulateInstruction::Context context;
- context.type = EmulateInstruction::eContextRelativeBranchImmediate;
- const uint64_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
- if (!success)
- return false;
-
- int64_t offset = llvm::SignExtend64<28>(Bits32(opcode, 25, 0) << 2);
- BranchType branch_type = Bit32(opcode, 31) ? BranchType_CALL : BranchType_JMP;
- addr_t target = pc + offset;
- context.SetImmediateSigned(offset);
+ EmulateInstruction::Context context;
+ context.type = EmulateInstruction::eContextRelativeBranchImmediate;
+ const uint64_t pc = ReadRegisterUnsigned(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC, 0, &success);
+ if (!success)
+ return false;
- switch (branch_type)
- {
- case BranchType_CALL:
- {
- addr_t x30 = pc + 4;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, arm64_dwarf::x30, x30))
- return false;
- }
- break;
- case BranchType_JMP:
- break;
- default:
- return false;
- }
+ int64_t offset = llvm::SignExtend64<28>(Bits32(opcode, 25, 0) << 2);
+ BranchType branch_type = Bit32(opcode, 31) ? BranchType_CALL : BranchType_JMP;
+ addr_t target = pc + offset;
+ context.SetImmediateSigned(offset);
+
+ switch (branch_type) {
+ case BranchType_CALL: {
+ addr_t x30 = pc + 4;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, arm64_dwarf::x30,
+ x30))
+ return false;
+ } break;
+ case BranchType_JMP:
+ break;
+ default:
+ return false;
+ }
- if (!BranchTo(context, 64, target))
- return false;
- return true;
+ if (!BranchTo(context, 64, target))
+ return false;
+ return true;
}
-bool
-EmulateInstructionARM64::EmulateBcond (const uint32_t opcode)
-{
+bool EmulateInstructionARM64::EmulateBcond(const uint32_t opcode) {
#if 0
// ARM64 pseudo code...
bits(64) offset = SignExtend(imm19:'00', 64);
@@ -1055,29 +1115,27 @@ EmulateInstructionARM64::EmulateBcond (c
BranchTo(PC[] + offset, BranchType_JMP);
#endif
- if (ConditionHolds(Bits32(opcode, 3, 0)))
- {
- bool success = false;
+ if (ConditionHolds(Bits32(opcode, 3, 0))) {
+ bool success = false;
- const uint64_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
- if (!success)
- return false;
-
- int64_t offset = llvm::SignExtend64<21>(Bits32(opcode, 23, 5) << 2);
- addr_t target = pc + offset;
-
- EmulateInstruction::Context context;
- context.type = EmulateInstruction::eContextRelativeBranchImmediate;
- context.SetImmediateSigned(offset);
- if (!BranchTo(context, 64, target))
- return false;
- }
- return true;
+ const uint64_t pc = ReadRegisterUnsigned(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
+ if (!success)
+ return false;
+
+ int64_t offset = llvm::SignExtend64<21>(Bits32(opcode, 23, 5) << 2);
+ addr_t target = pc + offset;
+
+ EmulateInstruction::Context context;
+ context.type = EmulateInstruction::eContextRelativeBranchImmediate;
+ context.SetImmediateSigned(offset);
+ if (!BranchTo(context, 64, target))
+ return false;
+ }
+ return true;
}
-bool
-EmulateInstructionARM64::EmulateCBZ (const uint32_t opcode)
-{
+bool EmulateInstructionARM64::EmulateCBZ(const uint32_t opcode) {
#if 0
integer t = UInt(Rt);
integer datasize = if sf == '1' then 64 else 32;
@@ -1089,34 +1147,33 @@ EmulateInstructionARM64::EmulateCBZ (con
BranchTo(PC[] + offset, BranchType_JMP);
#endif
- bool success = false;
+ bool success = false;
- uint32_t t = Bits32(opcode, 4, 0);
- bool is_zero = Bit32(opcode, 24) == 0;
- int32_t offset = llvm::SignExtend64<21>(Bits32(opcode, 23, 5) << 2);
+ uint32_t t = Bits32(opcode, 4, 0);
+ bool is_zero = Bit32(opcode, 24) == 0;
+ int32_t offset = llvm::SignExtend64<21>(Bits32(opcode, 23, 5) << 2);
+
+ const uint64_t operand = ReadRegisterUnsigned(
+ eRegisterKindDWARF, arm64_dwarf::x0 + t, 0, &success);
+ if (!success)
+ return false;
- const uint64_t operand = ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::x0 + t, 0, &success);
+ if (m_ignore_conditions || ((operand == 0) == is_zero)) {
+ const uint64_t pc = ReadRegisterUnsigned(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
if (!success)
- return false;
+ return false;
- if (m_ignore_conditions || ((operand == 0) == is_zero))
- {
- const uint64_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
- if (!success)
- return false;
-
- EmulateInstruction::Context context;
- context.type = EmulateInstruction::eContextRelativeBranchImmediate;
- context.SetImmediateSigned(offset);
- if (!BranchTo(context, 64, pc + offset))
- return false;
- }
- return true;
+ EmulateInstruction::Context context;
+ context.type = EmulateInstruction::eContextRelativeBranchImmediate;
+ context.SetImmediateSigned(offset);
+ if (!BranchTo(context, 64, pc + offset))
+ return false;
+ }
+ return true;
}
-bool
-EmulateInstructionARM64::EmulateTBZ (const uint32_t opcode)
-{
+bool EmulateInstructionARM64::EmulateTBZ(const uint32_t opcode) {
#if 0
integer t = UInt(Rt);
integer datasize = if b5 == '1' then 64 else 32;
@@ -1125,28 +1182,29 @@ EmulateInstructionARM64::EmulateTBZ (con
bits(64) offset = SignExtend(imm14:'00', 64);
#endif
- bool success = false;
+ bool success = false;
- uint32_t t = Bits32(opcode, 4, 0);
- uint32_t bit_pos = (Bit32(opcode, 31) << 6) | (Bits32(opcode, 23, 19));
- uint32_t bit_val = Bit32(opcode, 24);
- int64_t offset = llvm::SignExtend64<16>(Bits32(opcode, 18, 5) << 2);
+ uint32_t t = Bits32(opcode, 4, 0);
+ uint32_t bit_pos = (Bit32(opcode, 31) << 6) | (Bits32(opcode, 23, 19));
+ uint32_t bit_val = Bit32(opcode, 24);
+ int64_t offset = llvm::SignExtend64<16>(Bits32(opcode, 18, 5) << 2);
+
+ const uint64_t operand = ReadRegisterUnsigned(
+ eRegisterKindDWARF, arm64_dwarf::x0 + t, 0, &success);
+ if (!success)
+ return false;
- const uint64_t operand = ReadRegisterUnsigned(eRegisterKindDWARF, arm64_dwarf::x0 + t, 0, &success);
+ if (m_ignore_conditions || Bit32(operand, bit_pos) == bit_val) {
+ const uint64_t pc = ReadRegisterUnsigned(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
if (!success)
- return false;
+ return false;
- if (m_ignore_conditions || Bit32(operand, bit_pos) == bit_val)
- {
- const uint64_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
- if (!success)
- return false;
-
- EmulateInstruction::Context context;
- context.type = EmulateInstruction::eContextRelativeBranchImmediate;
- context.SetImmediateSigned(offset);
- if (!BranchTo(context, 64, pc + offset))
- return false;
- }
- return true;
+ EmulateInstruction::Context context;
+ context.type = EmulateInstruction::eContextRelativeBranchImmediate;
+ context.SetImmediateSigned(offset);
+ if (!BranchTo(context, 64, pc + offset))
+ return false;
+ }
+ return true;
}
Modified: lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h (original)
+++ lldb/trunk/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h Tue Sep 6 15:57:50 2016
@@ -14,288 +14,192 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "Plugins/Process/Utility/ARMDefines.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
-#include "Plugins/Process/Utility/ARMDefines.h"
-class EmulateInstructionARM64 : public lldb_private::EmulateInstruction
-{
-public:
- EmulateInstructionARM64 (const lldb_private::ArchSpec &arch) :
- EmulateInstruction (arch),
- m_opcode_pstate (),
- m_emulated_pstate (),
- m_ignore_conditions (false)
- {
+class EmulateInstructionARM64 : public lldb_private::EmulateInstruction {
+public:
+ EmulateInstructionARM64(const lldb_private::ArchSpec &arch)
+ : EmulateInstruction(arch), m_opcode_pstate(), m_emulated_pstate(),
+ m_ignore_conditions(false) {}
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetPluginDescriptionStatic();
+
+ static lldb_private::EmulateInstruction *
+ CreateInstance(const lldb_private::ArchSpec &arch,
+ lldb_private::InstructionType inst_type);
+
+ static bool SupportsEmulatingInstructionsOfTypeStatic(
+ lldb_private::InstructionType inst_type) {
+ switch (inst_type) {
+ case lldb_private::eInstructionTypeAny:
+ case lldb_private::eInstructionTypePrologueEpilogue:
+ return true;
+
+ case lldb_private::eInstructionTypePCModifying:
+ case lldb_private::eInstructionTypeAll:
+ return false;
}
+ return false;
+ }
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetPluginDescriptionStatic ();
-
- static lldb_private::EmulateInstruction *
- CreateInstance (const lldb_private::ArchSpec &arch,
- lldb_private::InstructionType inst_type);
-
- static bool
- SupportsEmulatingInstructionsOfTypeStatic (lldb_private::InstructionType inst_type)
- {
- switch (inst_type)
- {
- case lldb_private::eInstructionTypeAny:
- case lldb_private::eInstructionTypePrologueEpilogue:
- return true;
-
- case lldb_private::eInstructionTypePCModifying:
- case lldb_private::eInstructionTypeAll:
- return false;
- }
- return false;
- }
+ lldb_private::ConstString GetPluginName() override;
- lldb_private::ConstString
- GetPluginName() override;
+ uint32_t GetPluginVersion() override { return 1; }
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
+ bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
- bool
- SetTargetTriple(const lldb_private::ArchSpec &arch) override;
-
- bool
- SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
- {
- return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
- }
+ bool SupportsEmulatingInstructionsOfType(
+ lldb_private::InstructionType inst_type) override {
+ return SupportsEmulatingInstructionsOfTypeStatic(inst_type);
+ }
+
+ bool ReadInstruction() override;
+
+ bool EvaluateInstruction(uint32_t evaluate_options) override;
+
+ bool TestEmulation(lldb_private::Stream *out_stream,
+ lldb_private::ArchSpec &arch,
+ lldb_private::OptionValueDictionary *test_data) override {
+ return false;
+ }
+
+ bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ lldb_private::RegisterInfo ®_info) override;
+
+ bool
+ CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
+
+ typedef enum { AddrMode_OFF, AddrMode_PRE, AddrMode_POST } AddrMode;
+
+ typedef enum {
+ BranchType_CALL,
+ BranchType_ERET,
+ BranchType_DRET,
+ BranchType_RET,
+ BranchType_JMP
+ } BranchType;
+
+ typedef enum { CountOp_CLZ, CountOp_CLS, CountOp_CNT } CountOp;
+
+ typedef enum { RevOp_RBIT, RevOp_REV16, RevOp_REV32, RevOp_REV64 } RevOp;
+
+ typedef enum { BitwiseOp_NOT, BitwiseOp_RBIT } BitwiseOp;
+
+ typedef enum { EL0 = 0, EL1 = 1, EL2 = 2, EL3 = 3 } ExceptionLevel;
+
+ typedef enum {
+ ExtendType_SXTB,
+ ExtendType_SXTH,
+ ExtendType_SXTW,
+ ExtendType_SXTX,
+ ExtendType_UXTB,
+ ExtendType_UXTH,
+ ExtendType_UXTW,
+ ExtendType_UXTX
+ } ExtendType;
+
+ typedef enum { ExtractType_LEFT, ExtractType_RIGHT } ExtractType;
+
+ typedef enum { LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR } LogicalOp;
+
+ typedef enum { MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH, MemOp_NOP } MemOp;
+
+ typedef enum { MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K } MoveWideOp;
+
+ typedef enum {
+ ShiftType_LSL,
+ ShiftType_LSR,
+ ShiftType_ASR,
+ ShiftType_ROR
+ } ShiftType;
+
+ typedef enum { SP0 = 0, SPx = 1 } StackPointerSelection;
+
+ typedef enum {
+ Unpredictable_WBOVERLAP,
+ Unpredictable_LDPOVERLAP
+ } Unpredictable;
+
+ typedef enum {
+ Constraint_NONE,
+ Constraint_UNKNOWN,
+ Constraint_SUPPRESSWB,
+ Constraint_NOP
+ } ConstraintType;
+
+ typedef enum {
+ AccType_NORMAL,
+ AccType_UNPRIV,
+ AccType_STREAM,
+ AccType_ALIGNED,
+ AccType_ORDERED
+ } AccType;
+
+ typedef struct {
+ uint32_t N : 1, V : 1, C : 1,
+ Z : 1, // condition code flags â can also be accessed as
+ // PSTATE.[N,Z,C,V]
+ Q : 1, // AArch32 only â CSPR.Q bit
+ IT : 8, // AArch32 only â CPSR.IT bits
+ J : 1, // AArch32 only â CSPR.J bit
+ T : 1, // AArch32 only â CPSR.T bit
+ SS : 1, // Single step process state bit
+ IL : 1, // Illegal state bit
+ D : 1, A : 1, I : 1,
+ F : 1, // Interrupt masks â can also be accessed as PSTATE.[D,A,I,F]
+ E : 1, // AArch32 only â CSPR.E bit
+ M : 5, // AArch32 only â mode encodings
+ RW : 1, // Current register width â 0 is AArch64, 1 is AArch32
+ EL : 2, // Current exception level (see ExceptionLevel enum)
+ SP : 1; // AArch64 only - Stack Pointer selection (see
+ // StackPointerSelection enum)
+ } ProcState;
- bool
- ReadInstruction() override;
-
- bool
- EvaluateInstruction(uint32_t evaluate_options) override;
-
- bool
- TestEmulation(lldb_private::Stream *out_stream,
- lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data) override
- {
- return false;
- }
+protected:
+ typedef struct {
+ uint32_t mask;
+ uint32_t value;
+ uint32_t vfp_variants;
+ bool (EmulateInstructionARM64::*callback)(const uint32_t opcode);
+ const char *name;
+ } Opcode;
- bool
- GetRegisterInfo(lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- lldb_private::RegisterInfo ®_info) override;
-
- bool
- CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
-
- typedef enum
- {
- AddrMode_OFF,
- AddrMode_PRE,
- AddrMode_POST
- } AddrMode;
-
- typedef enum
- {
- BranchType_CALL,
- BranchType_ERET,
- BranchType_DRET,
- BranchType_RET,
- BranchType_JMP
- } BranchType;
-
- typedef enum
- {
- CountOp_CLZ,
- CountOp_CLS,
- CountOp_CNT
- } CountOp;
-
- typedef enum
- {
- RevOp_RBIT,
- RevOp_REV16,
- RevOp_REV32,
- RevOp_REV64
- } RevOp;
-
- typedef enum
- {
- BitwiseOp_NOT,
- BitwiseOp_RBIT
- } BitwiseOp;
-
- typedef enum
- {
- EL0 = 0,
- EL1 = 1,
- EL2 = 2,
- EL3 = 3
- } ExceptionLevel;
-
- typedef enum
- {
- ExtendType_SXTB,
- ExtendType_SXTH,
- ExtendType_SXTW,
- ExtendType_SXTX,
- ExtendType_UXTB,
- ExtendType_UXTH,
- ExtendType_UXTW,
- ExtendType_UXTX
- } ExtendType;
-
- typedef enum
- {
- ExtractType_LEFT,
- ExtractType_RIGHT
- } ExtractType;
-
- typedef enum
- {
- LogicalOp_AND,
- LogicalOp_EOR,
- LogicalOp_ORR
- } LogicalOp;
-
- typedef enum
- {
- MemOp_LOAD,
- MemOp_STORE,
- MemOp_PREFETCH,
- MemOp_NOP
- } MemOp;
-
- typedef enum
- {
- MoveWideOp_N,
- MoveWideOp_Z,
- MoveWideOp_K
- } MoveWideOp;
-
- typedef enum {
- ShiftType_LSL,
- ShiftType_LSR,
- ShiftType_ASR,
- ShiftType_ROR
- } ShiftType;
-
- typedef enum
- {
- SP0 = 0,
- SPx = 1
- } StackPointerSelection;
-
- typedef enum
- {
- Unpredictable_WBOVERLAP,
- Unpredictable_LDPOVERLAP
- } Unpredictable;
-
- typedef enum
- {
- Constraint_NONE,
- Constraint_UNKNOWN,
- Constraint_SUPPRESSWB,
- Constraint_NOP
- } ConstraintType;
-
- typedef enum
- {
- AccType_NORMAL,
- AccType_UNPRIV,
- AccType_STREAM,
- AccType_ALIGNED,
- AccType_ORDERED
- } AccType;
-
- typedef struct
- {
- uint32_t
- N:1,
- V:1,
- C:1,
- Z:1, // condition code flags â can also be accessed as PSTATE.[N,Z,C,V]
- Q:1, // AArch32 only â CSPR.Q bit
- IT:8, // AArch32 only â CPSR.IT bits
- J:1, // AArch32 only â CSPR.J bit
- T:1, // AArch32 only â CPSR.T bit
- SS:1, // Single step process state bit
- IL:1, // Illegal state bit
- D:1,
- A:1,
- I:1,
- F:1, // Interrupt masks â can also be accessed as PSTATE.[D,A,I,F]
- E:1, // AArch32 only â CSPR.E bit
- M:5, // AArch32 only â mode encodings
- RW:1, // Current register width â 0 is AArch64, 1 is AArch32
- EL:2, // Current exception level (see ExceptionLevel enum)
- SP:1; // AArch64 only - Stack Pointer selection (see StackPointerSelection enum)
- } ProcState;
+ static Opcode *GetOpcodeForInstruction(const uint32_t opcode);
-protected:
- typedef struct
- {
- uint32_t mask;
- uint32_t value;
- uint32_t vfp_variants;
- bool (EmulateInstructionARM64::*callback) (const uint32_t opcode);
- const char *name;
- } Opcode;
-
- static Opcode*
- GetOpcodeForInstruction (const uint32_t opcode);
-
- uint32_t
- GetFramePointerRegisterNumber() const;
-
- bool
- BranchTo (const Context &context, uint32_t N, lldb::addr_t target);
-
- bool
- ConditionHolds (const uint32_t cond);
-
- bool
- UsingAArch32 ();
-
- bool
- EmulateADDSUBImm (const uint32_t opcode);
-
- template <AddrMode a_mode> bool
- EmulateLDPSTP (const uint32_t opcode);
-
- template <AddrMode a_mode> bool
- EmulateLDRSTRImm (const uint32_t opcode);
-
- bool
- EmulateB (const uint32_t opcode);
-
- bool
- EmulateBcond (const uint32_t opcode);
-
- bool
- EmulateCBZ (const uint32_t opcode);
-
- bool
- EmulateTBZ (const uint32_t opcode);
-
- ProcState m_opcode_pstate;
- ProcState m_emulated_pstate; // This can get updated by the opcode.
- bool m_ignore_conditions;
+ uint32_t GetFramePointerRegisterNumber() const;
+
+ bool BranchTo(const Context &context, uint32_t N, lldb::addr_t target);
+
+ bool ConditionHolds(const uint32_t cond);
+
+ bool UsingAArch32();
+
+ bool EmulateADDSUBImm(const uint32_t opcode);
+
+ template <AddrMode a_mode> bool EmulateLDPSTP(const uint32_t opcode);
+
+ template <AddrMode a_mode> bool EmulateLDRSTRImm(const uint32_t opcode);
+
+ bool EmulateB(const uint32_t opcode);
+
+ bool EmulateBcond(const uint32_t opcode);
+
+ bool EmulateCBZ(const uint32_t opcode);
+
+ bool EmulateTBZ(const uint32_t opcode);
+
+ ProcState m_opcode_pstate;
+ ProcState m_emulated_pstate; // This can get updated by the opcode.
+ bool m_ignore_conditions;
};
#endif // EmulateInstructionARM64_h_
Modified: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++ -*-===//
+//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,30 +12,30 @@
#include <stdlib.h>
-#include "llvm-c/Disassembler.h"
-#include "llvm/Support/TargetSelect.h"
-#include "llvm/Support/TargetRegistry.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/MC/MCInstrInfo.h"
-#include "llvm/MC/MCDisassembler/MCDisassembler.h"
-#include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCContext.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Opcode.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Opcode.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
+#include "llvm-c/Disassembler.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCDisassembler/MCDisassembler.h"
+#include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
#include "llvm/ADT/STLExtras.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
-#include "Plugins/Process/Utility/RegisterContext_mips.h" //mips32 has same registers nos as mips64
+#include "Plugins/Process/Utility/RegisterContext_mips.h" //mips32 has same registers nos as mips64
using namespace lldb;
using namespace lldb_private;
@@ -42,7 +43,6 @@ using namespace lldb_private;
#define UInt(x) ((uint64_t)x)
#define integer int64_t
-
//----------------------------------------------------------------------
//
// EmulateInstructionMIPS implementation
@@ -51,1926 +51,2180 @@ using namespace lldb_private;
#ifdef __mips__
extern "C" {
- void LLVMInitializeMipsTargetInfo ();
- void LLVMInitializeMipsTarget ();
- void LLVMInitializeMipsAsmPrinter ();
- void LLVMInitializeMipsTargetMC ();
- void LLVMInitializeMipsDisassembler ();
+void LLVMInitializeMipsTargetInfo();
+void LLVMInitializeMipsTarget();
+void LLVMInitializeMipsAsmPrinter();
+void LLVMInitializeMipsTargetMC();
+void LLVMInitializeMipsDisassembler();
}
#endif
-EmulateInstructionMIPS::EmulateInstructionMIPS (const lldb_private::ArchSpec &arch) :
- EmulateInstruction (arch)
-{
- /* Create instance of llvm::MCDisassembler */
- std::string Error;
- llvm::Triple triple = arch.GetTriple();
- const llvm::Target *target = llvm::TargetRegistry::lookupTarget (triple.getTriple(), Error);
+EmulateInstructionMIPS::EmulateInstructionMIPS(
+ const lldb_private::ArchSpec &arch)
+ : EmulateInstruction(arch) {
+ /* Create instance of llvm::MCDisassembler */
+ std::string Error;
+ llvm::Triple triple = arch.GetTriple();
+ const llvm::Target *target =
+ llvm::TargetRegistry::lookupTarget(triple.getTriple(), Error);
- /*
- * If we fail to get the target then we haven't registered it. The SystemInitializerCommon
- * does not initialize targets, MCs and disassemblers. However we need the MCDisassembler
- * to decode the instructions so that the decoding complexity stays with LLVM.
- * Initialize the MIPS targets and disassemblers.
- */
+/*
+ * If we fail to get the target then we haven't registered it. The
+ * SystemInitializerCommon
+ * does not initialize targets, MCs and disassemblers. However we need the
+ * MCDisassembler
+ * to decode the instructions so that the decoding complexity stays with LLVM.
+ * Initialize the MIPS targets and disassemblers.
+*/
#ifdef __mips__
- if (!target)
- {
- LLVMInitializeMipsTargetInfo ();
- LLVMInitializeMipsTarget ();
- LLVMInitializeMipsAsmPrinter ();
- LLVMInitializeMipsTargetMC ();
- LLVMInitializeMipsDisassembler ();
- target = llvm::TargetRegistry::lookupTarget (triple.getTriple(), Error);
- }
+ if (!target) {
+ LLVMInitializeMipsTargetInfo();
+ LLVMInitializeMipsTarget();
+ LLVMInitializeMipsAsmPrinter();
+ LLVMInitializeMipsTargetMC();
+ LLVMInitializeMipsDisassembler();
+ target = llvm::TargetRegistry::lookupTarget(triple.getTriple(), Error);
+ }
#endif
- assert (target);
+ assert(target);
- llvm::StringRef cpu;
-
- switch (arch.GetCore())
- {
- case ArchSpec::eCore_mips32:
- case ArchSpec::eCore_mips32el:
- cpu = "mips32"; break;
- case ArchSpec::eCore_mips32r2:
- case ArchSpec::eCore_mips32r2el:
- cpu = "mips32r2"; break;
- case ArchSpec::eCore_mips32r3:
- case ArchSpec::eCore_mips32r3el:
- cpu = "mips32r3"; break;
- case ArchSpec::eCore_mips32r5:
- case ArchSpec::eCore_mips32r5el:
- cpu = "mips32r5"; break;
- case ArchSpec::eCore_mips32r6:
- case ArchSpec::eCore_mips32r6el:
- cpu = "mips32r6"; break;
- case ArchSpec::eCore_mips64:
- case ArchSpec::eCore_mips64el:
- cpu = "mips64"; break;
- case ArchSpec::eCore_mips64r2:
- case ArchSpec::eCore_mips64r2el:
- cpu = "mips64r2"; break;
- case ArchSpec::eCore_mips64r3:
- case ArchSpec::eCore_mips64r3el:
- cpu = "mips64r3"; break;
- case ArchSpec::eCore_mips64r5:
- case ArchSpec::eCore_mips64r5el:
- cpu = "mips64r5"; break;
- case ArchSpec::eCore_mips64r6:
- case ArchSpec::eCore_mips64r6el:
- cpu = "mips64r6"; break;
- default:
- cpu = "generic"; break;
- }
+ llvm::StringRef cpu;
- std::string features = "";
- uint32_t arch_flags = arch.GetFlags ();
- if (arch_flags & ArchSpec::eMIPSAse_msa)
- features += "+msa,";
- if (arch_flags & ArchSpec::eMIPSAse_dsp)
- features += "+dsp,";
- if (arch_flags & ArchSpec::eMIPSAse_dspr2)
- features += "+dspr2,";
+ switch (arch.GetCore()) {
+ case ArchSpec::eCore_mips32:
+ case ArchSpec::eCore_mips32el:
+ cpu = "mips32";
+ break;
+ case ArchSpec::eCore_mips32r2:
+ case ArchSpec::eCore_mips32r2el:
+ cpu = "mips32r2";
+ break;
+ case ArchSpec::eCore_mips32r3:
+ case ArchSpec::eCore_mips32r3el:
+ cpu = "mips32r3";
+ break;
+ case ArchSpec::eCore_mips32r5:
+ case ArchSpec::eCore_mips32r5el:
+ cpu = "mips32r5";
+ break;
+ case ArchSpec::eCore_mips32r6:
+ case ArchSpec::eCore_mips32r6el:
+ cpu = "mips32r6";
+ break;
+ case ArchSpec::eCore_mips64:
+ case ArchSpec::eCore_mips64el:
+ cpu = "mips64";
+ break;
+ case ArchSpec::eCore_mips64r2:
+ case ArchSpec::eCore_mips64r2el:
+ cpu = "mips64r2";
+ break;
+ case ArchSpec::eCore_mips64r3:
+ case ArchSpec::eCore_mips64r3el:
+ cpu = "mips64r3";
+ break;
+ case ArchSpec::eCore_mips64r5:
+ case ArchSpec::eCore_mips64r5el:
+ cpu = "mips64r5";
+ break;
+ case ArchSpec::eCore_mips64r6:
+ case ArchSpec::eCore_mips64r6el:
+ cpu = "mips64r6";
+ break;
+ default:
+ cpu = "generic";
+ break;
+ }
+
+ std::string features = "";
+ uint32_t arch_flags = arch.GetFlags();
+ if (arch_flags & ArchSpec::eMIPSAse_msa)
+ features += "+msa,";
+ if (arch_flags & ArchSpec::eMIPSAse_dsp)
+ features += "+dsp,";
+ if (arch_flags & ArchSpec::eMIPSAse_dspr2)
+ features += "+dspr2,";
+
+ m_reg_info.reset(target->createMCRegInfo(triple.getTriple()));
+ assert(m_reg_info.get());
+
+ m_insn_info.reset(target->createMCInstrInfo());
+ assert(m_insn_info.get());
+
+ m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple.getTriple()));
+ m_subtype_info.reset(
+ target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
+ assert(m_asm_info.get() && m_subtype_info.get());
+
+ m_context.reset(
+ new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
+ assert(m_context.get());
+
+ m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
+ assert(m_disasm.get());
+
+ /* Create alternate disassembler for microMIPS */
+ if (arch_flags & ArchSpec::eMIPSAse_mips16)
+ features += "+mips16,";
+ else if (arch_flags & ArchSpec::eMIPSAse_micromips)
+ features += "+micromips,";
+
+ m_alt_subtype_info.reset(
+ target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
+ assert(m_alt_subtype_info.get());
+
+ m_alt_disasm.reset(
+ target->createMCDisassembler(*m_alt_subtype_info, *m_context));
+ assert(m_alt_disasm.get());
+
+ m_next_inst_size = 0;
+ m_use_alt_disaasm = false;
+}
+
+void EmulateInstructionMIPS::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+}
+
+void EmulateInstructionMIPS::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+ConstString EmulateInstructionMIPS::GetPluginNameStatic() {
+ ConstString g_plugin_name("lldb.emulate-instruction.mips32");
+ return g_plugin_name;
+}
+
+lldb_private::ConstString EmulateInstructionMIPS::GetPluginName() {
+ static ConstString g_plugin_name("EmulateInstructionMIPS");
+ return g_plugin_name;
+}
- m_reg_info.reset (target->createMCRegInfo (triple.getTriple()));
- assert (m_reg_info.get());
+const char *EmulateInstructionMIPS::GetPluginDescriptionStatic() {
+ return "Emulate instructions for the MIPS32 architecture.";
+}
- m_insn_info.reset (target->createMCInstrInfo());
- assert (m_insn_info.get());
+EmulateInstruction *
+EmulateInstructionMIPS::CreateInstance(const ArchSpec &arch,
+ InstructionType inst_type) {
+ if (EmulateInstructionMIPS::SupportsEmulatingInstructionsOfTypeStatic(
+ inst_type)) {
+ if (arch.GetTriple().getArch() == llvm::Triple::mips ||
+ arch.GetTriple().getArch() == llvm::Triple::mipsel) {
+ std::auto_ptr<EmulateInstructionMIPS> emulate_insn_ap(
+ new EmulateInstructionMIPS(arch));
+ if (emulate_insn_ap.get())
+ return emulate_insn_ap.release();
+ }
+ }
+
+ return NULL;
+}
+
+bool EmulateInstructionMIPS::SetTargetTriple(const ArchSpec &arch) {
+ if (arch.GetTriple().getArch() == llvm::Triple::mips ||
+ arch.GetTriple().getArch() == llvm::Triple::mipsel)
+ return true;
+ return false;
+}
+
+const char *EmulateInstructionMIPS::GetRegisterName(unsigned reg_num,
+ bool alternate_name) {
+ if (alternate_name) {
+ switch (reg_num) {
+ case dwarf_sp_mips:
+ return "r29";
+ case dwarf_r30_mips:
+ return "r30";
+ case dwarf_ra_mips:
+ return "r31";
+ case dwarf_f0_mips:
+ return "f0";
+ case dwarf_f1_mips:
+ return "f1";
+ case dwarf_f2_mips:
+ return "f2";
+ case dwarf_f3_mips:
+ return "f3";
+ case dwarf_f4_mips:
+ return "f4";
+ case dwarf_f5_mips:
+ return "f5";
+ case dwarf_f6_mips:
+ return "f6";
+ case dwarf_f7_mips:
+ return "f7";
+ case dwarf_f8_mips:
+ return "f8";
+ case dwarf_f9_mips:
+ return "f9";
+ case dwarf_f10_mips:
+ return "f10";
+ case dwarf_f11_mips:
+ return "f11";
+ case dwarf_f12_mips:
+ return "f12";
+ case dwarf_f13_mips:
+ return "f13";
+ case dwarf_f14_mips:
+ return "f14";
+ case dwarf_f15_mips:
+ return "f15";
+ case dwarf_f16_mips:
+ return "f16";
+ case dwarf_f17_mips:
+ return "f17";
+ case dwarf_f18_mips:
+ return "f18";
+ case dwarf_f19_mips:
+ return "f19";
+ case dwarf_f20_mips:
+ return "f20";
+ case dwarf_f21_mips:
+ return "f21";
+ case dwarf_f22_mips:
+ return "f22";
+ case dwarf_f23_mips:
+ return "f23";
+ case dwarf_f24_mips:
+ return "f24";
+ case dwarf_f25_mips:
+ return "f25";
+ case dwarf_f26_mips:
+ return "f26";
+ case dwarf_f27_mips:
+ return "f27";
+ case dwarf_f28_mips:
+ return "f28";
+ case dwarf_f29_mips:
+ return "f29";
+ case dwarf_f30_mips:
+ return "f30";
+ case dwarf_f31_mips:
+ return "f31";
+ case dwarf_w0_mips:
+ return "w0";
+ case dwarf_w1_mips:
+ return "w1";
+ case dwarf_w2_mips:
+ return "w2";
+ case dwarf_w3_mips:
+ return "w3";
+ case dwarf_w4_mips:
+ return "w4";
+ case dwarf_w5_mips:
+ return "w5";
+ case dwarf_w6_mips:
+ return "w6";
+ case dwarf_w7_mips:
+ return "w7";
+ case dwarf_w8_mips:
+ return "w8";
+ case dwarf_w9_mips:
+ return "w9";
+ case dwarf_w10_mips:
+ return "w10";
+ case dwarf_w11_mips:
+ return "w11";
+ case dwarf_w12_mips:
+ return "w12";
+ case dwarf_w13_mips:
+ return "w13";
+ case dwarf_w14_mips:
+ return "w14";
+ case dwarf_w15_mips:
+ return "w15";
+ case dwarf_w16_mips:
+ return "w16";
+ case dwarf_w17_mips:
+ return "w17";
+ case dwarf_w18_mips:
+ return "w18";
+ case dwarf_w19_mips:
+ return "w19";
+ case dwarf_w20_mips:
+ return "w20";
+ case dwarf_w21_mips:
+ return "w21";
+ case dwarf_w22_mips:
+ return "w22";
+ case dwarf_w23_mips:
+ return "w23";
+ case dwarf_w24_mips:
+ return "w24";
+ case dwarf_w25_mips:
+ return "w25";
+ case dwarf_w26_mips:
+ return "w26";
+ case dwarf_w27_mips:
+ return "w27";
+ case dwarf_w28_mips:
+ return "w28";
+ case dwarf_w29_mips:
+ return "w29";
+ case dwarf_w30_mips:
+ return "w30";
+ case dwarf_w31_mips:
+ return "w31";
+ case dwarf_mir_mips:
+ return "mir";
+ case dwarf_mcsr_mips:
+ return "mcsr";
+ case dwarf_config5_mips:
+ return "config5";
+ default:
+ break;
+ }
+ return nullptr;
+ }
- m_asm_info.reset (target->createMCAsmInfo (*m_reg_info, triple.getTriple()));
- m_subtype_info.reset (target->createMCSubtargetInfo (triple.getTriple(), cpu, features));
- assert (m_asm_info.get() && m_subtype_info.get());
+ switch (reg_num) {
+ case dwarf_zero_mips:
+ return "r0";
+ case dwarf_r1_mips:
+ return "r1";
+ case dwarf_r2_mips:
+ return "r2";
+ case dwarf_r3_mips:
+ return "r3";
+ case dwarf_r4_mips:
+ return "r4";
+ case dwarf_r5_mips:
+ return "r5";
+ case dwarf_r6_mips:
+ return "r6";
+ case dwarf_r7_mips:
+ return "r7";
+ case dwarf_r8_mips:
+ return "r8";
+ case dwarf_r9_mips:
+ return "r9";
+ case dwarf_r10_mips:
+ return "r10";
+ case dwarf_r11_mips:
+ return "r11";
+ case dwarf_r12_mips:
+ return "r12";
+ case dwarf_r13_mips:
+ return "r13";
+ case dwarf_r14_mips:
+ return "r14";
+ case dwarf_r15_mips:
+ return "r15";
+ case dwarf_r16_mips:
+ return "r16";
+ case dwarf_r17_mips:
+ return "r17";
+ case dwarf_r18_mips:
+ return "r18";
+ case dwarf_r19_mips:
+ return "r19";
+ case dwarf_r20_mips:
+ return "r20";
+ case dwarf_r21_mips:
+ return "r21";
+ case dwarf_r22_mips:
+ return "r22";
+ case dwarf_r23_mips:
+ return "r23";
+ case dwarf_r24_mips:
+ return "r24";
+ case dwarf_r25_mips:
+ return "r25";
+ case dwarf_r26_mips:
+ return "r26";
+ case dwarf_r27_mips:
+ return "r27";
+ case dwarf_gp_mips:
+ return "gp";
+ case dwarf_sp_mips:
+ return "sp";
+ case dwarf_r30_mips:
+ return "fp";
+ case dwarf_ra_mips:
+ return "ra";
+ case dwarf_sr_mips:
+ return "sr";
+ case dwarf_lo_mips:
+ return "lo";
+ case dwarf_hi_mips:
+ return "hi";
+ case dwarf_bad_mips:
+ return "bad";
+ case dwarf_cause_mips:
+ return "cause";
+ case dwarf_pc_mips:
+ return "pc";
+ case dwarf_f0_mips:
+ return "f0";
+ case dwarf_f1_mips:
+ return "f1";
+ case dwarf_f2_mips:
+ return "f2";
+ case dwarf_f3_mips:
+ return "f3";
+ case dwarf_f4_mips:
+ return "f4";
+ case dwarf_f5_mips:
+ return "f5";
+ case dwarf_f6_mips:
+ return "f6";
+ case dwarf_f7_mips:
+ return "f7";
+ case dwarf_f8_mips:
+ return "f8";
+ case dwarf_f9_mips:
+ return "f9";
+ case dwarf_f10_mips:
+ return "f10";
+ case dwarf_f11_mips:
+ return "f11";
+ case dwarf_f12_mips:
+ return "f12";
+ case dwarf_f13_mips:
+ return "f13";
+ case dwarf_f14_mips:
+ return "f14";
+ case dwarf_f15_mips:
+ return "f15";
+ case dwarf_f16_mips:
+ return "f16";
+ case dwarf_f17_mips:
+ return "f17";
+ case dwarf_f18_mips:
+ return "f18";
+ case dwarf_f19_mips:
+ return "f19";
+ case dwarf_f20_mips:
+ return "f20";
+ case dwarf_f21_mips:
+ return "f21";
+ case dwarf_f22_mips:
+ return "f22";
+ case dwarf_f23_mips:
+ return "f23";
+ case dwarf_f24_mips:
+ return "f24";
+ case dwarf_f25_mips:
+ return "f25";
+ case dwarf_f26_mips:
+ return "f26";
+ case dwarf_f27_mips:
+ return "f27";
+ case dwarf_f28_mips:
+ return "f28";
+ case dwarf_f29_mips:
+ return "f29";
+ case dwarf_f30_mips:
+ return "f30";
+ case dwarf_f31_mips:
+ return "f31";
+ case dwarf_fcsr_mips:
+ return "fcsr";
+ case dwarf_fir_mips:
+ return "fir";
+ case dwarf_w0_mips:
+ return "w0";
+ case dwarf_w1_mips:
+ return "w1";
+ case dwarf_w2_mips:
+ return "w2";
+ case dwarf_w3_mips:
+ return "w3";
+ case dwarf_w4_mips:
+ return "w4";
+ case dwarf_w5_mips:
+ return "w5";
+ case dwarf_w6_mips:
+ return "w6";
+ case dwarf_w7_mips:
+ return "w7";
+ case dwarf_w8_mips:
+ return "w8";
+ case dwarf_w9_mips:
+ return "w9";
+ case dwarf_w10_mips:
+ return "w10";
+ case dwarf_w11_mips:
+ return "w11";
+ case dwarf_w12_mips:
+ return "w12";
+ case dwarf_w13_mips:
+ return "w13";
+ case dwarf_w14_mips:
+ return "w14";
+ case dwarf_w15_mips:
+ return "w15";
+ case dwarf_w16_mips:
+ return "w16";
+ case dwarf_w17_mips:
+ return "w17";
+ case dwarf_w18_mips:
+ return "w18";
+ case dwarf_w19_mips:
+ return "w19";
+ case dwarf_w20_mips:
+ return "w20";
+ case dwarf_w21_mips:
+ return "w21";
+ case dwarf_w22_mips:
+ return "w22";
+ case dwarf_w23_mips:
+ return "w23";
+ case dwarf_w24_mips:
+ return "w24";
+ case dwarf_w25_mips:
+ return "w25";
+ case dwarf_w26_mips:
+ return "w26";
+ case dwarf_w27_mips:
+ return "w27";
+ case dwarf_w28_mips:
+ return "w28";
+ case dwarf_w29_mips:
+ return "w29";
+ case dwarf_w30_mips:
+ return "w30";
+ case dwarf_w31_mips:
+ return "w31";
+ case dwarf_mcsr_mips:
+ return "mcsr";
+ case dwarf_mir_mips:
+ return "mir";
+ case dwarf_config5_mips:
+ return "config5";
+ }
+ return nullptr;
+}
+
+bool EmulateInstructionMIPS::GetRegisterInfo(RegisterKind reg_kind,
+ uint32_t reg_num,
+ RegisterInfo ®_info) {
+ if (reg_kind == eRegisterKindGeneric) {
+ switch (reg_num) {
+ case LLDB_REGNUM_GENERIC_PC:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_pc_mips;
+ break;
+ case LLDB_REGNUM_GENERIC_SP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_sp_mips;
+ break;
+ case LLDB_REGNUM_GENERIC_FP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_r30_mips;
+ break;
+ case LLDB_REGNUM_GENERIC_RA:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_ra_mips;
+ break;
+ case LLDB_REGNUM_GENERIC_FLAGS:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_sr_mips;
+ break;
+ default:
+ return false;
+ }
+ }
+
+ if (reg_kind == eRegisterKindDWARF) {
+ ::memset(®_info, 0, sizeof(RegisterInfo));
+ ::memset(reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
+
+ if (reg_num == dwarf_sr_mips || reg_num == dwarf_fcsr_mips ||
+ reg_num == dwarf_fir_mips || reg_num == dwarf_mcsr_mips ||
+ reg_num == dwarf_mir_mips || reg_num == dwarf_config5_mips) {
+ reg_info.byte_size = 4;
+ reg_info.format = eFormatHex;
+ reg_info.encoding = eEncodingUint;
+ } else if ((int)reg_num >= dwarf_zero_mips &&
+ (int)reg_num <= dwarf_f31_mips) {
+ reg_info.byte_size = 4;
+ reg_info.format = eFormatHex;
+ reg_info.encoding = eEncodingUint;
+ } else if ((int)reg_num >= dwarf_w0_mips &&
+ (int)reg_num <= dwarf_w31_mips) {
+ reg_info.byte_size = 16;
+ reg_info.format = eFormatVectorOfUInt8;
+ reg_info.encoding = eEncodingVector;
+ } else {
+ return false;
+ }
+
+ reg_info.name = GetRegisterName(reg_num, false);
+ reg_info.alt_name = GetRegisterName(reg_num, true);
+ reg_info.kinds[eRegisterKindDWARF] = reg_num;
+
+ switch (reg_num) {
+ case dwarf_r30_mips:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+ break;
+ case dwarf_ra_mips:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+ break;
+ case dwarf_sp_mips:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+ break;
+ case dwarf_pc_mips:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+ break;
+ case dwarf_sr_mips:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+ return false;
+}
+
+EmulateInstructionMIPS::MipsOpcode *
+EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
+ static EmulateInstructionMIPS::MipsOpcode g_opcodes[] = {
+ //----------------------------------------------------------------------
+ // Prologue/Epilogue instructions
+ //----------------------------------------------------------------------
+ {"ADDiu", &EmulateInstructionMIPS::Emulate_ADDiu,
+ "ADDIU rt, rs, immediate"},
+ {"SW", &EmulateInstructionMIPS::Emulate_SW, "SW rt, offset(rs)"},
+ {"LW", &EmulateInstructionMIPS::Emulate_LW, "LW rt, offset(base)"},
+ {"SUBU", &EmulateInstructionMIPS::Emulate_SUBU_ADDU, "SUBU rd, rs, rt"},
+ {"ADDU", &EmulateInstructionMIPS::Emulate_SUBU_ADDU, "ADDU rd, rs, rt"},
+ {"LUI", &EmulateInstructionMIPS::Emulate_LUI, "LUI rt, immediate"},
+
+ //----------------------------------------------------------------------
+ // MicroMIPS Prologue/Epilogue instructions
+ //----------------------------------------------------------------------
+ {"ADDIUSP_MM", &EmulateInstructionMIPS::Emulate_ADDIUSP,
+ "ADDIU immediate"},
+ {"ADDIUS5_MM", &EmulateInstructionMIPS::Emulate_ADDIUS5,
+ "ADDIUS5 rd,immediate"},
+ {"SWSP_MM", &EmulateInstructionMIPS::Emulate_SWSP, "SWSP rt,offset(sp)"},
+ {"SWM16_MM", &EmulateInstructionMIPS::Emulate_SWM16_32,
+ "SWM16 reglist,offset(sp)"},
+ {"SWM32_MM", &EmulateInstructionMIPS::Emulate_SWM16_32,
+ "SWM32 reglist,offset(base)"},
+ {"SWP_MM", &EmulateInstructionMIPS::Emulate_SWM16_32,
+ "SWP rs1,offset(base)"},
+ {"LWSP_MM", &EmulateInstructionMIPS::Emulate_LWSP, "LWSP rt,offset(sp)"},
+ {"LWM16_MM", &EmulateInstructionMIPS::Emulate_LWM16_32,
+ "LWM16 reglist,offset(sp)"},
+ {"LWM32_MM", &EmulateInstructionMIPS::Emulate_LWM16_32,
+ "LWM32 reglist,offset(base)"},
+ {"LWP_MM", &EmulateInstructionMIPS::Emulate_LWM16_32,
+ "LWP rd,offset(base)"},
+ {"JRADDIUSP", &EmulateInstructionMIPS::Emulate_JRADDIUSP,
+ "JRADDIUSP immediate"},
+ //----------------------------------------------------------------------
+
+ // Load/Store instructions
+ //----------------------------------------------------------------------
+ /* Following list of emulated instructions are required by implementation
+ of hardware watchpoint
+ for MIPS in lldb. As we just need the address accessed by instructions,
+ we have generalised
+ all these instructions in 2 functions depending on their addressing
+ modes */
+
+ {"LB", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LB rt, offset(base)"},
+ {"LBE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LBE rt, offset(base)"},
+ {"LBU", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LBU rt, offset(base)"},
+ {"LBUE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LBUE rt, offset(base)"},
+ {"LDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LDC1 ft, offset(base)"},
+ {"LD", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LD rt, offset(base)"},
+ {"LDL", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LDL rt, offset(base)"},
+ {"LDR", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LDR rt, offset(base)"},
+ {"LLD", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LLD rt, offset(base)"},
+ {"LDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LDC2 rt, offset(base)"},
+ {"LDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "LDXC1 fd, index (base)"},
+ {"LH", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LH rt, offset(base)"},
+ {"LHE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LHE rt, offset(base)"},
+ {"LHU", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LHU rt, offset(base)"},
+ {"LHUE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LHUE rt, offset(base)"},
+ {"LL", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LL rt, offset(base)"},
+ {"LLE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LLE rt, offset(base)"},
+ {"LUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "LUXC1 fd, index (base)"},
+ {"LW", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LW rt, offset(base)"},
+ {"LWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWC1 ft, offset(base)"},
+ {"LWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWC2 rt, offset(base)"},
+ {"LWE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWE rt, offset(base)"},
+ {"LWL", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWL rt, offset(base)"},
+ {"LWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWLE rt, offset(base)"},
+ {"LWR", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWR rt, offset(base)"},
+ {"LWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWRE rt, offset(base)"},
+ {"LWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "LWXC1 fd, index (base)"},
+ {"LLX", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LLX rt, offset(base)"},
+ {"LLXE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LLXE rt, offset(base)"},
+ {"LLDX", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LLDX rt, offset(base)"},
+
+ {"SB", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SB rt, offset(base)"},
+ {"SBE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SBE rt, offset(base)"},
+ {"SC", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SC rt, offset(base)"},
+ {"SCE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SCE rt, offset(base)"},
+ {"SCD", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SCD rt, offset(base)"},
+ {"SD", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SD rt, offset(base)"},
+ {"SDL", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SDL rt, offset(base)"},
+ {"SDR", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SDR rt, offset(base)"},
+ {"SDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SDC1 ft, offset(base)"},
+ {"SDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SDC2 rt, offset(base)"},
+ {"SDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "SDXC1 fs, index(base)"},
+ {"SH", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SH rt, offset(base)"},
+ {"SHE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SHE rt, offset(base)"},
+ {"SUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "SUXC1 fs, index (base)"},
+ {"SWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWC1 ft, offset(base)"},
+ {"SWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWC2 rt, offset(base)"},
+ {"SWE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWE rt, offset(base)"},
+ {"SWL", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWL rt, offset(base)"},
+ {"SWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWLE rt, offset(base)"},
+ {"SWR", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWR rt, offset(base)"},
+ {"SWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWRE rt, offset(base)"},
+ {"SWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg,
+ "SWXC1 fs, index (base)"},
+ {"SCX", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SCX rt, offset(base)"},
+ {"SCXE", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SCXE rt, offset(base)"},
+ {"SCDX", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SCDX rt, offset(base)"},
+
+ //----------------------------------------------------------------------
+ // MicroMIPS Load/Store instructions
+ //----------------------------------------------------------------------
+ {"LBU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LBU16 rt, decoded_offset(base)"},
+ {"LHU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LHU16 rt, left_shifted_offset(base)"},
+ {"LW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LW16 rt, left_shifted_offset(base)"},
+ {"LWGP_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "LWGP rt, left_shifted_offset(gp)"},
+ {"SH16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SH16 rt, left_shifted_offset(base)"},
+ {"SW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SW16 rt, left_shifted_offset(base)"},
+ {"SW_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SWSP rt, left_shifted_offset(base)"},
+ {"SB16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
+ "SB16 rt, offset(base)"},
+
+ //----------------------------------------------------------------------
+ // Branch instructions
+ //----------------------------------------------------------------------
+ {"BEQ", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQ rs,rt,offset"},
+ {"BNE", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNE rs,rt,offset"},
+ {"BEQL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQL rs,rt,offset"},
+ {"BNEL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNEL rs,rt,offset"},
+ {"BGEZALL", &EmulateInstructionMIPS::Emulate_Bcond_Link,
+ "BGEZALL rt,offset"},
+ {"BAL", &EmulateInstructionMIPS::Emulate_BAL, "BAL offset"},
+ {"BGEZAL", &EmulateInstructionMIPS::Emulate_Bcond_Link,
+ "BGEZAL rs,offset"},
+ {"BALC", &EmulateInstructionMIPS::Emulate_BALC, "BALC offset"},
+ {"BC", &EmulateInstructionMIPS::Emulate_BC, "BC offset"},
+ {"BGEZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGEZ rs,offset"},
+ {"BLEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BLEZALC rs,offset"},
+ {"BGEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BGEZALC rs,offset"},
+ {"BLTZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BLTZALC rs,offset"},
+ {"BGTZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BGTZALC rs,offset"},
+ {"BEQZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BEQZALC rs,offset"},
+ {"BNEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,
+ "BNEZALC rs,offset"},
+ {"BEQC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BEQC rs,rt,offset"},
+ {"BNEC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BNEC rs,rt,offset"},
+ {"BLTC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BLTC rs,rt,offset"},
+ {"BGEC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BGEC rs,rt,offset"},
+ {"BLTUC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BLTUC rs,rt,offset"},
+ {"BGEUC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BGEUC rs,rt,offset"},
+ {"BLTZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BLTZC rt,offset"},
+ {"BLEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BLEZC rt,offset"},
+ {"BGEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BGEZC rt,offset"},
+ {"BGTZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BGTZC rt,offset"},
+ {"BEQZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BEQZC rt,offset"},
+ {"BNEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BNEZC rt,offset"},
+ {"BGEZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGEZL rt,offset"},
+ {"BGTZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGTZ rt,offset"},
+ {"BGTZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGTZL rt,offset"},
+ {"BLEZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLEZ rt,offset"},
+ {"BLEZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLEZL rt,offset"},
+ {"BLTZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLTZ rt,offset"},
+ {"BLTZAL", &EmulateInstructionMIPS::Emulate_Bcond_Link,
+ "BLTZAL rt,offset"},
+ {"BLTZALL", &EmulateInstructionMIPS::Emulate_Bcond_Link,
+ "BLTZALL rt,offset"},
+ {"BLTZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLTZL rt,offset"},
+ {"BOVC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BOVC rs,rt,offset"},
+ {"BNVC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C,
+ "BNVC rs,rt,offset"},
+ {"J", &EmulateInstructionMIPS::Emulate_J, "J target"},
+ {"JAL", &EmulateInstructionMIPS::Emulate_JAL, "JAL target"},
+ {"JALX", &EmulateInstructionMIPS::Emulate_JAL, "JALX target"},
+ {"JALR", &EmulateInstructionMIPS::Emulate_JALR, "JALR target"},
+ {"JALR_HB", &EmulateInstructionMIPS::Emulate_JALR, "JALR.HB target"},
+ {"JIALC", &EmulateInstructionMIPS::Emulate_JIALC, "JIALC rt,offset"},
+ {"JIC", &EmulateInstructionMIPS::Emulate_JIC, "JIC rt,offset"},
+ {"JR", &EmulateInstructionMIPS::Emulate_JR, "JR target"},
+ {"JR_HB", &EmulateInstructionMIPS::Emulate_JR, "JR.HB target"},
+ {"BC1F", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1F cc, offset"},
+ {"BC1T", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1T cc, offset"},
+ {"BC1FL", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1FL cc, offset"},
+ {"BC1TL", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1TL cc, offset"},
+ {"BC1EQZ", &EmulateInstructionMIPS::Emulate_BC1EQZ, "BC1EQZ ft, offset"},
+ {"BC1NEZ", &EmulateInstructionMIPS::Emulate_BC1NEZ, "BC1NEZ ft, offset"},
+ {"BC1ANY2F", &EmulateInstructionMIPS::Emulate_3D_branch,
+ "BC1ANY2F cc, offset"},
+ {"BC1ANY2T", &EmulateInstructionMIPS::Emulate_3D_branch,
+ "BC1ANY2T cc, offset"},
+ {"BC1ANY4F", &EmulateInstructionMIPS::Emulate_3D_branch,
+ "BC1ANY4F cc, offset"},
+ {"BC1ANY4T", &EmulateInstructionMIPS::Emulate_3D_branch,
+ "BC1ANY4T cc, offset"},
+ {"BNZ_B", &EmulateInstructionMIPS::Emulate_BNZB, "BNZ.b wt,s16"},
+ {"BNZ_H", &EmulateInstructionMIPS::Emulate_BNZH, "BNZ.h wt,s16"},
+ {"BNZ_W", &EmulateInstructionMIPS::Emulate_BNZW, "BNZ.w wt,s16"},
+ {"BNZ_D", &EmulateInstructionMIPS::Emulate_BNZD, "BNZ.d wt,s16"},
+ {"BZ_B", &EmulateInstructionMIPS::Emulate_BZB, "BZ.b wt,s16"},
+ {"BZ_H", &EmulateInstructionMIPS::Emulate_BZH, "BZ.h wt,s16"},
+ {"BZ_W", &EmulateInstructionMIPS::Emulate_BZW, "BZ.w wt,s16"},
+ {"BZ_D", &EmulateInstructionMIPS::Emulate_BZD, "BZ.d wt,s16"},
+ {"BNZ_V", &EmulateInstructionMIPS::Emulate_BNZV, "BNZ.V wt,s16"},
+ {"BZ_V", &EmulateInstructionMIPS::Emulate_BZV, "BZ.V wt,s16"},
+
+ //----------------------------------------------------------------------
+ // MicroMIPS Branch instructions
+ //----------------------------------------------------------------------
+ {"B16_MM", &EmulateInstructionMIPS::Emulate_B16_MM, "B16 offset"},
+ {"BEQZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BEQZ16 rs, offset"},
+ {"BNEZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BNEZ16 rs, offset"},
+ {"BEQZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BEQZC rs, offset"},
+ {"BNEZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BNEZC rs, offset"},
+ {"BGEZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BGEZALS rs, offset"},
+ {"BLTZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
+ "BLTZALS rs, offset"},
+ {"JALR16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALR16 rs"},
+ {"JALRS16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALRS16 rs"},
+ {"JR16_MM", &EmulateInstructionMIPS::Emulate_JR, "JR16 rs rs"},
+ {"JRC16_MM", &EmulateInstructionMIPS::Emulate_JR, "JRC16 rs rs"},
+ {"JALS_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALS target"},
+ {"JALX_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALX target"},
+ {"JALRS_MM", &EmulateInstructionMIPS::Emulate_JALRS, "JALRS rt, rs"},
+ };
+
+ static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
+
+ for (size_t i = 0; i < k_num_mips_opcodes; ++i) {
+ if (!strcasecmp(g_opcodes[i].op_name, op_name))
+ return &g_opcodes[i];
+ }
- m_context.reset (new llvm::MCContext (m_asm_info.get(), m_reg_info.get(), nullptr));
- assert (m_context.get());
+ return NULL;
+}
- m_disasm.reset (target->createMCDisassembler (*m_subtype_info, *m_context));
- assert (m_disasm.get());
+uint32_t
+EmulateInstructionMIPS::GetSizeOfInstruction(lldb_private::DataExtractor &data,
+ uint64_t inst_addr) {
+ uint64_t next_inst_size = 0;
+ llvm::MCInst mc_insn;
+ llvm::MCDisassembler::DecodeStatus decode_status;
+ llvm::ArrayRef<uint8_t> raw_insn(data.GetDataStart(), data.GetByteSize());
+
+ if (m_use_alt_disaasm)
+ decode_status =
+ m_alt_disasm->getInstruction(mc_insn, next_inst_size, raw_insn,
+ inst_addr, llvm::nulls(), llvm::nulls());
+ else
+ decode_status =
+ m_disasm->getInstruction(mc_insn, next_inst_size, raw_insn, inst_addr,
+ llvm::nulls(), llvm::nulls());
- /* Create alternate disassembler for microMIPS */
- if (arch_flags & ArchSpec::eMIPSAse_mips16)
- features += "+mips16,";
- else if (arch_flags & ArchSpec::eMIPSAse_micromips)
- features += "+micromips,";
+ if (decode_status != llvm::MCDisassembler::Success)
+ return false;
- m_alt_subtype_info.reset (target->createMCSubtargetInfo (triple.getTriple(), cpu, features));
- assert (m_alt_subtype_info.get());
+ return m_insn_info->get(mc_insn.getOpcode()).getSize();
+}
- m_alt_disasm.reset (target->createMCDisassembler (*m_alt_subtype_info, *m_context));
- assert (m_alt_disasm.get());
+bool EmulateInstructionMIPS::SetInstruction(const Opcode &insn_opcode,
+ const Address &inst_addr,
+ Target *target) {
+ m_use_alt_disaasm = false;
+
+ if (EmulateInstruction::SetInstruction(insn_opcode, inst_addr, target)) {
+ if (inst_addr.GetAddressClass() == eAddressClassCodeAlternateISA) {
+ Error error;
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+
+ /*
+ * The address belongs to microMIPS function. To find the size of
+ * next instruction use microMIPS disassembler.
+ */
+ m_use_alt_disaasm = true;
+
+ uint32_t current_inst_size = insn_opcode.GetByteSize();
+ uint8_t buf[sizeof(uint32_t)];
+ uint64_t next_inst_addr = (m_addr & (~1ull)) + current_inst_size;
+ Address next_addr(next_inst_addr);
+
+ const size_t bytes_read =
+ target->ReadMemory(next_addr, /* Address of next instruction */
+ true, /* prefer_file_cache */
+ buf, sizeof(uint32_t), error, &load_addr);
- m_next_inst_size = 0;
- m_use_alt_disaasm = false;
-}
+ if (bytes_read == 0)
+ return true;
-void
-EmulateInstructionMIPS::Initialize ()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic (),
- GetPluginDescriptionStatic (),
- CreateInstance);
-}
+ DataExtractor data(buf, sizeof(uint32_t), GetByteOrder(),
+ GetAddressByteSize());
+ m_next_inst_size = GetSizeOfInstruction(data, next_inst_addr);
+ return true;
+ } else {
+ /*
+ * If the address class is not eAddressClassCodeAlternateISA then
+ * the function is not microMIPS. In this case instruction size is
+ * always 4 bytes.
+ */
+ m_next_inst_size = 4;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool EmulateInstructionMIPS::ReadInstruction() {
+ bool success = false;
+ m_addr = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC,
+ LLDB_INVALID_ADDRESS, &success);
+ if (success) {
+ Context read_inst_context;
+ read_inst_context.type = eContextReadOpcode;
+ read_inst_context.SetNoArgs();
+ m_opcode.SetOpcode32(
+ ReadMemoryUnsigned(read_inst_context, m_addr, 4, 0, &success),
+ GetByteOrder());
+ }
+ if (!success)
+ m_addr = LLDB_INVALID_ADDRESS;
+ return success;
+}
+
+bool EmulateInstructionMIPS::EvaluateInstruction(uint32_t evaluate_options) {
+ bool success = false;
+ llvm::MCInst mc_insn;
+ uint64_t insn_size;
+ DataExtractor data;
+
+ /* Keep the complexity of the decode logic with the llvm::MCDisassembler
+ * class. */
+ if (m_opcode.GetData(data)) {
+ llvm::MCDisassembler::DecodeStatus decode_status;
+ llvm::ArrayRef<uint8_t> raw_insn(data.GetDataStart(), data.GetByteSize());
+ if (m_use_alt_disaasm)
+ decode_status = m_alt_disasm->getInstruction(
+ mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+ else
+ decode_status = m_disasm->getInstruction(
+ mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
-void
-EmulateInstructionMIPS::Terminate ()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
-}
+ if (decode_status != llvm::MCDisassembler::Success)
+ return false;
+ }
-ConstString
-EmulateInstructionMIPS::GetPluginNameStatic ()
-{
- ConstString g_plugin_name ("lldb.emulate-instruction.mips32");
- return g_plugin_name;
-}
+ /*
+ * mc_insn.getOpcode() returns decoded opcode. However to make use
+ * of llvm::Mips::<insn> we would need "MipsGenInstrInfo.inc".
+ */
+ const char *op_name = m_insn_info->getName(mc_insn.getOpcode());
-lldb_private::ConstString
-EmulateInstructionMIPS::GetPluginName()
-{
- static ConstString g_plugin_name ("EmulateInstructionMIPS");
- return g_plugin_name;
-}
+ if (op_name == NULL)
+ return false;
-const char *
-EmulateInstructionMIPS::GetPluginDescriptionStatic ()
-{
- return "Emulate instructions for the MIPS32 architecture.";
-}
+ /*
+ * Decoding has been done already. Just get the call-back function
+ * and emulate the instruction.
+ */
+ MipsOpcode *opcode_data = GetOpcodeForInstruction(op_name);
-EmulateInstruction *
-EmulateInstructionMIPS::CreateInstance (const ArchSpec &arch, InstructionType inst_type)
-{
- if (EmulateInstructionMIPS::SupportsEmulatingInstructionsOfTypeStatic(inst_type))
- {
- if (arch.GetTriple().getArch() == llvm::Triple::mips
- || arch.GetTriple().getArch() == llvm::Triple::mipsel)
- {
- std::auto_ptr<EmulateInstructionMIPS> emulate_insn_ap (new EmulateInstructionMIPS (arch));
- if (emulate_insn_ap.get())
- return emulate_insn_ap.release();
- }
- }
-
- return NULL;
-}
+ if (opcode_data == NULL)
+ return false;
-bool
-EmulateInstructionMIPS::SetTargetTriple (const ArchSpec &arch)
-{
- if (arch.GetTriple().getArch () == llvm::Triple::mips
- || arch.GetTriple().getArch () == llvm::Triple::mipsel)
- return true;
+ uint64_t old_pc = 0, new_pc = 0;
+ const bool auto_advance_pc =
+ evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
+
+ if (auto_advance_pc) {
+ old_pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
+ }
+
+ /* emulate instruction */
+ success = (this->*opcode_data->callback)(mc_insn);
+ if (!success)
return false;
-}
-const char *
-EmulateInstructionMIPS::GetRegisterName (unsigned reg_num, bool alternate_name)
-{
- if (alternate_name)
- {
- switch (reg_num)
- {
- case dwarf_sp_mips: return "r29";
- case dwarf_r30_mips: return "r30";
- case dwarf_ra_mips: return "r31";
- case dwarf_f0_mips: return "f0";
- case dwarf_f1_mips: return "f1";
- case dwarf_f2_mips: return "f2";
- case dwarf_f3_mips: return "f3";
- case dwarf_f4_mips: return "f4";
- case dwarf_f5_mips: return "f5";
- case dwarf_f6_mips: return "f6";
- case dwarf_f7_mips: return "f7";
- case dwarf_f8_mips: return "f8";
- case dwarf_f9_mips: return "f9";
- case dwarf_f10_mips: return "f10";
- case dwarf_f11_mips: return "f11";
- case dwarf_f12_mips: return "f12";
- case dwarf_f13_mips: return "f13";
- case dwarf_f14_mips: return "f14";
- case dwarf_f15_mips: return "f15";
- case dwarf_f16_mips: return "f16";
- case dwarf_f17_mips: return "f17";
- case dwarf_f18_mips: return "f18";
- case dwarf_f19_mips: return "f19";
- case dwarf_f20_mips: return "f20";
- case dwarf_f21_mips: return "f21";
- case dwarf_f22_mips: return "f22";
- case dwarf_f23_mips: return "f23";
- case dwarf_f24_mips: return "f24";
- case dwarf_f25_mips: return "f25";
- case dwarf_f26_mips: return "f26";
- case dwarf_f27_mips: return "f27";
- case dwarf_f28_mips: return "f28";
- case dwarf_f29_mips: return "f29";
- case dwarf_f30_mips: return "f30";
- case dwarf_f31_mips: return "f31";
- case dwarf_w0_mips: return "w0";
- case dwarf_w1_mips: return "w1";
- case dwarf_w2_mips: return "w2";
- case dwarf_w3_mips: return "w3";
- case dwarf_w4_mips: return "w4";
- case dwarf_w5_mips: return "w5";
- case dwarf_w6_mips: return "w6";
- case dwarf_w7_mips: return "w7";
- case dwarf_w8_mips: return "w8";
- case dwarf_w9_mips: return "w9";
- case dwarf_w10_mips: return "w10";
- case dwarf_w11_mips: return "w11";
- case dwarf_w12_mips: return "w12";
- case dwarf_w13_mips: return "w13";
- case dwarf_w14_mips: return "w14";
- case dwarf_w15_mips: return "w15";
- case dwarf_w16_mips: return "w16";
- case dwarf_w17_mips: return "w17";
- case dwarf_w18_mips: return "w18";
- case dwarf_w19_mips: return "w19";
- case dwarf_w20_mips: return "w20";
- case dwarf_w21_mips: return "w21";
- case dwarf_w22_mips: return "w22";
- case dwarf_w23_mips: return "w23";
- case dwarf_w24_mips: return "w24";
- case dwarf_w25_mips: return "w25";
- case dwarf_w26_mips: return "w26";
- case dwarf_w27_mips: return "w27";
- case dwarf_w28_mips: return "w28";
- case dwarf_w29_mips: return "w29";
- case dwarf_w30_mips: return "w30";
- case dwarf_w31_mips: return "w31";
- case dwarf_mir_mips: return "mir";
- case dwarf_mcsr_mips: return "mcsr";
- case dwarf_config5_mips: return "config5";
- default:
- break;
- }
- return nullptr;
- }
+ if (auto_advance_pc) {
+ new_pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- switch (reg_num)
- {
- case dwarf_zero_mips: return "r0";
- case dwarf_r1_mips: return "r1";
- case dwarf_r2_mips: return "r2";
- case dwarf_r3_mips: return "r3";
- case dwarf_r4_mips: return "r4";
- case dwarf_r5_mips: return "r5";
- case dwarf_r6_mips: return "r6";
- case dwarf_r7_mips: return "r7";
- case dwarf_r8_mips: return "r8";
- case dwarf_r9_mips: return "r9";
- case dwarf_r10_mips: return "r10";
- case dwarf_r11_mips: return "r11";
- case dwarf_r12_mips: return "r12";
- case dwarf_r13_mips: return "r13";
- case dwarf_r14_mips: return "r14";
- case dwarf_r15_mips: return "r15";
- case dwarf_r16_mips: return "r16";
- case dwarf_r17_mips: return "r17";
- case dwarf_r18_mips: return "r18";
- case dwarf_r19_mips: return "r19";
- case dwarf_r20_mips: return "r20";
- case dwarf_r21_mips: return "r21";
- case dwarf_r22_mips: return "r22";
- case dwarf_r23_mips: return "r23";
- case dwarf_r24_mips: return "r24";
- case dwarf_r25_mips: return "r25";
- case dwarf_r26_mips: return "r26";
- case dwarf_r27_mips: return "r27";
- case dwarf_gp_mips: return "gp";
- case dwarf_sp_mips: return "sp";
- case dwarf_r30_mips: return "fp";
- case dwarf_ra_mips: return "ra";
- case dwarf_sr_mips: return "sr";
- case dwarf_lo_mips: return "lo";
- case dwarf_hi_mips: return "hi";
- case dwarf_bad_mips: return "bad";
- case dwarf_cause_mips: return "cause";
- case dwarf_pc_mips: return "pc";
- case dwarf_f0_mips: return "f0";
- case dwarf_f1_mips: return "f1";
- case dwarf_f2_mips: return "f2";
- case dwarf_f3_mips: return "f3";
- case dwarf_f4_mips: return "f4";
- case dwarf_f5_mips: return "f5";
- case dwarf_f6_mips: return "f6";
- case dwarf_f7_mips: return "f7";
- case dwarf_f8_mips: return "f8";
- case dwarf_f9_mips: return "f9";
- case dwarf_f10_mips: return "f10";
- case dwarf_f11_mips: return "f11";
- case dwarf_f12_mips: return "f12";
- case dwarf_f13_mips: return "f13";
- case dwarf_f14_mips: return "f14";
- case dwarf_f15_mips: return "f15";
- case dwarf_f16_mips: return "f16";
- case dwarf_f17_mips: return "f17";
- case dwarf_f18_mips: return "f18";
- case dwarf_f19_mips: return "f19";
- case dwarf_f20_mips: return "f20";
- case dwarf_f21_mips: return "f21";
- case dwarf_f22_mips: return "f22";
- case dwarf_f23_mips: return "f23";
- case dwarf_f24_mips: return "f24";
- case dwarf_f25_mips: return "f25";
- case dwarf_f26_mips: return "f26";
- case dwarf_f27_mips: return "f27";
- case dwarf_f28_mips: return "f28";
- case dwarf_f29_mips: return "f29";
- case dwarf_f30_mips: return "f30";
- case dwarf_f31_mips: return "f31";
- case dwarf_fcsr_mips: return "fcsr";
- case dwarf_fir_mips: return "fir";
- case dwarf_w0_mips: return "w0";
- case dwarf_w1_mips: return "w1";
- case dwarf_w2_mips: return "w2";
- case dwarf_w3_mips: return "w3";
- case dwarf_w4_mips: return "w4";
- case dwarf_w5_mips: return "w5";
- case dwarf_w6_mips: return "w6";
- case dwarf_w7_mips: return "w7";
- case dwarf_w8_mips: return "w8";
- case dwarf_w9_mips: return "w9";
- case dwarf_w10_mips: return "w10";
- case dwarf_w11_mips: return "w11";
- case dwarf_w12_mips: return "w12";
- case dwarf_w13_mips: return "w13";
- case dwarf_w14_mips: return "w14";
- case dwarf_w15_mips: return "w15";
- case dwarf_w16_mips: return "w16";
- case dwarf_w17_mips: return "w17";
- case dwarf_w18_mips: return "w18";
- case dwarf_w19_mips: return "w19";
- case dwarf_w20_mips: return "w20";
- case dwarf_w21_mips: return "w21";
- case dwarf_w22_mips: return "w22";
- case dwarf_w23_mips: return "w23";
- case dwarf_w24_mips: return "w24";
- case dwarf_w25_mips: return "w25";
- case dwarf_w26_mips: return "w26";
- case dwarf_w27_mips: return "w27";
- case dwarf_w28_mips: return "w28";
- case dwarf_w29_mips: return "w29";
- case dwarf_w30_mips: return "w30";
- case dwarf_w31_mips: return "w31";
- case dwarf_mcsr_mips: return "mcsr";
- case dwarf_mir_mips: return "mir";
- case dwarf_config5_mips: return "config5";
+ /* If we haven't changed the PC, change it here */
+ if (old_pc == new_pc) {
+ new_pc += 4;
+ Context context;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ new_pc))
+ return false;
}
- return nullptr;
+ }
+
+ return true;
}
-bool
-EmulateInstructionMIPS::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo ®_info)
-{
- if (reg_kind == eRegisterKindGeneric)
- {
- switch (reg_num)
- {
- case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = dwarf_pc_mips; break;
- case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sp_mips; break;
- case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_r30_mips; break;
- case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = dwarf_ra_mips; break;
- case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sr_mips; break;
- default:
- return false;
- }
- }
+bool EmulateInstructionMIPS::CreateFunctionEntryUnwind(
+ UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
- if (reg_kind == eRegisterKindDWARF)
- {
- ::memset (®_info, 0, sizeof(RegisterInfo));
- ::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
-
- if (reg_num == dwarf_sr_mips || reg_num == dwarf_fcsr_mips || reg_num == dwarf_fir_mips || reg_num == dwarf_mcsr_mips || reg_num == dwarf_mir_mips || reg_num == dwarf_config5_mips)
- {
- reg_info.byte_size = 4;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- }
- else if ((int)reg_num >= dwarf_zero_mips && (int)reg_num <= dwarf_f31_mips)
- {
- reg_info.byte_size = 4;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- }
- else if ((int)reg_num >= dwarf_w0_mips && (int)reg_num <= dwarf_w31_mips)
- {
- reg_info.byte_size = 16;
- reg_info.format = eFormatVectorOfUInt8;
- reg_info.encoding = eEncodingVector;
- }
- else
- {
- return false;
- }
-
- reg_info.name = GetRegisterName (reg_num, false);
- reg_info.alt_name = GetRegisterName (reg_num, true);
- reg_info.kinds[eRegisterKindDWARF] = reg_num;
-
- switch (reg_num)
- {
- case dwarf_r30_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
- case dwarf_ra_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
- case dwarf_sp_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
- case dwarf_pc_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
- case dwarf_sr_mips: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
- default: break;
- }
- return true;
- }
- return false;
-}
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+ const bool can_replace = false;
-EmulateInstructionMIPS::MipsOpcode*
-EmulateInstructionMIPS::GetOpcodeForInstruction (const char *op_name)
-{
- static EmulateInstructionMIPS::MipsOpcode
- g_opcodes[] =
- {
- //----------------------------------------------------------------------
- // Prologue/Epilogue instructions
- //----------------------------------------------------------------------
- { "ADDiu", &EmulateInstructionMIPS::Emulate_ADDiu, "ADDIU rt, rs, immediate" },
- { "SW", &EmulateInstructionMIPS::Emulate_SW, "SW rt, offset(rs)" },
- { "LW", &EmulateInstructionMIPS::Emulate_LW, "LW rt, offset(base)" },
- { "SUBU", &EmulateInstructionMIPS::Emulate_SUBU_ADDU, "SUBU rd, rs, rt" },
- { "ADDU", &EmulateInstructionMIPS::Emulate_SUBU_ADDU, "ADDU rd, rs, rt" },
- { "LUI", &EmulateInstructionMIPS::Emulate_LUI, "LUI rt, immediate" },
-
- //----------------------------------------------------------------------
- // MicroMIPS Prologue/Epilogue instructions
- //----------------------------------------------------------------------
- { "ADDIUSP_MM", &EmulateInstructionMIPS::Emulate_ADDIUSP, "ADDIU immediate" },
- { "ADDIUS5_MM", &EmulateInstructionMIPS::Emulate_ADDIUS5, "ADDIUS5 rd,immediate" },
- { "SWSP_MM", &EmulateInstructionMIPS::Emulate_SWSP, "SWSP rt,offset(sp)" },
- { "SWM16_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWM16 reglist,offset(sp)" },
- { "SWM32_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWM32 reglist,offset(base)" },
- { "SWP_MM", &EmulateInstructionMIPS::Emulate_SWM16_32, "SWP rs1,offset(base)" },
- { "LWSP_MM", &EmulateInstructionMIPS::Emulate_LWSP, "LWSP rt,offset(sp)" },
- { "LWM16_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "LWM16 reglist,offset(sp)" },
- { "LWM32_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "LWM32 reglist,offset(base)" },
- { "LWP_MM", &EmulateInstructionMIPS::Emulate_LWM16_32, "LWP rd,offset(base)" },
- { "JRADDIUSP", &EmulateInstructionMIPS::Emulate_JRADDIUSP, "JRADDIUSP immediate" },
- //----------------------------------------------------------------------
-
- // Load/Store instructions
- //----------------------------------------------------------------------
- /* Following list of emulated instructions are required by implementation of hardware watchpoint
- for MIPS in lldb. As we just need the address accessed by instructions, we have generalised
- all these instructions in 2 functions depending on their addressing modes */
-
- { "LB", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LB rt, offset(base)" },
- { "LBE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBE rt, offset(base)" },
- { "LBU", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBU rt, offset(base)" },
- { "LBUE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBUE rt, offset(base)" },
- { "LDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDC1 ft, offset(base)" },
- { "LD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LD rt, offset(base)" },
- { "LDL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDL rt, offset(base)" },
- { "LDR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDR rt, offset(base)" },
- { "LLD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLD rt, offset(base)" },
- { "LDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LDC2 rt, offset(base)" },
- { "LDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LDXC1 fd, index (base)" },
- { "LH", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LH rt, offset(base)" },
- { "LHE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHE rt, offset(base)" },
- { "LHU", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHU rt, offset(base)" },
- { "LHUE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHUE rt, offset(base)" },
- { "LL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LL rt, offset(base)" },
- { "LLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLE rt, offset(base)" },
- { "LUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LUXC1 fd, index (base)" },
- { "LW", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LW rt, offset(base)" },
- { "LWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWC1 ft, offset(base)" },
- { "LWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWC2 rt, offset(base)" },
- { "LWE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWE rt, offset(base)" },
- { "LWL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWL rt, offset(base)" },
- { "LWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWLE rt, offset(base)" },
- { "LWR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWR rt, offset(base)" },
- { "LWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWRE rt, offset(base)" },
- { "LWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "LWXC1 fd, index (base)" },
- { "LLX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLX rt, offset(base)" },
- { "LLXE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLXE rt, offset(base)" },
- { "LLDX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LLDX rt, offset(base)" },
-
- { "SB", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SB rt, offset(base)" },
- { "SBE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SBE rt, offset(base)" },
- { "SC", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SC rt, offset(base)" },
- { "SCE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCE rt, offset(base)" },
- { "SCD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCD rt, offset(base)" },
- { "SD", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SD rt, offset(base)" },
- { "SDL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDL rt, offset(base)" },
- { "SDR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDR rt, offset(base)" },
- { "SDC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDC1 ft, offset(base)" },
- { "SDC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SDC2 rt, offset(base)" },
- { "SDXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SDXC1 fs, index(base)" },
- { "SH", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SH rt, offset(base)" },
- { "SHE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SHE rt, offset(base)" },
- { "SUXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SUXC1 fs, index (base)" },
- { "SWC1", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWC1 ft, offset(base)" },
- { "SWC2", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWC2 rt, offset(base)" },
- { "SWE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWE rt, offset(base)" },
- { "SWL", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWL rt, offset(base)" },
- { "SWLE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWLE rt, offset(base)" },
- { "SWR", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWR rt, offset(base)" },
- { "SWRE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWRE rt, offset(base)" },
- { "SWXC1", &EmulateInstructionMIPS::Emulate_LDST_Reg, "SWXC1 fs, index (base)" },
- { "SCX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCX rt, offset(base)" },
- { "SCXE", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCXE rt, offset(base)" },
- { "SCDX", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SCDX rt, offset(base)" },
-
- //----------------------------------------------------------------------
- // MicroMIPS Load/Store instructions
- //----------------------------------------------------------------------
- { "LBU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LBU16 rt, decoded_offset(base)" },
- { "LHU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LHU16 rt, left_shifted_offset(base)" },
- { "LW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LW16 rt, left_shifted_offset(base)" },
- { "LWGP_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "LWGP rt, left_shifted_offset(gp)" },
- { "SH16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SH16 rt, left_shifted_offset(base)" },
- { "SW16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SW16 rt, left_shifted_offset(base)" },
- { "SW_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SWSP rt, left_shifted_offset(base)" },
- { "SB16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm, "SB16 rt, offset(base)" },
-
- //----------------------------------------------------------------------
- // Branch instructions
- //----------------------------------------------------------------------
- { "BEQ", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQ rs,rt,offset" },
- { "BNE", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNE rs,rt,offset" },
- { "BEQL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQL rs,rt,offset" },
- { "BNEL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNEL rs,rt,offset" },
- { "BGEZALL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BGEZALL rt,offset" },
- { "BAL", &EmulateInstructionMIPS::Emulate_BAL, "BAL offset" },
- { "BGEZAL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BGEZAL rs,offset" },
- { "BALC", &EmulateInstructionMIPS::Emulate_BALC, "BALC offset" },
- { "BC", &EmulateInstructionMIPS::Emulate_BC, "BC offset" },
- { "BGEZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGEZ rs,offset" },
- { "BLEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BLEZALC rs,offset" },
- { "BGEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BGEZALC rs,offset" },
- { "BLTZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BLTZALC rs,offset" },
- { "BGTZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BGTZALC rs,offset" },
- { "BEQZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BEQZALC rs,offset" },
- { "BNEZALC", &EmulateInstructionMIPS::Emulate_Bcond_Link_C,"BNEZALC rs,offset" },
- { "BEQC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BEQC rs,rt,offset" },
- { "BNEC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BNEC rs,rt,offset" },
- { "BLTC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BLTC rs,rt,offset" },
- { "BGEC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BGEC rs,rt,offset" },
- { "BLTUC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BLTUC rs,rt,offset" },
- { "BGEUC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BGEUC rs,rt,offset" },
- { "BLTZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BLTZC rt,offset" },
- { "BLEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BLEZC rt,offset" },
- { "BGEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BGEZC rt,offset" },
- { "BGTZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BGTZC rt,offset" },
- { "BEQZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BEQZC rt,offset" },
- { "BNEZC", &EmulateInstructionMIPS::Emulate_BXX_2ops_C, "BNEZC rt,offset" },
- { "BGEZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGEZL rt,offset" },
- { "BGTZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGTZ rt,offset" },
- { "BGTZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BGTZL rt,offset" },
- { "BLEZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLEZ rt,offset" },
- { "BLEZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLEZL rt,offset" },
- { "BLTZ", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLTZ rt,offset" },
- { "BLTZAL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BLTZAL rt,offset" },
- { "BLTZALL", &EmulateInstructionMIPS::Emulate_Bcond_Link, "BLTZALL rt,offset" },
- { "BLTZL", &EmulateInstructionMIPS::Emulate_BXX_2ops, "BLTZL rt,offset" },
- { "BOVC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BOVC rs,rt,offset" },
- { "BNVC", &EmulateInstructionMIPS::Emulate_BXX_3ops_C, "BNVC rs,rt,offset" },
- { "J", &EmulateInstructionMIPS::Emulate_J, "J target" },
- { "JAL", &EmulateInstructionMIPS::Emulate_JAL, "JAL target" },
- { "JALX", &EmulateInstructionMIPS::Emulate_JAL, "JALX target" },
- { "JALR", &EmulateInstructionMIPS::Emulate_JALR, "JALR target" },
- { "JALR_HB", &EmulateInstructionMIPS::Emulate_JALR, "JALR.HB target" },
- { "JIALC", &EmulateInstructionMIPS::Emulate_JIALC, "JIALC rt,offset" },
- { "JIC", &EmulateInstructionMIPS::Emulate_JIC, "JIC rt,offset" },
- { "JR", &EmulateInstructionMIPS::Emulate_JR, "JR target" },
- { "JR_HB", &EmulateInstructionMIPS::Emulate_JR, "JR.HB target" },
- { "BC1F", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1F cc, offset" },
- { "BC1T", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1T cc, offset" },
- { "BC1FL", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1FL cc, offset" },
- { "BC1TL", &EmulateInstructionMIPS::Emulate_FP_branch, "BC1TL cc, offset" },
- { "BC1EQZ", &EmulateInstructionMIPS::Emulate_BC1EQZ, "BC1EQZ ft, offset" },
- { "BC1NEZ", &EmulateInstructionMIPS::Emulate_BC1NEZ, "BC1NEZ ft, offset" },
- { "BC1ANY2F", &EmulateInstructionMIPS::Emulate_3D_branch, "BC1ANY2F cc, offset" },
- { "BC1ANY2T", &EmulateInstructionMIPS::Emulate_3D_branch, "BC1ANY2T cc, offset" },
- { "BC1ANY4F", &EmulateInstructionMIPS::Emulate_3D_branch, "BC1ANY4F cc, offset" },
- { "BC1ANY4T", &EmulateInstructionMIPS::Emulate_3D_branch, "BC1ANY4T cc, offset" },
- { "BNZ_B", &EmulateInstructionMIPS::Emulate_BNZB, "BNZ.b wt,s16" },
- { "BNZ_H", &EmulateInstructionMIPS::Emulate_BNZH, "BNZ.h wt,s16" },
- { "BNZ_W", &EmulateInstructionMIPS::Emulate_BNZW, "BNZ.w wt,s16" },
- { "BNZ_D", &EmulateInstructionMIPS::Emulate_BNZD, "BNZ.d wt,s16" },
- { "BZ_B", &EmulateInstructionMIPS::Emulate_BZB, "BZ.b wt,s16" },
- { "BZ_H", &EmulateInstructionMIPS::Emulate_BZH, "BZ.h wt,s16" },
- { "BZ_W", &EmulateInstructionMIPS::Emulate_BZW, "BZ.w wt,s16" },
- { "BZ_D", &EmulateInstructionMIPS::Emulate_BZD, "BZ.d wt,s16" },
- { "BNZ_V", &EmulateInstructionMIPS::Emulate_BNZV, "BNZ.V wt,s16" },
- { "BZ_V", &EmulateInstructionMIPS::Emulate_BZV, "BZ.V wt,s16" },
-
- //----------------------------------------------------------------------
- // MicroMIPS Branch instructions
- //----------------------------------------------------------------------
- { "B16_MM", &EmulateInstructionMIPS::Emulate_B16_MM, "B16 offset" },
- { "BEQZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BEQZ16 rs, offset" },
- { "BNEZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BNEZ16 rs, offset" },
- { "BEQZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BEQZC rs, offset" },
- { "BNEZC_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BNEZC rs, offset" },
- { "BGEZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BGEZALS rs, offset" },
- { "BLTZALS_MM", &EmulateInstructionMIPS::Emulate_Branch_MM, "BLTZALS rs, offset" },
- { "JALR16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALR16 rs" },
- { "JALRS16_MM", &EmulateInstructionMIPS::Emulate_JALRx16_MM, "JALRS16 rs" },
- { "JR16_MM", &EmulateInstructionMIPS::Emulate_JR, "JR16 rs rs" },
- { "JRC16_MM", &EmulateInstructionMIPS::Emulate_JR, "JRC16 rs rs" },
- { "JALS_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALS target" },
- { "JALX_MM", &EmulateInstructionMIPS::Emulate_JALx, "JALX target" },
- { "JALRS_MM", &EmulateInstructionMIPS::Emulate_JALRS, "JALRS rt, rs" },
- };
-
- static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
-
- for (size_t i = 0; i < k_num_mips_opcodes; ++i)
- {
- if (! strcasecmp (g_opcodes[i].op_name, op_name))
- return &g_opcodes[i];
- }
+ // Our previous Call Frame Address is the stack pointer
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips, 0);
- return NULL;
-}
+ // Our previous PC is in the RA
+ row->SetRegisterLocationToRegister(dwarf_pc_mips, dwarf_ra_mips, can_replace);
-uint32_t
-EmulateInstructionMIPS::GetSizeOfInstruction (lldb_private::DataExtractor& data, uint64_t inst_addr)
-{
- uint64_t next_inst_size = 0;
- llvm::MCInst mc_insn;
- llvm::MCDisassembler::DecodeStatus decode_status;
- llvm::ArrayRef<uint8_t> raw_insn (data.GetDataStart(), data.GetByteSize());
+ unwind_plan.AppendRow(row);
- if (m_use_alt_disaasm)
- decode_status = m_alt_disasm->getInstruction (mc_insn, next_inst_size, raw_insn, inst_addr, llvm::nulls(), llvm::nulls());
- else
- decode_status = m_disasm->getInstruction (mc_insn, next_inst_size, raw_insn, inst_addr, llvm::nulls(), llvm::nulls());
+ // All other registers are the same.
+ unwind_plan.SetSourceName("EmulateInstructionMIPS");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolYes);
+ unwind_plan.SetReturnAddressRegister(dwarf_ra_mips);
- if (decode_status != llvm::MCDisassembler::Success)
- return false;
-
- return m_insn_info->get(mc_insn.getOpcode()).getSize();
+ return true;
}
-bool
-EmulateInstructionMIPS::SetInstruction (const Opcode &insn_opcode, const Address &inst_addr, Target *target)
-{
- m_use_alt_disaasm = false;
-
- if (EmulateInstruction::SetInstruction (insn_opcode, inst_addr, target))
- {
- if (inst_addr.GetAddressClass() == eAddressClassCodeAlternateISA)
- {
- Error error;
- lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
-
- /*
- * The address belongs to microMIPS function. To find the size of
- * next instruction use microMIPS disassembler.
- */
- m_use_alt_disaasm = true;
-
- uint32_t current_inst_size = insn_opcode.GetByteSize();
- uint8_t buf[sizeof(uint32_t)];
- uint64_t next_inst_addr = (m_addr & (~1ull)) + current_inst_size;
- Address next_addr (next_inst_addr);
-
- const size_t bytes_read = target->ReadMemory (next_addr, /* Address of next instruction */
- true, /* prefer_file_cache */
- buf,
- sizeof(uint32_t),
- error,
- &load_addr);
-
- if (bytes_read == 0)
- return true;
-
- DataExtractor data (buf, sizeof(uint32_t), GetByteOrder(), GetAddressByteSize());
- m_next_inst_size = GetSizeOfInstruction (data, next_inst_addr);
- return true;
- }
- else
- {
- /*
- * If the address class is not eAddressClassCodeAlternateISA then
- * the function is not microMIPS. In this case instruction size is
- * always 4 bytes.
- */
- m_next_inst_size = 4;
- return true;
- }
- }
+bool EmulateInstructionMIPS::nonvolatile_reg_p(uint32_t regnum) {
+ switch (regnum) {
+ case dwarf_r16_mips:
+ case dwarf_r17_mips:
+ case dwarf_r18_mips:
+ case dwarf_r19_mips:
+ case dwarf_r20_mips:
+ case dwarf_r21_mips:
+ case dwarf_r22_mips:
+ case dwarf_r23_mips:
+ case dwarf_gp_mips:
+ case dwarf_sp_mips:
+ case dwarf_r30_mips:
+ case dwarf_ra_mips:
+ return true;
+ default:
return false;
+ }
+ return false;
}
-bool
-EmulateInstructionMIPS::ReadInstruction ()
-{
- bool success = false;
- m_addr = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success);
- if (success)
- {
- Context read_inst_context;
- read_inst_context.type = eContextReadOpcode;
- read_inst_context.SetNoArgs ();
- m_opcode.SetOpcode32 (ReadMemoryUnsigned (read_inst_context, m_addr, 4, 0, &success), GetByteOrder());
- }
- if (!success)
- m_addr = LLDB_INVALID_ADDRESS;
- return success;
-}
+bool EmulateInstructionMIPS::Emulate_ADDiu(llvm::MCInst &insn) {
+ // ADDIU rt, rs, immediate
+ // GPR[rt] <- GPR[rs] + sign_extend(immediate)
-bool
-EmulateInstructionMIPS::EvaluateInstruction (uint32_t evaluate_options)
-{
- bool success = false;
- llvm::MCInst mc_insn;
- uint64_t insn_size;
- DataExtractor data;
-
- /* Keep the complexity of the decode logic with the llvm::MCDisassembler class. */
- if (m_opcode.GetData (data))
- {
- llvm::MCDisassembler::DecodeStatus decode_status;
- llvm::ArrayRef<uint8_t> raw_insn (data.GetDataStart(), data.GetByteSize());
- if (m_use_alt_disaasm)
- decode_status = m_alt_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
- else
- decode_status = m_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+ uint8_t dst, src;
+ bool success = false;
+ const uint32_t imm16 = insn.getOperand(2).getImm();
+ int64_t imm = SignedBits(imm16, 15, 0);
- if (decode_status != llvm::MCDisassembler::Success)
- return false;
- }
+ dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
- /*
- * mc_insn.getOpcode() returns decoded opcode. However to make use
- * of llvm::Mips::<insn> we would need "MipsGenInstrInfo.inc".
- */
- const char *op_name = m_insn_info->getName (mc_insn.getOpcode ());
+ // If immediate value is greater then 2^16 - 1 then clang generate
+ // LUI, ADDIU, SUBU instructions in prolog.
+ // Example
+ // lui $1, 0x2
+ // addiu $1, $1, -0x5920
+ // subu $sp, $sp, $1
+ // In this case, ADDIU dst and src will be same and not equal to sp
+ if (dst == src) {
+ Context context;
- if (op_name == NULL)
- return false;
+ /* read <src> register */
+ const int64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
+ if (!success)
+ return false;
- /*
- * Decoding has been done already. Just get the call-back function
- * and emulate the instruction.
- */
- MipsOpcode *opcode_data = GetOpcodeForInstruction (op_name);
+ /* Check if this is daddiu sp, sp, imm16 */
+ if (dst == dwarf_sp_mips) {
+ uint64_t result = src_opd_val + imm;
+ RegisterInfo reg_info_sp;
- if (opcode_data == NULL)
- return false;
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, imm);
- uint64_t old_pc = 0, new_pc = 0;
- const bool auto_advance_pc = evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
+ /* We are allocating bytes on stack */
+ context.type = eContextAdjustStackPointer;
- if (auto_advance_pc)
- {
- old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ return true;
}
- /* emulate instruction */
- success = (this->*opcode_data->callback) (mc_insn);
- if (!success)
- return false;
+ imm += src_opd_val;
+ context.SetImmediateSigned(imm);
+ context.type = eContextImmediate;
- if (auto_advance_pc)
- {
- new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
-
- /* If we haven't changed the PC, change it here */
- if (old_pc == new_pc)
- {
- new_pc += 4;
- Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, new_pc))
- return false;
- }
- }
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips + dst, imm))
+ return false;
+ }
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
-{
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind (eRegisterKindDWARF);
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
- const bool can_replace = false;
-
- // Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips, 0);
-
- // Our previous PC is in the RA
- row->SetRegisterLocationToRegister(dwarf_pc_mips, dwarf_ra_mips, can_replace);
-
- unwind_plan.AppendRow (row);
-
- // All other registers are the same.
- unwind_plan.SetSourceName ("EmulateInstructionMIPS");
- unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolYes);
- unwind_plan.SetReturnAddressRegister (dwarf_ra_mips);
+bool EmulateInstructionMIPS::Emulate_SW(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t imm16 = insn.getOperand(2).getImm();
+ uint32_t imm = SignedBits(imm16, 15, 0);
+ uint32_t src, base;
+ int32_t address;
+ Context bad_vaddr_context;
- return true;
-}
+ RegisterInfo reg_info_base;
-bool
-EmulateInstructionMIPS::nonvolatile_reg_p (uint32_t regnum)
-{
- switch (regnum)
- {
- case dwarf_r16_mips:
- case dwarf_r17_mips:
- case dwarf_r18_mips:
- case dwarf_r19_mips:
- case dwarf_r20_mips:
- case dwarf_r21_mips:
- case dwarf_r22_mips:
- case dwarf_r23_mips:
- case dwarf_gp_mips:
- case dwarf_sp_mips:
- case dwarf_r30_mips:
- case dwarf_ra_mips:
- return true;
- default:
- return false;
- }
+ src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
return false;
-}
-bool
-EmulateInstructionMIPS::Emulate_ADDiu (llvm::MCInst& insn)
-{
- // ADDIU rt, rs, immediate
- // GPR[rt] <- GPR[rs] + sign_extend(immediate)
-
- uint8_t dst, src;
- bool success = false;
- const uint32_t imm16 = insn.getOperand(2).getImm();
- int64_t imm = SignedBits(imm16, 15, 0);
-
- dst = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
-
- // If immediate value is greater then 2^16 - 1 then clang generate
- // LUI, ADDIU, SUBU instructions in prolog.
- // Example
- // lui $1, 0x2
- // addiu $1, $1, -0x5920
- // subu $sp, $sp, $1
- // In this case, ADDIU dst and src will be same and not equal to sp
- if (dst == src)
- {
- Context context;
-
- /* read <src> register */
- const int64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
- if (!success)
- return false;
-
- /* Check if this is daddiu sp, sp, imm16 */
- if (dst == dwarf_sp_mips)
- {
- uint64_t result = src_opd_val + imm;
- RegisterInfo reg_info_sp;
-
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, imm);
-
- /* We are allocating bytes on stack */
- context.type = eContextAdjustStackPointer;
-
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
- return true;
- }
-
- imm += src_opd_val;
- context.SetImmediateSigned (imm);
- context.type = eContextImmediate;
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + dst, imm))
- return false;
- }
+ /* destination address */
+ address = address + imm;
- return true;
-}
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
-bool
-EmulateInstructionMIPS::Emulate_SW (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t imm16 = insn.getOperand(2).getImm();
- uint32_t imm = SignedBits(imm16, 15, 0);
- uint32_t src, base;
- int32_t address;
- Context bad_vaddr_context;
+ /* We look for sp based non-volatile register stores */
+ if (nonvolatile_reg_p(src)) {
- RegisterInfo reg_info_base;
+ RegisterInfo reg_info_src;
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + src,
+ reg_info_src))
+ return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset(reg_info_src, reg_info_base, 0);
- /* read base register */
- address = (int32_t)ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ Error error;
- /* destination address */
- address = address + imm;
+ if (!ReadRegister(®_info_base, data_src))
+ return false;
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+ if (data_src.GetAsMemoryData(®_info_src, buffer, reg_info_src.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
- /* We look for sp based non-volatile register stores */
- if (nonvolatile_reg_p (src))
- {
+ if (!WriteMemory(context, address, buffer, reg_info_src.byte_size))
+ return false;
- RegisterInfo reg_info_src;
+ return true;
+ }
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
- return false;
+ return false;
+}
- Context context;
- RegisterValue data_src;
- context.type = eContextPushRegisterOnStack;
- context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
+bool EmulateInstructionMIPS::Emulate_LW(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t src, base;
+ int32_t imm, address;
+ Context bad_vaddr_context;
- uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
- Error error;
+ src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ imm = insn.getOperand(2).getImm();
- if (!ReadRegister (®_info_base, data_src))
- return false;
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- if (data_src.GetAsMemoryData (®_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
- return false;
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- if (!WriteMemory (context, address, buffer, reg_info_src.byte_size))
- return false;
+ /* destination address */
+ address = address + imm;
- return true;
- }
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
- return false;
-}
+ if (nonvolatile_reg_p(src)) {
+ RegisterValue data_src;
+ RegisterInfo reg_info_src;
-bool
-EmulateInstructionMIPS::Emulate_LW (llvm::MCInst& insn)
-{
- bool success =false;
- uint32_t src, base;
- int32_t imm, address;
- Context bad_vaddr_context;
-
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- imm = insn.getOperand(2).getImm();
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + src,
+ reg_info_src))
+ return false;
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ Context context;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress(address);
- /* read base register */
- address = (int32_t)ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ if (!WriteRegister(context, ®_info_src, data_src))
+ return false;
- /* destination address */
- address = address + imm;
+ return true;
+ }
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
-
- if (nonvolatile_reg_p (src))
- {
- RegisterValue data_src;
- RegisterInfo reg_info_src;
-
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
- return false;
-
- Context context;
- context.type = eContextPopRegisterOffStack;
- context.SetAddress (address);
+ return false;
+}
- if (!WriteRegister (context, ®_info_src, data_src))
- return false;
+bool EmulateInstructionMIPS::Emulate_SUBU_ADDU(llvm::MCInst &insn) {
+ // SUBU sp, <src>, <rt>
+ // ADDU sp, <src>, <rt>
+ // ADDU dst, sp, <rt>
- return true;
- }
+ bool success = false;
+ uint64_t result;
+ uint8_t src, dst, rt;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- return false;
-}
+ dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
-bool
-EmulateInstructionMIPS::Emulate_SUBU_ADDU (llvm::MCInst& insn)
-{
- // SUBU sp, <src>, <rt>
- // ADDU sp, <src>, <rt>
- // ADDU dst, sp, <rt>
-
- bool success = false;
- uint64_t result;
- uint8_t src, dst, rt;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- dst = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
-
- /* Check if sp is destination register */
- if (dst == dwarf_sp_mips)
- {
- rt = m_reg_info->getEncodingValue (insn.getOperand(2).getReg());
-
- /* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
- if (!success)
- return false;
-
- /* read <rt > register */
- uint64_t rt_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
-
- if (!strcasecmp (op_name, "SUBU"))
- result = src_opd_val - rt_opd_val;
- else
- result = src_opd_val + rt_opd_val;
-
- Context context;
- RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, rt_opd_val);
+ /* Check if sp is destination register */
+ if (dst == dwarf_sp_mips) {
+ rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg());
- /* We are allocating bytes on stack */
- context.type = eContextAdjustStackPointer;
+ /* read <src> register */
+ uint64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
+ if (!success)
+ return false;
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ /* read <rt > register */
+ uint64_t rt_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
- return true;
- }
- else if (src == dwarf_sp_mips)
- {
- rt = m_reg_info->getEncodingValue (insn.getOperand(2).getReg());
-
- /* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
- if (!success)
- return false;
-
- /* read <rt> register */
- uint64_t rt_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
-
- Context context;
-
- if (!strcasecmp (op_name, "SUBU"))
- result = src_opd_val - rt_opd_val;
- else
- result = src_opd_val + rt_opd_val;
+ if (!strcasecmp(op_name, "SUBU"))
+ result = src_opd_val - rt_opd_val;
+ else
+ result = src_opd_val + rt_opd_val;
- context.SetImmediateSigned (result);
- context.type = eContextImmediate;
+ Context context;
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, rt_opd_val);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + dst, result))
- return false;
- }
+ /* We are allocating bytes on stack */
+ context.type = eContextAdjustStackPointer;
+
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, result);
return true;
-}
+ } else if (src == dwarf_sp_mips) {
+ rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg());
+
+ /* read <src> register */
+ uint64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + src, 0, &success);
+ if (!success)
+ return false;
+
+ /* read <rt> register */
+ uint64_t rt_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
-bool
-EmulateInstructionMIPS::Emulate_LUI (llvm::MCInst& insn)
-{
- // LUI rt, immediate
- // GPR[rt] <- sign_extend(immediate << 16)
-
- const uint32_t imm32 = insn.getOperand(1).getImm() << 16;
- int64_t imm = SignedBits(imm32, 31, 0);
- uint8_t rt;
Context context;
-
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- context.SetImmediateSigned (imm);
+
+ if (!strcasecmp(op_name, "SUBU"))
+ result = src_opd_val - rt_opd_val;
+ else
+ result = src_opd_val + rt_opd_val;
+
+ context.SetImmediateSigned(result);
context.type = eContextImmediate;
- if (WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + rt, imm))
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips + dst, result))
+ return false;
+ }
+
+ return true;
+}
+
+bool EmulateInstructionMIPS::Emulate_LUI(llvm::MCInst &insn) {
+ // LUI rt, immediate
+ // GPR[rt] <- sign_extend(immediate << 16)
+
+ const uint32_t imm32 = insn.getOperand(1).getImm() << 16;
+ int64_t imm = SignedBits(imm32, 31, 0);
+ uint8_t rt;
+ Context context;
+
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ context.SetImmediateSigned(imm);
+ context.type = eContextImmediate;
+ if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips + rt,
+ imm))
+ return true;
+
+ return false;
+}
+
+bool EmulateInstructionMIPS::Emulate_ADDIUSP(llvm::MCInst &insn) {
+ bool success = false;
+ const uint32_t imm9 = insn.getOperand(0).getImm();
+ uint64_t result;
+
+ // This instruction operates implicitly on stack pointer, so read <sp>
+ // register.
+ uint64_t src_opd_val =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
+ if (!success)
return false;
+
+ result = src_opd_val + imm9;
+
+ Context context;
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, imm9);
+
+ // We are adjusting the stack.
+ context.type = eContextAdjustStackPointer;
+
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_ADDIUSP (llvm::MCInst& insn)
-{
- bool success = false;
- const uint32_t imm9 = insn.getOperand(0).getImm();
- uint64_t result;
+bool EmulateInstructionMIPS::Emulate_ADDIUS5(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t base;
+ const uint32_t imm4 = insn.getOperand(2).getImm();
+ uint64_t result;
+
+ // The source and destination register is same for this instruction.
+ base = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
- // This instruction operates implicitly on stack pointer, so read <sp> register.
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
+ // We are looking for stack adjustment only
+ if (base == dwarf_sp_mips) {
+ // Read stack pointer register
+ uint64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
if (!success)
- return false;
+ return false;
- result = src_opd_val + imm9;
+ result = src_opd_val + imm4;
Context context;
RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, imm9);
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, imm4);
// We are adjusting the stack.
context.type = eContextAdjustStackPointer;
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
- return true;
-}
-
-bool
-EmulateInstructionMIPS::Emulate_ADDIUS5 (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base;
- const uint32_t imm4 = insn.getOperand(2).getImm();
- uint64_t result;
-
- // The source and destination register is same for this instruction.
- base = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
-
- // We are looking for stack adjustment only
- if (base == dwarf_sp_mips)
- {
- // Read stack pointer register
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
-
- result = src_opd_val + imm4;
-
- Context context;
- RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, imm4);
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, result);
+ }
- // We are adjusting the stack.
- context.type = eContextAdjustStackPointer;
+ return true;
+}
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result);
- }
+bool EmulateInstructionMIPS::Emulate_SWSP(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t imm5 = insn.getOperand(2).getImm();
+ uint32_t src, base;
+ Context bad_vaddr_context;
+ uint32_t address;
- return true;
-}
+ src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
-bool
-EmulateInstructionMIPS::Emulate_SWSP (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t imm5 = insn.getOperand(2).getImm();
- uint32_t src, base;
- Context bad_vaddr_context;
- uint32_t address;
+ RegisterInfo reg_info_base;
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- RegisterInfo reg_info_base;
+ // read base register
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + base, 0,
+ &success);
+ if (!success)
+ return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ // destination address
+ address = address + imm5;
- // read base register
- address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ // We use bad_vaddr_context to store base address which is used by H/W
+ // watchpoint
+ // Set the bad_vaddr register with base address used in the instruction
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
- // destination address
- address = address + imm5;
+ // We look for sp based non-volatile register stores.
+ if (base == dwarf_sp_mips && nonvolatile_reg_p(src)) {
+ RegisterInfo reg_info_src = {};
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset(reg_info_src, reg_info_base, 0);
- // We use bad_vaddr_context to store base address which is used by H/W watchpoint
- // Set the bad_vaddr register with base address used in the instruction
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
-
- // We look for sp based non-volatile register stores.
- if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
- {
- RegisterInfo reg_info_src = {};
- Context context;
- RegisterValue data_src;
- context.type = eContextPushRegisterOnStack;
- context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
-
- uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
- Error error;
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ Error error;
- if (!ReadRegister (®_info_base, data_src))
- return false;
+ if (!ReadRegister(®_info_base, data_src))
+ return false;
- if (data_src.GetAsMemoryData (®_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
- return false;
+ if (data_src.GetAsMemoryData(®_info_src, buffer, reg_info_src.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
- if (!WriteMemory (context, address, buffer, reg_info_src.byte_size))
- return false;
+ if (!WriteMemory(context, address, buffer, reg_info_src.byte_size))
+ return false;
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
/* Emulate SWM16,SWM32 and SWP instruction.
- SWM16 always has stack pointer as a base register (but it is still available in MCInst as an operand).
+ SWM16 always has stack pointer as a base register (but it is still available
+ in MCInst as an operand).
SWM32 and SWP can have base register other than stack pointer.
*/
-bool
-EmulateInstructionMIPS::Emulate_SWM16_32 (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t src, base;
- uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on no of regs to store.
+bool EmulateInstructionMIPS::Emulate_SWM16_32(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t src, base;
+ uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on
+ // no of regs to store.
+
+ // Base register is second last operand of the instruction.
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+
+ // We are looking for sp based stores so if base is not a stack pointer then
+ // don't proceed.
+ if (base != dwarf_sp_mips)
+ return false;
- // Base register is second last operand of the instruction.
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+ // offset is always the last operand.
+ uint32_t offset = insn.getOperand(num_operands - 1).getImm();
- // We are looking for sp based stores so if base is not a stack pointer then don't proceed.
- if (base != dwarf_sp_mips)
- return false;
+ RegisterInfo reg_info_base;
+ RegisterInfo reg_info_src;
- // offset is always the last operand.
- uint32_t offset = insn.getOperand(num_operands-1).getImm();
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- RegisterInfo reg_info_base;
- RegisterInfo reg_info_src;
-
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ // read SP
+ uint32_t base_address = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- // read SP
- uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ // Resulting base addrss
+ base_address = base_address + offset;
- // Resulting base addrss
- base_address = base_address + offset;
+ // Total no of registers to be stored are num_operands-2.
+ for (uint32_t i = 0; i < num_operands - 2; i++) {
+ // Get the register number to be stored.
+ src = m_reg_info->getEncodingValue(insn.getOperand(i).getReg());
- // Total no of registers to be stored are num_operands-2.
- for (uint32_t i = 0; i < num_operands - 2; i++)
- {
- // Get the register number to be stored.
- src = m_reg_info->getEncodingValue (insn.getOperand(i).getReg());
-
- /*
- Record only non-volatile stores.
- This check is required for SWP instruction because source operand could be any register.
- SWM16 and SWM32 instruction always has saved registers as source operands.
- */
- if (!nonvolatile_reg_p (src))
- return false;
-
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
- return false;
-
- Context context;
- RegisterValue data_src;
- context.type = eContextPushRegisterOnStack;
- context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
-
- uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
- Error error;
-
- if (!ReadRegister (®_info_base, data_src))
- return false;
+ /*
+ Record only non-volatile stores.
+ This check is required for SWP instruction because source operand could
+ be any register.
+ SWM16 and SWM32 instruction always has saved registers as source
+ operands.
+ */
+ if (!nonvolatile_reg_p(src))
+ return false;
- if (data_src.GetAsMemoryData (®_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
- return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + src,
+ reg_info_src))
+ return false;
- if (!WriteMemory (context, base_address, buffer, reg_info_src.byte_size))
- return false;
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset(reg_info_src, reg_info_base, 0);
- // Stack address for next register
- base_address = base_address + reg_info_src.byte_size;
- }
- return true;
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ Error error;
+
+ if (!ReadRegister(®_info_base, data_src))
+ return false;
+
+ if (data_src.GetAsMemoryData(®_info_src, buffer, reg_info_src.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context, base_address, buffer, reg_info_src.byte_size))
+ return false;
+
+ // Stack address for next register
+ base_address = base_address + reg_info_src.byte_size;
+ }
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_LWSP (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- uint32_t base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- uint32_t imm5 = insn.getOperand(2).getImm();
- Context bad_vaddr_context;
+bool EmulateInstructionMIPS::Emulate_LWSP(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ uint32_t base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ uint32_t imm5 = insn.getOperand(2).getImm();
+ Context bad_vaddr_context;
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- // read base register
- uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ // read base register
+ uint32_t base_address = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- base_address = base_address + imm5;
+ base_address = base_address + imm5;
- // We use bad_vaddr_context to store base address which is used by H/W watchpoint
- // Set the bad_vaddr register with base address used in the instruction
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, base_address);
-
- if (base == dwarf_sp_mips && nonvolatile_reg_p (src))
- {
- RegisterValue data_src;
- RegisterInfo reg_info_src;
-
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + src, reg_info_src))
- return false;
-
- Context context;
- context.type = eContextPopRegisterOffStack;
- context.SetAddress (base_address);
+ // We use bad_vaddr_context to store base address which is used by H/W
+ // watchpoint
+ // Set the bad_vaddr register with base address used in the instruction
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ base_address);
- if (!WriteRegister (context, ®_info_src, data_src))
- return false;
+ if (base == dwarf_sp_mips && nonvolatile_reg_p(src)) {
+ RegisterValue data_src;
+ RegisterInfo reg_info_src;
- return true;
- }
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + src,
+ reg_info_src))
+ return false;
- return false;
+ Context context;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress(base_address);
+
+ if (!WriteRegister(context, ®_info_src, data_src))
+ return false;
+
+ return true;
+ }
+
+ return false;
}
/* Emulate LWM16, LWM32 and LWP instructions.
- LWM16 always has stack pointer as a base register (but it is still available in MCInst as an operand).
+ LWM16 always has stack pointer as a base register (but it is still available
+ in MCInst as an operand).
LWM32 and LWP can have base register other than stack pointer.
*/
-bool
-EmulateInstructionMIPS::Emulate_LWM16_32 (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t dst, base;
- uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on no of regs to store.
- uint32_t imm = insn.getOperand(num_operands-1).getImm(); // imm is the last operand in the instruction.
-
- // Base register is second last operand of the instruction.
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
+bool EmulateInstructionMIPS::Emulate_LWM16_32(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t dst, base;
+ uint32_t num_operands = insn.getNumOperands(); // No of operands vary based on
+ // no of regs to store.
+ uint32_t imm = insn.getOperand(num_operands - 1)
+ .getImm(); // imm is the last operand in the instruction.
+
+ // Base register is second last operand of the instruction.
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+
+ // We are looking for sp based loads so if base is not a stack pointer then
+ // don't proceed.
+ if (base != dwarf_sp_mips)
+ return false;
- // We are looking for sp based loads so if base is not a stack pointer then don't proceed.
- if (base != dwarf_sp_mips)
- return false;
+ uint32_t base_address = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ base_address = base_address + imm;
- base_address = base_address + imm;
+ RegisterValue data_dst;
+ RegisterInfo reg_info_dst;
- RegisterValue data_dst;
- RegisterInfo reg_info_dst;
+ // Total no of registers to be re-stored are num_operands-2.
+ for (uint32_t i = 0; i < num_operands - 2; i++) {
+ // Get the register number to be re-stored.
+ dst = m_reg_info->getEncodingValue(insn.getOperand(i).getReg());
- // Total no of registers to be re-stored are num_operands-2.
- for (uint32_t i = 0; i < num_operands - 2; i++)
- {
- // Get the register number to be re-stored.
- dst = m_reg_info->getEncodingValue (insn.getOperand(i).getReg());
-
- /*
- Record only non-volatile loads.
- This check is required for LWP instruction because destination operand could be any register.
- LWM16 and LWM32 instruction always has saved registers as destination operands.
- */
- if (!nonvolatile_reg_p (dst))
- return false;
-
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + dst, reg_info_dst))
- return false;
-
- Context context;
- context.type = eContextPopRegisterOffStack;
- context.SetAddress (base_address + (i*4));
+ /*
+ Record only non-volatile loads.
+ This check is required for LWP instruction because destination operand
+ could be any register.
+ LWM16 and LWM32 instruction always has saved registers as destination
+ operands.
+ */
+ if (!nonvolatile_reg_p(dst))
+ return false;
- if (!WriteRegister (context, ®_info_dst, data_dst))
- return false;
- }
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + dst,
+ reg_info_dst))
+ return false;
- return true;
+ Context context;
+ context.type = eContextPopRegisterOffStack;
+ context.SetAddress(base_address + (i * 4));
+
+ if (!WriteRegister(context, ®_info_dst, data_dst))
+ return false;
+ }
+
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JRADDIUSP (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t imm5 = insn.getOperand(0).getImm();
-
- /* JRADDIUSP immediate
- * PC <- RA
- * SP <- SP + zero_extend(Immediate << 2)
- */
-
- // This instruction operates implicitly on stack pointer, so read <sp> register.
- int32_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_JRADDIUSP(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t imm5 = insn.getOperand(0).getImm();
- int32_t ra_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_ra_mips, 0, &success);
- if (!success)
- return false;
-
- int32_t result = src_opd_val + imm5;
+ /* JRADDIUSP immediate
+ * PC <- RA
+ * SP <- SP + zero_extend(Immediate << 2)
+ */
- Context context;
+ // This instruction operates implicitly on stack pointer, so read <sp>
+ // register.
+ int32_t src_opd_val =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_sp_mips, 0, &success);
+ if (!success)
+ return false;
- // Update the PC
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, ra_val))
- return false;
-
- RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, imm5);
+ int32_t ra_val =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_ra_mips, 0, &success);
+ if (!success)
+ return false;
- // We are adjusting stack
- context.type = eContextAdjustStackPointer;
+ int32_t result = src_opd_val + imm5;
- // update SP
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips, result))
- return false;
+ Context context;
- return true;
+ // Update the PC
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ ra_val))
+ return false;
+
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, imm5);
+
+ // We are adjusting stack
+ context.type = eContextAdjustStackPointer;
+
+ // update SP
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips,
+ result))
+ return false;
+
+ return true;
}
-static int
-IsAdd64bitOverflow (int32_t a, int32_t b)
-{
- int32_t r = (uint32_t) a + (uint32_t) b;
+static int IsAdd64bitOverflow(int32_t a, int32_t b) {
+ int32_t r = (uint32_t)a + (uint32_t)b;
return (a < 0 && b < 0 && r >= 0) || (a >= 0 && b >= 0 && r < 0);
}
-/*
+/*
Emulate below MIPS branch instructions.
BEQ, BNE : Branch on condition
BEQL, BNEL : Branch likely
*/
-bool
-EmulateInstructionMIPS::Emulate_BXX_3ops (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- int32_t offset, pc, target = 0, rs_val, rt_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- offset = insn.getOperand(2).getImm();
+bool EmulateInstructionMIPS::Emulate_BXX_3ops(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ int32_t offset, pc, target = 0, rs_val, rt_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BEQ") ||
- !strcasecmp (op_name, "BEQL"))
- {
- if (rs_val == rt_val)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BNE") ||
- !strcasecmp (op_name, "BNEL"))
- {
- if (rs_val != rt_val)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BEQ") || !strcasecmp(op_name, "BEQL")) {
+ if (rs_val == rt_val)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BNE") || !strcasecmp(op_name, "BNEL")) {
+ if (rs_val != rt_val)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
-
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
-/*
+/*
Emulate below MIPS branch instructions.
- BEQC, BNEC, BLTC, BGEC, BLTUC, BGEUC, BOVC, BNVC: Compact branch instructions with no delay slot
+ BEQC, BNEC, BLTC, BGEC, BLTUC, BGEUC, BOVC, BNVC: Compact branch
+ instructions with no delay slot
*/
-bool
-EmulateInstructionMIPS::Emulate_BXX_3ops_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- int32_t offset, pc, target = 0, rs_val, rt_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
-
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- offset = insn.getOperand(2).getImm();
+bool EmulateInstructionMIPS::Emulate_BXX_3ops_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ int32_t offset, pc, target = 0, rs_val, rt_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BEQC"))
- {
- if (rs_val == rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEC"))
- {
- if (rs_val != rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTC"))
- {
- if (rs_val < rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEC"))
- {
- if (rs_val >= rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTUC"))
- {
- if (rs_val < rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEUC"))
- {
- if ((uint32_t)rs_val >= (uint32_t)rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BOVC"))
- {
- if (IsAdd64bitOverflow (rs_val, rt_val))
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNVC"))
- {
- if (!IsAdd64bitOverflow (rs_val, rt_val))
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BEQC")) {
+ if (rs_val == rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEC")) {
+ if (rs_val != rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTC")) {
+ if (rs_val < rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEC")) {
+ if (rs_val >= rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTUC")) {
+ if (rs_val < rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEUC")) {
+ if ((uint32_t)rs_val >= (uint32_t)rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BOVC")) {
+ if (IsAdd64bitOverflow(rs_val, rt_val))
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNVC")) {
+ if (!IsAdd64bitOverflow(rs_val, rt_val))
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
-
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
-/*
+/*
Emulate below MIPS conditional branch and link instructions.
BLEZALC, BGEZALC, BLTZALC, BGTZALC, BEQZALC, BNEZALC : Compact branches
*/
-bool
-EmulateInstructionMIPS::Emulate_Bcond_Link_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int32_t offset, pc, target = 0;
- int32_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS::Emulate_Bcond_Link_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int32_t offset, pc, target = 0;
+ int32_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLEZALC"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEZALC"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTZALC"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGTZALC"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BEQZALC"))
- {
- if (rs_val == 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEZALC"))
- {
- if (rs_val != 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BLEZALC")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEZALC")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTZALC")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGTZALC")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BEQZALC")) {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEZALC")) {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
-
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 4))
+ return false;
+
+ return true;
}
-/*
+/*
Emulate below MIPS Non-Compact conditional branch and link instructions.
BLTZAL, BGEZAL :
BLTZALL, BGEZALL : Branch likely
*/
-bool
-EmulateInstructionMIPS::Emulate_Bcond_Link (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int32_t offset, pc, target = 0;
- int32_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS::Emulate_Bcond_Link(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int32_t offset, pc, target = 0;
+ int32_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZAL") ||
- !strcasecmp (op_name, "BLTZALL"))
- {
- if ((int32_t) rs_val < 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGEZAL") ||
- !strcasecmp (op_name, "BGEZALL"))
- {
- if ((int32_t) rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BLTZAL") || !strcasecmp(op_name, "BLTZALL")) {
+ if ((int32_t)rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGEZAL") ||
+ !strcasecmp(op_name, "BGEZALL")) {
+ if ((int32_t)rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS branch instructions.
BLTZL, BGEZL, BGTZL, BLEZL : Branch likely
BLTZ, BGEZ, BGTZ, BLEZ : Non-compact branches
*/
-bool
-EmulateInstructionMIPS::Emulate_BXX_2ops (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int32_t offset, pc, target = 0;
- int32_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS::Emulate_BXX_2ops(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int32_t offset, pc, target = 0;
+ int32_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZL") ||
- !strcasecmp (op_name, "BLTZ"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGEZL") ||
- !strcasecmp (op_name, "BGEZ"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGTZL") ||
- !strcasecmp (op_name, "BGTZ"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BLEZL") ||
- !strcasecmp (op_name, "BLEZ"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BLTZL") || !strcasecmp(op_name, "BLTZ")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGEZL") || !strcasecmp(op_name, "BGEZ")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGTZL") || !strcasecmp(op_name, "BGTZ")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BLEZL") || !strcasecmp(op_name, "BLEZ")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS branch instructions.
BLTZC, BLEZC, BGEZC, BGTZC, BEQZC, BNEZC : Compact Branches
*/
-bool
-EmulateInstructionMIPS::Emulate_BXX_2ops_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int32_t offset, pc, target = 0;
- int32_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+bool EmulateInstructionMIPS::Emulate_BXX_2ops_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int32_t offset, pc, target = 0;
+ int32_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZC"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLEZC"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEZC"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGTZC"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BEQZC"))
- {
- if (rs_val == 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEZC"))
- {
- if (rs_val != 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BLTZC")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLEZC")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEZC")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGTZC")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BEQZC")) {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEZC")) {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_B16_MM (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t offset, pc, target;
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+bool EmulateInstructionMIPS::Emulate_B16_MM(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t offset, pc, target;
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
- offset = insn.getOperand(0).getImm();
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- // unconditional branch
- target = pc + offset;
+ // unconditional branch
+ target = pc + offset;
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
/*
@@ -1978,503 +2232,498 @@ EmulateInstructionMIPS::Emulate_B16_MM (
BEQZ16, BNEZ16 are 16 bit instructions with delay slot.
BGEZALS, BLTZALS are 16 bit instructions with short (2-byte) delay slot.
*/
-bool
-EmulateInstructionMIPS::Emulate_Branch_MM (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t target = 0;
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
- bool update_ra = false;
- uint32_t ra_offset = 0;
-
- /*
- * BEQZ16 rs, offset
- * condition <- (GPR[rs] = 0)
- * if condition then
- * PC = PC + sign_ext (offset || 0)
- *
- * BNEZ16 rs, offset
- * condition <- (GPR[rs] != 0)
- * if condition then
- * PC = PC + sign_ext (offset || 0)
- *
- * BEQZC rs, offset (compact instruction: No delay slot)
- * condition <- (GPR[rs] == 0)
- * if condition then
- * PC = PC + 4 + sign_ext (offset || 0)
- */
-
- uint32_t rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- int32_t offset = insn.getOperand(1).getImm();
+bool EmulateInstructionMIPS::Emulate_Branch_MM(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t target = 0;
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+ bool update_ra = false;
+ uint32_t ra_offset = 0;
+
+ /*
+ * BEQZ16 rs, offset
+ * condition <- (GPR[rs] = 0)
+ * if condition then
+ * PC = PC + sign_ext (offset || 0)
+ *
+ * BNEZ16 rs, offset
+ * condition <- (GPR[rs] != 0)
+ * if condition then
+ * PC = PC + sign_ext (offset || 0)
+ *
+ * BEQZC rs, offset (compact instruction: No delay slot)
+ * condition <- (GPR[rs] == 0)
+ * if condition then
+ * PC = PC + 4 + sign_ext (offset || 0)
+ */
+
+ uint32_t rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
+
+ int32_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ int32_t rs_val = (int32_t)ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- int32_t rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ if (!strcasecmp(op_name, "BEQZ16_MM")) {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + current_inst_size +
+ m_next_inst_size; // Skip delay slot instruction.
+ } else if (!strcasecmp(op_name, "BNEZ16_MM")) {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + current_inst_size +
+ m_next_inst_size; // Skip delay slot instruction.
+ } else if (!strcasecmp(op_name, "BEQZC_MM")) {
+ if (rs_val == 0)
+ target = pc + 4 + offset;
+ else
+ target =
+ pc +
+ 4; // 32 bit instruction and does not have delay slot instruction.
+ } else if (!strcasecmp(op_name, "BNEZC_MM")) {
+ if (rs_val != 0)
+ target = pc + 4 + offset;
+ else
+ target =
+ pc +
+ 4; // 32 bit instruction and does not have delay slot instruction.
+ } else if (!strcasecmp(op_name, "BGEZALS_MM")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
- if (!strcasecmp (op_name, "BEQZ16_MM"))
- {
- if (rs_val == 0)
- target = pc + offset;
- else
- target = pc + current_inst_size + m_next_inst_size; // Skip delay slot instruction.
- }
- else if (!strcasecmp (op_name, "BNEZ16_MM"))
- {
- if (rs_val != 0)
- target = pc + offset;
- else
- target = pc + current_inst_size + m_next_inst_size; // Skip delay slot instruction.
- }
- else if (!strcasecmp (op_name, "BEQZC_MM"))
- {
- if (rs_val == 0)
- target = pc + 4 + offset;
- else
- target = pc + 4; // 32 bit instruction and does not have delay slot instruction.
- }
- else if (!strcasecmp (op_name, "BNEZC_MM"))
- {
- if (rs_val != 0)
- target = pc + 4 + offset;
- else
- target = pc + 4; // 32 bit instruction and does not have delay slot instruction.
- }
- else if (!strcasecmp (op_name, "BGEZALS_MM"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
-
- update_ra = true;
- ra_offset = 6;
- }
- else if (!strcasecmp (op_name, "BLTZALS_MM"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
-
- update_ra = true;
- ra_offset = 6;
- }
+ update_ra = true;
+ ra_offset = 6;
+ } else if (!strcasecmp(op_name, "BLTZALS_MM")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 6; // 32 bit instruction with short (2-byte) delay slot
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ update_ra = true;
+ ra_offset = 6;
+ }
+
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (update_ra)
- {
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
- return false;
- }
- return true;
+ if (update_ra) {
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + ra_offset))
+ return false;
+ }
+ return true;
}
/* Emulate micromips jump instructions.
JALR16,JALRS16
*/
-bool
-EmulateInstructionMIPS::Emulate_JALRx16_MM (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t ra_offset = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- uint32_t rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
-
- uint32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_JALRx16_MM(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t ra_offset = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+
+ uint32_t rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+
+ uint32_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- uint32_t rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ uint32_t rs_val = ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "JALR16_MM"))
- ra_offset = 6; // 2-byte instruction with 4-byte delay slot.
- else if (!strcasecmp (op_name, "JALRS16_MM"))
- ra_offset = 4; // 2-byte instruction with 2-byte delay slot.
+ if (!strcasecmp(op_name, "JALR16_MM"))
+ ra_offset = 6; // 2-byte instruction with 4-byte delay slot.
+ else if (!strcasecmp(op_name, "JALRS16_MM"))
+ ra_offset = 4; // 2-byte instruction with 2-byte delay slot.
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ rs_val))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + ra_offset))
+ return false;
- return true;
+ return true;
}
/* Emulate JALS and JALX instructions.
JALS 32 bit instruction with short (2-byte) delay slot.
JALX 32 bit instruction with 4-byte delay slot.
*/
-bool
-EmulateInstructionMIPS::Emulate_JALx (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t offset=0, target=0, pc=0, ra_offset=0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- /*
- * JALS target
- * RA = PC + 6
- * offset = sign_ext (offset << 1)
- * PC = PC[31-27] | offset
- * JALX target
- * RA = PC + 8
- * offset = sign_ext (offset << 2)
- * PC = PC[31-28] | offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_JALx(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t offset = 0, target = 0, pc = 0, ra_offset = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+
+ /*
+ * JALS target
+ * RA = PC + 6
+ * offset = sign_ext (offset << 1)
+ * PC = PC[31-27] | offset
+ * JALX target
+ * RA = PC + 8
+ * offset = sign_ext (offset << 2)
+ * PC = PC[31-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- // These are PC-region branches and not PC-relative.
- if (!strcasecmp (op_name, "JALS_MM"))
- {
- // target address is in the âcurrentâ 128 MB-aligned region
- target = (pc & 0xF8000000UL) | offset;
- ra_offset = 6;
- }
- else if (!strcasecmp (op_name, "JALX_MM"))
- {
- // target address is in the âcurrentâ 256 MB-aligned region
- target = (pc & 0xF0000000UL) | offset;
- ra_offset = 8;
- }
+ // These are PC-region branches and not PC-relative.
+ if (!strcasecmp(op_name, "JALS_MM")) {
+ // target address is in the âcurrentâ 128 MB-aligned region
+ target = (pc & 0xF8000000UL) | offset;
+ ra_offset = 6;
+ } else if (!strcasecmp(op_name, "JALX_MM")) {
+ // target address is in the âcurrentâ 256 MB-aligned region
+ target = (pc & 0xF0000000UL) | offset;
+ ra_offset = 8;
+ }
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + ra_offset))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + ra_offset))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JALRS (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs=0, rt=0;
- int32_t pc=0, rs_val=0;
-
- /*
- JALRS rt, rs
- GPR[rt] <- PC + 6
- PC <- GPR[rs]
- */
+bool EmulateInstructionMIPS::Emulate_JALRS(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs = 0, rt = 0;
+ int32_t pc = 0, rs_val = 0;
+
+ /*
+ JALRS rt, rs
+ GPR[rt] <- PC + 6
+ PC <- GPR[rs]
+ */
+
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rs = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+
+ rs_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rs, 0, &success);
+ if (!success)
+ return false;
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ Context context;
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
-
- Context context;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ rs_val))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
- return false;
+ // This is 4-byte instruction with 2-byte delay slot.
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips + rt,
+ pc + 6))
+ return false;
- // This is 4-byte instruction with 2-byte delay slot.
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + rt, pc + 6))
- return false;
-
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BAL (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t offset, pc, target;
-
- /*
- * BAL offset
- * offset = sign_ext (offset << 2)
- * RA = PC + 8
- * PC = PC + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_BAL(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t offset, pc, target;
+
+ /*
+ * BAL offset
+ * offset = sign_ext (offset << 2)
+ * RA = PC + 8
+ * PC = PC + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BALC (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t offset, pc, target;
-
- /*
- * BALC offset
- * offset = sign_ext (offset << 2)
- * RA = PC + 4
- * PC = PC + 4 + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_BALC(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t offset, pc, target;
+
+ /*
+ * BALC offset
+ * offset = sign_ext (offset << 2)
+ * RA = PC + 4
+ * PC = PC + 4 + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 4))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BC (llvm::MCInst& insn)
-{
- bool success = false;
- int32_t offset, pc, target;
-
- /*
- * BC offset
- * offset = sign_ext (offset << 2)
- * PC = PC + 4 + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_BC(llvm::MCInst &insn) {
+ bool success = false;
+ int32_t offset, pc, target;
+
+ /*
+ * BC offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC + 4 + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_J (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t offset, pc;
-
- /*
- * J offset
- * offset = sign_ext (offset << 2)
- * PC = PC[63-28] | offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_J(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t offset, pc;
+
+ /*
+ * J offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC[63-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- /* This is a PC-region branch and not PC-relative */
- pc = (pc & 0xF0000000UL) | offset;
+ /* This is a PC-region branch and not PC-relative */
+ pc = (pc & 0xF0000000UL) | offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, pc))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, pc))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JAL (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t offset, target, pc;
-
- /*
- * JAL offset
- * offset = sign_ext (offset << 2)
- * PC = PC[63-28] | offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS::Emulate_JAL(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t offset, target, pc;
+
+ /*
+ * JAL offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC[63-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- /* This is a PC-region branch and not PC-relative */
- target = (pc & 0xF0000000UL) | offset;
+ /* This is a PC-region branch and not PC-relative */
+ target = (pc & 0xF0000000UL) | offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JALR (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- uint32_t pc, rs_val;
-
- /*
- * JALR rt, rs
- * GPR[rt] = PC + 8
- * PC = GPR[rs]
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+bool EmulateInstructionMIPS::Emulate_JALR(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ uint32_t pc, rs_val;
+
+ /*
+ * JALR rt, rs
+ * GPR[rt] = PC + 8
+ * PC = GPR[rs]
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rs = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + rs, 0,
+ &success);
+ if (!success)
+ return false;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ rs_val))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips + rt, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips + rt,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JIALC (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rt;
- int32_t target, offset, pc, rt_val;
-
- /*
- * JIALC rt, offset
- * offset = sign_ext (offset)
- * PC = GPR[rt] + offset
- * RA = PC + 4
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+bool EmulateInstructionMIPS::Emulate_JIALC(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rt;
+ int32_t target, offset, pc, rt_val;
+
+ /*
+ * JIALC rt, offset
+ * offset = sign_ext (offset)
+ * PC = GPR[rt] + offset
+ * RA = PC + 4
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
- target = rt_val + offset;
+ target = rt_val + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips,
+ pc + 4))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JIC (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rt;
- int32_t target, offset, rt_val;
-
- /*
- * JIC rt, offset
- * offset = sign_ext (offset)
- * PC = GPR[rt] + offset
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- rt_val = (int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rt, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_JIC(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rt;
+ int32_t target, offset, rt_val;
+
+ /*
+ * JIC rt, offset
+ * offset = sign_ext (offset)
+ * PC = GPR[rt] + offset
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
+
+ rt_val = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + rt, 0, &success);
+ if (!success)
+ return false;
- target = rt_val + offset;
+ target = rt_val + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_JR (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- uint32_t rs_val;
-
- /*
- * JR rs
- * PC = GPR[rs]
- */
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
+bool EmulateInstructionMIPS::Emulate_JR(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ uint32_t rs_val;
+
+ /*
+ * JR rs
+ * PC = GPR[rs]
+ */
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+
+ rs_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + rs, 0,
+ &success);
+ if (!success)
+ return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + rs, 0, &success);
- if (!success)
- return false;
+ Context context;
- Context context;
-
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, rs_val))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ rs_val))
+ return false;
- return true;
+ return true;
}
/*
@@ -2482,419 +2731,400 @@ EmulateInstructionMIPS::Emulate_JR (llvm
BC1F, BC1FL : Branch on FP False (L stands for branch likely)
BC1T, BC1TL : Branch on FP True (L stands for branch likely)
*/
-bool
-EmulateInstructionMIPS::Emulate_FP_branch (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t cc, fcsr;
- int32_t pc, offset, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_FP_branch(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t cc, fcsr;
+ int32_t pc, offset, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
- if (!success)
- return false;
+ cc = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- /* fcsr[23], fcsr[25-31] are vaild condition bits */
- fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BC1F") ||
- !strcasecmp (op_name, "BC1FL"))
- {
- if ((fcsr & (1 << cc)) == 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1T") ||
- !strcasecmp (op_name, "BC1TL"))
- {
- if ((fcsr & (1 << cc)) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- Context context;
+ fcsr = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ /* fcsr[23], fcsr[25-31] are vaild condition bits */
+ fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
- return true;
+ if (!strcasecmp(op_name, "BC1F") || !strcasecmp(op_name, "BC1FL")) {
+ if ((fcsr & (1 << cc)) == 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1T") || !strcasecmp(op_name, "BC1TL")) {
+ if ((fcsr & (1 << cc)) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BC1EQZ (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t ft;
- uint32_t ft_val;
- int32_t target, pc, offset;
-
- /*
- * BC1EQZ ft, offset
- * condition <- (FPR[ft].bit0 == 0)
- * if condition then
- * offset = sign_ext (offset)
- * PC = PC + 4 + offset
- */
- ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_BC1EQZ(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t ft;
+ uint32_t ft_val;
+ int32_t target, pc, offset;
+
+ /*
+ * BC1EQZ ft, offset
+ * condition <- (FPR[ft].bit0 == 0)
+ * if condition then
+ * offset = sign_ext (offset)
+ * PC = PC + 4 + offset
+ */
+ ft = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + ft, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- if ((ft_val & 1) == 0)
- target = pc + 4 + offset;
- else
- target = pc + 8;
-
- Context context;
+ ft_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + ft, 0,
+ &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if ((ft_val & 1) == 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 8;
- return true;
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BC1NEZ (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t ft;
- uint32_t ft_val;
- int32_t target, pc, offset;
-
- /*
- * BC1NEZ ft, offset
- * condition <- (FPR[ft].bit0 != 0)
- * if condition then
- * offset = sign_ext (offset)
- * PC = PC + 4 + offset
- */
- ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_BC1NEZ(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t ft;
+ uint32_t ft_val;
+ int32_t target, pc, offset;
+
+ /*
+ * BC1NEZ ft, offset
+ * condition <- (FPR[ft].bit0 != 0)
+ * if condition then
+ * offset = sign_ext (offset)
+ * PC = PC + 4 + offset
+ */
+ ft = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + ft, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- if ((ft_val & 1) != 0)
- target = pc + 4 + offset;
- else
- target = pc + 8;
-
- Context context;
+ ft_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + ft, 0,
+ &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if ((ft_val & 1) != 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 8;
- return true;
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
/*
Emulate MIPS-3D Branch instructions
- BC1ANY2F, BC1ANY2T : Branch on Any of Two Floating Point Condition Codes False/True
- BC1ANY4F, BC1ANY4T : Branch on Any of Four Floating Point Condition Codes False/True
+ BC1ANY2F, BC1ANY2T : Branch on Any of Two Floating Point Condition Codes
+ False/True
+ BC1ANY4F, BC1ANY4T : Branch on Any of Four Floating Point Condition Codes
+ False/True
*/
-bool
-EmulateInstructionMIPS::Emulate_3D_branch (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t cc, fcsr;
- int32_t pc, offset, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_3D_branch(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t cc, fcsr;
+ int32_t pc, offset, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips, 0, &success);
- if (!success)
- return false;
+ cc = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- /* fcsr[23], fcsr[25-31] are vaild condition bits */
- fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BC1ANY2F"))
- {
- /* if any one bit is 0 */
- if (((fcsr >> cc) & 3) != 3)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY2T"))
- {
- /* if any one bit is 1 */
- if (((fcsr >> cc) & 3) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY4F"))
- {
- /* if any one bit is 0 */
- if (((fcsr >> cc) & 0xf) != 0xf)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY4T"))
- {
- /* if any one bit is 1 */
- if (((fcsr >> cc) & 0xf) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- Context context;
+ fcsr = (uint32_t)ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_fcsr_mips, 0,
+ &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ /* fcsr[23], fcsr[25-31] are vaild condition bits */
+ fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
- return true;
+ if (!strcasecmp(op_name, "BC1ANY2F")) {
+ /* if any one bit is 0 */
+ if (((fcsr >> cc) & 3) != 3)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY2T")) {
+ /* if any one bit is 1 */
+ if (((fcsr >> cc) & 3) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY4F")) {
+ /* if any one bit is 0 */
+ if (((fcsr >> cc) & 0xf) != 0xf)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY4T")) {
+ /* if any one bit is 1 */
+ if (((fcsr >> cc) & 0xf) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BNZB (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 1, true);
+bool EmulateInstructionMIPS::Emulate_BNZB(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 1, true);
}
-bool
-EmulateInstructionMIPS::Emulate_BNZH (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 2, true);
+bool EmulateInstructionMIPS::Emulate_BNZH(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 2, true);
}
-bool
-EmulateInstructionMIPS::Emulate_BNZW (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 4, true);
+bool EmulateInstructionMIPS::Emulate_BNZW(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 4, true);
}
-bool
-EmulateInstructionMIPS::Emulate_BNZD (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 8, true);
+bool EmulateInstructionMIPS::Emulate_BNZD(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 8, true);
}
-bool
-EmulateInstructionMIPS::Emulate_BZB (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 1, false);
+bool EmulateInstructionMIPS::Emulate_BZB(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 1, false);
}
-bool
-EmulateInstructionMIPS::Emulate_BZH (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 2, false);
+bool EmulateInstructionMIPS::Emulate_BZH(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 2, false);
}
-bool
-EmulateInstructionMIPS::Emulate_BZW (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 4, false);
+bool EmulateInstructionMIPS::Emulate_BZW(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 4, false);
}
-bool
-EmulateInstructionMIPS::Emulate_BZD (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 8, false);
+bool EmulateInstructionMIPS::Emulate_BZD(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 8, false);
}
-bool
-EmulateInstructionMIPS::Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz)
-{
- bool success = false, branch_hit = true;
- int32_t target = 0;
- RegisterValue reg_value;
- const uint8_t *ptr = NULL;
+bool EmulateInstructionMIPS::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
+ int element_byte_size,
+ bool bnz) {
+ bool success = false, branch_hit = true;
+ int32_t target = 0;
+ RegisterValue reg_value;
+ const uint8_t *ptr = NULL;
- uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- int32_t offset = insn.getOperand(1).getImm();
+ uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
- int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+ int32_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
- ptr = (const uint8_t *)reg_value.GetBytes();
- else
- return false;
+ if (ReadRegister(eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
+ ptr = (const uint8_t *)reg_value.GetBytes();
+ else
+ return false;
- for(int i = 0; i < 16 / element_byte_size; i++)
- {
- switch(element_byte_size)
- {
- case 1:
- if((*ptr == 0 && bnz) || (*ptr != 0 && !bnz) )
- branch_hit = false;
- break;
- case 2:
- if ((*(const uint16_t *)ptr == 0 && bnz) || (*(const uint16_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- case 4:
- if ((*(const uint32_t *)ptr == 0 && bnz) || (*(const uint32_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- case 8:
- if ((*(const uint64_t *)ptr == 0 && bnz) || (*(const uint64_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- }
- if(!branch_hit)
- break;
- ptr = ptr + element_byte_size;
- }
+ for (int i = 0; i < 16 / element_byte_size; i++) {
+ switch (element_byte_size) {
+ case 1:
+ if ((*ptr == 0 && bnz) || (*ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 2:
+ if ((*(const uint16_t *)ptr == 0 && bnz) ||
+ (*(const uint16_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 4:
+ if ((*(const uint32_t *)ptr == 0 && bnz) ||
+ (*(const uint32_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 8:
+ if ((*(const uint64_t *)ptr == 0 && bnz) ||
+ (*(const uint64_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ }
+ if (!branch_hit)
+ break;
+ ptr = ptr + element_byte_size;
+ }
- if(branch_hit)
- target = pc + offset;
- else
- target = pc + 8;
+ if (branch_hit)
+ target = pc + offset;
+ else
+ target = pc + 8;
- Context context;
- context.type = eContextRelativeBranchImmediate;
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS::Emulate_BNZV (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_V (insn, true);
-}
-
-bool
-EmulateInstructionMIPS::Emulate_BZV (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_V (insn, false);
-}
-
-bool
-EmulateInstructionMIPS::Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz)
-{
- bool success = false;
- int32_t target = 0;
- llvm::APInt wr_val = llvm::APInt::getNullValue(128);
- llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
- llvm::APInt zero_value = llvm::APInt::getNullValue(128);
- RegisterValue reg_value;
-
- uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- int32_t offset = insn.getOperand(1).getImm();
-
- int32_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS::Emulate_BNZV(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_V(insn, true);
+}
- if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
- wr_val = reg_value.GetAsUInt128(fail_value);
- else
- return false;
+bool EmulateInstructionMIPS::Emulate_BZV(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_V(insn, false);
+}
- if((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) || (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
- target = pc + offset;
- else
- target = pc + 8;
+bool EmulateInstructionMIPS::Emulate_MSA_Branch_V(llvm::MCInst &insn,
+ bool bnz) {
+ bool success = false;
+ int32_t target = 0;
+ llvm::APInt wr_val = llvm::APInt::getNullValue(128);
+ llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
+ llvm::APInt zero_value = llvm::APInt::getNullValue(128);
+ RegisterValue reg_value;
- Context context;
- context.type = eContextRelativeBranchImmediate;
+ uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ int32_t offset = insn.getOperand(1).getImm();
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
- return false;
+ int32_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips, 0, &success);
+ if (!success)
+ return false;
- return true;
-}
+ if (ReadRegister(eRegisterKindDWARF, dwarf_w0_mips + wt, reg_value))
+ wr_val = reg_value.GetAsUInt128(fail_value);
+ else
+ return false;
-bool
-EmulateInstructionMIPS::Emulate_LDST_Imm (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base;
- int32_t imm, address;
- Context bad_vaddr_context;
-
- uint32_t num_operands = insn.getNumOperands();
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
- imm = insn.getOperand(num_operands-1).getImm();
+ if ((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) ||
+ (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
+ target = pc + offset;
+ else
+ target = pc + 8;
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
- /* read base register */
- address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target))
+ return false;
- /* destination address */
- address = address + imm;
+ return true;
+}
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+bool EmulateInstructionMIPS::Emulate_LDST_Imm(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t base;
+ int32_t imm, address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+ imm = insn.getOperand(num_operands - 1).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- return true;
-}
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
-bool
-EmulateInstructionMIPS::Emulate_LDST_Reg (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base, index;
- int32_t address, index_address;
- Context bad_vaddr_context;
-
- uint32_t num_operands = insn.getNumOperands();
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
- index = m_reg_info->getEncodingValue (insn.getOperand(num_operands-1).getReg());
+ /* destination address */
+ address = address + imm;
- RegisterInfo reg_info_base, reg_info_index;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
+
+ return true;
+}
+
+bool EmulateInstructionMIPS::Emulate_LDST_Reg(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t base, index;
+ int32_t address, index_address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+ index =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 1).getReg());
+
+ RegisterInfo reg_info_base, reg_info_index;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + index, reg_info_index))
- return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + index,
+ reg_info_index))
+ return false;
- /* read base register */
- address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ /* read base register */
+ address = (int32_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + base, 0, &success);
+ if (!success)
+ return false;
- /* read index register */
- index_address =(int32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + index, 0, &success);
- if (!success)
- return false;
+ /* read index register */
+ index_address = (int32_t)ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips + index, 0, &success);
+ if (!success)
+ return false;
- /* destination address */
- address = address + index_address;
+ /* destination address */
+ address = address + index_address;
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
- return true;
+ return true;
}
Modified: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- EmulateInstructionMIPS.h ------------------------------------*- C++ -*-===//
+//===-- EmulateInstructionMIPS.h ------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,286 +11,209 @@
#ifndef EmulateInstructionMIPS_h_
#define EmulateInstructionMIPS_h_
-namespace llvm
-{
- class MCDisassembler;
- class MCSubtargetInfo;
- class MCRegisterInfo;
- class MCAsmInfo;
- class MCContext;
- class MCInstrInfo;
- class MCInst;
+namespace llvm {
+class MCDisassembler;
+class MCSubtargetInfo;
+class MCRegisterInfo;
+class MCAsmInfo;
+class MCContext;
+class MCInstrInfo;
+class MCInst;
}
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
-class EmulateInstructionMIPS : public lldb_private::EmulateInstruction
-{
-public:
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetPluginDescriptionStatic ();
-
- static lldb_private::EmulateInstruction *
- CreateInstance (const lldb_private::ArchSpec &arch,
- lldb_private::InstructionType inst_type);
-
- static bool
- SupportsEmulatingInstructionsOfTypeStatic (lldb_private::InstructionType inst_type)
- {
- switch (inst_type)
- {
- case lldb_private::eInstructionTypeAny:
- case lldb_private::eInstructionTypePrologueEpilogue:
- case lldb_private::eInstructionTypePCModifying:
- return true;
-
- case lldb_private::eInstructionTypeAll:
- return false;
- }
- return false;
+class EmulateInstructionMIPS : public lldb_private::EmulateInstruction {
+public:
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetPluginDescriptionStatic();
+
+ static lldb_private::EmulateInstruction *
+ CreateInstance(const lldb_private::ArchSpec &arch,
+ lldb_private::InstructionType inst_type);
+
+ static bool SupportsEmulatingInstructionsOfTypeStatic(
+ lldb_private::InstructionType inst_type) {
+ switch (inst_type) {
+ case lldb_private::eInstructionTypeAny:
+ case lldb_private::eInstructionTypePrologueEpilogue:
+ case lldb_private::eInstructionTypePCModifying:
+ return true;
+
+ case lldb_private::eInstructionTypeAll:
+ return false;
}
+ return false;
+ }
- lldb_private::ConstString
- GetPluginName() override;
+ lldb_private::ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
+ uint32_t GetPluginVersion() override { return 1; }
- bool
- SetTargetTriple (const lldb_private::ArchSpec &arch) override;
-
- EmulateInstructionMIPS (const lldb_private::ArchSpec &arch);
-
- bool
- SupportsEmulatingInstructionsOfType (lldb_private::InstructionType inst_type) override
- {
- return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
- }
+ bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
- bool
- ReadInstruction () override;
-
- bool
- EvaluateInstruction (uint32_t evaluate_options) override;
-
- bool
- SetInstruction (const lldb_private::Opcode &insn_opcode,
- const lldb_private::Address &inst_addr,
- lldb_private::Target *target) override;
-
- bool
- TestEmulation (lldb_private::Stream *out_stream,
- lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data) override
- {
- return false;
- }
+ EmulateInstructionMIPS(const lldb_private::ArchSpec &arch);
+
+ bool SupportsEmulatingInstructionsOfType(
+ lldb_private::InstructionType inst_type) override {
+ return SupportsEmulatingInstructionsOfTypeStatic(inst_type);
+ }
+
+ bool ReadInstruction() override;
+
+ bool EvaluateInstruction(uint32_t evaluate_options) override;
+
+ bool SetInstruction(const lldb_private::Opcode &insn_opcode,
+ const lldb_private::Address &inst_addr,
+ lldb_private::Target *target) override;
- bool
- GetRegisterInfo (lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- lldb_private::RegisterInfo ®_info) override;
+ bool TestEmulation(lldb_private::Stream *out_stream,
+ lldb_private::ArchSpec &arch,
+ lldb_private::OptionValueDictionary *test_data) override {
+ return false;
+ }
- bool
- CreateFunctionEntryUnwind (lldb_private::UnwindPlan &unwind_plan) override;
+ bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ lldb_private::RegisterInfo ®_info) override;
+ bool
+ CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
protected:
+ typedef struct {
+ const char *op_name;
+ bool (EmulateInstructionMIPS::*callback)(llvm::MCInst &insn);
+ const char *insn_name;
+ } MipsOpcode;
- typedef struct
- {
- const char *op_name;
- bool (EmulateInstructionMIPS::*callback) (llvm::MCInst& insn);
- const char *insn_name;
- } MipsOpcode;
-
- static MipsOpcode*
- GetOpcodeForInstruction (const char *op_name);
+ static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
- uint32_t
- GetSizeOfInstruction (lldb_private::DataExtractor& data, uint64_t inst_addr);
+ uint32_t GetSizeOfInstruction(lldb_private::DataExtractor &data,
+ uint64_t inst_addr);
- bool
- Emulate_ADDiu (llvm::MCInst& insn);
+ bool Emulate_ADDiu(llvm::MCInst &insn);
- bool
- Emulate_SUBU_ADDU (llvm::MCInst& insn);
+ bool Emulate_SUBU_ADDU(llvm::MCInst &insn);
- bool
- Emulate_LUI (llvm::MCInst& insn);
+ bool Emulate_LUI(llvm::MCInst &insn);
- bool
- Emulate_SW (llvm::MCInst& insn);
+ bool Emulate_SW(llvm::MCInst &insn);
- bool
- Emulate_LW (llvm::MCInst& insn);
+ bool Emulate_LW(llvm::MCInst &insn);
- bool
- Emulate_ADDIUSP (llvm::MCInst& insn);
+ bool Emulate_ADDIUSP(llvm::MCInst &insn);
- bool
- Emulate_ADDIUS5 (llvm::MCInst& insn);
+ bool Emulate_ADDIUS5(llvm::MCInst &insn);
- bool
- Emulate_SWSP (llvm::MCInst& insn);
+ bool Emulate_SWSP(llvm::MCInst &insn);
- bool
- Emulate_SWM16_32 (llvm::MCInst& insn);
+ bool Emulate_SWM16_32(llvm::MCInst &insn);
- bool
- Emulate_LWSP (llvm::MCInst& insn);
+ bool Emulate_LWSP(llvm::MCInst &insn);
- bool
- Emulate_LWM16_32 (llvm::MCInst& insn);
+ bool Emulate_LWM16_32(llvm::MCInst &insn);
- bool
- Emulate_JRADDIUSP (llvm::MCInst& insn);
+ bool Emulate_JRADDIUSP(llvm::MCInst &insn);
- bool
- Emulate_LDST_Imm (llvm::MCInst& insn);
+ bool Emulate_LDST_Imm(llvm::MCInst &insn);
- bool
- Emulate_LDST_Reg (llvm::MCInst& insn);
+ bool Emulate_LDST_Reg(llvm::MCInst &insn);
- bool
- Emulate_BXX_3ops (llvm::MCInst& insn);
+ bool Emulate_BXX_3ops(llvm::MCInst &insn);
- bool
- Emulate_BXX_3ops_C (llvm::MCInst& insn);
+ bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
- bool
- Emulate_BXX_2ops (llvm::MCInst& insn);
+ bool Emulate_BXX_2ops(llvm::MCInst &insn);
- bool
- Emulate_BXX_2ops_C (llvm::MCInst& insn);
+ bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
- bool
- Emulate_Bcond_Link_C (llvm::MCInst& insn);
+ bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
- bool
- Emulate_Bcond_Link (llvm::MCInst& insn);
+ bool Emulate_Bcond_Link(llvm::MCInst &insn);
- bool
- Emulate_FP_branch (llvm::MCInst& insn);
+ bool Emulate_FP_branch(llvm::MCInst &insn);
- bool
- Emulate_3D_branch (llvm::MCInst& insn);
+ bool Emulate_3D_branch(llvm::MCInst &insn);
- bool
- Emulate_BAL (llvm::MCInst& insn);
+ bool Emulate_BAL(llvm::MCInst &insn);
- bool
- Emulate_BALC (llvm::MCInst& insn);
+ bool Emulate_BALC(llvm::MCInst &insn);
- bool
- Emulate_BC (llvm::MCInst& insn);
+ bool Emulate_BC(llvm::MCInst &insn);
- bool
- Emulate_J (llvm::MCInst& insn);
+ bool Emulate_J(llvm::MCInst &insn);
- bool
- Emulate_JAL (llvm::MCInst& insn);
+ bool Emulate_JAL(llvm::MCInst &insn);
- bool
- Emulate_JALR (llvm::MCInst& insn);
+ bool Emulate_JALR(llvm::MCInst &insn);
- bool
- Emulate_JIALC (llvm::MCInst& insn);
+ bool Emulate_JIALC(llvm::MCInst &insn);
- bool
- Emulate_JIC (llvm::MCInst& insn);
+ bool Emulate_JIC(llvm::MCInst &insn);
- bool
- Emulate_JR (llvm::MCInst& insn);
+ bool Emulate_JR(llvm::MCInst &insn);
- bool
- Emulate_BC1EQZ (llvm::MCInst& insn);
+ bool Emulate_BC1EQZ(llvm::MCInst &insn);
- bool
- Emulate_BC1NEZ (llvm::MCInst& insn);
+ bool Emulate_BC1NEZ(llvm::MCInst &insn);
- bool
- Emulate_BNZB (llvm::MCInst& insn);
+ bool Emulate_BNZB(llvm::MCInst &insn);
- bool
- Emulate_BNZH (llvm::MCInst& insn);
+ bool Emulate_BNZH(llvm::MCInst &insn);
- bool
- Emulate_BNZW (llvm::MCInst& insn);
+ bool Emulate_BNZW(llvm::MCInst &insn);
- bool
- Emulate_BNZD (llvm::MCInst& insn);
+ bool Emulate_BNZD(llvm::MCInst &insn);
- bool
- Emulate_BZB (llvm::MCInst& insn);
+ bool Emulate_BZB(llvm::MCInst &insn);
- bool
- Emulate_BZH (llvm::MCInst& insn);
+ bool Emulate_BZH(llvm::MCInst &insn);
- bool
- Emulate_BZW (llvm::MCInst& insn);
+ bool Emulate_BZW(llvm::MCInst &insn);
- bool
- Emulate_BZD (llvm::MCInst& insn);
+ bool Emulate_BZD(llvm::MCInst &insn);
- bool
- Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz);
+ bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
+ bool bnz);
- bool
- Emulate_BNZV (llvm::MCInst& insn);
+ bool Emulate_BNZV(llvm::MCInst &insn);
- bool
- Emulate_BZV (llvm::MCInst& insn);
+ bool Emulate_BZV(llvm::MCInst &insn);
- bool
- Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz);
+ bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
- bool
- Emulate_B16_MM (llvm::MCInst& insn);
+ bool Emulate_B16_MM(llvm::MCInst &insn);
- bool
- Emulate_Branch_MM (llvm::MCInst& insn);
+ bool Emulate_Branch_MM(llvm::MCInst &insn);
- bool
- Emulate_JALRx16_MM (llvm::MCInst& insn);
+ bool Emulate_JALRx16_MM(llvm::MCInst &insn);
- bool
- Emulate_JALx (llvm::MCInst& insn);
+ bool Emulate_JALx(llvm::MCInst &insn);
- bool
- Emulate_JALRS (llvm::MCInst& insn);
+ bool Emulate_JALRS(llvm::MCInst &insn);
- bool
- nonvolatile_reg_p (uint32_t regnum);
+ bool nonvolatile_reg_p(uint32_t regnum);
- const char *
- GetRegisterName (unsigned reg_num, bool altnernate_name);
+ const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
private:
- std::unique_ptr<llvm::MCDisassembler> m_disasm;
- std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;
- std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
- std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;
- std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
- std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
- std::unique_ptr<llvm::MCContext> m_context;
- std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
- uint32_t m_next_inst_size;
- bool m_use_alt_disaasm;
+ std::unique_ptr<llvm::MCDisassembler> m_disasm;
+ std::unique_ptr<llvm::MCDisassembler> m_alt_disasm;
+ std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
+ std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info;
+ std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
+ std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
+ std::unique_ptr<llvm::MCContext> m_context;
+ std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
+ uint32_t m_next_inst_size;
+ bool m_use_alt_disaasm;
};
-#endif // EmulateInstructionMIPS_h_
+#endif // EmulateInstructionMIPS_h_
Modified: lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- EmulateInstructionMIPS64.cpp -------------------------------*- C++ -*-===//
+//===-- EmulateInstructionMIPS64.cpp -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,25 +12,25 @@
#include <stdlib.h>
-#include "llvm-c/Disassembler.h"
-#include "llvm/Support/TargetSelect.h"
-#include "llvm/Support/TargetRegistry.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/MC/MCInstrInfo.h"
-#include "llvm/MC/MCDisassembler/MCDisassembler.h"
-#include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCContext.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Opcode.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Opcode.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "llvm-c/Disassembler.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCDisassembler/MCDisassembler.h"
+#include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
#include "llvm/ADT/STLExtras.h"
@@ -42,7 +43,6 @@ using namespace lldb_private;
#define UInt(x) ((uint64_t)x)
#define integer int64_t
-
//----------------------------------------------------------------------
//
// EmulateInstructionMIPS64 implementation
@@ -51,987 +51,1261 @@ using namespace lldb_private;
#ifdef __mips__
extern "C" {
- void LLVMInitializeMipsTargetInfo ();
- void LLVMInitializeMipsTarget ();
- void LLVMInitializeMipsAsmPrinter ();
- void LLVMInitializeMipsTargetMC ();
- void LLVMInitializeMipsDisassembler ();
+void LLVMInitializeMipsTargetInfo();
+void LLVMInitializeMipsTarget();
+void LLVMInitializeMipsAsmPrinter();
+void LLVMInitializeMipsTargetMC();
+void LLVMInitializeMipsDisassembler();
}
#endif
-EmulateInstructionMIPS64::EmulateInstructionMIPS64 (const lldb_private::ArchSpec &arch) :
- EmulateInstruction (arch)
-{
- /* Create instance of llvm::MCDisassembler */
- std::string Error;
- llvm::Triple triple = arch.GetTriple();
- const llvm::Target *target = llvm::TargetRegistry::lookupTarget (triple.getTriple(), Error);
-
- /*
- * If we fail to get the target then we haven't registered it. The SystemInitializerCommon
- * does not initialize targets, MCs and disassemblers. However we need the MCDisassembler
- * to decode the instructions so that the decoding complexity stays with LLVM.
- * Initialize the MIPS targets and disassemblers.
- */
+EmulateInstructionMIPS64::EmulateInstructionMIPS64(
+ const lldb_private::ArchSpec &arch)
+ : EmulateInstruction(arch) {
+ /* Create instance of llvm::MCDisassembler */
+ std::string Error;
+ llvm::Triple triple = arch.GetTriple();
+ const llvm::Target *target =
+ llvm::TargetRegistry::lookupTarget(triple.getTriple(), Error);
+
+/*
+ * If we fail to get the target then we haven't registered it. The
+ * SystemInitializerCommon
+ * does not initialize targets, MCs and disassemblers. However we need the
+ * MCDisassembler
+ * to decode the instructions so that the decoding complexity stays with LLVM.
+ * Initialize the MIPS targets and disassemblers.
+*/
#ifdef __mips__
- if (!target)
- {
- LLVMInitializeMipsTargetInfo ();
- LLVMInitializeMipsTarget ();
- LLVMInitializeMipsAsmPrinter ();
- LLVMInitializeMipsTargetMC ();
- LLVMInitializeMipsDisassembler ();
- target = llvm::TargetRegistry::lookupTarget (triple.getTriple(), Error);
- }
+ if (!target) {
+ LLVMInitializeMipsTargetInfo();
+ LLVMInitializeMipsTarget();
+ LLVMInitializeMipsAsmPrinter();
+ LLVMInitializeMipsTargetMC();
+ LLVMInitializeMipsDisassembler();
+ target = llvm::TargetRegistry::lookupTarget(triple.getTriple(), Error);
+ }
#endif
- assert (target);
-
- llvm::StringRef cpu;
+ assert(target);
- switch (arch.GetCore())
- {
- case ArchSpec::eCore_mips32:
- case ArchSpec::eCore_mips32el:
- cpu = "mips32"; break;
- case ArchSpec::eCore_mips32r2:
- case ArchSpec::eCore_mips32r2el:
- cpu = "mips32r2"; break;
- case ArchSpec::eCore_mips32r3:
- case ArchSpec::eCore_mips32r3el:
- cpu = "mips32r3"; break;
- case ArchSpec::eCore_mips32r5:
- case ArchSpec::eCore_mips32r5el:
- cpu = "mips32r5"; break;
- case ArchSpec::eCore_mips32r6:
- case ArchSpec::eCore_mips32r6el:
- cpu = "mips32r6"; break;
- case ArchSpec::eCore_mips64:
- case ArchSpec::eCore_mips64el:
- cpu = "mips64"; break;
- case ArchSpec::eCore_mips64r2:
- case ArchSpec::eCore_mips64r2el:
- cpu = "mips64r2"; break;
- case ArchSpec::eCore_mips64r3:
- case ArchSpec::eCore_mips64r3el:
- cpu = "mips64r3"; break;
- case ArchSpec::eCore_mips64r5:
- case ArchSpec::eCore_mips64r5el:
- cpu = "mips64r5"; break;
- case ArchSpec::eCore_mips64r6:
- case ArchSpec::eCore_mips64r6el:
- cpu = "mips64r6"; break;
- default:
- cpu = "generic"; break;
- }
+ llvm::StringRef cpu;
- std::string features = "";
- uint32_t arch_flags = arch.GetFlags ();
- if (arch_flags & ArchSpec::eMIPSAse_msa)
- features += "+msa,";
- if (arch_flags & ArchSpec::eMIPSAse_dsp)
- features += "+dsp,";
- if (arch_flags & ArchSpec::eMIPSAse_dspr2)
- features += "+dspr2,";
- if (arch_flags & ArchSpec::eMIPSAse_mips16)
- features += "+mips16,";
- if (arch_flags & ArchSpec::eMIPSAse_micromips)
- features += "+micromips,";
-
- m_reg_info.reset (target->createMCRegInfo (triple.getTriple()));
- assert (m_reg_info.get());
-
- m_insn_info.reset (target->createMCInstrInfo());
- assert (m_insn_info.get());
-
- m_asm_info.reset (target->createMCAsmInfo (*m_reg_info, triple.getTriple()));
- m_subtype_info.reset (target->createMCSubtargetInfo (triple.getTriple(), cpu, features));
- assert (m_asm_info.get() && m_subtype_info.get());
-
- m_context.reset (new llvm::MCContext (m_asm_info.get(), m_reg_info.get(), nullptr));
- assert (m_context.get());
-
- m_disasm.reset (target->createMCDisassembler (*m_subtype_info, *m_context));
- assert (m_disasm.get());
-}
-
-void
-EmulateInstructionMIPS64::Initialize ()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic (),
- GetPluginDescriptionStatic (),
- CreateInstance);
-}
-
-void
-EmulateInstructionMIPS64::Terminate ()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
-}
-
-ConstString
-EmulateInstructionMIPS64::GetPluginNameStatic ()
-{
- ConstString g_plugin_name ("lldb.emulate-instruction.mips64");
- return g_plugin_name;
-}
-
-lldb_private::ConstString
-EmulateInstructionMIPS64::GetPluginName()
-{
- static ConstString g_plugin_name ("EmulateInstructionMIPS64");
- return g_plugin_name;
-}
-
-const char *
-EmulateInstructionMIPS64::GetPluginDescriptionStatic ()
-{
- return "Emulate instructions for the MIPS64 architecture.";
+ switch (arch.GetCore()) {
+ case ArchSpec::eCore_mips32:
+ case ArchSpec::eCore_mips32el:
+ cpu = "mips32";
+ break;
+ case ArchSpec::eCore_mips32r2:
+ case ArchSpec::eCore_mips32r2el:
+ cpu = "mips32r2";
+ break;
+ case ArchSpec::eCore_mips32r3:
+ case ArchSpec::eCore_mips32r3el:
+ cpu = "mips32r3";
+ break;
+ case ArchSpec::eCore_mips32r5:
+ case ArchSpec::eCore_mips32r5el:
+ cpu = "mips32r5";
+ break;
+ case ArchSpec::eCore_mips32r6:
+ case ArchSpec::eCore_mips32r6el:
+ cpu = "mips32r6";
+ break;
+ case ArchSpec::eCore_mips64:
+ case ArchSpec::eCore_mips64el:
+ cpu = "mips64";
+ break;
+ case ArchSpec::eCore_mips64r2:
+ case ArchSpec::eCore_mips64r2el:
+ cpu = "mips64r2";
+ break;
+ case ArchSpec::eCore_mips64r3:
+ case ArchSpec::eCore_mips64r3el:
+ cpu = "mips64r3";
+ break;
+ case ArchSpec::eCore_mips64r5:
+ case ArchSpec::eCore_mips64r5el:
+ cpu = "mips64r5";
+ break;
+ case ArchSpec::eCore_mips64r6:
+ case ArchSpec::eCore_mips64r6el:
+ cpu = "mips64r6";
+ break;
+ default:
+ cpu = "generic";
+ break;
+ }
+
+ std::string features = "";
+ uint32_t arch_flags = arch.GetFlags();
+ if (arch_flags & ArchSpec::eMIPSAse_msa)
+ features += "+msa,";
+ if (arch_flags & ArchSpec::eMIPSAse_dsp)
+ features += "+dsp,";
+ if (arch_flags & ArchSpec::eMIPSAse_dspr2)
+ features += "+dspr2,";
+ if (arch_flags & ArchSpec::eMIPSAse_mips16)
+ features += "+mips16,";
+ if (arch_flags & ArchSpec::eMIPSAse_micromips)
+ features += "+micromips,";
+
+ m_reg_info.reset(target->createMCRegInfo(triple.getTriple()));
+ assert(m_reg_info.get());
+
+ m_insn_info.reset(target->createMCInstrInfo());
+ assert(m_insn_info.get());
+
+ m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple.getTriple()));
+ m_subtype_info.reset(
+ target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
+ assert(m_asm_info.get() && m_subtype_info.get());
+
+ m_context.reset(
+ new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
+ assert(m_context.get());
+
+ m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
+ assert(m_disasm.get());
+}
+
+void EmulateInstructionMIPS64::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+}
+
+void EmulateInstructionMIPS64::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+ConstString EmulateInstructionMIPS64::GetPluginNameStatic() {
+ ConstString g_plugin_name("lldb.emulate-instruction.mips64");
+ return g_plugin_name;
+}
+
+lldb_private::ConstString EmulateInstructionMIPS64::GetPluginName() {
+ static ConstString g_plugin_name("EmulateInstructionMIPS64");
+ return g_plugin_name;
}
-EmulateInstruction *
-EmulateInstructionMIPS64::CreateInstance (const ArchSpec &arch, InstructionType inst_type)
-{
- if (EmulateInstructionMIPS64::SupportsEmulatingInstructionsOfTypeStatic(inst_type))
- {
- if (arch.GetTriple().getArch() == llvm::Triple::mips64
- || arch.GetTriple().getArch() == llvm::Triple::mips64el)
- {
- std::auto_ptr<EmulateInstructionMIPS64> emulate_insn_ap (new EmulateInstructionMIPS64 (arch));
- if (emulate_insn_ap.get())
- return emulate_insn_ap.release();
- }
- }
-
- return NULL;
+const char *EmulateInstructionMIPS64::GetPluginDescriptionStatic() {
+ return "Emulate instructions for the MIPS64 architecture.";
}
-bool
-EmulateInstructionMIPS64::SetTargetTriple (const ArchSpec &arch)
-{
- if (arch.GetTriple().getArch () == llvm::Triple::mips64
- || arch.GetTriple().getArch () == llvm::Triple::mips64el)
- return true;
- return false;
-}
-
-const char *
-EmulateInstructionMIPS64::GetRegisterName (unsigned reg_num, bool alternate_name)
-{
- if (alternate_name)
- {
- switch (reg_num)
- {
- case dwarf_sp_mips64: return "r29";
- case dwarf_r30_mips64: return "r30";
- case dwarf_ra_mips64: return "r31";
- case dwarf_f0_mips64: return "f0";
- case dwarf_f1_mips64: return "f1";
- case dwarf_f2_mips64: return "f2";
- case dwarf_f3_mips64: return "f3";
- case dwarf_f4_mips64: return "f4";
- case dwarf_f5_mips64: return "f5";
- case dwarf_f6_mips64: return "f6";
- case dwarf_f7_mips64: return "f7";
- case dwarf_f8_mips64: return "f8";
- case dwarf_f9_mips64: return "f9";
- case dwarf_f10_mips64: return "f10";
- case dwarf_f11_mips64: return "f11";
- case dwarf_f12_mips64: return "f12";
- case dwarf_f13_mips64: return "f13";
- case dwarf_f14_mips64: return "f14";
- case dwarf_f15_mips64: return "f15";
- case dwarf_f16_mips64: return "f16";
- case dwarf_f17_mips64: return "f17";
- case dwarf_f18_mips64: return "f18";
- case dwarf_f19_mips64: return "f19";
- case dwarf_f20_mips64: return "f20";
- case dwarf_f21_mips64: return "f21";
- case dwarf_f22_mips64: return "f22";
- case dwarf_f23_mips64: return "f23";
- case dwarf_f24_mips64: return "f24";
- case dwarf_f25_mips64: return "f25";
- case dwarf_f26_mips64: return "f26";
- case dwarf_f27_mips64: return "f27";
- case dwarf_f28_mips64: return "f28";
- case dwarf_f29_mips64: return "f29";
- case dwarf_f30_mips64: return "f30";
- case dwarf_f31_mips64: return "f31";
- case dwarf_w0_mips64: return "w0";
- case dwarf_w1_mips64: return "w1";
- case dwarf_w2_mips64: return "w2";
- case dwarf_w3_mips64: return "w3";
- case dwarf_w4_mips64: return "w4";
- case dwarf_w5_mips64: return "w5";
- case dwarf_w6_mips64: return "w6";
- case dwarf_w7_mips64: return "w7";
- case dwarf_w8_mips64: return "w8";
- case dwarf_w9_mips64: return "w9";
- case dwarf_w10_mips64: return "w10";
- case dwarf_w11_mips64: return "w11";
- case dwarf_w12_mips64: return "w12";
- case dwarf_w13_mips64: return "w13";
- case dwarf_w14_mips64: return "w14";
- case dwarf_w15_mips64: return "w15";
- case dwarf_w16_mips64: return "w16";
- case dwarf_w17_mips64: return "w17";
- case dwarf_w18_mips64: return "w18";
- case dwarf_w19_mips64: return "w19";
- case dwarf_w20_mips64: return "w20";
- case dwarf_w21_mips64: return "w21";
- case dwarf_w22_mips64: return "w22";
- case dwarf_w23_mips64: return "w23";
- case dwarf_w24_mips64: return "w24";
- case dwarf_w25_mips64: return "w25";
- case dwarf_w26_mips64: return "w26";
- case dwarf_w27_mips64: return "w27";
- case dwarf_w28_mips64: return "w28";
- case dwarf_w29_mips64: return "w29";
- case dwarf_w30_mips64: return "w30";
- case dwarf_w31_mips64: return "w31";
- case dwarf_mir_mips64: return "mir";
- case dwarf_mcsr_mips64: return "mcsr";
- case dwarf_config5_mips64: return "config5";
- default:
- break;
- }
- return nullptr;
- }
-
- switch (reg_num)
- {
- case dwarf_zero_mips64: return "r0";
- case dwarf_r1_mips64: return "r1";
- case dwarf_r2_mips64: return "r2";
- case dwarf_r3_mips64: return "r3";
- case dwarf_r4_mips64: return "r4";
- case dwarf_r5_mips64: return "r5";
- case dwarf_r6_mips64: return "r6";
- case dwarf_r7_mips64: return "r7";
- case dwarf_r8_mips64: return "r8";
- case dwarf_r9_mips64: return "r9";
- case dwarf_r10_mips64: return "r10";
- case dwarf_r11_mips64: return "r11";
- case dwarf_r12_mips64: return "r12";
- case dwarf_r13_mips64: return "r13";
- case dwarf_r14_mips64: return "r14";
- case dwarf_r15_mips64: return "r15";
- case dwarf_r16_mips64: return "r16";
- case dwarf_r17_mips64: return "r17";
- case dwarf_r18_mips64: return "r18";
- case dwarf_r19_mips64: return "r19";
- case dwarf_r20_mips64: return "r20";
- case dwarf_r21_mips64: return "r21";
- case dwarf_r22_mips64: return "r22";
- case dwarf_r23_mips64: return "r23";
- case dwarf_r24_mips64: return "r24";
- case dwarf_r25_mips64: return "r25";
- case dwarf_r26_mips64: return "r26";
- case dwarf_r27_mips64: return "r27";
- case dwarf_gp_mips64: return "gp";
- case dwarf_sp_mips64: return "sp";
- case dwarf_r30_mips64: return "fp";
- case dwarf_ra_mips64: return "ra";
- case dwarf_sr_mips64: return "sr";
- case dwarf_lo_mips64: return "lo";
- case dwarf_hi_mips64: return "hi";
- case dwarf_bad_mips64: return "bad";
- case dwarf_cause_mips64: return "cause";
- case dwarf_pc_mips64: return "pc";
- case dwarf_f0_mips64: return "f0";
- case dwarf_f1_mips64: return "f1";
- case dwarf_f2_mips64: return "f2";
- case dwarf_f3_mips64: return "f3";
- case dwarf_f4_mips64: return "f4";
- case dwarf_f5_mips64: return "f5";
- case dwarf_f6_mips64: return "f6";
- case dwarf_f7_mips64: return "f7";
- case dwarf_f8_mips64: return "f8";
- case dwarf_f9_mips64: return "f9";
- case dwarf_f10_mips64: return "f10";
- case dwarf_f11_mips64: return "f11";
- case dwarf_f12_mips64: return "f12";
- case dwarf_f13_mips64: return "f13";
- case dwarf_f14_mips64: return "f14";
- case dwarf_f15_mips64: return "f15";
- case dwarf_f16_mips64: return "f16";
- case dwarf_f17_mips64: return "f17";
- case dwarf_f18_mips64: return "f18";
- case dwarf_f19_mips64: return "f19";
- case dwarf_f20_mips64: return "f20";
- case dwarf_f21_mips64: return "f21";
- case dwarf_f22_mips64: return "f22";
- case dwarf_f23_mips64: return "f23";
- case dwarf_f24_mips64: return "f24";
- case dwarf_f25_mips64: return "f25";
- case dwarf_f26_mips64: return "f26";
- case dwarf_f27_mips64: return "f27";
- case dwarf_f28_mips64: return "f28";
- case dwarf_f29_mips64: return "f29";
- case dwarf_f30_mips64: return "f30";
- case dwarf_f31_mips64: return "f31";
- case dwarf_fcsr_mips64: return "fcsr";
- case dwarf_fir_mips64: return "fir";
- case dwarf_w0_mips64: return "w0";
- case dwarf_w1_mips64: return "w1";
- case dwarf_w2_mips64: return "w2";
- case dwarf_w3_mips64: return "w3";
- case dwarf_w4_mips64: return "w4";
- case dwarf_w5_mips64: return "w5";
- case dwarf_w6_mips64: return "w6";
- case dwarf_w7_mips64: return "w7";
- case dwarf_w8_mips64: return "w8";
- case dwarf_w9_mips64: return "w9";
- case dwarf_w10_mips64: return "w10";
- case dwarf_w11_mips64: return "w11";
- case dwarf_w12_mips64: return "w12";
- case dwarf_w13_mips64: return "w13";
- case dwarf_w14_mips64: return "w14";
- case dwarf_w15_mips64: return "w15";
- case dwarf_w16_mips64: return "w16";
- case dwarf_w17_mips64: return "w17";
- case dwarf_w18_mips64: return "w18";
- case dwarf_w19_mips64: return "w19";
- case dwarf_w20_mips64: return "w20";
- case dwarf_w21_mips64: return "w21";
- case dwarf_w22_mips64: return "w22";
- case dwarf_w23_mips64: return "w23";
- case dwarf_w24_mips64: return "w24";
- case dwarf_w25_mips64: return "w25";
- case dwarf_w26_mips64: return "w26";
- case dwarf_w27_mips64: return "w27";
- case dwarf_w28_mips64: return "w28";
- case dwarf_w29_mips64: return "w29";
- case dwarf_w30_mips64: return "w30";
- case dwarf_w31_mips64: return "w31";
- case dwarf_mcsr_mips64: return "mcsr";
- case dwarf_mir_mips64: return "mir";
- case dwarf_config5_mips64: return "config5";
+EmulateInstruction *
+EmulateInstructionMIPS64::CreateInstance(const ArchSpec &arch,
+ InstructionType inst_type) {
+ if (EmulateInstructionMIPS64::SupportsEmulatingInstructionsOfTypeStatic(
+ inst_type)) {
+ if (arch.GetTriple().getArch() == llvm::Triple::mips64 ||
+ arch.GetTriple().getArch() == llvm::Triple::mips64el) {
+ std::auto_ptr<EmulateInstructionMIPS64> emulate_insn_ap(
+ new EmulateInstructionMIPS64(arch));
+ if (emulate_insn_ap.get())
+ return emulate_insn_ap.release();
+ }
+ }
+
+ return NULL;
+}
+
+bool EmulateInstructionMIPS64::SetTargetTriple(const ArchSpec &arch) {
+ if (arch.GetTriple().getArch() == llvm::Triple::mips64 ||
+ arch.GetTriple().getArch() == llvm::Triple::mips64el)
+ return true;
+ return false;
+}
+
+const char *EmulateInstructionMIPS64::GetRegisterName(unsigned reg_num,
+ bool alternate_name) {
+ if (alternate_name) {
+ switch (reg_num) {
+ case dwarf_sp_mips64:
+ return "r29";
+ case dwarf_r30_mips64:
+ return "r30";
+ case dwarf_ra_mips64:
+ return "r31";
+ case dwarf_f0_mips64:
+ return "f0";
+ case dwarf_f1_mips64:
+ return "f1";
+ case dwarf_f2_mips64:
+ return "f2";
+ case dwarf_f3_mips64:
+ return "f3";
+ case dwarf_f4_mips64:
+ return "f4";
+ case dwarf_f5_mips64:
+ return "f5";
+ case dwarf_f6_mips64:
+ return "f6";
+ case dwarf_f7_mips64:
+ return "f7";
+ case dwarf_f8_mips64:
+ return "f8";
+ case dwarf_f9_mips64:
+ return "f9";
+ case dwarf_f10_mips64:
+ return "f10";
+ case dwarf_f11_mips64:
+ return "f11";
+ case dwarf_f12_mips64:
+ return "f12";
+ case dwarf_f13_mips64:
+ return "f13";
+ case dwarf_f14_mips64:
+ return "f14";
+ case dwarf_f15_mips64:
+ return "f15";
+ case dwarf_f16_mips64:
+ return "f16";
+ case dwarf_f17_mips64:
+ return "f17";
+ case dwarf_f18_mips64:
+ return "f18";
+ case dwarf_f19_mips64:
+ return "f19";
+ case dwarf_f20_mips64:
+ return "f20";
+ case dwarf_f21_mips64:
+ return "f21";
+ case dwarf_f22_mips64:
+ return "f22";
+ case dwarf_f23_mips64:
+ return "f23";
+ case dwarf_f24_mips64:
+ return "f24";
+ case dwarf_f25_mips64:
+ return "f25";
+ case dwarf_f26_mips64:
+ return "f26";
+ case dwarf_f27_mips64:
+ return "f27";
+ case dwarf_f28_mips64:
+ return "f28";
+ case dwarf_f29_mips64:
+ return "f29";
+ case dwarf_f30_mips64:
+ return "f30";
+ case dwarf_f31_mips64:
+ return "f31";
+ case dwarf_w0_mips64:
+ return "w0";
+ case dwarf_w1_mips64:
+ return "w1";
+ case dwarf_w2_mips64:
+ return "w2";
+ case dwarf_w3_mips64:
+ return "w3";
+ case dwarf_w4_mips64:
+ return "w4";
+ case dwarf_w5_mips64:
+ return "w5";
+ case dwarf_w6_mips64:
+ return "w6";
+ case dwarf_w7_mips64:
+ return "w7";
+ case dwarf_w8_mips64:
+ return "w8";
+ case dwarf_w9_mips64:
+ return "w9";
+ case dwarf_w10_mips64:
+ return "w10";
+ case dwarf_w11_mips64:
+ return "w11";
+ case dwarf_w12_mips64:
+ return "w12";
+ case dwarf_w13_mips64:
+ return "w13";
+ case dwarf_w14_mips64:
+ return "w14";
+ case dwarf_w15_mips64:
+ return "w15";
+ case dwarf_w16_mips64:
+ return "w16";
+ case dwarf_w17_mips64:
+ return "w17";
+ case dwarf_w18_mips64:
+ return "w18";
+ case dwarf_w19_mips64:
+ return "w19";
+ case dwarf_w20_mips64:
+ return "w20";
+ case dwarf_w21_mips64:
+ return "w21";
+ case dwarf_w22_mips64:
+ return "w22";
+ case dwarf_w23_mips64:
+ return "w23";
+ case dwarf_w24_mips64:
+ return "w24";
+ case dwarf_w25_mips64:
+ return "w25";
+ case dwarf_w26_mips64:
+ return "w26";
+ case dwarf_w27_mips64:
+ return "w27";
+ case dwarf_w28_mips64:
+ return "w28";
+ case dwarf_w29_mips64:
+ return "w29";
+ case dwarf_w30_mips64:
+ return "w30";
+ case dwarf_w31_mips64:
+ return "w31";
+ case dwarf_mir_mips64:
+ return "mir";
+ case dwarf_mcsr_mips64:
+ return "mcsr";
+ case dwarf_config5_mips64:
+ return "config5";
+ default:
+ break;
}
return nullptr;
-}
+ }
-bool
-EmulateInstructionMIPS64::GetRegisterInfo (RegisterKind reg_kind, uint32_t reg_num, RegisterInfo ®_info)
-{
- if (reg_kind == eRegisterKindGeneric)
- {
- switch (reg_num)
- {
- case LLDB_REGNUM_GENERIC_PC: reg_kind = eRegisterKindDWARF; reg_num = dwarf_pc_mips64; break;
- case LLDB_REGNUM_GENERIC_SP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sp_mips64; break;
- case LLDB_REGNUM_GENERIC_FP: reg_kind = eRegisterKindDWARF; reg_num = dwarf_r30_mips64; break;
- case LLDB_REGNUM_GENERIC_RA: reg_kind = eRegisterKindDWARF; reg_num = dwarf_ra_mips64; break;
- case LLDB_REGNUM_GENERIC_FLAGS: reg_kind = eRegisterKindDWARF; reg_num = dwarf_sr_mips64; break;
- default:
- return false;
- }
- }
+ switch (reg_num) {
+ case dwarf_zero_mips64:
+ return "r0";
+ case dwarf_r1_mips64:
+ return "r1";
+ case dwarf_r2_mips64:
+ return "r2";
+ case dwarf_r3_mips64:
+ return "r3";
+ case dwarf_r4_mips64:
+ return "r4";
+ case dwarf_r5_mips64:
+ return "r5";
+ case dwarf_r6_mips64:
+ return "r6";
+ case dwarf_r7_mips64:
+ return "r7";
+ case dwarf_r8_mips64:
+ return "r8";
+ case dwarf_r9_mips64:
+ return "r9";
+ case dwarf_r10_mips64:
+ return "r10";
+ case dwarf_r11_mips64:
+ return "r11";
+ case dwarf_r12_mips64:
+ return "r12";
+ case dwarf_r13_mips64:
+ return "r13";
+ case dwarf_r14_mips64:
+ return "r14";
+ case dwarf_r15_mips64:
+ return "r15";
+ case dwarf_r16_mips64:
+ return "r16";
+ case dwarf_r17_mips64:
+ return "r17";
+ case dwarf_r18_mips64:
+ return "r18";
+ case dwarf_r19_mips64:
+ return "r19";
+ case dwarf_r20_mips64:
+ return "r20";
+ case dwarf_r21_mips64:
+ return "r21";
+ case dwarf_r22_mips64:
+ return "r22";
+ case dwarf_r23_mips64:
+ return "r23";
+ case dwarf_r24_mips64:
+ return "r24";
+ case dwarf_r25_mips64:
+ return "r25";
+ case dwarf_r26_mips64:
+ return "r26";
+ case dwarf_r27_mips64:
+ return "r27";
+ case dwarf_gp_mips64:
+ return "gp";
+ case dwarf_sp_mips64:
+ return "sp";
+ case dwarf_r30_mips64:
+ return "fp";
+ case dwarf_ra_mips64:
+ return "ra";
+ case dwarf_sr_mips64:
+ return "sr";
+ case dwarf_lo_mips64:
+ return "lo";
+ case dwarf_hi_mips64:
+ return "hi";
+ case dwarf_bad_mips64:
+ return "bad";
+ case dwarf_cause_mips64:
+ return "cause";
+ case dwarf_pc_mips64:
+ return "pc";
+ case dwarf_f0_mips64:
+ return "f0";
+ case dwarf_f1_mips64:
+ return "f1";
+ case dwarf_f2_mips64:
+ return "f2";
+ case dwarf_f3_mips64:
+ return "f3";
+ case dwarf_f4_mips64:
+ return "f4";
+ case dwarf_f5_mips64:
+ return "f5";
+ case dwarf_f6_mips64:
+ return "f6";
+ case dwarf_f7_mips64:
+ return "f7";
+ case dwarf_f8_mips64:
+ return "f8";
+ case dwarf_f9_mips64:
+ return "f9";
+ case dwarf_f10_mips64:
+ return "f10";
+ case dwarf_f11_mips64:
+ return "f11";
+ case dwarf_f12_mips64:
+ return "f12";
+ case dwarf_f13_mips64:
+ return "f13";
+ case dwarf_f14_mips64:
+ return "f14";
+ case dwarf_f15_mips64:
+ return "f15";
+ case dwarf_f16_mips64:
+ return "f16";
+ case dwarf_f17_mips64:
+ return "f17";
+ case dwarf_f18_mips64:
+ return "f18";
+ case dwarf_f19_mips64:
+ return "f19";
+ case dwarf_f20_mips64:
+ return "f20";
+ case dwarf_f21_mips64:
+ return "f21";
+ case dwarf_f22_mips64:
+ return "f22";
+ case dwarf_f23_mips64:
+ return "f23";
+ case dwarf_f24_mips64:
+ return "f24";
+ case dwarf_f25_mips64:
+ return "f25";
+ case dwarf_f26_mips64:
+ return "f26";
+ case dwarf_f27_mips64:
+ return "f27";
+ case dwarf_f28_mips64:
+ return "f28";
+ case dwarf_f29_mips64:
+ return "f29";
+ case dwarf_f30_mips64:
+ return "f30";
+ case dwarf_f31_mips64:
+ return "f31";
+ case dwarf_fcsr_mips64:
+ return "fcsr";
+ case dwarf_fir_mips64:
+ return "fir";
+ case dwarf_w0_mips64:
+ return "w0";
+ case dwarf_w1_mips64:
+ return "w1";
+ case dwarf_w2_mips64:
+ return "w2";
+ case dwarf_w3_mips64:
+ return "w3";
+ case dwarf_w4_mips64:
+ return "w4";
+ case dwarf_w5_mips64:
+ return "w5";
+ case dwarf_w6_mips64:
+ return "w6";
+ case dwarf_w7_mips64:
+ return "w7";
+ case dwarf_w8_mips64:
+ return "w8";
+ case dwarf_w9_mips64:
+ return "w9";
+ case dwarf_w10_mips64:
+ return "w10";
+ case dwarf_w11_mips64:
+ return "w11";
+ case dwarf_w12_mips64:
+ return "w12";
+ case dwarf_w13_mips64:
+ return "w13";
+ case dwarf_w14_mips64:
+ return "w14";
+ case dwarf_w15_mips64:
+ return "w15";
+ case dwarf_w16_mips64:
+ return "w16";
+ case dwarf_w17_mips64:
+ return "w17";
+ case dwarf_w18_mips64:
+ return "w18";
+ case dwarf_w19_mips64:
+ return "w19";
+ case dwarf_w20_mips64:
+ return "w20";
+ case dwarf_w21_mips64:
+ return "w21";
+ case dwarf_w22_mips64:
+ return "w22";
+ case dwarf_w23_mips64:
+ return "w23";
+ case dwarf_w24_mips64:
+ return "w24";
+ case dwarf_w25_mips64:
+ return "w25";
+ case dwarf_w26_mips64:
+ return "w26";
+ case dwarf_w27_mips64:
+ return "w27";
+ case dwarf_w28_mips64:
+ return "w28";
+ case dwarf_w29_mips64:
+ return "w29";
+ case dwarf_w30_mips64:
+ return "w30";
+ case dwarf_w31_mips64:
+ return "w31";
+ case dwarf_mcsr_mips64:
+ return "mcsr";
+ case dwarf_mir_mips64:
+ return "mir";
+ case dwarf_config5_mips64:
+ return "config5";
+ }
+ return nullptr;
+}
+
+bool EmulateInstructionMIPS64::GetRegisterInfo(RegisterKind reg_kind,
+ uint32_t reg_num,
+ RegisterInfo ®_info) {
+ if (reg_kind == eRegisterKindGeneric) {
+ switch (reg_num) {
+ case LLDB_REGNUM_GENERIC_PC:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_pc_mips64;
+ break;
+ case LLDB_REGNUM_GENERIC_SP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_sp_mips64;
+ break;
+ case LLDB_REGNUM_GENERIC_FP:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_r30_mips64;
+ break;
+ case LLDB_REGNUM_GENERIC_RA:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_ra_mips64;
+ break;
+ case LLDB_REGNUM_GENERIC_FLAGS:
+ reg_kind = eRegisterKindDWARF;
+ reg_num = dwarf_sr_mips64;
+ break;
+ default:
+ return false;
+ }
+ }
+
+ if (reg_kind == eRegisterKindDWARF) {
+ ::memset(®_info, 0, sizeof(RegisterInfo));
+ ::memset(reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
+
+ if (reg_num == dwarf_sr_mips64 || reg_num == dwarf_fcsr_mips64 ||
+ reg_num == dwarf_fir_mips64 || reg_num == dwarf_mcsr_mips64 ||
+ reg_num == dwarf_mir_mips64 || reg_num == dwarf_config5_mips64) {
+ reg_info.byte_size = 4;
+ reg_info.format = eFormatHex;
+ reg_info.encoding = eEncodingUint;
+ } else if ((int)reg_num >= dwarf_zero_mips64 &&
+ (int)reg_num <= dwarf_f31_mips64) {
+ reg_info.byte_size = 8;
+ reg_info.format = eFormatHex;
+ reg_info.encoding = eEncodingUint;
+ } else if ((int)reg_num >= dwarf_w0_mips64 &&
+ (int)reg_num <= dwarf_w31_mips64) {
+ reg_info.byte_size = 16;
+ reg_info.format = eFormatVectorOfUInt8;
+ reg_info.encoding = eEncodingVector;
+ } else {
+ return false;
+ }
+
+ reg_info.name = GetRegisterName(reg_num, false);
+ reg_info.alt_name = GetRegisterName(reg_num, true);
+ reg_info.kinds[eRegisterKindDWARF] = reg_num;
+
+ switch (reg_num) {
+ case dwarf_r30_mips64:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+ break;
+ case dwarf_ra_mips64:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+ break;
+ case dwarf_sp_mips64:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+ break;
+ case dwarf_pc_mips64:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+ break;
+ case dwarf_sr_mips64:
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+ return false;
+}
+
+EmulateInstructionMIPS64::MipsOpcode *
+EmulateInstructionMIPS64::GetOpcodeForInstruction(const char *op_name) {
+ static EmulateInstructionMIPS64::MipsOpcode g_opcodes[] = {
+ //----------------------------------------------------------------------
+ // Prologue/Epilogue instructions
+ //----------------------------------------------------------------------
+ {"DADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu,
+ "DADDIU rt, rs, immediate"},
+ {"ADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu,
+ "ADDIU rt, rs, immediate"},
+ {"SD", &EmulateInstructionMIPS64::Emulate_SD, "SD rt, offset(rs)"},
+ {"LD", &EmulateInstructionMIPS64::Emulate_LD, "LD rt, offset(base)"},
+ {"DSUBU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU,
+ "DSUBU rd, rs, rt"},
+ {"SUBU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU,
+ "SUBU rd, rs, rt"},
+ {"DADDU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU,
+ "DADDU rd, rs, rt"},
+ {"ADDU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU,
+ "ADDU rd, rs, rt"},
+ {"LUI", &EmulateInstructionMIPS64::Emulate_LUI, "LUI rt, immediate"},
+
+ //----------------------------------------------------------------------
+ // Load/Store instructions
+ //----------------------------------------------------------------------
+ /* Following list of emulated instructions are required by implementation
+ of hardware watchpoint
+ for MIPS in lldb. As we just need the address accessed by instructions,
+ we have generalised
+ all these instructions in 2 functions depending on their addressing
+ modes */
+
+ {"LB", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LB rt, offset(base)"},
+ {"LBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LBE rt, offset(base)"},
+ {"LBU", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LBU rt, offset(base)"},
+ {"LBUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LBUE rt, offset(base)"},
+ {"LDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LDC1 ft, offset(base)"},
+ {"LDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LDL rt, offset(base)"},
+ {"LDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LDR rt, offset(base)"},
+ {"LLD", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LLD rt, offset(base)"},
+ {"LDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LDC2 rt, offset(base)"},
+ {"LDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "LDXC1 fd, index (base)"},
+ {"LH", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LH rt, offset(base)"},
+ {"LHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LHE rt, offset(base)"},
+ {"LHU", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LHU rt, offset(base)"},
+ {"LHUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LHUE rt, offset(base)"},
+ {"LL", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LL rt, offset(base)"},
+ {"LLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LLE rt, offset(base)"},
+ {"LUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "LUXC1 fd, index (base)"},
+ {"LW", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LW rt, offset(rs)"},
+ {"LWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWC1 ft, offset(base)"},
+ {"LWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWC2 rt, offset(base)"},
+ {"LWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWE rt, offset(base)"},
+ {"LWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWL rt, offset(base)"},
+ {"LWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWLE rt, offset(base)"},
+ {"LWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWR rt, offset(base)"},
+ {"LWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "LWRE rt, offset(base)"},
+ {"LWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "LWXC1 fd, index (base)"},
+
+ {"SB", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SB rt, offset(base)"},
+ {"SBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SBE rt, offset(base)"},
+ {"SC", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SC rt, offset(base)"},
+ {"SCE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SCE rt, offset(base)"},
+ {"SCD", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SCD rt, offset(base)"},
+ {"SDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SDL rt, offset(base)"},
+ {"SDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SDR rt, offset(base)"},
+ {"SDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SDC1 ft, offset(base)"},
+ {"SDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SDC2 rt, offset(base)"},
+ {"SDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "SDXC1 fs, index (base)"},
+ {"SH", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SH rt, offset(base)"},
+ {"SHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SHE rt, offset(base)"},
+ {"SUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "SUXC1 fs, index (base)"},
+ {"SW", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SW rt, offset(rs)"},
+ {"SWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWC1 ft, offset(base)"},
+ {"SWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWC2 rt, offset(base)"},
+ {"SWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWE rt, offset(base)"},
+ {"SWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWL rt, offset(base)"},
+ {"SWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWLE rt, offset(base)"},
+ {"SWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWR rt, offset(base)"},
+ {"SWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm,
+ "SWRE rt, offset(base)"},
+ {"SWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
+ "SWXC1 fs, index (base)"},
+
+ //----------------------------------------------------------------------
+ // Branch instructions
+ //----------------------------------------------------------------------
+ {"BEQ", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BEQ rs,rt,offset"},
+ {"BNE", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BNE rs,rt,offset"},
+ {"BEQL", &EmulateInstructionMIPS64::Emulate_BXX_3ops,
+ "BEQL rs,rt,offset"},
+ {"BNEL", &EmulateInstructionMIPS64::Emulate_BXX_3ops,
+ "BNEL rs,rt,offset"},
+ {"BGEZALL", &EmulateInstructionMIPS64::Emulate_Bcond_Link,
+ "BGEZALL rt,offset"},
+ {"BAL", &EmulateInstructionMIPS64::Emulate_BAL, "BAL offset"},
+ {"BGEZAL", &EmulateInstructionMIPS64::Emulate_Bcond_Link,
+ "BGEZAL rs,offset"},
+ {"BALC", &EmulateInstructionMIPS64::Emulate_BALC, "BALC offset"},
+ {"BC", &EmulateInstructionMIPS64::Emulate_BC, "BC offset"},
+ {"BGEZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGEZ rs,offset"},
+ {"BLEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BLEZALC rs,offset"},
+ {"BGEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BGEZALC rs,offset"},
+ {"BLTZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BLTZALC rs,offset"},
+ {"BGTZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BGTZALC rs,offset"},
+ {"BEQZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BEQZALC rs,offset"},
+ {"BNEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,
+ "BNEZALC rs,offset"},
+ {"BEQC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BEQC rs,rt,offset"},
+ {"BNEC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BNEC rs,rt,offset"},
+ {"BLTC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BLTC rs,rt,offset"},
+ {"BGEC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BGEC rs,rt,offset"},
+ {"BLTUC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BLTUC rs,rt,offset"},
+ {"BGEUC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BGEUC rs,rt,offset"},
+ {"BLTZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BLTZC rt,offset"},
+ {"BLEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BLEZC rt,offset"},
+ {"BGEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BGEZC rt,offset"},
+ {"BGTZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BGTZC rt,offset"},
+ {"BEQZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BEQZC rt,offset"},
+ {"BNEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C,
+ "BNEZC rt,offset"},
+ {"BGEZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGEZL rt,offset"},
+ {"BGTZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGTZ rt,offset"},
+ {"BGTZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGTZL rt,offset"},
+ {"BLEZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLEZ rt,offset"},
+ {"BLEZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLEZL rt,offset"},
+ {"BLTZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLTZ rt,offset"},
+ {"BLTZAL", &EmulateInstructionMIPS64::Emulate_Bcond_Link,
+ "BLTZAL rt,offset"},
+ {"BLTZALL", &EmulateInstructionMIPS64::Emulate_Bcond_Link,
+ "BLTZALL rt,offset"},
+ {"BLTZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLTZL rt,offset"},
+ {"BOVC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BOVC rs,rt,offset"},
+ {"BNVC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C,
+ "BNVC rs,rt,offset"},
+ {"J", &EmulateInstructionMIPS64::Emulate_J, "J target"},
+ {"JAL", &EmulateInstructionMIPS64::Emulate_JAL, "JAL target"},
+ {"JALX", &EmulateInstructionMIPS64::Emulate_JAL, "JALX target"},
+ {"JALR", &EmulateInstructionMIPS64::Emulate_JALR, "JALR target"},
+ {"JALR_HB", &EmulateInstructionMIPS64::Emulate_JALR, "JALR.HB target"},
+ {"JIALC", &EmulateInstructionMIPS64::Emulate_JIALC, "JIALC rt,offset"},
+ {"JIC", &EmulateInstructionMIPS64::Emulate_JIC, "JIC rt,offset"},
+ {"JR", &EmulateInstructionMIPS64::Emulate_JR, "JR target"},
+ {"JR_HB", &EmulateInstructionMIPS64::Emulate_JR, "JR.HB target"},
+ {"BC1F", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1F cc, offset"},
+ {"BC1T", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1T cc, offset"},
+ {"BC1FL", &EmulateInstructionMIPS64::Emulate_FP_branch,
+ "BC1FL cc, offset"},
+ {"BC1TL", &EmulateInstructionMIPS64::Emulate_FP_branch,
+ "BC1TL cc, offset"},
+ {"BC1EQZ", &EmulateInstructionMIPS64::Emulate_BC1EQZ,
+ "BC1EQZ ft, offset"},
+ {"BC1NEZ", &EmulateInstructionMIPS64::Emulate_BC1NEZ,
+ "BC1NEZ ft, offset"},
+ {"BC1ANY2F", &EmulateInstructionMIPS64::Emulate_3D_branch,
+ "BC1ANY2F cc, offset"},
+ {"BC1ANY2T", &EmulateInstructionMIPS64::Emulate_3D_branch,
+ "BC1ANY2T cc, offset"},
+ {"BC1ANY4F", &EmulateInstructionMIPS64::Emulate_3D_branch,
+ "BC1ANY4F cc, offset"},
+ {"BC1ANY4T", &EmulateInstructionMIPS64::Emulate_3D_branch,
+ "BC1ANY4T cc, offset"},
+ {"BNZ_B", &EmulateInstructionMIPS64::Emulate_BNZB, "BNZ.b wt,s16"},
+ {"BNZ_H", &EmulateInstructionMIPS64::Emulate_BNZH, "BNZ.h wt,s16"},
+ {"BNZ_W", &EmulateInstructionMIPS64::Emulate_BNZW, "BNZ.w wt,s16"},
+ {"BNZ_D", &EmulateInstructionMIPS64::Emulate_BNZD, "BNZ.d wt,s16"},
+ {"BZ_B", &EmulateInstructionMIPS64::Emulate_BZB, "BZ.b wt,s16"},
+ {"BZ_H", &EmulateInstructionMIPS64::Emulate_BZH, "BZ.h wt,s16"},
+ {"BZ_W", &EmulateInstructionMIPS64::Emulate_BZW, "BZ.w wt,s16"},
+ {"BZ_D", &EmulateInstructionMIPS64::Emulate_BZD, "BZ.d wt,s16"},
+ {"BNZ_V", &EmulateInstructionMIPS64::Emulate_BNZV, "BNZ.V wt,s16"},
+ {"BZ_V", &EmulateInstructionMIPS64::Emulate_BZV, "BZ.V wt,s16"},
+ };
+
+ static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
+
+ for (size_t i = 0; i < k_num_mips_opcodes; ++i) {
+ if (!strcasecmp(g_opcodes[i].op_name, op_name))
+ return &g_opcodes[i];
+ }
+
+ return NULL;
+}
+
+bool EmulateInstructionMIPS64::ReadInstruction() {
+ bool success = false;
+ m_addr = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC,
+ LLDB_INVALID_ADDRESS, &success);
+ if (success) {
+ Context read_inst_context;
+ read_inst_context.type = eContextReadOpcode;
+ read_inst_context.SetNoArgs();
+ m_opcode.SetOpcode32(
+ ReadMemoryUnsigned(read_inst_context, m_addr, 4, 0, &success),
+ GetByteOrder());
+ }
+ if (!success)
+ m_addr = LLDB_INVALID_ADDRESS;
+ return success;
+}
+
+bool EmulateInstructionMIPS64::EvaluateInstruction(uint32_t evaluate_options) {
+ bool success = false;
+ llvm::MCInst mc_insn;
+ uint64_t insn_size;
+ DataExtractor data;
+
+ /* Keep the complexity of the decode logic with the llvm::MCDisassembler
+ * class. */
+ if (m_opcode.GetData(data)) {
+ llvm::MCDisassembler::DecodeStatus decode_status;
+ llvm::ArrayRef<uint8_t> raw_insn(data.GetDataStart(), data.GetByteSize());
+ decode_status = m_disasm->getInstruction(
+ mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
+ if (decode_status != llvm::MCDisassembler::Success)
+ return false;
+ }
+
+ /*
+ * mc_insn.getOpcode() returns decoded opcode. However to make use
+ * of llvm::Mips::<insn> we would need "MipsGenInstrInfo.inc".
+ */
+ const char *op_name = m_insn_info->getName(mc_insn.getOpcode());
- if (reg_kind == eRegisterKindDWARF)
- {
- ::memset (®_info, 0, sizeof(RegisterInfo));
- ::memset (reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
-
- if (reg_num == dwarf_sr_mips64 || reg_num == dwarf_fcsr_mips64 || reg_num == dwarf_fir_mips64 || reg_num == dwarf_mcsr_mips64 || reg_num == dwarf_mir_mips64 || reg_num == dwarf_config5_mips64)
- {
- reg_info.byte_size = 4;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- }
- else if ((int)reg_num >= dwarf_zero_mips64 && (int)reg_num <= dwarf_f31_mips64)
- {
- reg_info.byte_size = 8;
- reg_info.format = eFormatHex;
- reg_info.encoding = eEncodingUint;
- }
- else if ((int)reg_num >= dwarf_w0_mips64 && (int)reg_num <= dwarf_w31_mips64)
- {
- reg_info.byte_size = 16;
- reg_info.format = eFormatVectorOfUInt8;
- reg_info.encoding = eEncodingVector;
- }
- else
- {
- return false;
- }
-
- reg_info.name = GetRegisterName (reg_num, false);
- reg_info.alt_name = GetRegisterName (reg_num, true);
- reg_info.kinds[eRegisterKindDWARF] = reg_num;
-
- switch (reg_num)
- {
- case dwarf_r30_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP; break;
- case dwarf_ra_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; break;
- case dwarf_sp_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP; break;
- case dwarf_pc_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC; break;
- case dwarf_sr_mips64: reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; break;
- default: break;
- }
- return true;
- }
+ if (op_name == NULL)
return false;
-}
-EmulateInstructionMIPS64::MipsOpcode*
-EmulateInstructionMIPS64::GetOpcodeForInstruction (const char *op_name)
-{
- static EmulateInstructionMIPS64::MipsOpcode
- g_opcodes[] =
- {
- //----------------------------------------------------------------------
- // Prologue/Epilogue instructions
- //----------------------------------------------------------------------
- { "DADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu, "DADDIU rt, rs, immediate" },
- { "ADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu, "ADDIU rt, rs, immediate" },
- { "SD", &EmulateInstructionMIPS64::Emulate_SD, "SD rt, offset(rs)" },
- { "LD", &EmulateInstructionMIPS64::Emulate_LD, "LD rt, offset(base)" },
- { "DSUBU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU, "DSUBU rd, rs, rt" },
- { "SUBU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU, "SUBU rd, rs, rt" },
- { "DADDU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU, "DADDU rd, rs, rt" },
- { "ADDU", &EmulateInstructionMIPS64::Emulate_DSUBU_DADDU, "ADDU rd, rs, rt" },
- { "LUI", &EmulateInstructionMIPS64::Emulate_LUI, "LUI rt, immediate" },
-
-
-
-
- //----------------------------------------------------------------------
- // Load/Store instructions
- //----------------------------------------------------------------------
- /* Following list of emulated instructions are required by implementation of hardware watchpoint
- for MIPS in lldb. As we just need the address accessed by instructions, we have generalised
- all these instructions in 2 functions depending on their addressing modes */
-
- { "LB", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LB rt, offset(base)" },
- { "LBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBE rt, offset(base)" },
- { "LBU", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBU rt, offset(base)" },
- { "LBUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LBUE rt, offset(base)" },
- { "LDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDC1 ft, offset(base)" },
- { "LDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDL rt, offset(base)" },
- { "LDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDR rt, offset(base)" },
- { "LLD", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LLD rt, offset(base)" },
- { "LDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LDC2 rt, offset(base)" },
- { "LDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LDXC1 fd, index (base)" },
- { "LH", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LH rt, offset(base)" },
- { "LHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHE rt, offset(base)" },
- { "LHU", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHU rt, offset(base)" },
- { "LHUE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LHUE rt, offset(base)" },
- { "LL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LL rt, offset(base)" },
- { "LLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LLE rt, offset(base)" },
- { "LUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LUXC1 fd, index (base)" },
- { "LW", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LW rt, offset(rs)" },
- { "LWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWC1 ft, offset(base)" },
- { "LWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWC2 rt, offset(base)" },
- { "LWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWE rt, offset(base)" },
- { "LWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWL rt, offset(base)" },
- { "LWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWLE rt, offset(base)" },
- { "LWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWR rt, offset(base)" },
- { "LWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "LWRE rt, offset(base)" },
- { "LWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "LWXC1 fd, index (base)" },
-
- { "SB", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SB rt, offset(base)" },
- { "SBE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SBE rt, offset(base)" },
- { "SC", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SC rt, offset(base)" },
- { "SCE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SCE rt, offset(base)" },
- { "SCD", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SCD rt, offset(base)" },
- { "SDL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDL rt, offset(base)" },
- { "SDR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDR rt, offset(base)" },
- { "SDC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDC1 ft, offset(base)" },
- { "SDC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SDC2 rt, offset(base)" },
- { "SDXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SDXC1 fs, index (base)" },
- { "SH", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SH rt, offset(base)" },
- { "SHE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SHE rt, offset(base)" },
- { "SUXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SUXC1 fs, index (base)" },
- { "SW", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SW rt, offset(rs)" },
- { "SWC1", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWC1 ft, offset(base)" },
- { "SWC2", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWC2 rt, offset(base)" },
- { "SWE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWE rt, offset(base)" },
- { "SWL", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWL rt, offset(base)" },
- { "SWLE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWLE rt, offset(base)" },
- { "SWR", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWR rt, offset(base)" },
- { "SWRE", &EmulateInstructionMIPS64::Emulate_LDST_Imm, "SWRE rt, offset(base)" },
- { "SWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg, "SWXC1 fs, index (base)" },
-
- //----------------------------------------------------------------------
- // Branch instructions
- //----------------------------------------------------------------------
- { "BEQ", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BEQ rs,rt,offset" },
- { "BNE", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BNE rs,rt,offset" },
- { "BEQL", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BEQL rs,rt,offset" },
- { "BNEL", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BNEL rs,rt,offset" },
- { "BGEZALL", &EmulateInstructionMIPS64::Emulate_Bcond_Link, "BGEZALL rt,offset" },
- { "BAL", &EmulateInstructionMIPS64::Emulate_BAL, "BAL offset" },
- { "BGEZAL", &EmulateInstructionMIPS64::Emulate_Bcond_Link, "BGEZAL rs,offset" },
- { "BALC", &EmulateInstructionMIPS64::Emulate_BALC, "BALC offset" },
- { "BC", &EmulateInstructionMIPS64::Emulate_BC, "BC offset" },
- { "BGEZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGEZ rs,offset" },
- { "BLEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BLEZALC rs,offset" },
- { "BGEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BGEZALC rs,offset" },
- { "BLTZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BLTZALC rs,offset" },
- { "BGTZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BGTZALC rs,offset" },
- { "BEQZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BEQZALC rs,offset" },
- { "BNEZALC", &EmulateInstructionMIPS64::Emulate_Bcond_Link_C,"BNEZALC rs,offset" },
- { "BEQC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BEQC rs,rt,offset" },
- { "BNEC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BNEC rs,rt,offset" },
- { "BLTC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BLTC rs,rt,offset" },
- { "BGEC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BGEC rs,rt,offset" },
- { "BLTUC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BLTUC rs,rt,offset" },
- { "BGEUC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BGEUC rs,rt,offset" },
- { "BLTZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BLTZC rt,offset" },
- { "BLEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BLEZC rt,offset" },
- { "BGEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BGEZC rt,offset" },
- { "BGTZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BGTZC rt,offset" },
- { "BEQZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BEQZC rt,offset" },
- { "BNEZC", &EmulateInstructionMIPS64::Emulate_BXX_2ops_C, "BNEZC rt,offset" },
- { "BGEZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGEZL rt,offset" },
- { "BGTZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGTZ rt,offset" },
- { "BGTZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BGTZL rt,offset" },
- { "BLEZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLEZ rt,offset" },
- { "BLEZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLEZL rt,offset" },
- { "BLTZ", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLTZ rt,offset" },
- { "BLTZAL", &EmulateInstructionMIPS64::Emulate_Bcond_Link, "BLTZAL rt,offset" },
- { "BLTZALL", &EmulateInstructionMIPS64::Emulate_Bcond_Link, "BLTZALL rt,offset" },
- { "BLTZL", &EmulateInstructionMIPS64::Emulate_BXX_2ops, "BLTZL rt,offset" },
- { "BOVC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BOVC rs,rt,offset" },
- { "BNVC", &EmulateInstructionMIPS64::Emulate_BXX_3ops_C, "BNVC rs,rt,offset" },
- { "J", &EmulateInstructionMIPS64::Emulate_J, "J target" },
- { "JAL", &EmulateInstructionMIPS64::Emulate_JAL, "JAL target" },
- { "JALX", &EmulateInstructionMIPS64::Emulate_JAL, "JALX target" },
- { "JALR", &EmulateInstructionMIPS64::Emulate_JALR, "JALR target" },
- { "JALR_HB", &EmulateInstructionMIPS64::Emulate_JALR, "JALR.HB target" },
- { "JIALC", &EmulateInstructionMIPS64::Emulate_JIALC, "JIALC rt,offset" },
- { "JIC", &EmulateInstructionMIPS64::Emulate_JIC, "JIC rt,offset" },
- { "JR", &EmulateInstructionMIPS64::Emulate_JR, "JR target" },
- { "JR_HB", &EmulateInstructionMIPS64::Emulate_JR, "JR.HB target" },
- { "BC1F", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1F cc, offset" },
- { "BC1T", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1T cc, offset" },
- { "BC1FL", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1FL cc, offset" },
- { "BC1TL", &EmulateInstructionMIPS64::Emulate_FP_branch, "BC1TL cc, offset" },
- { "BC1EQZ", &EmulateInstructionMIPS64::Emulate_BC1EQZ, "BC1EQZ ft, offset" },
- { "BC1NEZ", &EmulateInstructionMIPS64::Emulate_BC1NEZ, "BC1NEZ ft, offset" },
- { "BC1ANY2F", &EmulateInstructionMIPS64::Emulate_3D_branch, "BC1ANY2F cc, offset" },
- { "BC1ANY2T", &EmulateInstructionMIPS64::Emulate_3D_branch, "BC1ANY2T cc, offset" },
- { "BC1ANY4F", &EmulateInstructionMIPS64::Emulate_3D_branch, "BC1ANY4F cc, offset" },
- { "BC1ANY4T", &EmulateInstructionMIPS64::Emulate_3D_branch, "BC1ANY4T cc, offset" },
- { "BNZ_B", &EmulateInstructionMIPS64::Emulate_BNZB, "BNZ.b wt,s16" },
- { "BNZ_H", &EmulateInstructionMIPS64::Emulate_BNZH, "BNZ.h wt,s16" },
- { "BNZ_W", &EmulateInstructionMIPS64::Emulate_BNZW, "BNZ.w wt,s16" },
- { "BNZ_D", &EmulateInstructionMIPS64::Emulate_BNZD, "BNZ.d wt,s16" },
- { "BZ_B", &EmulateInstructionMIPS64::Emulate_BZB, "BZ.b wt,s16" },
- { "BZ_H", &EmulateInstructionMIPS64::Emulate_BZH, "BZ.h wt,s16" },
- { "BZ_W", &EmulateInstructionMIPS64::Emulate_BZW, "BZ.w wt,s16" },
- { "BZ_D", &EmulateInstructionMIPS64::Emulate_BZD, "BZ.d wt,s16" },
- { "BNZ_V", &EmulateInstructionMIPS64::Emulate_BNZV, "BNZ.V wt,s16" },
- { "BZ_V", &EmulateInstructionMIPS64::Emulate_BZV, "BZ.V wt,s16" },
- };
-
- static const size_t k_num_mips_opcodes = llvm::array_lengthof(g_opcodes);
-
- for (size_t i = 0; i < k_num_mips_opcodes; ++i)
- {
- if (! strcasecmp (g_opcodes[i].op_name, op_name))
- return &g_opcodes[i];
- }
+ /*
+ * Decoding has been done already. Just get the call-back function
+ * and emulate the instruction.
+ */
+ MipsOpcode *opcode_data = GetOpcodeForInstruction(op_name);
- return NULL;
-}
+ if (opcode_data == NULL)
+ return false;
-bool
-EmulateInstructionMIPS64::ReadInstruction ()
-{
- bool success = false;
- m_addr = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success);
- if (success)
- {
- Context read_inst_context;
- read_inst_context.type = eContextReadOpcode;
- read_inst_context.SetNoArgs ();
- m_opcode.SetOpcode32 (ReadMemoryUnsigned (read_inst_context, m_addr, 4, 0, &success), GetByteOrder());
- }
+ uint64_t old_pc = 0, new_pc = 0;
+ const bool auto_advance_pc =
+ evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
+
+ if (auto_advance_pc) {
+ old_pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
+ }
+
+ /* emulate instruction */
+ success = (this->*opcode_data->callback)(mc_insn);
+ if (!success)
+ return false;
+
+ if (auto_advance_pc) {
+ new_pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
if (!success)
- m_addr = LLDB_INVALID_ADDRESS;
- return success;
-}
+ return false;
-bool
-EmulateInstructionMIPS64::EvaluateInstruction (uint32_t evaluate_options)
-{
- bool success = false;
- llvm::MCInst mc_insn;
- uint64_t insn_size;
- DataExtractor data;
-
- /* Keep the complexity of the decode logic with the llvm::MCDisassembler class. */
- if (m_opcode.GetData (data))
- {
- llvm::MCDisassembler::DecodeStatus decode_status;
- llvm::ArrayRef<uint8_t> raw_insn (data.GetDataStart(), data.GetByteSize());
- decode_status = m_disasm->getInstruction (mc_insn, insn_size, raw_insn, m_addr, llvm::nulls(), llvm::nulls());
- if (decode_status != llvm::MCDisassembler::Success)
- return false;
+ /* If we haven't changed the PC, change it here */
+ if (old_pc == new_pc) {
+ new_pc += 4;
+ Context context;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ new_pc))
+ return false;
}
+ }
- /*
- * mc_insn.getOpcode() returns decoded opcode. However to make use
- * of llvm::Mips::<insn> we would need "MipsGenInstrInfo.inc".
- */
- const char *op_name = m_insn_info->getName (mc_insn.getOpcode ());
+ return true;
+}
- if (op_name == NULL)
- return false;
+bool EmulateInstructionMIPS64::CreateFunctionEntryUnwind(
+ UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
- /*
- * Decoding has been done already. Just get the call-back function
- * and emulate the instruction.
- */
- MipsOpcode *opcode_data = GetOpcodeForInstruction (op_name);
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+ const bool can_replace = false;
- if (opcode_data == NULL)
- return false;
+ // Our previous Call Frame Address is the stack pointer
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips64, 0);
- uint64_t old_pc = 0, new_pc = 0;
- const bool auto_advance_pc = evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
+ // Our previous PC is in the RA
+ row->SetRegisterLocationToRegister(dwarf_pc_mips64, dwarf_ra_mips64,
+ can_replace);
- if (auto_advance_pc)
- {
- old_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
- }
+ unwind_plan.AppendRow(row);
- /* emulate instruction */
- success = (this->*opcode_data->callback) (mc_insn);
- if (!success)
- return false;
+ // All other registers are the same.
+ unwind_plan.SetSourceName("EmulateInstructionMIPS64");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolYes);
+ unwind_plan.SetReturnAddressRegister(dwarf_ra_mips64);
- if (auto_advance_pc)
- {
- new_pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
-
- /* If we haven't changed the PC, change it here */
- if (old_pc == new_pc)
- {
- new_pc += 4;
- Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, new_pc))
- return false;
- }
- }
+ return true;
+}
+bool EmulateInstructionMIPS64::nonvolatile_reg_p(uint64_t regnum) {
+ switch (regnum) {
+ case dwarf_r16_mips64:
+ case dwarf_r17_mips64:
+ case dwarf_r18_mips64:
+ case dwarf_r19_mips64:
+ case dwarf_r20_mips64:
+ case dwarf_r21_mips64:
+ case dwarf_r22_mips64:
+ case dwarf_r23_mips64:
+ case dwarf_gp_mips64:
+ case dwarf_sp_mips64:
+ case dwarf_r30_mips64:
+ case dwarf_ra_mips64:
return true;
+ default:
+ return false;
+ }
+ return false;
}
-bool
-EmulateInstructionMIPS64::CreateFunctionEntryUnwind (UnwindPlan &unwind_plan)
-{
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind (eRegisterKindDWARF);
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
- const bool can_replace = false;
-
- // Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_sp_mips64, 0);
-
- // Our previous PC is in the RA
- row->SetRegisterLocationToRegister(dwarf_pc_mips64, dwarf_ra_mips64, can_replace);
-
- unwind_plan.AppendRow (row);
-
- // All other registers are the same.
- unwind_plan.SetSourceName ("EmulateInstructionMIPS64");
- unwind_plan.SetSourcedFromCompiler (eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions (eLazyBoolYes);
- unwind_plan.SetReturnAddressRegister (dwarf_ra_mips64);
+bool EmulateInstructionMIPS64::Emulate_DADDiu(llvm::MCInst &insn) {
+ // DADDIU rt, rs, immediate
+ // GPR[rt] <- GPR[rs] + sign_extend(immediate)
- return true;
-}
+ uint8_t dst, src;
+ bool success = false;
+ const uint32_t imm16 = insn.getOperand(2).getImm();
+ int64_t imm = SignedBits(imm16, 15, 0);
+
+ dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+
+ // If immediate is greater than 2^16 - 1 then clang generate
+ // LUI, (D)ADDIU,(D)SUBU instructions in prolog.
+ // Example
+ // lui $1, 0x2
+ // daddiu $1, $1, -0x5920
+ // dsubu $sp, $sp, $1
+ // In this case, (D)ADDIU dst and src will be same and not equal to sp
+ if (dst == src) {
+ Context context;
-bool
-EmulateInstructionMIPS64::nonvolatile_reg_p (uint64_t regnum)
-{
- switch (regnum)
- {
- case dwarf_r16_mips64:
- case dwarf_r17_mips64:
- case dwarf_r18_mips64:
- case dwarf_r19_mips64:
- case dwarf_r20_mips64:
- case dwarf_r21_mips64:
- case dwarf_r22_mips64:
- case dwarf_r23_mips64:
- case dwarf_gp_mips64:
- case dwarf_sp_mips64:
- case dwarf_r30_mips64:
- case dwarf_ra_mips64:
- return true;
- default:
- return false;
+ /* read <src> register */
+ const int64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
+ if (!success)
+ return false;
+
+ /* Check if this is daddiu sp, sp, imm16 */
+ if (dst == dwarf_sp_mips64) {
+ uint64_t result = src_opd_val + imm;
+ RegisterInfo reg_info_sp;
+
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips64, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, imm);
+
+ /* We are allocating bytes on stack */
+ context.type = eContextAdjustStackPointer;
+
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips64,
+ result);
+ return true;
}
+
+ imm += src_opd_val;
+ context.SetImmediateSigned(imm);
+ context.type = eContextImmediate;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips64 + dst, imm))
+ return false;
+ }
+
+ return true;
+}
+
+bool EmulateInstructionMIPS64::Emulate_SD(llvm::MCInst &insn) {
+ uint64_t address;
+ RegisterInfo reg_info_base;
+ RegisterInfo reg_info_src;
+ bool success = false;
+ uint32_t imm16 = insn.getOperand(2).getImm();
+ uint64_t imm = SignedBits(imm16, 15, 0);
+ uint32_t src, base;
+ Context bad_vaddr_context;
+
+ src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips64 + base,
+ reg_info_base) ||
+ !GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips64 + src,
+ reg_info_src))
return false;
-}
-bool
-EmulateInstructionMIPS64::Emulate_DADDiu (llvm::MCInst& insn)
-{
- // DADDIU rt, rs, immediate
- // GPR[rt] <- GPR[rs] + sign_extend(immediate)
-
- uint8_t dst, src;
- bool success = false;
- const uint32_t imm16 = insn.getOperand(2).getImm();
- int64_t imm = SignedBits(imm16, 15, 0);
-
- dst = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
-
- // If immediate is greater than 2^16 - 1 then clang generate
- // LUI, (D)ADDIU,(D)SUBU instructions in prolog.
- // Example
- // lui $1, 0x2
- // daddiu $1, $1, -0x5920
- // dsubu $sp, $sp, $1
- // In this case, (D)ADDIU dst and src will be same and not equal to sp
- if (dst == src)
- {
- Context context;
-
- /* read <src> register */
- const int64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
- if (!success)
- return false;
-
- /* Check if this is daddiu sp, sp, imm16 */
- if (dst == dwarf_sp_mips64)
- {
- uint64_t result = src_opd_val + imm;
- RegisterInfo reg_info_sp;
-
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips64, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, imm);
-
- /* We are allocating bytes on stack */
- context.type = eContextAdjustStackPointer;
-
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips64, result);
- return true;
- }
-
- imm += src_opd_val;
- context.SetImmediateSigned (imm);
- context.type = eContextImmediate;
+ /* read SP */
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + base,
+ 0, &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips64 + dst, imm))
- return false;
- }
+ /* destination address */
+ address = address + imm;
- return true;
+ /* We look for sp based non-volatile register stores */
+ if (nonvolatile_reg_p(src)) {
+ Context context;
+ RegisterValue data_src;
+ context.type = eContextPushRegisterOnStack;
+ context.SetRegisterToRegisterPlusOffset(reg_info_src, reg_info_base, 0);
+
+ uint8_t buffer[RegisterValue::kMaxRegisterByteSize];
+ Error error;
+
+ if (!ReadRegister(®_info_base, data_src))
+ return false;
+
+ if (data_src.GetAsMemoryData(®_info_src, buffer, reg_info_src.byte_size,
+ eByteOrderLittle, error) == 0)
+ return false;
+
+ if (!WriteMemory(context, address, buffer, reg_info_src.byte_size))
+ return false;
+ }
+
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64,
+ address);
+
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_SD (llvm::MCInst& insn)
-{
- uint64_t address;
- RegisterInfo reg_info_base;
- RegisterInfo reg_info_src;
- bool success = false;
- uint32_t imm16 = insn.getOperand(2).getImm();
- uint64_t imm = SignedBits(imm16, 15, 0);
- uint32_t src, base;
- Context bad_vaddr_context;
+bool EmulateInstructionMIPS64::Emulate_LD(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t src, base;
+ int64_t imm, address;
+ Context bad_vaddr_context;
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+ src = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ base = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ imm = insn.getOperand(2).getImm();
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + base, reg_info_base)
- || !GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + src, reg_info_src))
- return false;
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips64 + base,
+ reg_info_base))
+ return false;
- /* read SP */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + base, 0, &success);
- if (!success)
- return false;
+ /* read base register */
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + base,
+ 0, &success);
+ if (!success)
+ return false;
- /* destination address */
- address = address + imm;
+ /* destination address */
+ address = address + imm;
- /* We look for sp based non-volatile register stores */
- if (nonvolatile_reg_p (src))
- {
- Context context;
- RegisterValue data_src;
- context.type = eContextPushRegisterOnStack;
- context.SetRegisterToRegisterPlusOffset (reg_info_src, reg_info_base, 0);
-
- uint8_t buffer [RegisterValue::kMaxRegisterByteSize];
- Error error;
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64,
+ address);
- if (!ReadRegister (®_info_base, data_src))
- return false;
+ if (nonvolatile_reg_p(src)) {
+ RegisterValue data_src;
+ RegisterInfo reg_info_src;
- if (data_src.GetAsMemoryData (®_info_src, buffer, reg_info_src.byte_size, eByteOrderLittle, error) == 0)
- return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips64 + src,
+ reg_info_src))
+ return false;
- if (!WriteMemory (context, address, buffer, reg_info_src.byte_size))
- return false;
- }
+ Context context;
+ context.type = eContextRegisterLoad;
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64, address);
+ if (!WriteRegister(context, ®_info_src, data_src))
+ return false;
return true;
+ }
+
+ return false;
}
-bool
-EmulateInstructionMIPS64::Emulate_LD (llvm::MCInst& insn)
-{
- bool success =false;
- uint32_t src, base;
- int64_t imm, address;
- Context bad_vaddr_context;
-
- src = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- base = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- imm = insn.getOperand(2).getImm();
+bool EmulateInstructionMIPS64::Emulate_LUI(llvm::MCInst &insn) {
+ // LUI rt, immediate
+ // GPR[rt] <- sign_extend(immediate << 16)
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + base, reg_info_base))
- return false;
+ const uint32_t imm32 = insn.getOperand(1).getImm() << 16;
+ int64_t imm = SignedBits(imm32, 31, 0);
+ uint8_t rt;
+ Context context;
- /* read base register */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + base, 0, &success);
- if (!success)
- return false;
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ context.SetImmediateSigned(imm);
+ context.type = eContextImmediate;
- /* destination address */
- address = address + imm;
+ if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips64 + rt,
+ imm))
+ return true;
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips64, address);
+ return false;
+}
+bool EmulateInstructionMIPS64::Emulate_DSUBU_DADDU(llvm::MCInst &insn) {
+ // DSUBU sp, <src>, <rt>
+ // DADDU sp, <src>, <rt>
+ // DADDU dst, sp, <rt>
- if (nonvolatile_reg_p (src))
- {
- RegisterValue data_src;
- RegisterInfo reg_info_src;
+ bool success = false;
+ uint64_t result;
+ uint8_t src, dst, rt;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips64 + src, reg_info_src))
- return false;
+ dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
- Context context;
- context.type = eContextRegisterLoad;
+ /* Check if sp is destination register */
+ if (dst == dwarf_sp_mips64) {
+ rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg());
- if (!WriteRegister (context, ®_info_src, data_src))
- return false;
+ /* read <src> register */
+ uint64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
+ if (!success)
+ return false;
- return true;
- }
+ /* read <rt > register */
+ uint64_t rt_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- return false;
-}
+ if (!strcasecmp(op_name, "DSUBU") || !strcasecmp(op_name, "SUBU"))
+ result = src_opd_val - rt_opd_val;
+ else
+ result = src_opd_val + rt_opd_val;
-bool
-EmulateInstructionMIPS64::Emulate_LUI (llvm::MCInst& insn)
-{
- // LUI rt, immediate
- // GPR[rt] <- sign_extend(immediate << 16)
-
- const uint32_t imm32 = insn.getOperand(1).getImm() << 16;
- int64_t imm = SignedBits(imm32, 31, 0);
- uint8_t rt;
Context context;
-
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- context.SetImmediateSigned (imm);
- context.type = eContextImmediate;
+ RegisterInfo reg_info_sp;
+ if (GetRegisterInfo(eRegisterKindDWARF, dwarf_sp_mips64, reg_info_sp))
+ context.SetRegisterPlusOffset(reg_info_sp, rt_opd_val);
- if (WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips64 + rt, imm))
- return true;
+ /* We are allocating bytes on stack */
+ context.type = eContextAdjustStackPointer;
- return false;
-}
+ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips64, result);
-bool
-EmulateInstructionMIPS64::Emulate_DSUBU_DADDU (llvm::MCInst& insn)
-{
- // DSUBU sp, <src>, <rt>
- // DADDU sp, <src>, <rt>
- // DADDU dst, sp, <rt>
-
- bool success = false;
- uint64_t result;
- uint8_t src, dst, rt;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- dst = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- src = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
-
- /* Check if sp is destination register */
- if (dst == dwarf_sp_mips64)
- {
- rt = m_reg_info->getEncodingValue (insn.getOperand(2).getReg());
-
- /* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
- if (!success)
- return false;
-
- /* read <rt > register */
- uint64_t rt_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
-
- if (!strcasecmp (op_name, "DSUBU") || !strcasecmp (op_name, "SUBU"))
- result = src_opd_val - rt_opd_val;
- else
- result = src_opd_val + rt_opd_val;
-
- Context context;
- RegisterInfo reg_info_sp;
- if (GetRegisterInfo (eRegisterKindDWARF, dwarf_sp_mips64, reg_info_sp))
- context.SetRegisterPlusOffset (reg_info_sp, rt_opd_val);
+ return true;
+ } else if (src == dwarf_sp_mips64) {
+ rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg());
- /* We are allocating bytes on stack */
- context.type = eContextAdjustStackPointer;
+ /* read <src> register */
+ uint64_t src_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
+ if (!success)
+ return false;
- WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_sp_mips64, result);
+ /* read <rt> register */
+ uint64_t rt_opd_val = ReadRegisterUnsigned(
+ eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- return true;
- }
- else if (src == dwarf_sp_mips64)
- {
- rt = m_reg_info->getEncodingValue (insn.getOperand(2).getReg());
-
- /* read <src> register */
- uint64_t src_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
- if (!success)
- return false;
-
- /* read <rt> register */
- uint64_t rt_opd_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
-
- Context context;
-
- if (!strcasecmp (op_name, "DSUBU") || !strcasecmp (op_name, "SUBU"))
- result = src_opd_val - rt_opd_val;
- else
- result = src_opd_val + rt_opd_val;
+ Context context;
- context.SetImmediateSigned (result);
- context.type = eContextImmediate;
+ if (!strcasecmp(op_name, "DSUBU") || !strcasecmp(op_name, "SUBU"))
+ result = src_opd_val - rt_opd_val;
+ else
+ result = src_opd_val + rt_opd_val;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips64 + dst, result))
- return false;
- }
+ context.SetImmediateSigned(result);
+ context.type = eContextImmediate;
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips64 + dst, result))
+ return false;
+ }
+
+ return true;
}
/*
@@ -1039,706 +1313,651 @@ EmulateInstructionMIPS64::Emulate_DSUBU_
BEQ, BNE : Branch on condition
BEQL, BNEL : Branch likely
*/
-bool
-EmulateInstructionMIPS64::Emulate_BXX_3ops (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- int64_t offset, pc, rs_val, rt_val, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- offset = insn.getOperand(2).getImm();
+bool EmulateInstructionMIPS64::Emulate_BXX_3ops(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ int64_t offset, pc, rs_val, rt_val, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BEQ") ||
- !strcasecmp (op_name, "BEQL"))
- {
- if (rs_val == rt_val)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BNE") ||
- !strcasecmp (op_name, "BNEL"))
- {
- if (rs_val != rt_val)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BEQ") || !strcasecmp(op_name, "BEQL")) {
+ if (rs_val == rt_val)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BNE") || !strcasecmp(op_name, "BNEL")) {
+ if (rs_val != rt_val)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS Non-Compact conditional branch and link instructions.
BLTZAL, BGEZAL :
BLTZALL, BGEZALL : Branch likely
*/
-bool
-EmulateInstructionMIPS64::Emulate_Bcond_Link (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int64_t offset, pc, target = 0;
- int64_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS64::Emulate_Bcond_Link(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int64_t offset, pc, target = 0;
+ int64_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZAL") ||
- !strcasecmp (op_name, "BLTZALL"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGEZAL") ||
- !strcasecmp (op_name, "BGEZALL"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BLTZAL") || !strcasecmp(op_name, "BLTZALL")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGEZAL") ||
+ !strcasecmp(op_name, "BGEZALL")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BAL (llvm::MCInst& insn)
-{
- bool success = false;
- int64_t offset, pc, target;
-
- /*
- * BAL offset
- * offset = sign_ext (offset << 2)
- * RA = PC + 8
- * PC = PC + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS64::Emulate_BAL(llvm::MCInst &insn) {
+ bool success = false;
+ int64_t offset, pc, target;
+
+ /*
+ * BAL offset
+ * offset = sign_ext (offset << 2)
+ * RA = PC + 8
+ * PC = PC + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BALC (llvm::MCInst& insn)
-{
- bool success = false;
- int64_t offset, pc, target;
-
- /*
- * BALC offset
- * offset = sign_ext (offset << 2)
- * RA = PC + 4
- * PC = PC + 4 + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS64::Emulate_BALC(llvm::MCInst &insn) {
+ bool success = false;
+ int64_t offset, pc, target;
+
+ /*
+ * BALC offset
+ * offset = sign_ext (offset << 2)
+ * RA = PC + 4
+ * PC = PC + 4 + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 4))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS conditional branch and link instructions.
BLEZALC, BGEZALC, BLTZALC, BGTZALC, BEQZALC, BNEZALC : Compact branches
*/
-bool
-EmulateInstructionMIPS64::Emulate_Bcond_Link_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int64_t offset, pc, rs_val, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS64::Emulate_Bcond_Link_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int64_t offset, pc, rs_val, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLEZALC"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEZALC"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTZALC"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGTZALC"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BEQZALC"))
- {
- if (rs_val == 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEZALC"))
- {
- if (rs_val != 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BLEZALC")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEZALC")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTZALC")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGTZALC")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BEQZALC")) {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEZALC")) {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 4))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS branch instructions.
BLTZL, BGEZL, BGTZL, BLEZL : Branch likely
BLTZ, BGEZ, BGTZ, BLEZ : Non-compact branches
*/
-bool
-EmulateInstructionMIPS64::Emulate_BXX_2ops (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int64_t offset, pc, rs_val, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
+bool EmulateInstructionMIPS64::Emulate_BXX_2ops(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int64_t offset, pc, rs_val, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZL") ||
- !strcasecmp (op_name, "BLTZ"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGEZL") ||
- !strcasecmp (op_name, "BGEZ"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BGTZL") ||
- !strcasecmp (op_name, "BGTZ"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BLEZL") ||
- !strcasecmp (op_name, "BLEZ"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ if (!strcasecmp(op_name, "BLTZL") || !strcasecmp(op_name, "BLTZ")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGEZL") || !strcasecmp(op_name, "BGEZ")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BGTZL") || !strcasecmp(op_name, "BGTZ")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BLEZL") || !strcasecmp(op_name, "BLEZ")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BC (llvm::MCInst& insn)
-{
- bool success = false;
- int64_t offset, pc, target;
-
- /*
- * BC offset
- * offset = sign_ext (offset << 2)
- * PC = PC + 4 + offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS64::Emulate_BC(llvm::MCInst &insn) {
+ bool success = false;
+ int64_t offset, pc, target;
+
+ /*
+ * BC offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC + 4 + offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- target = pc + offset;
+ target = pc + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-static int
-IsAdd64bitOverflow (int64_t a, int64_t b)
-{
- int64_t r = (uint64_t) a + (uint64_t) b;
+static int IsAdd64bitOverflow(int64_t a, int64_t b) {
+ int64_t r = (uint64_t)a + (uint64_t)b;
return (a < 0 && b < 0 && r >= 0) || (a >= 0 && b >= 0 && r < 0);
}
/*
Emulate below MIPS branch instructions.
- BEQC, BNEC, BLTC, BGEC, BLTUC, BGEUC, BOVC, BNVC: Compact branch instructions with no delay slot
+ BEQC, BNEC, BLTC, BGEC, BLTUC, BGEUC, BOVC, BNVC: Compact branch
+ instructions with no delay slot
*/
-bool
-EmulateInstructionMIPS64::Emulate_BXX_3ops_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- int64_t offset, pc, rs_val, rt_val, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
-
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rt = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
- offset = insn.getOperand(2).getImm();
+bool EmulateInstructionMIPS64::Emulate_BXX_3ops_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ int64_t offset, pc, rs_val, rt_val, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
+ offset = insn.getOperand(2).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BEQC"))
- {
- if (rs_val == rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEC"))
- {
- if (rs_val != rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTC"))
- {
- if (rs_val < rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEC"))
- {
- if (rs_val >= rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLTUC"))
- {
- if (rs_val < rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEUC"))
- {
- if ((uint32_t)rs_val >= (uint32_t)rt_val)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BOVC"))
- {
- if (IsAdd64bitOverflow (rs_val, rt_val))
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNVC"))
- {
- if (!IsAdd64bitOverflow (rs_val, rt_val))
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BEQC")) {
+ if (rs_val == rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEC")) {
+ if (rs_val != rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTC")) {
+ if (rs_val < rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEC")) {
+ if (rs_val >= rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLTUC")) {
+ if (rs_val < rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEUC")) {
+ if ((uint32_t)rs_val >= (uint32_t)rt_val)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BOVC")) {
+ if (IsAdd64bitOverflow(rs_val, rt_val))
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNVC")) {
+ if (!IsAdd64bitOverflow(rs_val, rt_val))
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-/*
+/*
Emulate below MIPS branch instructions.
BLTZC, BLEZC, BGEZC, BGTZC, BEQZC, BNEZC : Compact Branches
*/
-bool
-EmulateInstructionMIPS64::Emulate_BXX_2ops_C (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- int64_t offset, pc, target = 0;
- int64_t rs_val;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
- uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
+bool EmulateInstructionMIPS64::Emulate_BXX_2ops_C(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ int64_t offset, pc, target = 0;
+ int64_t rs_val;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+ uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rs, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BLTZC"))
- {
- if (rs_val < 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BLEZC"))
- {
- if (rs_val <= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGEZC"))
- {
- if (rs_val >= 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BGTZC"))
- {
- if (rs_val > 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BEQZC"))
- {
- if (rs_val == 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
- else if (!strcasecmp (op_name, "BNEZC"))
- {
- if (rs_val != 0)
- target = pc + offset;
- else
- target = pc + 4;
- }
+ if (!strcasecmp(op_name, "BLTZC")) {
+ if (rs_val < 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BLEZC")) {
+ if (rs_val <= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGEZC")) {
+ if (rs_val >= 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BGTZC")) {
+ if (rs_val > 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BEQZC")) {
+ if (rs_val == 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ } else if (!strcasecmp(op_name, "BNEZC")) {
+ if (rs_val != 0)
+ target = pc + offset;
+ else
+ target = pc + 4;
+ }
- Context context;
- context.type = eContextRelativeBranchImmediate;
- context.SetImmediate (current_inst_size + offset);
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
+ context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_J (llvm::MCInst& insn)
-{
- bool success = false;
- uint64_t offset, pc;
-
- /*
- * J offset
- * offset = sign_ext (offset << 2)
- * PC = PC[63-28] | offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS64::Emulate_J(llvm::MCInst &insn) {
+ bool success = false;
+ uint64_t offset, pc;
+
+ /*
+ * J offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC[63-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- /* This is a PC-region branch and not PC-relative */
- pc = (pc & 0xFFFFFFFFF0000000ULL) | offset;
+ /* This is a PC-region branch and not PC-relative */
+ pc = (pc & 0xFFFFFFFFF0000000ULL) | offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, pc))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, pc))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_JAL (llvm::MCInst& insn)
-{
- bool success = false;
- uint64_t offset, target, pc;
-
- /*
- * JAL offset
- * offset = sign_ext (offset << 2)
- * PC = PC[63-28] | offset
- */
- offset = insn.getOperand(0).getImm();
+bool EmulateInstructionMIPS64::Emulate_JAL(llvm::MCInst &insn) {
+ bool success = false;
+ uint64_t offset, target, pc;
+
+ /*
+ * JAL offset
+ * offset = sign_ext (offset << 2)
+ * PC = PC[63-28] | offset
+ */
+ offset = insn.getOperand(0).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- /* This is a PC-region branch and not PC-relative */
- target = (pc & 0xFFFFFFFFF0000000ULL) | offset;
+ /* This is a PC-region branch and not PC-relative */
+ target = (pc & 0xFFFFFFFFF0000000ULL) | offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_JALR (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs, rt;
- uint64_t pc, rs_val;
-
- /*
- * JALR rt, rs
- * GPR[rt] = PC + 8
- * PC = GPR[rs]
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- rs = m_reg_info->getEncodingValue (insn.getOperand(1).getReg());
+bool EmulateInstructionMIPS64::Emulate_JALR(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs, rt;
+ uint64_t pc, rs_val;
+
+ /*
+ * JALR rt, rs
+ * GPR[rt] = PC + 8
+ * PC = GPR[rs]
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ rs = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+ rs_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0,
+ &success);
+ if (!success)
+ return false;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, rs_val))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ rs_val))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_zero_mips64 + rt, pc + 8))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, pc + 8))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_JIALC (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rt;
- int64_t target, offset, pc, rt_val;
-
- /*
- * JIALC rt, offset
- * offset = sign_ext (offset)
- * PC = GPR[rt] + offset
- * RA = PC + 4
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+bool EmulateInstructionMIPS64::Emulate_JIALC(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rt;
+ int64_t target, offset, pc, rt_val;
+
+ /*
+ * JIALC rt, offset
+ * offset = sign_ext (offset)
+ * PC = GPR[rt] + offset
+ * RA = PC + 4
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
+ rt_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- target = rt_val + offset;
+ target = rt_val + offset;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_ra_mips64, pc + 4))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_ra_mips64,
+ pc + 4))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_JIC (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rt;
- int64_t target, offset, rt_val;
-
- /*
- * JIC rt, offset
- * offset = sign_ext (offset)
- * PC = GPR[rt] + offset
- */
- rt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+bool EmulateInstructionMIPS64::Emulate_JIC(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rt;
+ int64_t target, offset, rt_val;
+
+ /*
+ * JIC rt, offset
+ * offset = sign_ext (offset)
+ * PC = GPR[rt] + offset
+ */
+ rt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
+
+ rt_val = (int64_t)ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, 0, &success);
+ if (!success)
+ return false;
- rt_val = (int64_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rt, 0, &success);
- if (!success)
- return false;
+ target = rt_val + offset;
- target = rt_val + offset;
+ Context context;
- Context context;
-
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_JR (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t rs;
- uint64_t rs_val;
-
- /*
- * JR rs
- * PC = GPR[rs]
- */
- rs = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
-
- rs_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS64::Emulate_JR(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t rs;
+ uint64_t rs_val;
+
+ /*
+ * JR rs
+ * PC = GPR[rs]
+ */
+ rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+
+ rs_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + rs, 0,
+ &success);
+ if (!success)
+ return false;
- Context context;
+ Context context;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, rs_val))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ rs_val))
+ return false;
- return true;
+ return true;
}
/*
@@ -1746,428 +1965,410 @@ EmulateInstructionMIPS64::Emulate_JR (ll
BC1F, BC1FL : Branch on FP False (L stands for branch likely)
BC1T, BC1TL : Branch on FP True (L stands for branch likely)
*/
-bool
-EmulateInstructionMIPS64::Emulate_FP_branch (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t cc, fcsr;
- int64_t pc, offset, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- /*
- * BC1F cc, offset
- * condition <- (FPConditionCode(cc) == 0)
- * if condition then
- * offset = sign_ext (offset)
- * PC = PC + offset
- */
- cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
+bool EmulateInstructionMIPS64::Emulate_FP_branch(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t cc, fcsr;
+ int64_t pc, offset, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
+
+ /*
+ * BC1F cc, offset
+ * condition <- (FPConditionCode(cc) == 0)
+ * if condition then
+ * offset = sign_ext (offset)
+ * PC = PC + offset
+ */
+ cc = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- fcsr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
- if (!success)
- return false;
+ fcsr =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
+ if (!success)
+ return false;
- /* fcsr[23], fcsr[25-31] are vaild condition bits */
- fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
-
- if (!strcasecmp (op_name, "BC1F") ||
- !strcasecmp (op_name, "BC1FL"))
- {
- if ((fcsr & (1 << cc)) == 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1T") ||
- !strcasecmp (op_name, "BC1TL"))
- {
- if ((fcsr & (1 << cc)) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ /* fcsr[23], fcsr[25-31] are vaild condition bits */
+ fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
- Context context;
+ if (!strcasecmp(op_name, "BC1F") || !strcasecmp(op_name, "BC1FL")) {
+ if ((fcsr & (1 << cc)) == 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1T") || !strcasecmp(op_name, "BC1TL")) {
+ if ((fcsr & (1 << cc)) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ Context context;
- return true;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BC1EQZ (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t ft;
- uint64_t ft_val;
- int64_t target, pc, offset;
-
- /*
- * BC1EQZ ft, offset
- * condition <- (FPR[ft].bit0 == 0)
- * if condition then
- * offset = sign_ext (offset)
- * PC = PC + 4 + offset
- */
- ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS64::Emulate_BC1EQZ(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t ft;
+ uint64_t ft_val;
+ int64_t target, pc, offset;
+
+ /*
+ * BC1EQZ ft, offset
+ * condition <- (FPR[ft].bit0 == 0)
+ * if condition then
+ * offset = sign_ext (offset)
+ * PC = PC + 4 + offset
+ */
+ ft = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- if ((ft_val & 1) == 0)
- target = pc + 4 + offset;
- else
- target = pc + 8;
-
- Context context;
+ ft_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0,
+ &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if ((ft_val & 1) == 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 8;
- return true;
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BC1NEZ (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t ft;
- uint64_t ft_val;
- int64_t target, pc, offset;
-
- /*
- * BC1NEZ ft, offset
- * condition <- (FPR[ft].bit0 != 0)
- * if condition then
- * offset = sign_ext (offset)
- * PC = PC + 4 + offset
- */
- ft = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS64::Emulate_BC1NEZ(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t ft;
+ uint64_t ft_val;
+ int64_t target, pc, offset;
+
+ /*
+ * BC1NEZ ft, offset
+ * condition <- (FPR[ft].bit0 != 0)
+ * if condition then
+ * offset = sign_ext (offset)
+ * PC = PC + 4 + offset
+ */
+ ft = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- ft_val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0, &success);
- if (!success)
- return false;
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- if ((ft_val & 1) != 0)
- target = pc + 4 + offset;
- else
- target = pc + 8;
-
- Context context;
+ ft_val = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips64 + ft, 0,
+ &success);
+ if (!success)
+ return false;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if ((ft_val & 1) != 0)
+ target = pc + 4 + offset;
+ else
+ target = pc + 8;
- return true;
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
+
+ return true;
}
/*
Emulate MIPS-3D Branch instructions
- BC1ANY2F, BC1ANY2T : Branch on Any of Two Floating Point Condition Codes False/True
- BC1ANY4F, BC1ANY4T : Branch on Any of Four Floating Point Condition Codes False/True
+ BC1ANY2F, BC1ANY2T : Branch on Any of Two Floating Point Condition Codes
+ False/True
+ BC1ANY4F, BC1ANY4T : Branch on Any of Four Floating Point Condition Codes
+ False/True
*/
-bool
-EmulateInstructionMIPS64::Emulate_3D_branch (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t cc, fcsr;
- int64_t pc, offset, target = 0;
- const char *op_name = m_insn_info->getName (insn.getOpcode ());
-
- cc = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- offset = insn.getOperand(1).getImm();
-
- pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS64::Emulate_3D_branch(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t cc, fcsr;
+ int64_t pc, offset, target = 0;
+ const char *op_name = m_insn_info->getName(insn.getOpcode());
- fcsr = (uint32_t) ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_fcsr_mips64, 0, &success);
- if (!success)
- return false;
+ cc = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ offset = insn.getOperand(1).getImm();
- /* fcsr[23], fcsr[25-31] are vaild condition bits */
- fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
+ pc = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- if (!strcasecmp (op_name, "BC1ANY2F"))
- {
- /* if any one bit is 0 */
- if (((fcsr >> cc) & 3) != 3)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY2T"))
- {
- /* if any one bit is 1 */
- if (((fcsr >> cc) & 3) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY4F"))
- {
- /* if any one bit is 0 */
- if (((fcsr >> cc) & 0xf) != 0xf)
- target = pc + offset;
- else
- target = pc + 8;
- }
- else if (!strcasecmp (op_name, "BC1ANY4T"))
- {
- /* if any one bit is 1 */
- if (((fcsr >> cc) & 0xf) != 0)
- target = pc + offset;
- else
- target = pc + 8;
- }
+ fcsr = (uint32_t)ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_fcsr_mips64,
+ 0, &success);
+ if (!success)
+ return false;
- Context context;
+ /* fcsr[23], fcsr[25-31] are vaild condition bits */
+ fcsr = ((fcsr >> 24) & 0xfe) | ((fcsr >> 23) & 0x01);
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!strcasecmp(op_name, "BC1ANY2F")) {
+ /* if any one bit is 0 */
+ if (((fcsr >> cc) & 3) != 3)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY2T")) {
+ /* if any one bit is 1 */
+ if (((fcsr >> cc) & 3) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY4F")) {
+ /* if any one bit is 0 */
+ if (((fcsr >> cc) & 0xf) != 0xf)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ } else if (!strcasecmp(op_name, "BC1ANY4T")) {
+ /* if any one bit is 1 */
+ if (((fcsr >> cc) & 0xf) != 0)
+ target = pc + offset;
+ else
+ target = pc + 8;
+ }
- return true;
+ Context context;
+
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
+
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BNZB (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 1, true);
+bool EmulateInstructionMIPS64::Emulate_BNZB(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 1, true);
}
-bool
-EmulateInstructionMIPS64::Emulate_BNZH (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 2, true);
+bool EmulateInstructionMIPS64::Emulate_BNZH(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 2, true);
}
-bool
-EmulateInstructionMIPS64::Emulate_BNZW (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 4, true);
+bool EmulateInstructionMIPS64::Emulate_BNZW(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 4, true);
}
-bool
-EmulateInstructionMIPS64::Emulate_BNZD (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 8, true);
+bool EmulateInstructionMIPS64::Emulate_BNZD(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 8, true);
}
-bool
-EmulateInstructionMIPS64::Emulate_BZB (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 1, false);
+bool EmulateInstructionMIPS64::Emulate_BZB(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 1, false);
}
-bool
-EmulateInstructionMIPS64::Emulate_BZH (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 2, false);
+bool EmulateInstructionMIPS64::Emulate_BZH(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 2, false);
}
-bool
-EmulateInstructionMIPS64::Emulate_BZW (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 4, false);
+bool EmulateInstructionMIPS64::Emulate_BZW(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 4, false);
}
-bool
-EmulateInstructionMIPS64::Emulate_BZD (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_DF(insn, 8, false);
+bool EmulateInstructionMIPS64::Emulate_BZD(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_DF(insn, 8, false);
}
-bool
-EmulateInstructionMIPS64::Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz)
-{
- bool success = false, branch_hit = true;
- int64_t target = 0;
- RegisterValue reg_value;
- const uint8_t *ptr = NULL;
+bool EmulateInstructionMIPS64::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
+ int element_byte_size,
+ bool bnz) {
+ bool success = false, branch_hit = true;
+ int64_t target = 0;
+ RegisterValue reg_value;
+ const uint8_t *ptr = NULL;
- uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- int64_t offset = insn.getOperand(1).getImm();
+ uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ int64_t offset = insn.getOperand(1).getImm();
- int64_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+ int64_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
- ptr = (const uint8_t *)reg_value.GetBytes();
- else
- return false;
+ if (ReadRegister(eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
+ ptr = (const uint8_t *)reg_value.GetBytes();
+ else
+ return false;
- for(int i = 0; i < 16 / element_byte_size; i++)
- {
- switch(element_byte_size)
- {
- case 1:
- if((*ptr == 0 && bnz) || (*ptr != 0 && !bnz) )
- branch_hit = false;
- break;
- case 2:
- if ((*(const uint16_t *)ptr == 0 && bnz) || (*(const uint16_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- case 4:
- if ((*(const uint32_t *)ptr == 0 && bnz) || (*(const uint32_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- case 8:
- if ((*(const uint64_t *)ptr == 0 && bnz) || (*(const uint64_t *)ptr != 0 && !bnz))
- branch_hit = false;
- break;
- }
- if(!branch_hit)
- break;
- ptr = ptr + element_byte_size;
- }
+ for (int i = 0; i < 16 / element_byte_size; i++) {
+ switch (element_byte_size) {
+ case 1:
+ if ((*ptr == 0 && bnz) || (*ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 2:
+ if ((*(const uint16_t *)ptr == 0 && bnz) ||
+ (*(const uint16_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 4:
+ if ((*(const uint32_t *)ptr == 0 && bnz) ||
+ (*(const uint32_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ case 8:
+ if ((*(const uint64_t *)ptr == 0 && bnz) ||
+ (*(const uint64_t *)ptr != 0 && !bnz))
+ branch_hit = false;
+ break;
+ }
+ if (!branch_hit)
+ break;
+ ptr = ptr + element_byte_size;
+ }
- if(branch_hit)
- target = pc + offset;
- else
- target = pc + 8;
+ if (branch_hit)
+ target = pc + offset;
+ else
+ target = pc + 8;
- Context context;
- context.type = eContextRelativeBranchImmediate;
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- return true;
+ return true;
}
-bool
-EmulateInstructionMIPS64::Emulate_BNZV (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_V (insn, true);
-}
-
-bool
-EmulateInstructionMIPS64::Emulate_BZV (llvm::MCInst& insn)
-{
- return Emulate_MSA_Branch_V (insn, false);
-}
-
-bool
-EmulateInstructionMIPS64::Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz)
-{
- bool success = false;
- int64_t target = 0;
- llvm::APInt wr_val = llvm::APInt::getNullValue(128);
- llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
- llvm::APInt zero_value = llvm::APInt::getNullValue(128);
- RegisterValue reg_value;
-
- uint32_t wt = m_reg_info->getEncodingValue (insn.getOperand(0).getReg());
- int64_t offset = insn.getOperand(1).getImm();
-
- int64_t pc = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
- if (!success)
- return false;
+bool EmulateInstructionMIPS64::Emulate_BNZV(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_V(insn, true);
+}
- if (ReadRegister (eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
- wr_val = reg_value.GetAsUInt128(fail_value);
- else
- return false;
+bool EmulateInstructionMIPS64::Emulate_BZV(llvm::MCInst &insn) {
+ return Emulate_MSA_Branch_V(insn, false);
+}
- if((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) || (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
- target = pc + offset;
- else
- target = pc + 8;
+bool EmulateInstructionMIPS64::Emulate_MSA_Branch_V(llvm::MCInst &insn,
+ bool bnz) {
+ bool success = false;
+ int64_t target = 0;
+ llvm::APInt wr_val = llvm::APInt::getNullValue(128);
+ llvm::APInt fail_value = llvm::APInt::getMaxValue(128);
+ llvm::APInt zero_value = llvm::APInt::getNullValue(128);
+ RegisterValue reg_value;
- Context context;
- context.type = eContextRelativeBranchImmediate;
+ uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
+ int64_t offset = insn.getOperand(1).getImm();
- if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips64, target))
- return false;
+ int64_t pc =
+ ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_pc_mips64, 0, &success);
+ if (!success)
+ return false;
- return true;
-}
+ if (ReadRegister(eRegisterKindDWARF, dwarf_w0_mips64 + wt, reg_value))
+ wr_val = reg_value.GetAsUInt128(fail_value);
+ else
+ return false;
-bool
-EmulateInstructionMIPS64::Emulate_LDST_Imm (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base;
- int64_t imm, address;
- Context bad_vaddr_context;
-
- uint32_t num_operands = insn.getNumOperands();
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
- imm = insn.getOperand(num_operands-1).getImm();
+ if ((llvm::APInt::isSameValue(zero_value, wr_val) && !bnz) ||
+ (!llvm::APInt::isSameValue(zero_value, wr_val) && bnz))
+ target = pc + offset;
+ else
+ target = pc + 8;
- RegisterInfo reg_info_base;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ Context context;
+ context.type = eContextRelativeBranchImmediate;
- /* read base register */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target))
+ return false;
- /* destination address */
- address = address + imm;
+ return true;
+}
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+bool EmulateInstructionMIPS64::Emulate_LDST_Imm(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t base;
+ int64_t imm, address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+ imm = insn.getOperand(num_operands - 1).getImm();
+
+ RegisterInfo reg_info_base;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- return true;
-}
+ /* read base register */
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + base, 0,
+ &success);
+ if (!success)
+ return false;
-bool
-EmulateInstructionMIPS64::Emulate_LDST_Reg (llvm::MCInst& insn)
-{
- bool success = false;
- uint32_t base, index;
- int64_t address, index_address;
- Context bad_vaddr_context;
-
- uint32_t num_operands = insn.getNumOperands();
- base = m_reg_info->getEncodingValue (insn.getOperand(num_operands-2).getReg());
- index = m_reg_info->getEncodingValue (insn.getOperand(num_operands-1).getReg());
+ /* destination address */
+ address = address + imm;
- RegisterInfo reg_info_base, reg_info_index;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + base, reg_info_base))
- return false;
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
+
+ return true;
+}
+
+bool EmulateInstructionMIPS64::Emulate_LDST_Reg(llvm::MCInst &insn) {
+ bool success = false;
+ uint32_t base, index;
+ int64_t address, index_address;
+ Context bad_vaddr_context;
+
+ uint32_t num_operands = insn.getNumOperands();
+ base =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 2).getReg());
+ index =
+ m_reg_info->getEncodingValue(insn.getOperand(num_operands - 1).getReg());
+
+ RegisterInfo reg_info_base, reg_info_index;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + base,
+ reg_info_base))
+ return false;
- if (!GetRegisterInfo (eRegisterKindDWARF, dwarf_zero_mips + index, reg_info_index))
- return false;
+ if (!GetRegisterInfo(eRegisterKindDWARF, dwarf_zero_mips + index,
+ reg_info_index))
+ return false;
- /* read base register */
- address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + base, 0, &success);
- if (!success)
- return false;
+ /* read base register */
+ address = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_zero_mips + base, 0,
+ &success);
+ if (!success)
+ return false;
- /* read index register */
- index_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_zero_mips + index, 0, &success);
- if (!success)
- return false;
+ /* read index register */
+ index_address = ReadRegisterUnsigned(eRegisterKindDWARF,
+ dwarf_zero_mips + index, 0, &success);
+ if (!success)
+ return false;
- /* destination address */
- address = address + index_address;
+ /* destination address */
+ address = address + index_address;
- /* Set the bad_vaddr register with base address used in the instruction */
- bad_vaddr_context.type = eContextInvalid;
- WriteRegisterUnsigned (bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips, address);
+ /* Set the bad_vaddr register with base address used in the instruction */
+ bad_vaddr_context.type = eContextInvalid;
+ WriteRegisterUnsigned(bad_vaddr_context, eRegisterKindDWARF, dwarf_bad_mips,
+ address);
- return true;
+ return true;
}
Modified: lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h (original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h Tue Sep 6 15:57:50 2016
@@ -18,232 +18,170 @@
#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
-namespace llvm
-{
- class MCDisassembler;
- class MCSubtargetInfo;
- class MCRegisterInfo;
- class MCAsmInfo;
- class MCContext;
- class MCInstrInfo;
- class MCInst;
+namespace llvm {
+class MCDisassembler;
+class MCSubtargetInfo;
+class MCRegisterInfo;
+class MCAsmInfo;
+class MCContext;
+class MCInstrInfo;
+class MCInst;
} // namespace llvm
-class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction
-{
-public:
- EmulateInstructionMIPS64(const lldb_private::ArchSpec &arch);
-
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- static lldb_private::ConstString
- GetPluginNameStatic ();
-
- static const char *
- GetPluginDescriptionStatic ();
-
- static lldb_private::EmulateInstruction *
- CreateInstance (const lldb_private::ArchSpec &arch,
- lldb_private::InstructionType inst_type);
-
- static bool
- SupportsEmulatingInstructionsOfTypeStatic (lldb_private::InstructionType inst_type)
- {
- switch (inst_type)
- {
- case lldb_private::eInstructionTypeAny:
- case lldb_private::eInstructionTypePrologueEpilogue:
- case lldb_private::eInstructionTypePCModifying:
- return true;
-
- case lldb_private::eInstructionTypeAll:
- return false;
- }
- return false;
- }
+class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction {
+public:
+ EmulateInstructionMIPS64(const lldb_private::ArchSpec &arch);
- lldb_private::ConstString
- GetPluginName() override;
+ static void Initialize();
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
+ static void Terminate();
- bool
- SetTargetTriple(const lldb_private::ArchSpec &arch) override;
-
- bool
- SupportsEmulatingInstructionsOfType(lldb_private::InstructionType inst_type) override
- {
- return SupportsEmulatingInstructionsOfTypeStatic (inst_type);
- }
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetPluginDescriptionStatic();
- bool
- ReadInstruction() override;
-
- bool
- EvaluateInstruction(uint32_t evaluate_options) override;
-
- bool
- TestEmulation(lldb_private::Stream *out_stream,
- lldb_private::ArchSpec &arch,
- lldb_private::OptionValueDictionary *test_data) override
- {
- return false;
+ static lldb_private::EmulateInstruction *
+ CreateInstance(const lldb_private::ArchSpec &arch,
+ lldb_private::InstructionType inst_type);
+
+ static bool SupportsEmulatingInstructionsOfTypeStatic(
+ lldb_private::InstructionType inst_type) {
+ switch (inst_type) {
+ case lldb_private::eInstructionTypeAny:
+ case lldb_private::eInstructionTypePrologueEpilogue:
+ case lldb_private::eInstructionTypePCModifying:
+ return true;
+
+ case lldb_private::eInstructionTypeAll:
+ return false;
}
+ return false;
+ }
+
+ lldb_private::ConstString GetPluginName() override;
- bool
- GetRegisterInfo(lldb::RegisterKind reg_kind,
- uint32_t reg_num,
- lldb_private::RegisterInfo ®_info) override;
+ uint32_t GetPluginVersion() override { return 1; }
- bool
- CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
+ bool SetTargetTriple(const lldb_private::ArchSpec &arch) override;
+
+ bool SupportsEmulatingInstructionsOfType(
+ lldb_private::InstructionType inst_type) override {
+ return SupportsEmulatingInstructionsOfTypeStatic(inst_type);
+ }
+
+ bool ReadInstruction() override;
+
+ bool EvaluateInstruction(uint32_t evaluate_options) override;
+
+ bool TestEmulation(lldb_private::Stream *out_stream,
+ lldb_private::ArchSpec &arch,
+ lldb_private::OptionValueDictionary *test_data) override {
+ return false;
+ }
+
+ bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
+ lldb_private::RegisterInfo ®_info) override;
+
+ bool
+ CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
protected:
- typedef struct
- {
- const char *op_name;
- bool (EmulateInstructionMIPS64::*callback) (llvm::MCInst& insn);
- const char *insn_name;
- } MipsOpcode;
-
- static MipsOpcode*
- GetOpcodeForInstruction (const char *op_name);
+ typedef struct {
+ const char *op_name;
+ bool (EmulateInstructionMIPS64::*callback)(llvm::MCInst &insn);
+ const char *insn_name;
+ } MipsOpcode;
+
+ static MipsOpcode *GetOpcodeForInstruction(const char *op_name);
- bool
- Emulate_DADDiu (llvm::MCInst& insn);
+ bool Emulate_DADDiu(llvm::MCInst &insn);
- bool
- Emulate_DSUBU_DADDU (llvm::MCInst& insn);
+ bool Emulate_DSUBU_DADDU(llvm::MCInst &insn);
- bool
- Emulate_LUI (llvm::MCInst& insn);
+ bool Emulate_LUI(llvm::MCInst &insn);
- bool
- Emulate_SD (llvm::MCInst& insn);
+ bool Emulate_SD(llvm::MCInst &insn);
- bool
- Emulate_LD (llvm::MCInst& insn);
+ bool Emulate_LD(llvm::MCInst &insn);
- bool
- Emulate_LDST_Imm (llvm::MCInst& insn);
+ bool Emulate_LDST_Imm(llvm::MCInst &insn);
- bool
- Emulate_LDST_Reg (llvm::MCInst& insn);
+ bool Emulate_LDST_Reg(llvm::MCInst &insn);
- bool
- Emulate_BXX_3ops (llvm::MCInst& insn);
+ bool Emulate_BXX_3ops(llvm::MCInst &insn);
- bool
- Emulate_BXX_3ops_C (llvm::MCInst& insn);
+ bool Emulate_BXX_3ops_C(llvm::MCInst &insn);
- bool
- Emulate_BXX_2ops (llvm::MCInst& insn);
+ bool Emulate_BXX_2ops(llvm::MCInst &insn);
- bool
- Emulate_BXX_2ops_C (llvm::MCInst& insn);
+ bool Emulate_BXX_2ops_C(llvm::MCInst &insn);
- bool
- Emulate_Bcond_Link_C (llvm::MCInst& insn);
+ bool Emulate_Bcond_Link_C(llvm::MCInst &insn);
- bool
- Emulate_Bcond_Link (llvm::MCInst& insn);
+ bool Emulate_Bcond_Link(llvm::MCInst &insn);
- bool
- Emulate_FP_branch (llvm::MCInst& insn);
+ bool Emulate_FP_branch(llvm::MCInst &insn);
- bool
- Emulate_3D_branch (llvm::MCInst& insn);
+ bool Emulate_3D_branch(llvm::MCInst &insn);
- bool
- Emulate_BAL (llvm::MCInst& insn);
+ bool Emulate_BAL(llvm::MCInst &insn);
- bool
- Emulate_BALC (llvm::MCInst& insn);
+ bool Emulate_BALC(llvm::MCInst &insn);
- bool
- Emulate_BC (llvm::MCInst& insn);
+ bool Emulate_BC(llvm::MCInst &insn);
- bool
- Emulate_J (llvm::MCInst& insn);
+ bool Emulate_J(llvm::MCInst &insn);
- bool
- Emulate_JAL (llvm::MCInst& insn);
+ bool Emulate_JAL(llvm::MCInst &insn);
- bool
- Emulate_JALR (llvm::MCInst& insn);
+ bool Emulate_JALR(llvm::MCInst &insn);
- bool
- Emulate_JIALC (llvm::MCInst& insn);
+ bool Emulate_JIALC(llvm::MCInst &insn);
- bool
- Emulate_JIC (llvm::MCInst& insn);
+ bool Emulate_JIC(llvm::MCInst &insn);
- bool
- Emulate_JR (llvm::MCInst& insn);
+ bool Emulate_JR(llvm::MCInst &insn);
- bool
- Emulate_BC1EQZ (llvm::MCInst& insn);
+ bool Emulate_BC1EQZ(llvm::MCInst &insn);
- bool
- Emulate_BC1NEZ (llvm::MCInst& insn);
+ bool Emulate_BC1NEZ(llvm::MCInst &insn);
- bool
- Emulate_BNZB (llvm::MCInst& insn);
+ bool Emulate_BNZB(llvm::MCInst &insn);
- bool
- Emulate_BNZH (llvm::MCInst& insn);
+ bool Emulate_BNZH(llvm::MCInst &insn);
- bool
- Emulate_BNZW (llvm::MCInst& insn);
+ bool Emulate_BNZW(llvm::MCInst &insn);
- bool
- Emulate_BNZD (llvm::MCInst& insn);
+ bool Emulate_BNZD(llvm::MCInst &insn);
- bool
- Emulate_BZB (llvm::MCInst& insn);
+ bool Emulate_BZB(llvm::MCInst &insn);
- bool
- Emulate_BZH (llvm::MCInst& insn);
+ bool Emulate_BZH(llvm::MCInst &insn);
- bool
- Emulate_BZW (llvm::MCInst& insn);
+ bool Emulate_BZW(llvm::MCInst &insn);
- bool
- Emulate_BZD (llvm::MCInst& insn);
+ bool Emulate_BZD(llvm::MCInst &insn);
- bool
- Emulate_MSA_Branch_DF (llvm::MCInst& insn, int element_byte_size, bool bnz);
+ bool Emulate_MSA_Branch_DF(llvm::MCInst &insn, int element_byte_size,
+ bool bnz);
- bool
- Emulate_BNZV (llvm::MCInst& insn);
+ bool Emulate_BNZV(llvm::MCInst &insn);
- bool
- Emulate_BZV (llvm::MCInst& insn);
+ bool Emulate_BZV(llvm::MCInst &insn);
- bool
- Emulate_MSA_Branch_V (llvm::MCInst& insn, bool bnz);
+ bool Emulate_MSA_Branch_V(llvm::MCInst &insn, bool bnz);
- bool
- nonvolatile_reg_p (uint64_t regnum);
+ bool nonvolatile_reg_p(uint64_t regnum);
- const char *
- GetRegisterName (unsigned reg_num, bool altnernate_name);
+ const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
private:
- std::unique_ptr<llvm::MCDisassembler> m_disasm;
- std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
- std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
- std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
- std::unique_ptr<llvm::MCContext> m_context;
- std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
+ std::unique_ptr<llvm::MCDisassembler> m_disasm;
+ std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info;
+ std::unique_ptr<llvm::MCRegisterInfo> m_reg_info;
+ std::unique_ptr<llvm::MCAsmInfo> m_asm_info;
+ std::unique_ptr<llvm::MCContext> m_context;
+ std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
};
#endif // EmulateInstructionMIPS64_h_
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp Tue Sep 6 15:57:50 2016
@@ -12,9 +12,9 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
@@ -30,63 +30,47 @@ using namespace lldb;
using namespace lldb_private;
lldb::InstrumentationRuntimeSP
-AddressSanitizerRuntime::CreateInstance (const lldb::ProcessSP &process_sp)
-{
- return InstrumentationRuntimeSP(new AddressSanitizerRuntime(process_sp));
+AddressSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(new AddressSanitizerRuntime(process_sp));
}
-void
-AddressSanitizerRuntime::Initialize()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- "AddressSanitizer instrumentation runtime plugin.",
- CreateInstance,
- GetTypeStatic);
+void AddressSanitizerRuntime::Initialize() {
+ PluginManager::RegisterPlugin(
+ GetPluginNameStatic(), "AddressSanitizer instrumentation runtime plugin.",
+ CreateInstance, GetTypeStatic);
}
-void
-AddressSanitizerRuntime::Terminate()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
+void AddressSanitizerRuntime::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString
-AddressSanitizerRuntime::GetPluginNameStatic()
-{
- return ConstString("AddressSanitizer");
+lldb_private::ConstString AddressSanitizerRuntime::GetPluginNameStatic() {
+ return ConstString("AddressSanitizer");
}
-lldb::InstrumentationRuntimeType
-AddressSanitizerRuntime::GetTypeStatic()
-{
- return eInstrumentationRuntimeTypeAddressSanitizer;
+lldb::InstrumentationRuntimeType AddressSanitizerRuntime::GetTypeStatic() {
+ return eInstrumentationRuntimeTypeAddressSanitizer;
}
-AddressSanitizerRuntime::~AddressSanitizerRuntime()
-{
- Deactivate();
-}
+AddressSanitizerRuntime::~AddressSanitizerRuntime() { Deactivate(); }
const RegularExpression &
-AddressSanitizerRuntime::GetPatternForRuntimeLibrary()
-{
- // FIXME: This shouldn't include the "dylib" suffix.
- static RegularExpression regex("libclang_rt.asan_(.*)_dynamic\\.dylib");
- return regex;
+AddressSanitizerRuntime::GetPatternForRuntimeLibrary() {
+ // FIXME: This shouldn't include the "dylib" suffix.
+ static RegularExpression regex("libclang_rt.asan_(.*)_dynamic\\.dylib");
+ return regex;
}
-bool
-AddressSanitizerRuntime::CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp)
-{
- const Symbol *symbol =
- module_sp->FindFirstSymbolWithNameAndType(ConstString("__asan_get_alloc_stack"), lldb::eSymbolTypeAny);
+bool AddressSanitizerRuntime::CheckIfRuntimeIsValid(
+ const lldb::ModuleSP module_sp) {
+ const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
+ ConstString("__asan_get_alloc_stack"), lldb::eSymbolTypeAny);
- return symbol != nullptr;
+ return symbol != nullptr;
}
-#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2*1000*1000
-const char *
-address_sanitizer_retrieve_report_data_prefix = R"(
+#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
+const char *address_sanitizer_retrieve_report_data_prefix = R"(
extern "C"
{
int __asan_report_present();
@@ -100,8 +84,7 @@ size_t __asan_get_report_access_size();
}
)";
-const char *
-address_sanitizer_retrieve_report_data_command = R"(
+const char *address_sanitizer_retrieve_report_data_command = R"(
struct {
int present;
int access_type;
@@ -124,194 +107,208 @@ t.description = __asan_get_report_descri
t
)";
-StructuredData::ObjectSP
-AddressSanitizerRuntime::RetrieveReportData()
-{
- ProcessSP process_sp = GetProcessSP();
- if (!process_sp)
- return StructuredData::ObjectSP();
-
- ThreadSP thread_sp = process_sp->GetThreadList().GetExpressionExecutionThread();
- StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
-
- if (!frame_sp)
- return StructuredData::ObjectSP();
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetTryAllThreads(true);
- options.SetStopOthers(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
- options.SetPrefix(address_sanitizer_retrieve_report_data_prefix);
- options.SetAutoApplyFixIts(false);
- options.SetLanguage(eLanguageTypeObjC_plus_plus);
-
- ValueObjectSP return_value_sp;
- ExecutionContext exe_ctx;
- Error eval_error;
- frame_sp->CalculateExecutionContext(exe_ctx);
- ExpressionResults result = UserExpression::Evaluate (exe_ctx,
- options,
- address_sanitizer_retrieve_report_data_command,
- "",
- return_value_sp,
- eval_error);
- if (result != eExpressionCompleted) {
- process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf("Warning: Cannot evaluate AddressSanitizer expression:\n%s\n", eval_error.AsCString());
- return StructuredData::ObjectSP();
- }
-
- int present = return_value_sp->GetValueForExpressionPath(".present")->GetValueAsUnsigned(0);
- if (present != 1)
- return StructuredData::ObjectSP();
-
- addr_t pc = return_value_sp->GetValueForExpressionPath(".pc")->GetValueAsUnsigned(0);
- /* commented out because rdar://problem/18533301
- addr_t bp = return_value_sp->GetValueForExpressionPath(".bp")->GetValueAsUnsigned(0);
- addr_t sp = return_value_sp->GetValueForExpressionPath(".sp")->GetValueAsUnsigned(0);
- */
- addr_t address = return_value_sp->GetValueForExpressionPath(".address")->GetValueAsUnsigned(0);
- addr_t access_type = return_value_sp->GetValueForExpressionPath(".access_type")->GetValueAsUnsigned(0);
- addr_t access_size = return_value_sp->GetValueForExpressionPath(".access_size")->GetValueAsUnsigned(0);
- addr_t description_ptr = return_value_sp->GetValueForExpressionPath(".description")->GetValueAsUnsigned(0);
- std::string description;
- Error error;
- process_sp->ReadCStringFromMemory(description_ptr, description, error);
-
- StructuredData::Dictionary *dict = new StructuredData::Dictionary();
- dict->AddStringItem("instrumentation_class", "AddressSanitizer");
- dict->AddStringItem("stop_type", "fatal_error");
- dict->AddIntegerItem("pc", pc);
- /* commented out because rdar://problem/18533301
- dict->AddIntegerItem("bp", bp);
- dict->AddIntegerItem("sp", sp);
- */
- dict->AddIntegerItem("address", address);
- dict->AddIntegerItem("access_type", access_type);
- dict->AddIntegerItem("access_size", access_size);
- dict->AddStringItem("description", description);
+StructuredData::ObjectSP AddressSanitizerRuntime::RetrieveReportData() {
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return StructuredData::ObjectSP();
+
+ ThreadSP thread_sp =
+ process_sp->GetThreadList().GetExpressionExecutionThread();
+ StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+
+ if (!frame_sp)
+ return StructuredData::ObjectSP();
+
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetTryAllThreads(true);
+ options.SetStopOthers(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
+ options.SetPrefix(address_sanitizer_retrieve_report_data_prefix);
+ options.SetAutoApplyFixIts(false);
+ options.SetLanguage(eLanguageTypeObjC_plus_plus);
+
+ ValueObjectSP return_value_sp;
+ ExecutionContext exe_ctx;
+ Error eval_error;
+ frame_sp->CalculateExecutionContext(exe_ctx);
+ ExpressionResults result = UserExpression::Evaluate(
+ exe_ctx, options, address_sanitizer_retrieve_report_data_command, "",
+ return_value_sp, eval_error);
+ if (result != eExpressionCompleted) {
+ process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf(
+ "Warning: Cannot evaluate AddressSanitizer expression:\n%s\n",
+ eval_error.AsCString());
+ return StructuredData::ObjectSP();
+ }
+
+ int present = return_value_sp->GetValueForExpressionPath(".present")
+ ->GetValueAsUnsigned(0);
+ if (present != 1)
+ return StructuredData::ObjectSP();
+
+ addr_t pc =
+ return_value_sp->GetValueForExpressionPath(".pc")->GetValueAsUnsigned(0);
+ /* commented out because rdar://problem/18533301
+ addr_t bp =
+ return_value_sp->GetValueForExpressionPath(".bp")->GetValueAsUnsigned(0);
+ addr_t sp =
+ return_value_sp->GetValueForExpressionPath(".sp")->GetValueAsUnsigned(0);
+ */
+ addr_t address = return_value_sp->GetValueForExpressionPath(".address")
+ ->GetValueAsUnsigned(0);
+ addr_t access_type =
+ return_value_sp->GetValueForExpressionPath(".access_type")
+ ->GetValueAsUnsigned(0);
+ addr_t access_size =
+ return_value_sp->GetValueForExpressionPath(".access_size")
+ ->GetValueAsUnsigned(0);
+ addr_t description_ptr =
+ return_value_sp->GetValueForExpressionPath(".description")
+ ->GetValueAsUnsigned(0);
+ std::string description;
+ Error error;
+ process_sp->ReadCStringFromMemory(description_ptr, description, error);
+
+ StructuredData::Dictionary *dict = new StructuredData::Dictionary();
+ dict->AddStringItem("instrumentation_class", "AddressSanitizer");
+ dict->AddStringItem("stop_type", "fatal_error");
+ dict->AddIntegerItem("pc", pc);
+ /* commented out because rdar://problem/18533301
+ dict->AddIntegerItem("bp", bp);
+ dict->AddIntegerItem("sp", sp);
+ */
+ dict->AddIntegerItem("address", address);
+ dict->AddIntegerItem("access_type", access_type);
+ dict->AddIntegerItem("access_size", access_size);
+ dict->AddStringItem("description", description);
- return StructuredData::ObjectSP(dict);
+ return StructuredData::ObjectSP(dict);
}
std::string
-AddressSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report)
-{
- std::string description = report->GetAsDictionary()->GetValueForKey("description")->GetAsString()->GetValue();
- if (description == "heap-use-after-free") {
- return "Use of deallocated memory detected";
- } else if (description == "heap-buffer-overflow") {
- return "Heap buffer overflow detected";
- } else if (description == "stack-buffer-underflow") {
- return "Stack buffer underflow detected";
- } else if (description == "initialization-order-fiasco") {
- return "Initialization order problem detected";
- } else if (description == "stack-buffer-overflow") {
- return "Stack buffer overflow detected";
- } else if (description == "stack-use-after-return") {
- return "Use of returned stack memory detected";
- } else if (description == "use-after-poison") {
- return "Use of poisoned memory detected";
- } else if (description == "container-overflow") {
- return "Container overflow detected";
- } else if (description == "stack-use-after-scope") {
- return "Use of out-of-scope stack memory detected";
- } else if (description == "global-buffer-overflow") {
- return "Global buffer overflow detected";
- } else if (description == "unknown-crash") {
- return "Invalid memory access detected";
+AddressSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
+ std::string description = report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue();
+ if (description == "heap-use-after-free") {
+ return "Use of deallocated memory detected";
+ } else if (description == "heap-buffer-overflow") {
+ return "Heap buffer overflow detected";
+ } else if (description == "stack-buffer-underflow") {
+ return "Stack buffer underflow detected";
+ } else if (description == "initialization-order-fiasco") {
+ return "Initialization order problem detected";
+ } else if (description == "stack-buffer-overflow") {
+ return "Stack buffer overflow detected";
+ } else if (description == "stack-use-after-return") {
+ return "Use of returned stack memory detected";
+ } else if (description == "use-after-poison") {
+ return "Use of poisoned memory detected";
+ } else if (description == "container-overflow") {
+ return "Container overflow detected";
+ } else if (description == "stack-use-after-scope") {
+ return "Use of out-of-scope stack memory detected";
+ } else if (description == "global-buffer-overflow") {
+ return "Global buffer overflow detected";
+ } else if (description == "unknown-crash") {
+ return "Invalid memory access detected";
+ }
+
+ // for unknown report codes just show the code
+ return description;
+}
+
+bool AddressSanitizerRuntime::NotifyBreakpointHit(
+ void *baton, StoppointCallbackContext *context, user_id_t break_id,
+ user_id_t break_loc_id) {
+ assert(baton && "null baton");
+ if (!baton)
+ return false;
+
+ AddressSanitizerRuntime *const instance =
+ static_cast<AddressSanitizerRuntime *>(baton);
+
+ StructuredData::ObjectSP report = instance->RetrieveReportData();
+ std::string description;
+ if (report) {
+ description = instance->FormatDescription(report);
+ }
+ ProcessSP process_sp = instance->GetProcessSP();
+ // Make sure this is the right process
+ if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP()) {
+ ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
+ if (thread_sp)
+ thread_sp->SetStopInfo(InstrumentationRuntimeStopInfo::
+ CreateStopReasonWithInstrumentationData(
+ *thread_sp, description.c_str(), report));
+
+ StreamFileSP stream_sp(
+ process_sp->GetTarget().GetDebugger().GetOutputFile());
+ if (stream_sp) {
+ stream_sp->Printf("AddressSanitizer report breakpoint hit. Use 'thread "
+ "info -s' to get extended information about the "
+ "report.\n");
}
-
- // for unknown report codes just show the code
- return description;
-}
+ return true; // Return true to stop the target
+ } else
+ return false; // Let target run
+}
+
+void AddressSanitizerRuntime::Activate() {
+ if (IsActive())
+ return;
+
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return;
+
+ ConstString symbol_name("__asan::AsanDie()");
+ const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType(
+ symbol_name, eSymbolTypeCode);
+
+ if (symbol == NULL)
+ return;
+
+ if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
+ return;
+
+ Target &target = process_sp->GetTarget();
+ addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
+
+ if (symbol_address == LLDB_INVALID_ADDRESS)
+ return;
+
+ bool internal = true;
+ bool hardware = false;
+ Breakpoint *breakpoint =
+ process_sp->GetTarget()
+ .CreateBreakpoint(symbol_address, internal, hardware)
+ .get();
+ breakpoint->SetCallback(AddressSanitizerRuntime::NotifyBreakpointHit, this,
+ true);
+ breakpoint->SetBreakpointKind("address-sanitizer-report");
+ SetBreakpointID(breakpoint->GetID());
+
+ StreamFileSP stream_sp(process_sp->GetTarget().GetDebugger().GetOutputFile());
+ if (stream_sp) {
+ stream_sp->Printf("AddressSanitizer debugger support is active. Memory "
+ "error breakpoint has been installed and you can now use "
+ "the 'memory history' command.\n");
+ }
-bool
-AddressSanitizerRuntime::NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, user_id_t break_id, user_id_t break_loc_id)
-{
- assert (baton && "null baton");
- if (!baton)
- return false;
-
- AddressSanitizerRuntime *const instance = static_cast<AddressSanitizerRuntime*>(baton);
-
- StructuredData::ObjectSP report = instance->RetrieveReportData();
- std::string description;
- if (report) {
- description = instance->FormatDescription(report);
- }
- ProcessSP process_sp = instance->GetProcessSP();
- // Make sure this is the right process
- if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP())
- {
- ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
- if (thread_sp)
- thread_sp->SetStopInfo(InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(*thread_sp, description.c_str(), report));
-
- StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
- if (stream_sp)
- {
- stream_sp->Printf ("AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.\n");
- }
- return true; // Return true to stop the target
- }
- else
- return false; // Let target run
+ SetActive(true);
}
-void
-AddressSanitizerRuntime::Activate()
-{
- if (IsActive())
- return;
-
+void AddressSanitizerRuntime::Deactivate() {
+ if (GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
ProcessSP process_sp = GetProcessSP();
- if (!process_sp)
- return;
-
- ConstString symbol_name ("__asan::AsanDie()");
- const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType (symbol_name, eSymbolTypeCode);
-
- if (symbol == NULL)
- return;
-
- if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
- return;
-
- Target &target = process_sp->GetTarget();
- addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
-
- if (symbol_address == LLDB_INVALID_ADDRESS)
- return;
-
- bool internal = true;
- bool hardware = false;
- Breakpoint *breakpoint = process_sp->GetTarget().CreateBreakpoint(symbol_address, internal, hardware).get();
- breakpoint->SetCallback (AddressSanitizerRuntime::NotifyBreakpointHit, this, true);
- breakpoint->SetBreakpointKind ("address-sanitizer-report");
- SetBreakpointID(breakpoint->GetID());
-
- StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
- if (stream_sp)
- {
- stream_sp->Printf ("AddressSanitizer debugger support is active. Memory error breakpoint has been installed and you can now use the 'memory history' command.\n");
- }
-
- SetActive(true);
-}
-
-void
-AddressSanitizerRuntime::Deactivate()
-{
- if (GetBreakpointID() != LLDB_INVALID_BREAK_ID)
- {
- ProcessSP process_sp = GetProcessSP();
- if (process_sp)
- {
- process_sp->GetTarget().RemoveBreakpointByID(GetBreakpointID());
- SetBreakpointID(LLDB_INVALID_BREAK_ID);
- }
+ if (process_sp) {
+ process_sp->GetTarget().RemoveBreakpointByID(GetBreakpointID());
+ SetBreakpointID(LLDB_INVALID_BREAK_ID);
}
- SetActive(false);
+ }
+ SetActive(false);
}
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h Tue Sep 6 15:57:50 2016
@@ -14,73 +14,58 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/StructuredData.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Process.h"
-#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class AddressSanitizerRuntime : public lldb_private::InstrumentationRuntime
-{
+
+class AddressSanitizerRuntime : public lldb_private::InstrumentationRuntime {
public:
- ~AddressSanitizerRuntime() override;
+ ~AddressSanitizerRuntime() override;
+
+ static lldb::InstrumentationRuntimeSP
+ CreateInstance(const lldb::ProcessSP &process_sp);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static lldb::InstrumentationRuntimeType GetTypeStatic();
+
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
+
+ uint32_t GetPluginVersion() override { return 1; }
- static lldb::InstrumentationRuntimeSP
- CreateInstance (const lldb::ProcessSP &process_sp);
-
- static void
- Initialize();
-
- static void
- Terminate();
-
- static lldb_private::ConstString
- GetPluginNameStatic();
-
- static lldb::InstrumentationRuntimeType
- GetTypeStatic();
-
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- virtual lldb::InstrumentationRuntimeType
- GetType() { return GetTypeStatic(); }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
private:
- AddressSanitizerRuntime(const lldb::ProcessSP &process_sp) : lldb_private::InstrumentationRuntime(process_sp) {}
+ AddressSanitizerRuntime(const lldb::ProcessSP &process_sp)
+ : lldb_private::InstrumentationRuntime(process_sp) {}
+
+ const RegularExpression &GetPatternForRuntimeLibrary() override;
- const RegularExpression &
- GetPatternForRuntimeLibrary() override;
+ bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
- bool
- CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
+ void Activate() override;
- void
- Activate() override;
-
- void
- Deactivate();
-
- static bool
- NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
-
- StructuredData::ObjectSP
- RetrieveReportData();
-
- std::string
- FormatDescription(StructuredData::ObjectSP report);
+ void Deactivate();
+
+ static bool NotifyBreakpointHit(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+
+ StructuredData::ObjectSP RetrieveReportData();
+
+ std::string FormatDescription(StructuredData::ObjectSP report);
};
-
+
} // namespace lldb_private
#endif // liblldb_AddressSanitizerRuntime_h_
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp Tue Sep 6 15:57:50 2016
@@ -9,12 +9,13 @@
#include "ThreadSanitizerRuntime.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
@@ -29,53 +30,38 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/HistoryThread.h"
using namespace lldb;
using namespace lldb_private;
lldb::InstrumentationRuntimeSP
-ThreadSanitizerRuntime::CreateInstance (const lldb::ProcessSP &process_sp)
-{
- return InstrumentationRuntimeSP(new ThreadSanitizerRuntime(process_sp));
+ThreadSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(new ThreadSanitizerRuntime(process_sp));
}
-void
-ThreadSanitizerRuntime::Initialize()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- "ThreadSanitizer instrumentation runtime plugin.",
- CreateInstance,
- GetTypeStatic);
+void ThreadSanitizerRuntime::Initialize() {
+ PluginManager::RegisterPlugin(
+ GetPluginNameStatic(), "ThreadSanitizer instrumentation runtime plugin.",
+ CreateInstance, GetTypeStatic);
}
-void
-ThreadSanitizerRuntime::Terminate()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
+void ThreadSanitizerRuntime::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString
-ThreadSanitizerRuntime::GetPluginNameStatic()
-{
- return ConstString("ThreadSanitizer");
+lldb_private::ConstString ThreadSanitizerRuntime::GetPluginNameStatic() {
+ return ConstString("ThreadSanitizer");
}
-lldb::InstrumentationRuntimeType
-ThreadSanitizerRuntime::GetTypeStatic()
-{
- return eInstrumentationRuntimeTypeThreadSanitizer;
+lldb::InstrumentationRuntimeType ThreadSanitizerRuntime::GetTypeStatic() {
+ return eInstrumentationRuntimeTypeThreadSanitizer;
}
-ThreadSanitizerRuntime::~ThreadSanitizerRuntime()
-{
- Deactivate();
-}
+ThreadSanitizerRuntime::~ThreadSanitizerRuntime() { Deactivate(); }
-#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2*1000*1000
+#define RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC 2 * 1000 * 1000
-const char *
-thread_sanitizer_retrieve_report_data_prefix = R"(
+const char *thread_sanitizer_retrieve_report_data_prefix = R"(
extern "C"
{
void *__tsan_get_current_report();
@@ -169,8 +155,7 @@ struct data {
};
)";
-const char *
-thread_sanitizer_retrieve_report_data_command = R"(
+const char *thread_sanitizer_retrieve_report_data_command = R"(
data t = {0};
t.report = __tsan_get_current_report();
@@ -216,629 +201,820 @@ t;
)";
static StructuredData::Array *
-CreateStackTrace(ValueObjectSP o, const std::string &trace_item_name = ".trace") {
- StructuredData::Array *trace = new StructuredData::Array();
- ValueObjectSP trace_value_object = o->GetValueForExpressionPath(trace_item_name.c_str());
- for (int j = 0; j < 8; j++) {
- addr_t trace_addr = trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
- if (trace_addr == 0)
- break;
- trace->AddItem(StructuredData::ObjectSP(new StructuredData::Integer(trace_addr)));
- }
- return trace;
-}
+CreateStackTrace(ValueObjectSP o,
+ const std::string &trace_item_name = ".trace") {
+ StructuredData::Array *trace = new StructuredData::Array();
+ ValueObjectSP trace_value_object =
+ o->GetValueForExpressionPath(trace_item_name.c_str());
+ for (int j = 0; j < 8; j++) {
+ addr_t trace_addr =
+ trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
+ if (trace_addr == 0)
+ break;
+ trace->AddItem(
+ StructuredData::ObjectSP(new StructuredData::Integer(trace_addr)));
+ }
+ return trace;
+}
+
+static StructuredData::Array *ConvertToStructuredArray(
+ ValueObjectSP return_value_sp, const std::string &items_name,
+ const std::string &count_name,
+ std::function<void(ValueObjectSP o, StructuredData::Dictionary *dict)> const
+ &callback) {
+ StructuredData::Array *array = new StructuredData::Array();
+ unsigned int count =
+ return_value_sp->GetValueForExpressionPath(count_name.c_str())
+ ->GetValueAsUnsigned(0);
+ ValueObjectSP objects =
+ return_value_sp->GetValueForExpressionPath(items_name.c_str());
+ for (unsigned int i = 0; i < count; i++) {
+ ValueObjectSP o = objects->GetChildAtIndex(i, true);
+ StructuredData::Dictionary *dict = new StructuredData::Dictionary();
-static StructuredData::Array *
-ConvertToStructuredArray(ValueObjectSP return_value_sp, const std::string &items_name, const std::string &count_name, std::function <void(ValueObjectSP o, StructuredData::Dictionary *dict)> const &callback)
-{
- StructuredData::Array *array = new StructuredData::Array();
- unsigned int count = return_value_sp->GetValueForExpressionPath(count_name.c_str())->GetValueAsUnsigned(0);
- ValueObjectSP objects = return_value_sp->GetValueForExpressionPath(items_name.c_str());
- for (unsigned int i = 0; i < count; i++) {
- ValueObjectSP o = objects->GetChildAtIndex(i, true);
- StructuredData::Dictionary *dict = new StructuredData::Dictionary();
-
- callback(o, dict);
-
- array->AddItem(StructuredData::ObjectSP(dict));
- }
- return array;
-}
+ callback(o, dict);
-static std::string
-RetrieveString(ValueObjectSP return_value_sp, ProcessSP process_sp, const std::string &expression_path)
-{
- addr_t ptr = return_value_sp->GetValueForExpressionPath(expression_path.c_str())->GetValueAsUnsigned(0);
- std::string str;
- Error error;
- process_sp->ReadCStringFromMemory(ptr, str, error);
- return str;
+ array->AddItem(StructuredData::ObjectSP(dict));
+ }
+ return array;
+}
+
+static std::string RetrieveString(ValueObjectSP return_value_sp,
+ ProcessSP process_sp,
+ const std::string &expression_path) {
+ addr_t ptr =
+ return_value_sp->GetValueForExpressionPath(expression_path.c_str())
+ ->GetValueAsUnsigned(0);
+ std::string str;
+ Error error;
+ process_sp->ReadCStringFromMemory(ptr, str, error);
+ return str;
}
static void
-GetRenumberedThreadIds(ProcessSP process_sp, ValueObjectSP data, std::map<uint64_t, user_id_t> &thread_id_map)
-{
- ConvertToStructuredArray(data, ".threads", ".thread_count", [process_sp, &thread_id_map] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- uint64_t thread_id = o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0);
- uint64_t thread_os_id = o->GetValueForExpressionPath(".os_id")->GetValueAsUnsigned(0);
+GetRenumberedThreadIds(ProcessSP process_sp, ValueObjectSP data,
+ std::map<uint64_t, user_id_t> &thread_id_map) {
+ ConvertToStructuredArray(
+ data, ".threads", ".thread_count",
+ [process_sp, &thread_id_map](ValueObjectSP o,
+ StructuredData::Dictionary *dict) {
+ uint64_t thread_id =
+ o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0);
+ uint64_t thread_os_id =
+ o->GetValueForExpressionPath(".os_id")->GetValueAsUnsigned(0);
user_id_t lldb_user_id = 0;
-
+
bool can_update = true;
- ThreadSP lldb_thread = process_sp->GetThreadList().FindThreadByID(thread_os_id, can_update);
+ ThreadSP lldb_thread = process_sp->GetThreadList().FindThreadByID(
+ thread_os_id, can_update);
if (lldb_thread) {
- lldb_user_id = lldb_thread->GetIndexID();
+ lldb_user_id = lldb_thread->GetIndexID();
} else {
- // This isn't a live thread anymore. Ask process to assign a new Index ID (or return an old one if we've already seen this thread_os_id).
- // It will also make sure that no new threads are assigned this Index ID.
- lldb_user_id = process_sp->AssignIndexIDToThread(thread_os_id);
+ // This isn't a live thread anymore. Ask process to assign a new
+ // Index ID (or return an old one if we've already seen this
+ // thread_os_id).
+ // It will also make sure that no new threads are assigned this Index
+ // ID.
+ lldb_user_id = process_sp->AssignIndexIDToThread(thread_os_id);
}
-
+
thread_id_map[thread_id] = lldb_user_id;
- });
+ });
}
-static user_id_t Renumber(uint64_t id, std::map<uint64_t, user_id_t> &thread_id_map) {
- auto IT = thread_id_map.find(id);
- if (IT == thread_id_map.end())
- return 0;
-
- return IT->second;
+static user_id_t Renumber(uint64_t id,
+ std::map<uint64_t, user_id_t> &thread_id_map) {
+ auto IT = thread_id_map.find(id);
+ if (IT == thread_id_map.end())
+ return 0;
+
+ return IT->second;
}
StructuredData::ObjectSP
-ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref)
-{
- ProcessSP process_sp = GetProcessSP();
- if (!process_sp)
- return StructuredData::ObjectSP();
-
- ThreadSP thread_sp = exe_ctx_ref.GetThreadSP();
- StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
-
- if (!frame_sp)
- return StructuredData::ObjectSP();
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetTryAllThreads(true);
- options.SetStopOthers(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
- options.SetPrefix(thread_sanitizer_retrieve_report_data_prefix);
- options.SetAutoApplyFixIts(false);
- options.SetLanguage(eLanguageTypeObjC_plus_plus);
-
- ValueObjectSP main_value;
- ExecutionContext exe_ctx;
- Error eval_error;
- frame_sp->CalculateExecutionContext(exe_ctx);
- ExpressionResults result = UserExpression::Evaluate (exe_ctx,
- options,
- thread_sanitizer_retrieve_report_data_command,
- "",
- main_value,
- eval_error);
- if (result != eExpressionCompleted) {
- process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf("Warning: Cannot evaluate ThreadSanitizer expression:\n%s\n", eval_error.AsCString());
- return StructuredData::ObjectSP();
- }
-
- std::map<uint64_t, user_id_t> thread_id_map;
- GetRenumberedThreadIds(process_sp, main_value, thread_id_map);
-
- StructuredData::Dictionary *dict = new StructuredData::Dictionary();
- dict->AddStringItem("instrumentation_class", "ThreadSanitizer");
- dict->AddStringItem("issue_type", RetrieveString(main_value, process_sp, ".description"));
- dict->AddIntegerItem("report_count", main_value->GetValueForExpressionPath(".report_count")->GetValueAsUnsigned(0));
- dict->AddItem("sleep_trace", StructuredData::ObjectSP(CreateStackTrace(main_value, ".sleep_trace")));
-
- StructuredData::Array *stacks = ConvertToStructuredArray(main_value, ".stacks", ".stack_count", [thread_sp] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return StructuredData::ObjectSP();
+
+ ThreadSP thread_sp = exe_ctx_ref.GetThreadSP();
+ StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+
+ if (!frame_sp)
+ return StructuredData::ObjectSP();
+
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetTryAllThreads(true);
+ options.SetStopOthers(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTimeoutUsec(RETRIEVE_REPORT_DATA_FUNCTION_TIMEOUT_USEC);
+ options.SetPrefix(thread_sanitizer_retrieve_report_data_prefix);
+ options.SetAutoApplyFixIts(false);
+ options.SetLanguage(eLanguageTypeObjC_plus_plus);
+
+ ValueObjectSP main_value;
+ ExecutionContext exe_ctx;
+ Error eval_error;
+ frame_sp->CalculateExecutionContext(exe_ctx);
+ ExpressionResults result = UserExpression::Evaluate(
+ exe_ctx, options, thread_sanitizer_retrieve_report_data_command, "",
+ main_value, eval_error);
+ if (result != eExpressionCompleted) {
+ process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf(
+ "Warning: Cannot evaluate ThreadSanitizer expression:\n%s\n",
+ eval_error.AsCString());
+ return StructuredData::ObjectSP();
+ }
+
+ std::map<uint64_t, user_id_t> thread_id_map;
+ GetRenumberedThreadIds(process_sp, main_value, thread_id_map);
+
+ StructuredData::Dictionary *dict = new StructuredData::Dictionary();
+ dict->AddStringItem("instrumentation_class", "ThreadSanitizer");
+ dict->AddStringItem("issue_type",
+ RetrieveString(main_value, process_sp, ".description"));
+ dict->AddIntegerItem("report_count",
+ main_value->GetValueForExpressionPath(".report_count")
+ ->GetValueAsUnsigned(0));
+ dict->AddItem("sleep_trace", StructuredData::ObjectSP(CreateStackTrace(
+ main_value, ".sleep_trace")));
+
+ StructuredData::Array *stacks = ConvertToStructuredArray(
+ main_value, ".stacks", ".stack_count",
+ [thread_sp](ValueObjectSP o, StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
// "stacks" happen on the current thread
dict->AddIntegerItem("thread_id", thread_sp->GetIndexID());
- });
- dict->AddItem("stacks", StructuredData::ObjectSP(stacks));
-
- StructuredData::Array *mops = ConvertToStructuredArray(main_value, ".mops", ".mop_count", [&thread_id_map] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("thread_id", Renumber(o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0), thread_id_map));
- dict->AddIntegerItem("size", o->GetValueForExpressionPath(".size")->GetValueAsUnsigned(0));
- dict->AddBooleanItem("is_write", o->GetValueForExpressionPath(".write")->GetValueAsUnsigned(0));
- dict->AddBooleanItem("is_atomic", o->GetValueForExpressionPath(".atomic")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("address", o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
+ });
+ dict->AddItem("stacks", StructuredData::ObjectSP(stacks));
+
+ StructuredData::Array *mops = ConvertToStructuredArray(
+ main_value, ".mops", ".mop_count",
+ [&thread_id_map](ValueObjectSP o, StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "thread_id",
+ Renumber(
+ o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0),
+ thread_id_map));
+ dict->AddIntegerItem(
+ "size",
+ o->GetValueForExpressionPath(".size")->GetValueAsUnsigned(0));
+ dict->AddBooleanItem(
+ "is_write",
+ o->GetValueForExpressionPath(".write")->GetValueAsUnsigned(0));
+ dict->AddBooleanItem(
+ "is_atomic",
+ o->GetValueForExpressionPath(".atomic")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "address",
+ o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
- });
- dict->AddItem("mops", StructuredData::ObjectSP(mops));
-
- StructuredData::Array *locs = ConvertToStructuredArray(main_value, ".locs", ".loc_count", [process_sp, &thread_id_map] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ });
+ dict->AddItem("mops", StructuredData::ObjectSP(mops));
+
+ StructuredData::Array *locs = ConvertToStructuredArray(
+ main_value, ".locs", ".loc_count",
+ [process_sp, &thread_id_map](ValueObjectSP o,
+ StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
dict->AddStringItem("type", RetrieveString(o, process_sp, ".type"));
- dict->AddIntegerItem("address", o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("start", o->GetValueForExpressionPath(".start")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("size", o->GetValueForExpressionPath(".size")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("thread_id", Renumber(o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0), thread_id_map));
- dict->AddIntegerItem("file_descriptor", o->GetValueForExpressionPath(".fd")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("suppressable", o->GetValueForExpressionPath(".suppressable")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "address",
+ o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "start",
+ o->GetValueForExpressionPath(".start")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "size",
+ o->GetValueForExpressionPath(".size")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "thread_id",
+ Renumber(
+ o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0),
+ thread_id_map));
+ dict->AddIntegerItem(
+ "file_descriptor",
+ o->GetValueForExpressionPath(".fd")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem("suppressable",
+ o->GetValueForExpressionPath(".suppressable")
+ ->GetValueAsUnsigned(0));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
- });
- dict->AddItem("locs", StructuredData::ObjectSP(locs));
-
- StructuredData::Array *mutexes = ConvertToStructuredArray(main_value, ".mutexes", ".mutex_count", [] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("mutex_id", o->GetValueForExpressionPath(".mutex_id")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("address", o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("destroyed", o->GetValueForExpressionPath(".destroyed")->GetValueAsUnsigned(0));
+ });
+ dict->AddItem("locs", StructuredData::ObjectSP(locs));
+
+ StructuredData::Array *mutexes = ConvertToStructuredArray(
+ main_value, ".mutexes", ".mutex_count",
+ [](ValueObjectSP o, StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "mutex_id",
+ o->GetValueForExpressionPath(".mutex_id")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "address",
+ o->GetValueForExpressionPath(".addr")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "destroyed",
+ o->GetValueForExpressionPath(".destroyed")->GetValueAsUnsigned(0));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
- });
- dict->AddItem("mutexes", StructuredData::ObjectSP(mutexes));
-
- StructuredData::Array *threads = ConvertToStructuredArray(main_value, ".threads", ".thread_count", [process_sp, &thread_id_map] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("thread_id", Renumber(o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0), thread_id_map));
- dict->AddIntegerItem("thread_os_id", o->GetValueForExpressionPath(".os_id")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("running", o->GetValueForExpressionPath(".running")->GetValueAsUnsigned(0));
+ });
+ dict->AddItem("mutexes", StructuredData::ObjectSP(mutexes));
+
+ StructuredData::Array *threads = ConvertToStructuredArray(
+ main_value, ".threads", ".thread_count",
+ [process_sp, &thread_id_map](ValueObjectSP o,
+ StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "thread_id",
+ Renumber(
+ o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0),
+ thread_id_map));
+ dict->AddIntegerItem(
+ "thread_os_id",
+ o->GetValueForExpressionPath(".os_id")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "running",
+ o->GetValueForExpressionPath(".running")->GetValueAsUnsigned(0));
dict->AddStringItem("name", RetrieveString(o, process_sp, ".name"));
- dict->AddIntegerItem("parent_thread_id", Renumber(o->GetValueForExpressionPath(".parent_tid")->GetValueAsUnsigned(0), thread_id_map));
+ dict->AddIntegerItem(
+ "parent_thread_id",
+ Renumber(o->GetValueForExpressionPath(".parent_tid")
+ ->GetValueAsUnsigned(0),
+ thread_id_map));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
- });
- dict->AddItem("threads", StructuredData::ObjectSP(threads));
-
- StructuredData::Array *unique_tids = ConvertToStructuredArray(main_value, ".unique_tids", ".unique_tid_count", [&thread_id_map] (ValueObjectSP o, StructuredData::Dictionary *dict) {
- dict->AddIntegerItem("index", o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
- dict->AddIntegerItem("tid", Renumber(o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0), thread_id_map));
- });
- dict->AddItem("unique_tids", StructuredData::ObjectSP(unique_tids));
-
- return StructuredData::ObjectSP(dict);
-}
-
-std::string
-ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report)
-{
- std::string description = report->GetAsDictionary()->GetValueForKey("issue_type")->GetAsString()->GetValue();
-
- if (description == "data-race") {
- return "Data race";
- } else if (description == "data-race-vptr") {
- return "Data race on C++ virtual pointer";
- } else if (description == "heap-use-after-free") {
- return "Use of deallocated memory";
- } else if (description == "heap-use-after-free-vptr") {
- return "Use of deallocated C++ virtual pointer";
- } else if (description == "thread-leak") {
- return "Thread leak";
- } else if (description == "locked-mutex-destroy") {
- return "Destruction of a locked mutex";
- } else if (description == "mutex-double-lock") {
- return "Double lock of a mutex";
- } else if (description == "mutex-invalid-access") {
- return "Use of an uninitialized or destroyed mutex";
- } else if (description == "mutex-bad-unlock") {
- return "Unlock of an unlocked mutex (or by a wrong thread)";
- } else if (description == "mutex-bad-read-lock") {
- return "Read lock of a write locked mutex";
- } else if (description == "mutex-bad-read-unlock") {
- return "Read unlock of a write locked mutex";
- } else if (description == "signal-unsafe-call") {
- return "Signal-unsafe call inside a signal handler";
- } else if (description == "errno-in-signal-handler") {
- return "Overwrite of errno in a signal handler";
- } else if (description == "lock-order-inversion") {
- return "Lock order inversion (potential deadlock)";
- }
-
- // for unknown report codes just show the code
- return description;
-}
+ });
+ dict->AddItem("threads", StructuredData::ObjectSP(threads));
-static std::string
-Sprintf(const char *format, ...)
-{
- StreamString s;
- va_list args;
- va_start (args, format);
- s.PrintfVarArg(format, args);
- va_end (args);
- return s.GetString();
-}
+ StructuredData::Array *unique_tids = ConvertToStructuredArray(
+ main_value, ".unique_tids", ".unique_tid_count",
+ [&thread_id_map](ValueObjectSP o, StructuredData::Dictionary *dict) {
+ dict->AddIntegerItem(
+ "index",
+ o->GetValueForExpressionPath(".idx")->GetValueAsUnsigned(0));
+ dict->AddIntegerItem(
+ "tid",
+ Renumber(
+ o->GetValueForExpressionPath(".tid")->GetValueAsUnsigned(0),
+ thread_id_map));
+ });
+ dict->AddItem("unique_tids", StructuredData::ObjectSP(unique_tids));
-static std::string
-GetSymbolNameFromAddress(ProcessSP process_sp, addr_t addr)
-{
- lldb_private::Address so_addr;
- if (! process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
- return "";
-
- lldb_private::Symbol *symbol = so_addr.CalculateSymbolContextSymbol();
- if (! symbol)
- return "";
-
- std::string sym_name = symbol->GetName().GetCString();
- return sym_name;
+ return StructuredData::ObjectSP(dict);
}
-static void
-GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr, Declaration &decl)
-{
+std::string
+ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
+ std::string description = report->GetAsDictionary()
+ ->GetValueForKey("issue_type")
+ ->GetAsString()
+ ->GetValue();
+
+ if (description == "data-race") {
+ return "Data race";
+ } else if (description == "data-race-vptr") {
+ return "Data race on C++ virtual pointer";
+ } else if (description == "heap-use-after-free") {
+ return "Use of deallocated memory";
+ } else if (description == "heap-use-after-free-vptr") {
+ return "Use of deallocated C++ virtual pointer";
+ } else if (description == "thread-leak") {
+ return "Thread leak";
+ } else if (description == "locked-mutex-destroy") {
+ return "Destruction of a locked mutex";
+ } else if (description == "mutex-double-lock") {
+ return "Double lock of a mutex";
+ } else if (description == "mutex-invalid-access") {
+ return "Use of an uninitialized or destroyed mutex";
+ } else if (description == "mutex-bad-unlock") {
+ return "Unlock of an unlocked mutex (or by a wrong thread)";
+ } else if (description == "mutex-bad-read-lock") {
+ return "Read lock of a write locked mutex";
+ } else if (description == "mutex-bad-read-unlock") {
+ return "Read unlock of a write locked mutex";
+ } else if (description == "signal-unsafe-call") {
+ return "Signal-unsafe call inside a signal handler";
+ } else if (description == "errno-in-signal-handler") {
+ return "Overwrite of errno in a signal handler";
+ } else if (description == "lock-order-inversion") {
+ return "Lock order inversion (potential deadlock)";
+ }
+
+ // for unknown report codes just show the code
+ return description;
+}
+
+static std::string Sprintf(const char *format, ...) {
+ StreamString s;
+ va_list args;
+ va_start(args, format);
+ s.PrintfVarArg(format, args);
+ va_end(args);
+ return s.GetString();
+}
+
+static std::string GetSymbolNameFromAddress(ProcessSP process_sp, addr_t addr) {
+ lldb_private::Address so_addr;
+ if (!process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(addr,
+ so_addr))
+ return "";
+
+ lldb_private::Symbol *symbol = so_addr.CalculateSymbolContextSymbol();
+ if (!symbol)
+ return "";
+
+ std::string sym_name = symbol->GetName().GetCString();
+ return sym_name;
+}
+
+static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
+ Declaration &decl) {
+ lldb_private::Address so_addr;
+ if (!process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(addr,
+ so_addr))
+ return;
+
+ lldb_private::Symbol *symbol = so_addr.CalculateSymbolContextSymbol();
+ if (!symbol)
+ return;
+
+ ConstString sym_name = symbol->GetMangled().GetName(
+ lldb::eLanguageTypeUnknown, Mangled::ePreferMangled);
+
+ ModuleSP module = symbol->CalculateSymbolContextModule();
+ if (!module)
+ return;
+
+ VariableList var_list;
+ module->FindGlobalVariables(sym_name, nullptr, true, 1U, var_list);
+ if (var_list.GetSize() < 1)
+ return;
+
+ VariableSP var = var_list.GetVariableAtIndex(0);
+ decl = var->GetDeclaration();
+}
+
+addr_t ThreadSanitizerRuntime::GetFirstNonInternalFramePc(
+ StructuredData::ObjectSP trace) {
+ ProcessSP process_sp = GetProcessSP();
+ ModuleSP runtime_module_sp = GetRuntimeModuleSP();
+
+ addr_t result = 0;
+ trace->GetAsArray()->ForEach([process_sp, runtime_module_sp,
+ &result](StructuredData::Object *o) -> bool {
+ addr_t addr = o->GetIntegerValue();
lldb_private::Address so_addr;
- if (! process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
- return;
-
- lldb_private::Symbol *symbol = so_addr.CalculateSymbolContextSymbol();
- if (! symbol)
- return;
-
- ConstString sym_name = symbol->GetMangled().GetName(lldb::eLanguageTypeUnknown, Mangled::ePreferMangled);
-
- ModuleSP module = symbol->CalculateSymbolContextModule();
- if (! module)
- return;
-
- VariableList var_list;
- module->FindGlobalVariables(sym_name, nullptr, true, 1U, var_list);
- if (var_list.GetSize() < 1)
- return;
-
- VariableSP var = var_list.GetVariableAtIndex(0);
- decl = var->GetDeclaration();
-}
+ if (!process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(
+ addr, so_addr))
+ return true;
+
+ if (so_addr.GetModule() == runtime_module_sp)
+ return true;
+
+ result = addr;
+ return false;
+ });
-addr_t
-ThreadSanitizerRuntime::GetFirstNonInternalFramePc(StructuredData::ObjectSP trace)
-{
- ProcessSP process_sp = GetProcessSP();
- ModuleSP runtime_module_sp = GetRuntimeModuleSP();
-
- addr_t result = 0;
- trace->GetAsArray()->ForEach([process_sp, runtime_module_sp, &result] (StructuredData::Object *o) -> bool {
- addr_t addr = o->GetIntegerValue();
- lldb_private::Address so_addr;
- if (! process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
- return true;
-
- if (so_addr.GetModule() == runtime_module_sp)
- return true;
-
- result = addr;
- return false;
- });
-
- return result;
+ return result;
}
std::string
-ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report)
-{
- ProcessSP process_sp = GetProcessSP();
-
- std::string summary = report->GetAsDictionary()->GetValueForKey("description")->GetAsString()->GetValue();
- addr_t pc = 0;
- if (report->GetAsDictionary()->GetValueForKey("mops")->GetAsArray()->GetSize() > 0)
- pc = GetFirstNonInternalFramePc(report->GetAsDictionary()->GetValueForKey("mops")->GetAsArray()->GetItemAtIndex(0)->GetAsDictionary()->GetValueForKey("trace"));
-
- if (report->GetAsDictionary()->GetValueForKey("stacks")->GetAsArray()->GetSize() > 0)
- pc = GetFirstNonInternalFramePc(report->GetAsDictionary()->GetValueForKey("stacks")->GetAsArray()->GetItemAtIndex(0)->GetAsDictionary()->GetValueForKey("trace"));
+ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
+ ProcessSP process_sp = GetProcessSP();
- if (pc != 0) {
- summary = summary + " in " + GetSymbolNameFromAddress(process_sp, pc);
+ std::string summary = report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue();
+ addr_t pc = 0;
+ if (report->GetAsDictionary()
+ ->GetValueForKey("mops")
+ ->GetAsArray()
+ ->GetSize() > 0)
+ pc = GetFirstNonInternalFramePc(report->GetAsDictionary()
+ ->GetValueForKey("mops")
+ ->GetAsArray()
+ ->GetItemAtIndex(0)
+ ->GetAsDictionary()
+ ->GetValueForKey("trace"));
+
+ if (report->GetAsDictionary()
+ ->GetValueForKey("stacks")
+ ->GetAsArray()
+ ->GetSize() > 0)
+ pc = GetFirstNonInternalFramePc(report->GetAsDictionary()
+ ->GetValueForKey("stacks")
+ ->GetAsArray()
+ ->GetItemAtIndex(0)
+ ->GetAsDictionary()
+ ->GetValueForKey("trace"));
+
+ if (pc != 0) {
+ summary = summary + " in " + GetSymbolNameFromAddress(process_sp, pc);
+ }
+
+ if (report->GetAsDictionary()
+ ->GetValueForKey("locs")
+ ->GetAsArray()
+ ->GetSize() > 0) {
+ StructuredData::ObjectSP loc = report->GetAsDictionary()
+ ->GetValueForKey("locs")
+ ->GetAsArray()
+ ->GetItemAtIndex(0);
+ addr_t addr = loc->GetAsDictionary()
+ ->GetValueForKey("address")
+ ->GetAsInteger()
+ ->GetValue();
+ if (addr == 0)
+ addr = loc->GetAsDictionary()
+ ->GetValueForKey("start")
+ ->GetAsInteger()
+ ->GetValue();
+
+ if (addr != 0) {
+ std::string global_name = GetSymbolNameFromAddress(process_sp, addr);
+ if (!global_name.empty()) {
+ summary = summary + " at " + global_name;
+ } else {
+ summary = summary + " at " + Sprintf("0x%llx", addr);
+ }
+ } else {
+ int fd = loc->GetAsDictionary()
+ ->GetValueForKey("file_descriptor")
+ ->GetAsInteger()
+ ->GetValue();
+ if (fd != 0) {
+ summary = summary + " on file descriptor " + Sprintf("%d", fd);
+ }
}
-
- if (report->GetAsDictionary()->GetValueForKey("locs")->GetAsArray()->GetSize() > 0) {
- StructuredData::ObjectSP loc = report->GetAsDictionary()->GetValueForKey("locs")->GetAsArray()->GetItemAtIndex(0);
- addr_t addr = loc->GetAsDictionary()->GetValueForKey("address")->GetAsInteger()->GetValue();
- if (addr == 0)
- addr = loc->GetAsDictionary()->GetValueForKey("start")->GetAsInteger()->GetValue();
-
- if (addr != 0) {
- std::string global_name = GetSymbolNameFromAddress(process_sp, addr);
- if (!global_name.empty()) {
- summary = summary + " at " + global_name;
- } else {
- summary = summary + " at " + Sprintf("0x%llx", addr);
- }
- } else {
- int fd = loc->GetAsDictionary()->GetValueForKey("file_descriptor")->GetAsInteger()->GetValue();
- if (fd != 0) {
- summary = summary + " on file descriptor " + Sprintf("%d", fd);
- }
- }
- }
-
- return summary;
+ }
+
+ return summary;
}
addr_t
-ThreadSanitizerRuntime::GetMainRacyAddress(StructuredData::ObjectSP report)
-{
- addr_t result = (addr_t)-1;
-
- report->GetObjectForDotSeparatedPath("mops")->GetAsArray()->ForEach([&result] (StructuredData::Object *o) -> bool {
- addr_t addr = o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
- if (addr < result) result = addr;
- return true;
- });
+ThreadSanitizerRuntime::GetMainRacyAddress(StructuredData::ObjectSP report) {
+ addr_t result = (addr_t)-1;
- return (result == (addr_t)-1) ? 0 : result;
-}
+ report->GetObjectForDotSeparatedPath("mops")->GetAsArray()->ForEach(
+ [&result](StructuredData::Object *o) -> bool {
+ addr_t addr =
+ o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
+ if (addr < result)
+ result = addr;
+ return true;
+ });
-std::string
-ThreadSanitizerRuntime::GetLocationDescription(StructuredData::ObjectSP report, addr_t &global_addr, std::string &global_name, std::string &filename, uint32_t &line)
-{
- std::string result = "";
-
- ProcessSP process_sp = GetProcessSP();
-
- if (report->GetAsDictionary()->GetValueForKey("locs")->GetAsArray()->GetSize() > 0) {
- StructuredData::ObjectSP loc = report->GetAsDictionary()->GetValueForKey("locs")->GetAsArray()->GetItemAtIndex(0);
- std::string type = loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
- if (type == "global") {
- global_addr = loc->GetAsDictionary()->GetValueForKey("address")->GetAsInteger()->GetValue();
- global_name = GetSymbolNameFromAddress(process_sp, global_addr);
- if (!global_name.empty()) {
- result = Sprintf("'%s' is a global variable (0x%llx)", global_name.c_str(), global_addr);
- } else {
- result = Sprintf("0x%llx is a global variable", global_addr);
- }
-
- Declaration decl;
- GetSymbolDeclarationFromAddress(process_sp, global_addr, decl);
- if (decl.GetFile()) {
- filename = decl.GetFile().GetPath();
- line = decl.GetLine();
- }
- } else if (type == "heap") {
- addr_t addr = loc->GetAsDictionary()->GetValueForKey("start")->GetAsInteger()->GetValue();
- long size = loc->GetAsDictionary()->GetValueForKey("size")->GetAsInteger()->GetValue();
- result = Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
- } else if (type == "stack") {
- int tid = loc->GetAsDictionary()->GetValueForKey("thread_id")->GetAsInteger()->GetValue();
- result = Sprintf("Location is stack of thread %d", tid);
- } else if (type == "tls") {
- int tid = loc->GetAsDictionary()->GetValueForKey("thread_id")->GetAsInteger()->GetValue();
- result = Sprintf("Location is TLS of thread %d", tid);
- } else if (type == "fd") {
- int fd = loc->GetAsDictionary()->GetValueForKey("file_descriptor")->GetAsInteger()->GetValue();
- result = Sprintf("Location is file descriptor %d", fd);
- }
- }
-
- return result;
+ return (result == (addr_t)-1) ? 0 : result;
}
-bool
-ThreadSanitizerRuntime::NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, user_id_t break_id, user_id_t break_loc_id)
-{
- assert (baton && "null baton");
- if (!baton)
- return false;
-
- ThreadSanitizerRuntime *const instance = static_cast<ThreadSanitizerRuntime*>(baton);
-
- StructuredData::ObjectSP report = instance->RetrieveReportData(context->exe_ctx_ref);
- std::string stop_reason_description;
- if (report) {
- std::string issue_description = instance->FormatDescription(report);
- report->GetAsDictionary()->AddStringItem("description", issue_description);
- stop_reason_description = issue_description + " detected";
- report->GetAsDictionary()->AddStringItem("stop_description", stop_reason_description);
- std::string summary = instance->GenerateSummary(report);
- report->GetAsDictionary()->AddStringItem("summary", summary);
- addr_t main_address = instance->GetMainRacyAddress(report);
- report->GetAsDictionary()->AddIntegerItem("memory_address", main_address);
-
- addr_t global_addr = 0;
- std::string global_name = "";
- std::string location_filename = "";
- uint32_t location_line = 0;
- std::string location_description = instance->GetLocationDescription(report, global_addr, global_name, location_filename, location_line);
- report->GetAsDictionary()->AddStringItem("location_description", location_description);
- if (global_addr != 0) {
- report->GetAsDictionary()->AddIntegerItem("global_address", global_addr);
- }
- if (!global_name.empty()) {
- report->GetAsDictionary()->AddStringItem("global_name", global_name);
- }
- if (location_filename != "") {
- report->GetAsDictionary()->AddStringItem("location_filename", location_filename);
- report->GetAsDictionary()->AddIntegerItem("location_line", location_line);
- }
-
- bool all_addresses_are_same = true;
- report->GetObjectForDotSeparatedPath("mops")->GetAsArray()->ForEach([&all_addresses_are_same, main_address] (StructuredData::Object *o) -> bool {
- addr_t addr = o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
- if (main_address != addr) all_addresses_are_same = false;
- return true;
+std::string ThreadSanitizerRuntime::GetLocationDescription(
+ StructuredData::ObjectSP report, addr_t &global_addr,
+ std::string &global_name, std::string &filename, uint32_t &line) {
+ std::string result = "";
+
+ ProcessSP process_sp = GetProcessSP();
+
+ if (report->GetAsDictionary()
+ ->GetValueForKey("locs")
+ ->GetAsArray()
+ ->GetSize() > 0) {
+ StructuredData::ObjectSP loc = report->GetAsDictionary()
+ ->GetValueForKey("locs")
+ ->GetAsArray()
+ ->GetItemAtIndex(0);
+ std::string type =
+ loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ if (type == "global") {
+ global_addr = loc->GetAsDictionary()
+ ->GetValueForKey("address")
+ ->GetAsInteger()
+ ->GetValue();
+ global_name = GetSymbolNameFromAddress(process_sp, global_addr);
+ if (!global_name.empty()) {
+ result = Sprintf("'%s' is a global variable (0x%llx)",
+ global_name.c_str(), global_addr);
+ } else {
+ result = Sprintf("0x%llx is a global variable", global_addr);
+ }
+
+ Declaration decl;
+ GetSymbolDeclarationFromAddress(process_sp, global_addr, decl);
+ if (decl.GetFile()) {
+ filename = decl.GetFile().GetPath();
+ line = decl.GetLine();
+ }
+ } else if (type == "heap") {
+ addr_t addr = loc->GetAsDictionary()
+ ->GetValueForKey("start")
+ ->GetAsInteger()
+ ->GetValue();
+ long size = loc->GetAsDictionary()
+ ->GetValueForKey("size")
+ ->GetAsInteger()
+ ->GetValue();
+ result =
+ Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
+ } else if (type == "stack") {
+ int tid = loc->GetAsDictionary()
+ ->GetValueForKey("thread_id")
+ ->GetAsInteger()
+ ->GetValue();
+ result = Sprintf("Location is stack of thread %d", tid);
+ } else if (type == "tls") {
+ int tid = loc->GetAsDictionary()
+ ->GetValueForKey("thread_id")
+ ->GetAsInteger()
+ ->GetValue();
+ result = Sprintf("Location is TLS of thread %d", tid);
+ } else if (type == "fd") {
+ int fd = loc->GetAsDictionary()
+ ->GetValueForKey("file_descriptor")
+ ->GetAsInteger()
+ ->GetValue();
+ result = Sprintf("Location is file descriptor %d", fd);
+ }
+ }
+
+ return result;
+}
+
+bool ThreadSanitizerRuntime::NotifyBreakpointHit(
+ void *baton, StoppointCallbackContext *context, user_id_t break_id,
+ user_id_t break_loc_id) {
+ assert(baton && "null baton");
+ if (!baton)
+ return false;
+
+ ThreadSanitizerRuntime *const instance =
+ static_cast<ThreadSanitizerRuntime *>(baton);
+
+ StructuredData::ObjectSP report =
+ instance->RetrieveReportData(context->exe_ctx_ref);
+ std::string stop_reason_description;
+ if (report) {
+ std::string issue_description = instance->FormatDescription(report);
+ report->GetAsDictionary()->AddStringItem("description", issue_description);
+ stop_reason_description = issue_description + " detected";
+ report->GetAsDictionary()->AddStringItem("stop_description",
+ stop_reason_description);
+ std::string summary = instance->GenerateSummary(report);
+ report->GetAsDictionary()->AddStringItem("summary", summary);
+ addr_t main_address = instance->GetMainRacyAddress(report);
+ report->GetAsDictionary()->AddIntegerItem("memory_address", main_address);
+
+ addr_t global_addr = 0;
+ std::string global_name = "";
+ std::string location_filename = "";
+ uint32_t location_line = 0;
+ std::string location_description = instance->GetLocationDescription(
+ report, global_addr, global_name, location_filename, location_line);
+ report->GetAsDictionary()->AddStringItem("location_description",
+ location_description);
+ if (global_addr != 0) {
+ report->GetAsDictionary()->AddIntegerItem("global_address", global_addr);
+ }
+ if (!global_name.empty()) {
+ report->GetAsDictionary()->AddStringItem("global_name", global_name);
+ }
+ if (location_filename != "") {
+ report->GetAsDictionary()->AddStringItem("location_filename",
+ location_filename);
+ report->GetAsDictionary()->AddIntegerItem("location_line", location_line);
+ }
+
+ bool all_addresses_are_same = true;
+ report->GetObjectForDotSeparatedPath("mops")->GetAsArray()->ForEach(
+ [&all_addresses_are_same,
+ main_address](StructuredData::Object *o) -> bool {
+ addr_t addr =
+ o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
+ if (main_address != addr)
+ all_addresses_are_same = false;
+ return true;
});
- report->GetAsDictionary()->AddBooleanItem("all_addresses_are_same", all_addresses_are_same);
- }
-
- ProcessSP process_sp = instance->GetProcessSP();
- // Make sure this is the right process
- if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP())
- {
- ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
- if (thread_sp)
- thread_sp->SetStopInfo(InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(*thread_sp, stop_reason_description.c_str(), report));
-
- StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
- if (stream_sp)
- {
- stream_sp->Printf ("ThreadSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.\n");
- }
- return true; // Return true to stop the target
- }
- else
- return false; // Let target run
+ report->GetAsDictionary()->AddBooleanItem("all_addresses_are_same",
+ all_addresses_are_same);
+ }
+
+ ProcessSP process_sp = instance->GetProcessSP();
+ // Make sure this is the right process
+ if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP()) {
+ ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
+ if (thread_sp)
+ thread_sp->SetStopInfo(
+ InstrumentationRuntimeStopInfo::
+ CreateStopReasonWithInstrumentationData(
+ *thread_sp, stop_reason_description.c_str(), report));
+
+ StreamFileSP stream_sp(
+ process_sp->GetTarget().GetDebugger().GetOutputFile());
+ if (stream_sp) {
+ stream_sp->Printf("ThreadSanitizer report breakpoint hit. Use 'thread "
+ "info -s' to get extended information about the "
+ "report.\n");
+ }
+ return true; // Return true to stop the target
+ } else
+ return false; // Let target run
}
-const RegularExpression &
-ThreadSanitizerRuntime::GetPatternForRuntimeLibrary() {
+const RegularExpression &ThreadSanitizerRuntime::GetPatternForRuntimeLibrary() {
static RegularExpression regex("libclang_rt.tsan_");
return regex;
}
-bool
-ThreadSanitizerRuntime::CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp)
-{
- static ConstString g_tsan_get_current_report("__tsan_get_current_report");
- const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(g_tsan_get_current_report, lldb::eSymbolTypeAny);
- return symbol != nullptr;
-}
-
-void
-ThreadSanitizerRuntime::Activate()
-{
- if (IsActive())
- return;
-
- ProcessSP process_sp = GetProcessSP();
- if (!process_sp)
- return;
-
- ConstString symbol_name ("__tsan_on_report");
- const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType (symbol_name, eSymbolTypeCode);
-
- if (symbol == NULL)
- return;
-
- if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
- return;
-
- Target &target = process_sp->GetTarget();
- addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
-
- if (symbol_address == LLDB_INVALID_ADDRESS)
- return;
-
- bool internal = true;
- bool hardware = false;
- Breakpoint *breakpoint = process_sp->GetTarget().CreateBreakpoint(symbol_address, internal, hardware).get();
- breakpoint->SetCallback (ThreadSanitizerRuntime::NotifyBreakpointHit, this, true);
- breakpoint->SetBreakpointKind ("thread-sanitizer-report");
- SetBreakpointID(breakpoint->GetID());
-
- StreamFileSP stream_sp (process_sp->GetTarget().GetDebugger().GetOutputFile());
- if (stream_sp)
- {
- stream_sp->Printf ("ThreadSanitizer debugger support is active.\n");
- }
-
- SetActive(true);
-}
+bool ThreadSanitizerRuntime::CheckIfRuntimeIsValid(
+ const lldb::ModuleSP module_sp) {
+ static ConstString g_tsan_get_current_report("__tsan_get_current_report");
+ const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
+ g_tsan_get_current_report, lldb::eSymbolTypeAny);
+ return symbol != nullptr;
+}
+
+void ThreadSanitizerRuntime::Activate() {
+ if (IsActive())
+ return;
+
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return;
+
+ ConstString symbol_name("__tsan_on_report");
+ const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType(
+ symbol_name, eSymbolTypeCode);
+
+ if (symbol == NULL)
+ return;
+
+ if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
+ return;
+
+ Target &target = process_sp->GetTarget();
+ addr_t symbol_address = symbol->GetAddressRef().GetOpcodeLoadAddress(&target);
+
+ if (symbol_address == LLDB_INVALID_ADDRESS)
+ return;
+
+ bool internal = true;
+ bool hardware = false;
+ Breakpoint *breakpoint =
+ process_sp->GetTarget()
+ .CreateBreakpoint(symbol_address, internal, hardware)
+ .get();
+ breakpoint->SetCallback(ThreadSanitizerRuntime::NotifyBreakpointHit, this,
+ true);
+ breakpoint->SetBreakpointKind("thread-sanitizer-report");
+ SetBreakpointID(breakpoint->GetID());
+
+ StreamFileSP stream_sp(process_sp->GetTarget().GetDebugger().GetOutputFile());
+ if (stream_sp) {
+ stream_sp->Printf("ThreadSanitizer debugger support is active.\n");
+ }
-void
-ThreadSanitizerRuntime::Deactivate()
-{
- if (GetBreakpointID() != LLDB_INVALID_BREAK_ID)
- {
- ProcessSP process_sp = GetProcessSP();
- if (process_sp)
- {
- process_sp->GetTarget().RemoveBreakpointByID(GetBreakpointID());
- SetBreakpointID(LLDB_INVALID_BREAK_ID);
- }
- }
- SetActive(false);
-}
-static std::string
-GenerateThreadName(const std::string &path, StructuredData::Object *o, StructuredData::ObjectSP main_info) {
- std::string result = "additional information";
-
- if (path == "mops") {
- int size = o->GetObjectForDotSeparatedPath("size")->GetIntegerValue();
- int thread_id = o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
- bool is_write = o->GetObjectForDotSeparatedPath("is_write")->GetBooleanValue();
- bool is_atomic = o->GetObjectForDotSeparatedPath("is_atomic")->GetBooleanValue();
- addr_t addr = o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
-
- std::string addr_string = Sprintf(" at 0x%llx", addr);
-
- if (main_info->GetObjectForDotSeparatedPath("all_addresses_are_same")->GetBooleanValue()){
- addr_string = "";
- }
-
- result = Sprintf("%s%s of size %d%s by thread %d", is_atomic ? "atomic " : "", is_write ? "write" : "read", size, addr_string.c_str(), thread_id);
- }
-
- if (path == "threads") {
- int thread_id = o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
- result = Sprintf("Thread %d created", thread_id);
- }
-
- if (path == "locs") {
- std::string type = o->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
- int thread_id = o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
- int fd = o->GetObjectForDotSeparatedPath("file_descriptor")->GetIntegerValue();
- if (type == "heap") {
- result = Sprintf("Heap block allocated by thread %d", thread_id);
- } else if (type == "fd") {
- result = Sprintf("File descriptor %d created by thread %t", fd, thread_id);
- }
- }
-
- if (path == "mutexes") {
- int mutex_id = o->GetObjectForDotSeparatedPath("mutex_id")->GetIntegerValue();
-
- result = Sprintf("Mutex M%d created", mutex_id);
- }
-
- if (path == "stacks") {
- int thread_id = o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
- result = Sprintf("Thread %d", thread_id);
- }
-
- result[0] = toupper(result[0]);
-
- return result;
+ SetActive(true);
}
-static void
-AddThreadsForPath(const std::string &path, ThreadCollectionSP threads, ProcessSP process_sp, StructuredData::ObjectSP info)
-{
- info->GetObjectForDotSeparatedPath(path)->GetAsArray()->ForEach([process_sp, threads, path, info] (StructuredData::Object *o) -> bool {
+void ThreadSanitizerRuntime::Deactivate() {
+ if (GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
+ ProcessSP process_sp = GetProcessSP();
+ if (process_sp) {
+ process_sp->GetTarget().RemoveBreakpointByID(GetBreakpointID());
+ SetBreakpointID(LLDB_INVALID_BREAK_ID);
+ }
+ }
+ SetActive(false);
+}
+static std::string GenerateThreadName(const std::string &path,
+ StructuredData::Object *o,
+ StructuredData::ObjectSP main_info) {
+ std::string result = "additional information";
+
+ if (path == "mops") {
+ int size = o->GetObjectForDotSeparatedPath("size")->GetIntegerValue();
+ int thread_id =
+ o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
+ bool is_write =
+ o->GetObjectForDotSeparatedPath("is_write")->GetBooleanValue();
+ bool is_atomic =
+ o->GetObjectForDotSeparatedPath("is_atomic")->GetBooleanValue();
+ addr_t addr = o->GetObjectForDotSeparatedPath("address")->GetIntegerValue();
+
+ std::string addr_string = Sprintf(" at 0x%llx", addr);
+
+ if (main_info->GetObjectForDotSeparatedPath("all_addresses_are_same")
+ ->GetBooleanValue()) {
+ addr_string = "";
+ }
+
+ result = Sprintf("%s%s of size %d%s by thread %d",
+ is_atomic ? "atomic " : "", is_write ? "write" : "read",
+ size, addr_string.c_str(), thread_id);
+ }
+
+ if (path == "threads") {
+ int thread_id =
+ o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
+ result = Sprintf("Thread %d created", thread_id);
+ }
+
+ if (path == "locs") {
+ std::string type =
+ o->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ int thread_id =
+ o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
+ int fd =
+ o->GetObjectForDotSeparatedPath("file_descriptor")->GetIntegerValue();
+ if (type == "heap") {
+ result = Sprintf("Heap block allocated by thread %d", thread_id);
+ } else if (type == "fd") {
+ result =
+ Sprintf("File descriptor %d created by thread %t", fd, thread_id);
+ }
+ }
+
+ if (path == "mutexes") {
+ int mutex_id =
+ o->GetObjectForDotSeparatedPath("mutex_id")->GetIntegerValue();
+
+ result = Sprintf("Mutex M%d created", mutex_id);
+ }
+
+ if (path == "stacks") {
+ int thread_id =
+ o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
+ result = Sprintf("Thread %d", thread_id);
+ }
+
+ result[0] = toupper(result[0]);
+
+ return result;
+}
+
+static void AddThreadsForPath(const std::string &path,
+ ThreadCollectionSP threads, ProcessSP process_sp,
+ StructuredData::ObjectSP info) {
+ info->GetObjectForDotSeparatedPath(path)->GetAsArray()->ForEach(
+ [process_sp, threads, path, info](StructuredData::Object *o) -> bool {
std::vector<lldb::addr_t> pcs;
- o->GetObjectForDotSeparatedPath("trace")->GetAsArray()->ForEach([&pcs] (StructuredData::Object *pc) -> bool {
- pcs.push_back(pc->GetAsInteger()->GetValue());
- return true;
- });
-
+ o->GetObjectForDotSeparatedPath("trace")->GetAsArray()->ForEach(
+ [&pcs](StructuredData::Object *pc) -> bool {
+ pcs.push_back(pc->GetAsInteger()->GetValue());
+ return true;
+ });
+
if (pcs.size() == 0)
- return true;
-
- StructuredData::ObjectSP thread_id_obj = o->GetObjectForDotSeparatedPath("thread_os_id");
+ return true;
+
+ StructuredData::ObjectSP thread_id_obj =
+ o->GetObjectForDotSeparatedPath("thread_os_id");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
-
+
uint32_t stop_id = 0;
bool stop_id_is_valid = false;
- HistoryThread *history_thread = new HistoryThread(*process_sp, tid, pcs, stop_id, stop_id_is_valid);
+ HistoryThread *history_thread =
+ new HistoryThread(*process_sp, tid, pcs, stop_id, stop_id_is_valid);
ThreadSP new_thread_sp(history_thread);
new_thread_sp->SetName(GenerateThreadName(path, o, info).c_str());
-
- // Save this in the Process' ExtendedThreadList so a strong pointer retains the object
+
+ // Save this in the Process' ExtendedThreadList so a strong pointer
+ // retains the object
process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
threads->AddThread(new_thread_sp);
-
+
return true;
- });
+ });
}
lldb::ThreadCollectionSP
-ThreadSanitizerRuntime::GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info)
-{
- ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
+ThreadSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
+ StructuredData::ObjectSP info) {
+ ThreadCollectionSP threads;
+ threads.reset(new ThreadCollection());
- if (info->GetObjectForDotSeparatedPath("instrumentation_class")->GetStringValue() != "ThreadSanitizer")
- return threads;
-
- ProcessSP process_sp = GetProcessSP();
-
- AddThreadsForPath("stacks", threads, process_sp, info);
- AddThreadsForPath("mops", threads, process_sp, info);
- AddThreadsForPath("locs", threads, process_sp, info);
- AddThreadsForPath("mutexes", threads, process_sp, info);
- AddThreadsForPath("threads", threads, process_sp, info);
-
+ if (info->GetObjectForDotSeparatedPath("instrumentation_class")
+ ->GetStringValue() != "ThreadSanitizer")
return threads;
+
+ ProcessSP process_sp = GetProcessSP();
+
+ AddThreadsForPath("stacks", threads, process_sp, info);
+ AddThreadsForPath("mops", threads, process_sp, info);
+ AddThreadsForPath("locs", threads, process_sp, info);
+ AddThreadsForPath("mutexes", threads, process_sp, info);
+ AddThreadsForPath("threads", threads, process_sp, info);
+
+ return threads;
}
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h Tue Sep 6 15:57:50 2016
@@ -14,88 +14,72 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/StructuredData.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/InstrumentationRuntime.h"
-#include "lldb/Core/StructuredData.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class ThreadSanitizerRuntime : public lldb_private::InstrumentationRuntime
-{
+
+class ThreadSanitizerRuntime : public lldb_private::InstrumentationRuntime {
public:
- ~ThreadSanitizerRuntime() override;
-
- static lldb::InstrumentationRuntimeSP
- CreateInstance (const lldb::ProcessSP &process_sp);
-
- static void
- Initialize();
-
- static void
- Terminate();
-
- static lldb_private::ConstString
- GetPluginNameStatic();
-
- static lldb::InstrumentationRuntimeType
- GetTypeStatic();
-
- lldb_private::ConstString
- GetPluginName() override
- {
- return GetPluginNameStatic();
- }
-
- virtual lldb::InstrumentationRuntimeType
- GetType() { return GetTypeStatic(); }
-
- uint32_t
- GetPluginVersion() override
- {
- return 1;
- }
-
- lldb::ThreadCollectionSP
- GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
-
+ ~ThreadSanitizerRuntime() override;
+
+ static lldb::InstrumentationRuntimeSP
+ CreateInstance(const lldb::ProcessSP &process_sp);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static lldb::InstrumentationRuntimeType GetTypeStatic();
+
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ lldb::ThreadCollectionSP
+ GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
+
private:
- ThreadSanitizerRuntime(const lldb::ProcessSP &process_sp) : lldb_private::InstrumentationRuntime(process_sp) {}
+ ThreadSanitizerRuntime(const lldb::ProcessSP &process_sp)
+ : lldb_private::InstrumentationRuntime(process_sp) {}
+
+ const RegularExpression &GetPatternForRuntimeLibrary() override;
+
+ bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
+
+ void Activate() override;
- const RegularExpression &
- GetPatternForRuntimeLibrary() override;
+ void Deactivate();
- bool
- CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
+ static bool NotifyBreakpointHit(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
- void
- Activate() override;
-
- void
- Deactivate();
-
- static bool
- NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
-
- StructuredData::ObjectSP
- RetrieveReportData(ExecutionContextRef exe_ctx_ref);
-
- std::string
- FormatDescription(StructuredData::ObjectSP report);
-
- std::string
- GenerateSummary(StructuredData::ObjectSP report);
-
- lldb::addr_t
- GetMainRacyAddress(StructuredData::ObjectSP report);
-
- std::string
- GetLocationDescription(StructuredData::ObjectSP report, lldb::addr_t &global_addr, std::string &global_name, std::string &filename, uint32_t &line);
-
- lldb::addr_t
- GetFirstNonInternalFramePc(StructuredData::ObjectSP trace);
+ StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
+
+ std::string FormatDescription(StructuredData::ObjectSP report);
+
+ std::string GenerateSummary(StructuredData::ObjectSP report);
+
+ lldb::addr_t GetMainRacyAddress(StructuredData::ObjectSP report);
+
+ std::string GetLocationDescription(StructuredData::ObjectSP report,
+ lldb::addr_t &global_addr,
+ std::string &global_name,
+ std::string &filename, uint32_t &line);
+
+ lldb::addr_t GetFirstNonInternalFramePc(StructuredData::ObjectSP trace);
};
-
+
} // namespace lldb_private
#endif // liblldb_ThreadSanitizerRuntime_h_
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp Tue Sep 6 15:57:50 2016
@@ -13,10 +13,10 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -35,507 +35,420 @@ using namespace lldb_private;
//------------------------------------------------------------------
// Debug Interface Structures
//------------------------------------------------------------------
-typedef enum
-{
- JIT_NOACTION = 0,
- JIT_REGISTER_FN,
- JIT_UNREGISTER_FN
+typedef enum {
+ JIT_NOACTION = 0,
+ JIT_REGISTER_FN,
+ JIT_UNREGISTER_FN
} jit_actions_t;
-template <typename ptr_t>
-struct jit_code_entry
-{
- ptr_t next_entry; // pointer
- ptr_t prev_entry; // pointer
- ptr_t symfile_addr; // pointer
- uint64_t symfile_size;
+template <typename ptr_t> struct jit_code_entry {
+ ptr_t next_entry; // pointer
+ ptr_t prev_entry; // pointer
+ ptr_t symfile_addr; // pointer
+ uint64_t symfile_size;
};
-template <typename ptr_t>
-struct jit_descriptor
-{
- uint32_t version;
- uint32_t action_flag; // Values are jit_action_t
- ptr_t relevant_entry; // pointer
- ptr_t first_entry; // pointer
+template <typename ptr_t> struct jit_descriptor {
+ uint32_t version;
+ uint32_t action_flag; // Values are jit_action_t
+ ptr_t relevant_entry; // pointer
+ ptr_t first_entry; // pointer
};
namespace {
- PropertyDefinition
- g_properties[] =
- {
- { "enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true , nullptr, nullptr, "Enable breakpoint on __jit_debug_register_code." },
- { nullptr , OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr }
- };
-
- enum
- {
- ePropertyEnableJITBreakpoint
- };
-
-
- class PluginProperties : public Properties
- {
- public:
- static ConstString
- GetSettingName()
- {
- return JITLoaderGDB::GetPluginNameStatic();
- }
-
- PluginProperties()
- {
- m_collection_sp.reset (new OptionValueProperties(GetSettingName()));
- m_collection_sp->Initialize(g_properties);
- }
-
- bool
- GetEnableJITBreakpoint() const
- {
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr,
- ePropertyEnableJITBreakpoint,
- g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
- }
-
- };
-
- typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
-
- static const JITLoaderGDBPropertiesSP&
- GetGlobalPluginProperties()
- {
- static const auto g_settings_sp(std::make_shared<PluginProperties>());
- return g_settings_sp;
- }
-
- template <typename ptr_t>
- bool ReadJITEntry(const addr_t from_addr, Process *process, jit_code_entry<ptr_t> *entry)
- {
- lldbassert(from_addr % sizeof(ptr_t) == 0);
-
- ArchSpec::Core core = process->GetTarget().GetArchitecture().GetCore();
- bool i386_target = ArchSpec::kCore_x86_32_first <= core && core <= ArchSpec::kCore_x86_32_last;
- uint8_t uint64_align_bytes = i386_target ? 4 : 8;
- const size_t data_byte_size = llvm::alignTo(sizeof(ptr_t) * 3, uint64_align_bytes) + sizeof(uint64_t);
-
- Error error;
- DataBufferHeap data(data_byte_size, 0);
- size_t bytes_read = process->ReadMemory(from_addr, data.GetBytes(), data.GetByteSize(), error);
- if (bytes_read != data_byte_size || !error.Success())
- return false;
-
- DataExtractor extractor (data.GetBytes(), data.GetByteSize(), process->GetByteOrder(), sizeof(ptr_t));
- lldb::offset_t offset = 0;
- entry->next_entry = extractor.GetPointer(&offset);
- entry->prev_entry = extractor.GetPointer(&offset);
- entry->symfile_addr = extractor.GetPointer(&offset);
- offset = llvm::alignTo(offset, uint64_align_bytes);
- entry->symfile_size = extractor.GetU64(&offset);
-
- return true;
- }
+PropertyDefinition g_properties[] = {
+ {"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
+ nullptr, "Enable breakpoint on __jit_debug_register_code."},
+ {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
+
+enum { ePropertyEnableJITBreakpoint };
+
+class PluginProperties : public Properties {
+public:
+ static ConstString GetSettingName() {
+ return JITLoaderGDB::GetPluginNameStatic();
+ }
+
+ PluginProperties() {
+ m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp->Initialize(g_properties);
+ }
+
+ bool GetEnableJITBreakpoint() const {
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyEnableJITBreakpoint,
+ g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
+ }
+};
-} // anonymous namespace end
+typedef std::shared_ptr<PluginProperties> JITLoaderGDBPropertiesSP;
-JITLoaderGDB::JITLoaderGDB (lldb_private::Process *process) :
- JITLoader(process),
- m_jit_objects(),
- m_jit_break_id(LLDB_INVALID_BREAK_ID),
- m_jit_descriptor_addr(LLDB_INVALID_ADDRESS)
-{
-}
-
-JITLoaderGDB::~JITLoaderGDB ()
-{
- if (LLDB_BREAK_ID_IS_VALID(m_jit_break_id))
- m_process->GetTarget().RemoveBreakpointByID (m_jit_break_id);
-}
-
-void
-JITLoaderGDB::DebuggerInitialize(Debugger &debugger)
-{
- if (!PluginManager::GetSettingForJITLoaderPlugin(debugger, PluginProperties::GetSettingName()))
- {
- const bool is_global_setting = true;
- PluginManager::CreateSettingForJITLoaderPlugin(debugger,
- GetGlobalPluginProperties()->GetValueProperties(),
- ConstString ("Properties for the JIT LoaderGDB plug-in."),
- is_global_setting);
- }
+static const JITLoaderGDBPropertiesSP &GetGlobalPluginProperties() {
+ static const auto g_settings_sp(std::make_shared<PluginProperties>());
+ return g_settings_sp;
}
-void JITLoaderGDB::DidAttach()
-{
- Target &target = m_process->GetTarget();
- ModuleList &module_list = target.GetImages();
- SetJITBreakpoint(module_list);
+template <typename ptr_t>
+bool ReadJITEntry(const addr_t from_addr, Process *process,
+ jit_code_entry<ptr_t> *entry) {
+ lldbassert(from_addr % sizeof(ptr_t) == 0);
+
+ ArchSpec::Core core = process->GetTarget().GetArchitecture().GetCore();
+ bool i386_target = ArchSpec::kCore_x86_32_first <= core &&
+ core <= ArchSpec::kCore_x86_32_last;
+ uint8_t uint64_align_bytes = i386_target ? 4 : 8;
+ const size_t data_byte_size =
+ llvm::alignTo(sizeof(ptr_t) * 3, uint64_align_bytes) + sizeof(uint64_t);
+
+ Error error;
+ DataBufferHeap data(data_byte_size, 0);
+ size_t bytes_read = process->ReadMemory(from_addr, data.GetBytes(),
+ data.GetByteSize(), error);
+ if (bytes_read != data_byte_size || !error.Success())
+ return false;
+
+ DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
+ process->GetByteOrder(), sizeof(ptr_t));
+ lldb::offset_t offset = 0;
+ entry->next_entry = extractor.GetPointer(&offset);
+ entry->prev_entry = extractor.GetPointer(&offset);
+ entry->symfile_addr = extractor.GetPointer(&offset);
+ offset = llvm::alignTo(offset, uint64_align_bytes);
+ entry->symfile_size = extractor.GetU64(&offset);
+
+ return true;
+}
+
+} // anonymous namespace end
+
+JITLoaderGDB::JITLoaderGDB(lldb_private::Process *process)
+ : JITLoader(process), m_jit_objects(),
+ m_jit_break_id(LLDB_INVALID_BREAK_ID),
+ m_jit_descriptor_addr(LLDB_INVALID_ADDRESS) {}
+
+JITLoaderGDB::~JITLoaderGDB() {
+ if (LLDB_BREAK_ID_IS_VALID(m_jit_break_id))
+ m_process->GetTarget().RemoveBreakpointByID(m_jit_break_id);
+}
+
+void JITLoaderGDB::DebuggerInitialize(Debugger &debugger) {
+ if (!PluginManager::GetSettingForJITLoaderPlugin(
+ debugger, PluginProperties::GetSettingName())) {
+ const bool is_global_setting = true;
+ PluginManager::CreateSettingForJITLoaderPlugin(
+ debugger, GetGlobalPluginProperties()->GetValueProperties(),
+ ConstString("Properties for the JIT LoaderGDB plug-in."),
+ is_global_setting);
+ }
+}
+
+void JITLoaderGDB::DidAttach() {
+ Target &target = m_process->GetTarget();
+ ModuleList &module_list = target.GetImages();
+ SetJITBreakpoint(module_list);
+}
+
+void JITLoaderGDB::DidLaunch() {
+ Target &target = m_process->GetTarget();
+ ModuleList &module_list = target.GetImages();
+ SetJITBreakpoint(module_list);
}
-void JITLoaderGDB::DidLaunch()
-{
- Target &target = m_process->GetTarget();
- ModuleList &module_list = target.GetImages();
+void JITLoaderGDB::ModulesDidLoad(ModuleList &module_list) {
+ if (!DidSetJITBreakpoint() && m_process->IsAlive())
SetJITBreakpoint(module_list);
}
-void
-JITLoaderGDB::ModulesDidLoad(ModuleList &module_list)
-{
- if (!DidSetJITBreakpoint() && m_process->IsAlive())
- SetJITBreakpoint(module_list);
-}
-
//------------------------------------------------------------------
// Setup the JIT Breakpoint
//------------------------------------------------------------------
-void
-JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list)
-{
- if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint())
- return;
-
- if ( DidSetJITBreakpoint() )
- return;
-
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+void JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list) {
+ if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint())
+ return;
+
+ if (DidSetJITBreakpoint())
+ return;
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+ if (log)
+ log->Printf("JITLoaderGDB::%s looking for JIT register hook", __FUNCTION__);
+
+ addr_t jit_addr = GetSymbolAddress(
+ module_list, ConstString("__jit_debug_register_code"), eSymbolTypeAny);
+ if (jit_addr == LLDB_INVALID_ADDRESS)
+ return;
+
+ m_jit_descriptor_addr = GetSymbolAddress(
+ module_list, ConstString("__jit_debug_descriptor"), eSymbolTypeData);
+ if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS) {
if (log)
- log->Printf("JITLoaderGDB::%s looking for JIT register hook",
- __FUNCTION__);
-
- addr_t jit_addr = GetSymbolAddress(module_list,
- ConstString("__jit_debug_register_code"),
- eSymbolTypeAny);
- if (jit_addr == LLDB_INVALID_ADDRESS)
- return;
-
- m_jit_descriptor_addr = GetSymbolAddress(module_list,
- ConstString("__jit_debug_descriptor"),
- eSymbolTypeData);
- if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS)
- {
- if (log)
- log->Printf(
- "JITLoaderGDB::%s failed to find JIT descriptor address",
- __FUNCTION__);
- return;
- }
-
- if (log)
- log->Printf("JITLoaderGDB::%s setting JIT breakpoint",
- __FUNCTION__);
-
- Breakpoint *bp =
- m_process->GetTarget().CreateBreakpoint(jit_addr, true, false).get();
- bp->SetCallback(JITDebugBreakpointHit, this, true);
- bp->SetBreakpointKind("jit-debug-register");
- m_jit_break_id = bp->GetID();
-
- ReadJITDescriptor(true);
-}
-
-bool
-JITLoaderGDB::JITDebugBreakpointHit(void *baton,
- StoppointCallbackContext *context,
- user_id_t break_id, user_id_t break_loc_id)
-{
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
- if (log)
- log->Printf("JITLoaderGDB::%s hit JIT breakpoint",
- __FUNCTION__);
- JITLoaderGDB *instance = static_cast<JITLoaderGDB *>(baton);
- return instance->ReadJITDescriptor(false);
+ log->Printf("JITLoaderGDB::%s failed to find JIT descriptor address",
+ __FUNCTION__);
+ return;
+ }
+
+ if (log)
+ log->Printf("JITLoaderGDB::%s setting JIT breakpoint", __FUNCTION__);
+
+ Breakpoint *bp =
+ m_process->GetTarget().CreateBreakpoint(jit_addr, true, false).get();
+ bp->SetCallback(JITDebugBreakpointHit, this, true);
+ bp->SetBreakpointKind("jit-debug-register");
+ m_jit_break_id = bp->GetID();
+
+ ReadJITDescriptor(true);
+}
+
+bool JITLoaderGDB::JITDebugBreakpointHit(void *baton,
+ StoppointCallbackContext *context,
+ user_id_t break_id,
+ user_id_t break_loc_id) {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+ if (log)
+ log->Printf("JITLoaderGDB::%s hit JIT breakpoint", __FUNCTION__);
+ JITLoaderGDB *instance = static_cast<JITLoaderGDB *>(baton);
+ return instance->ReadJITDescriptor(false);
}
static void updateSectionLoadAddress(const SectionList §ion_list,
- Target &target,
- uint64_t symbolfile_addr,
+ Target &target, uint64_t symbolfile_addr,
uint64_t symbolfile_size,
uint64_t &vmaddrheuristic,
- uint64_t &min_addr,
- uint64_t &max_addr)
-{
- const uint32_t num_sections = section_list.GetSize();
- for (uint32_t i = 0; i<num_sections; ++i)
- {
- SectionSP section_sp(section_list.GetSectionAtIndex(i));
- if (section_sp)
- {
- if(section_sp->IsFake()) {
- uint64_t lower = (uint64_t)-1;
- uint64_t upper = 0;
- updateSectionLoadAddress(section_sp->GetChildren(), target, symbolfile_addr, symbolfile_size, vmaddrheuristic,
- lower, upper);
- if (lower < min_addr)
- min_addr = lower;
- if (upper > max_addr)
- max_addr = upper;
- const lldb::addr_t slide_amount = lower - section_sp->GetFileAddress();
- section_sp->Slide(slide_amount, false);
- section_sp->GetChildren().Slide(-slide_amount, false);
- section_sp->SetByteSize (upper - lower);
- } else {
- vmaddrheuristic += 2<<section_sp->GetLog2Align();
- uint64_t lower;
- if (section_sp->GetFileAddress() > vmaddrheuristic)
- lower = section_sp->GetFileAddress();
- else {
- lower = symbolfile_addr+section_sp->GetFileOffset();
- section_sp->SetFileAddress(symbolfile_addr+section_sp->GetFileOffset());
- }
- target.SetSectionLoadAddress(section_sp, lower, true);
- uint64_t upper = lower + section_sp->GetByteSize();
- if (lower < min_addr)
- min_addr = lower;
- if (upper > max_addr)
- max_addr = upper;
- // This is an upper bound, but a good enough heuristic
- vmaddrheuristic += section_sp->GetByteSize();
- }
+ uint64_t &min_addr, uint64_t &max_addr) {
+ const uint32_t num_sections = section_list.GetSize();
+ for (uint32_t i = 0; i < num_sections; ++i) {
+ SectionSP section_sp(section_list.GetSectionAtIndex(i));
+ if (section_sp) {
+ if (section_sp->IsFake()) {
+ uint64_t lower = (uint64_t)-1;
+ uint64_t upper = 0;
+ updateSectionLoadAddress(section_sp->GetChildren(), target,
+ symbolfile_addr, symbolfile_size,
+ vmaddrheuristic, lower, upper);
+ if (lower < min_addr)
+ min_addr = lower;
+ if (upper > max_addr)
+ max_addr = upper;
+ const lldb::addr_t slide_amount = lower - section_sp->GetFileAddress();
+ section_sp->Slide(slide_amount, false);
+ section_sp->GetChildren().Slide(-slide_amount, false);
+ section_sp->SetByteSize(upper - lower);
+ } else {
+ vmaddrheuristic += 2 << section_sp->GetLog2Align();
+ uint64_t lower;
+ if (section_sp->GetFileAddress() > vmaddrheuristic)
+ lower = section_sp->GetFileAddress();
+ else {
+ lower = symbolfile_addr + section_sp->GetFileOffset();
+ section_sp->SetFileAddress(symbolfile_addr +
+ section_sp->GetFileOffset());
}
+ target.SetSectionLoadAddress(section_sp, lower, true);
+ uint64_t upper = lower + section_sp->GetByteSize();
+ if (lower < min_addr)
+ min_addr = lower;
+ if (upper > max_addr)
+ max_addr = upper;
+ // This is an upper bound, but a good enough heuristic
+ vmaddrheuristic += section_sp->GetByteSize();
+ }
}
+ }
}
-bool
-JITLoaderGDB::ReadJITDescriptor(bool all_entries)
-{
- if (m_process->GetTarget().GetArchitecture().GetAddressByteSize() == 8)
- return ReadJITDescriptorImpl<uint64_t>(all_entries);
- else
- return ReadJITDescriptorImpl<uint32_t>(all_entries);
+bool JITLoaderGDB::ReadJITDescriptor(bool all_entries) {
+ if (m_process->GetTarget().GetArchitecture().GetAddressByteSize() == 8)
+ return ReadJITDescriptorImpl<uint64_t>(all_entries);
+ else
+ return ReadJITDescriptorImpl<uint32_t>(all_entries);
}
template <typename ptr_t>
-bool
-JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries)
-{
- if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
- Target &target = m_process->GetTarget();
- ModuleList &module_list = target.GetImages();
-
- jit_descriptor<ptr_t> jit_desc;
- const size_t jit_desc_size = sizeof(jit_desc);
- Error error;
- size_t bytes_read = m_process->DoReadMemory(
- m_jit_descriptor_addr, &jit_desc, jit_desc_size, error);
- if (bytes_read != jit_desc_size || !error.Success())
- {
- if (log)
- log->Printf("JITLoaderGDB::%s failed to read JIT descriptor",
- __FUNCTION__);
- return false;
- }
-
- jit_actions_t jit_action = (jit_actions_t)jit_desc.action_flag;
- addr_t jit_relevant_entry = (addr_t)jit_desc.relevant_entry;
- if (all_entries)
- {
- jit_action = JIT_REGISTER_FN;
- jit_relevant_entry = (addr_t)jit_desc.first_entry;
- }
-
- while (jit_relevant_entry != 0)
- {
- jit_code_entry<ptr_t> jit_entry;
- if (!ReadJITEntry(jit_relevant_entry, m_process, &jit_entry))
- {
- if (log)
- log->Printf(
- "JITLoaderGDB::%s failed to read JIT entry at 0x%" PRIx64,
+bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
+ if (m_jit_descriptor_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_JIT_LOADER));
+ Target &target = m_process->GetTarget();
+ ModuleList &module_list = target.GetImages();
+
+ jit_descriptor<ptr_t> jit_desc;
+ const size_t jit_desc_size = sizeof(jit_desc);
+ Error error;
+ size_t bytes_read = m_process->DoReadMemory(m_jit_descriptor_addr, &jit_desc,
+ jit_desc_size, error);
+ if (bytes_read != jit_desc_size || !error.Success()) {
+ if (log)
+ log->Printf("JITLoaderGDB::%s failed to read JIT descriptor",
+ __FUNCTION__);
+ return false;
+ }
+
+ jit_actions_t jit_action = (jit_actions_t)jit_desc.action_flag;
+ addr_t jit_relevant_entry = (addr_t)jit_desc.relevant_entry;
+ if (all_entries) {
+ jit_action = JIT_REGISTER_FN;
+ jit_relevant_entry = (addr_t)jit_desc.first_entry;
+ }
+
+ while (jit_relevant_entry != 0) {
+ jit_code_entry<ptr_t> jit_entry;
+ if (!ReadJITEntry(jit_relevant_entry, m_process, &jit_entry)) {
+ if (log)
+ log->Printf("JITLoaderGDB::%s failed to read JIT entry at 0x%" PRIx64,
__FUNCTION__, jit_relevant_entry);
- return false;
- }
+ return false;
+ }
- const addr_t &symbolfile_addr = (addr_t)jit_entry.symfile_addr;
- const size_t &symbolfile_size = (size_t)jit_entry.symfile_size;
- ModuleSP module_sp;
-
- if (jit_action == JIT_REGISTER_FN)
- {
- if (log)
- log->Printf(
- "JITLoaderGDB::%s registering JIT entry at 0x%" PRIx64
+ const addr_t &symbolfile_addr = (addr_t)jit_entry.symfile_addr;
+ const size_t &symbolfile_size = (size_t)jit_entry.symfile_size;
+ ModuleSP module_sp;
+
+ if (jit_action == JIT_REGISTER_FN) {
+ if (log)
+ log->Printf("JITLoaderGDB::%s registering JIT entry at 0x%" PRIx64
" (%" PRIu64 " bytes)",
- __FUNCTION__, symbolfile_addr, (uint64_t) symbolfile_size);
+ __FUNCTION__, symbolfile_addr, (uint64_t)symbolfile_size);
- char jit_name[64];
- snprintf(jit_name, 64, "JIT(0x%" PRIx64 ")", symbolfile_addr);
- module_sp = m_process->ReadModuleFromMemory(
- FileSpec(jit_name, false), symbolfile_addr, symbolfile_size);
-
- if (module_sp && module_sp->GetObjectFile())
- {
- // load the symbol table right away
- module_sp->GetObjectFile()->GetSymtab();
-
- m_jit_objects.insert(std::make_pair(symbolfile_addr, module_sp));
- if (module_sp->GetObjectFile()->GetPluginName() == ConstString("mach-o"))
- {
- ObjectFile *image_object_file = module_sp->GetObjectFile();
- if (image_object_file)
- {
- const SectionList *section_list = image_object_file->GetSectionList ();
- if (section_list)
- {
- uint64_t vmaddrheuristic = 0;
- uint64_t lower = (uint64_t)-1;
- uint64_t upper = 0;
- updateSectionLoadAddress(*section_list, target, symbolfile_addr, symbolfile_size,
- vmaddrheuristic, lower, upper);
- }
- }
- }
- else
- {
- bool changed = false;
- module_sp->SetLoadAddress(target, 0, true, changed);
- }
-
- module_list.AppendIfNeeded(module_sp);
-
- ModuleList module_list;
- module_list.Append(module_sp);
- target.ModulesDidLoad(module_list);
- }
- else
- {
- if (log)
- log->Printf("JITLoaderGDB::%s failed to load module for "
- "JIT entry at 0x%" PRIx64,
- __FUNCTION__, symbolfile_addr);
+ char jit_name[64];
+ snprintf(jit_name, 64, "JIT(0x%" PRIx64 ")", symbolfile_addr);
+ module_sp = m_process->ReadModuleFromMemory(
+ FileSpec(jit_name, false), symbolfile_addr, symbolfile_size);
+
+ if (module_sp && module_sp->GetObjectFile()) {
+ // load the symbol table right away
+ module_sp->GetObjectFile()->GetSymtab();
+
+ m_jit_objects.insert(std::make_pair(symbolfile_addr, module_sp));
+ if (module_sp->GetObjectFile()->GetPluginName() ==
+ ConstString("mach-o")) {
+ ObjectFile *image_object_file = module_sp->GetObjectFile();
+ if (image_object_file) {
+ const SectionList *section_list =
+ image_object_file->GetSectionList();
+ if (section_list) {
+ uint64_t vmaddrheuristic = 0;
+ uint64_t lower = (uint64_t)-1;
+ uint64_t upper = 0;
+ updateSectionLoadAddress(*section_list, target, symbolfile_addr,
+ symbolfile_size, vmaddrheuristic, lower,
+ upper);
}
+ }
+ } else {
+ bool changed = false;
+ module_sp->SetLoadAddress(target, 0, true, changed);
}
- else if (jit_action == JIT_UNREGISTER_FN)
- {
- if (log)
- log->Printf(
- "JITLoaderGDB::%s unregistering JIT entry at 0x%" PRIx64,
+
+ module_list.AppendIfNeeded(module_sp);
+
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ target.ModulesDidLoad(module_list);
+ } else {
+ if (log)
+ log->Printf("JITLoaderGDB::%s failed to load module for "
+ "JIT entry at 0x%" PRIx64,
+ __FUNCTION__, symbolfile_addr);
+ }
+ } else if (jit_action == JIT_UNREGISTER_FN) {
+ if (log)
+ log->Printf("JITLoaderGDB::%s unregistering JIT entry at 0x%" PRIx64,
__FUNCTION__, symbolfile_addr);
- JITObjectMap::iterator it = m_jit_objects.find(symbolfile_addr);
- if (it != m_jit_objects.end())
- {
- module_sp = it->second;
- ObjectFile *image_object_file = module_sp->GetObjectFile();
- if (image_object_file)
- {
- const SectionList *section_list = image_object_file->GetSectionList ();
- if (section_list)
- {
- const uint32_t num_sections = section_list->GetSize();
- for (uint32_t i = 0; i<num_sections; ++i)
- {
- SectionSP section_sp(section_list->GetSectionAtIndex(i));
- if (section_sp)
- {
- target.GetSectionLoadList().SetSectionUnloaded (section_sp);
- }
- }
- }
- }
- module_list.Remove(module_sp);
- m_jit_objects.erase(it);
+ JITObjectMap::iterator it = m_jit_objects.find(symbolfile_addr);
+ if (it != m_jit_objects.end()) {
+ module_sp = it->second;
+ ObjectFile *image_object_file = module_sp->GetObjectFile();
+ if (image_object_file) {
+ const SectionList *section_list = image_object_file->GetSectionList();
+ if (section_list) {
+ const uint32_t num_sections = section_list->GetSize();
+ for (uint32_t i = 0; i < num_sections; ++i) {
+ SectionSP section_sp(section_list->GetSectionAtIndex(i));
+ if (section_sp) {
+ target.GetSectionLoadList().SetSectionUnloaded(section_sp);
+ }
}
+ }
}
- else if (jit_action == JIT_NOACTION)
- {
- // Nothing to do
- }
- else
- {
- assert(false && "Unknown jit action");
- }
-
- if (all_entries)
- jit_relevant_entry = (addr_t)jit_entry.next_entry;
- else
- jit_relevant_entry = 0;
+ module_list.Remove(module_sp);
+ m_jit_objects.erase(it);
+ }
+ } else if (jit_action == JIT_NOACTION) {
+ // Nothing to do
+ } else {
+ assert(false && "Unknown jit action");
}
- return false; // Continue Running.
+ if (all_entries)
+ jit_relevant_entry = (addr_t)jit_entry.next_entry;
+ else
+ jit_relevant_entry = 0;
+ }
+
+ return false; // Continue Running.
}
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
-lldb_private::ConstString
-JITLoaderGDB::GetPluginNameStatic()
-{
- static ConstString g_name("gdb");
- return g_name;
+lldb_private::ConstString JITLoaderGDB::GetPluginNameStatic() {
+ static ConstString g_name("gdb");
+ return g_name;
}
-JITLoaderSP
-JITLoaderGDB::CreateInstance(Process *process, bool force)
-{
- JITLoaderSP jit_loader_sp;
- ArchSpec arch (process->GetTarget().GetArchitecture());
- if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
- jit_loader_sp.reset(new JITLoaderGDB(process));
- return jit_loader_sp;
+JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
+ JITLoaderSP jit_loader_sp;
+ ArchSpec arch(process->GetTarget().GetArchitecture());
+ if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
+ jit_loader_sp.reset(new JITLoaderGDB(process));
+ return jit_loader_sp;
}
-const char *
-JITLoaderGDB::GetPluginDescriptionStatic()
-{
- return "JIT loader plug-in that watches for JIT events using the GDB interface.";
+const char *JITLoaderGDB::GetPluginDescriptionStatic() {
+ return "JIT loader plug-in that watches for JIT events using the GDB "
+ "interface.";
}
-lldb_private::ConstString
-JITLoaderGDB::GetPluginName()
-{
- return GetPluginNameStatic();
+lldb_private::ConstString JITLoaderGDB::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-JITLoaderGDB::GetPluginVersion()
-{
- return 1;
-}
+uint32_t JITLoaderGDB::GetPluginVersion() { return 1; }
-void
-JITLoaderGDB::Initialize()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- CreateInstance,
- DebuggerInitialize);
+void JITLoaderGDB::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance,
+ DebuggerInitialize);
}
-void
-JITLoaderGDB::Terminate()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
+void JITLoaderGDB::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-bool
-JITLoaderGDB::DidSetJITBreakpoint() const
-{
- return LLDB_BREAK_ID_IS_VALID(m_jit_break_id);
+bool JITLoaderGDB::DidSetJITBreakpoint() const {
+ return LLDB_BREAK_ID_IS_VALID(m_jit_break_id);
}
-addr_t
-JITLoaderGDB::GetSymbolAddress(ModuleList &module_list, const ConstString &name,
- SymbolType symbol_type) const
-{
- SymbolContextList target_symbols;
- Target &target = m_process->GetTarget();
+addr_t JITLoaderGDB::GetSymbolAddress(ModuleList &module_list,
+ const ConstString &name,
+ SymbolType symbol_type) const {
+ SymbolContextList target_symbols;
+ Target &target = m_process->GetTarget();
- if (!module_list.FindSymbolsWithNameAndType(name, symbol_type,
- target_symbols))
- return LLDB_INVALID_ADDRESS;
+ if (!module_list.FindSymbolsWithNameAndType(name, symbol_type,
+ target_symbols))
+ return LLDB_INVALID_ADDRESS;
- SymbolContext sym_ctx;
- target_symbols.GetContextAtIndex(0, sym_ctx);
+ SymbolContext sym_ctx;
+ target_symbols.GetContextAtIndex(0, sym_ctx);
- const Address jit_descriptor_addr = sym_ctx.symbol->GetAddress();
- if (!jit_descriptor_addr.IsValid())
- return LLDB_INVALID_ADDRESS;
+ const Address jit_descriptor_addr = sym_ctx.symbol->GetAddress();
+ if (!jit_descriptor_addr.IsValid())
+ return LLDB_INVALID_ADDRESS;
- const addr_t jit_addr = jit_descriptor_addr.GetLoadAddress(&target);
- return jit_addr;
+ const addr_t jit_addr = jit_descriptor_addr.GetLoadAddress(&target);
+ return jit_addr;
}
Modified: lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h (original)
+++ lldb/trunk/source/Plugins/JITLoader/GDB/JITLoaderGDB.h Tue Sep 6 15:57:50 2016
@@ -19,92 +19,73 @@
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/Process.h"
-class JITLoaderGDB : public lldb_private::JITLoader
-{
+class JITLoaderGDB : public lldb_private::JITLoader {
public:
- JITLoaderGDB(lldb_private::Process *process);
+ JITLoaderGDB(lldb_private::Process *process);
- ~JITLoaderGDB() override;
+ ~JITLoaderGDB() override;
- //------------------------------------------------------------------
- // Static Functions
- //------------------------------------------------------------------
- static void
- Initialize();
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- static lldb_private::ConstString
- GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- static const char *
- GetPluginDescriptionStatic();
+ static const char *GetPluginDescriptionStatic();
- static lldb::JITLoaderSP
- CreateInstance (lldb_private::Process *process, bool force);
+ static lldb::JITLoaderSP CreateInstance(lldb_private::Process *process,
+ bool force);
- static void
- DebuggerInitialize(lldb_private::Debugger &debugger);
+ static void DebuggerInitialize(lldb_private::Debugger &debugger);
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- lldb_private::ConstString
- GetPluginName() override;
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
- // JITLoader interface
- //------------------------------------------------------------------
- void
- DidAttach() override;
+ //------------------------------------------------------------------
+ // JITLoader interface
+ //------------------------------------------------------------------
+ void DidAttach() override;
- void
- DidLaunch() override;
+ void DidLaunch() override;
- void
- ModulesDidLoad(lldb_private::ModuleList &module_list) override;
+ void ModulesDidLoad(lldb_private::ModuleList &module_list) override;
private:
- lldb::addr_t
- GetSymbolAddress(lldb_private::ModuleList &module_list,
- const lldb_private::ConstString &name,
- lldb::SymbolType symbol_type) const;
-
- void
- SetJITBreakpoint(lldb_private::ModuleList &module_list);
-
- bool
- DidSetJITBreakpoint() const;
-
- bool
- ReadJITDescriptor(bool all_entries);
-
- template <typename ptr_t>
- bool
- ReadJITDescriptorImpl(bool all_entries);
-
- static bool
- JITDebugBreakpointHit(void *baton,
- lldb_private::StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- static void
- ProcessStateChangedCallback(void *baton,
- lldb_private::Process *process,
- lldb::StateType state);
-
- // A collection of in-memory jitted object addresses and their corresponding modules
- typedef std::map<lldb::addr_t, const lldb::ModuleSP> JITObjectMap;
- JITObjectMap m_jit_objects;
+ lldb::addr_t GetSymbolAddress(lldb_private::ModuleList &module_list,
+ const lldb_private::ConstString &name,
+ lldb::SymbolType symbol_type) const;
- lldb::user_id_t m_jit_break_id;
- lldb::addr_t m_jit_descriptor_addr;
+ void SetJITBreakpoint(lldb_private::ModuleList &module_list);
+ bool DidSetJITBreakpoint() const;
+
+ bool ReadJITDescriptor(bool all_entries);
+
+ template <typename ptr_t> bool ReadJITDescriptorImpl(bool all_entries);
+
+ static bool
+ JITDebugBreakpointHit(void *baton,
+ lldb_private::StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
+ static void ProcessStateChangedCallback(void *baton,
+ lldb_private::Process *process,
+ lldb::StateType state);
+
+ // A collection of in-memory jitted object addresses and their corresponding
+ // modules
+ typedef std::map<lldb::addr_t, const lldb::ModuleSP> JITObjectMap;
+ JITObjectMap m_jit_objects;
+
+ lldb::user_id_t m_jit_break_id;
+ lldb::addr_t m_jit_descriptor_addr;
};
#endif // liblldb_JITLoaderGDB_h_
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.cpp Tue Sep 6 15:57:50 2016
@@ -27,199 +27,185 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-namespace lldb_private
-{
-namespace formatters
-{
+namespace lldb_private {
+namespace formatters {
-class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd
-{
+class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
- BlockPointerSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
- : SyntheticChildrenFrontEnd(*valobj_sp),
- m_block_struct_type()
- {
- CompilerType block_pointer_type(m_backend.GetCompilerType());
- CompilerType function_pointer_type;
- block_pointer_type.IsBlockPointerType(&function_pointer_type);
-
- TargetSP target_sp(m_backend.GetTargetSP());
-
- if (!target_sp)
- {
- return;
- }
-
- Error err;
- TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(&err, lldb::eLanguageTypeC_plus_plus);
-
- if (!err.Success() || !type_system)
- {
- return;
- }
-
- ClangASTContext *clang_ast_context = llvm::dyn_cast<ClangASTContext>(type_system);
-
- if (!clang_ast_context)
- {
- return;
- }
-
- ClangASTImporterSP clang_ast_importer = target_sp->GetClangASTImporter();
-
- if (!clang_ast_importer)
- {
- return;
- }
-
- const char *const isa_name("__isa");
- const CompilerType isa_type = clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);
- const char *const flags_name("__flags");
- const CompilerType flags_type = clang_ast_context->GetBasicType(lldb::eBasicTypeInt);
- const char *const reserved_name("__reserved");
- const CompilerType reserved_type = clang_ast_context->GetBasicType(lldb::eBasicTypeInt);
- const char *const FuncPtr_name("__FuncPtr");
- const CompilerType FuncPtr_type = clang_ast_importer->CopyType(*clang_ast_context, function_pointer_type);
-
- m_block_struct_type = clang_ast_context->CreateStructForIdentifier(ConstString(),
- {
- {isa_name, isa_type},
- {flags_name, flags_type},
- {reserved_name, reserved_type},
- {FuncPtr_name, FuncPtr_type}
- });
-
- }
-
- ~BlockPointerSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override
- {
- const bool omit_empty_base_classes = false;
- return m_block_struct_type.GetNumChildren(omit_empty_base_classes);
- }
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override
- {
- if (!m_block_struct_type.IsValid())
- {
- return lldb::ValueObjectSP();
- }
-
- if (idx >= CalculateNumChildren())
- {
- return lldb::ValueObjectSP();
- }
-
- const bool thread_and_frame_only_if_stopped = true;
- ExecutionContext exe_ctx = m_backend.GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped);
- const bool transparent_pointers = false;
- const bool omit_empty_base_classes = false;
- const bool ignore_array_bounds = false;
- ValueObject *value_object = nullptr;
-
- std::string child_name;
- uint32_t child_byte_size = 0;
- int32_t child_byte_offset = 0;
- uint32_t child_bitfield_bit_size = 0;
- uint32_t child_bitfield_bit_offset = 0;
- bool child_is_base_class = false;
- bool child_is_deref_of_parent = false;
- uint64_t language_flags = 0;
-
- const CompilerType child_type = m_block_struct_type.GetChildCompilerTypeAtIndex(&exe_ctx, idx, transparent_pointers, omit_empty_base_classes, ignore_array_bounds, child_name, child_byte_size, child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, child_is_deref_of_parent, value_object, language_flags);
-
- ValueObjectSP struct_pointer_sp = m_backend.Cast(m_block_struct_type.GetPointerType());
-
- if (!struct_pointer_sp)
- {
- return lldb::ValueObjectSP();
- }
-
- Error err;
- ValueObjectSP struct_sp = struct_pointer_sp->Dereference(err);
-
- if (!struct_sp || !err.Success())
- {
- return lldb::ValueObjectSP();
- }
-
- ValueObjectSP child_sp(struct_sp->GetSyntheticChildAtOffset(child_byte_offset,
- child_type,
- true,
- ConstString(child_name.c_str(), child_name.size())));
-
- return child_sp;
- }
-
- // return true if this object is now safe to use forever without
- // ever updating again; the typical (and tested) answer here is
- // 'false'
- bool
- Update() override
- {
- return false;
- }
-
- // maybe return false if the block pointer is, say, null
- bool
- MightHaveChildren() override
- {
- return true;
- }
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override
- {
- if (!m_block_struct_type.IsValid())
- return UINT32_MAX;
-
- const bool omit_empty_base_classes = false;
- return m_block_struct_type.GetIndexOfChildWithName(name.AsCString(), omit_empty_base_classes);
+ BlockPointerSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_block_struct_type() {
+ CompilerType block_pointer_type(m_backend.GetCompilerType());
+ CompilerType function_pointer_type;
+ block_pointer_type.IsBlockPointerType(&function_pointer_type);
+
+ TargetSP target_sp(m_backend.GetTargetSP());
+
+ if (!target_sp) {
+ return;
+ }
+
+ Error err;
+ TypeSystem *type_system = target_sp->GetScratchTypeSystemForLanguage(
+ &err, lldb::eLanguageTypeC_plus_plus);
+
+ if (!err.Success() || !type_system) {
+ return;
+ }
+
+ ClangASTContext *clang_ast_context =
+ llvm::dyn_cast<ClangASTContext>(type_system);
+
+ if (!clang_ast_context) {
+ return;
+ }
+
+ ClangASTImporterSP clang_ast_importer = target_sp->GetClangASTImporter();
+
+ if (!clang_ast_importer) {
+ return;
+ }
+
+ const char *const isa_name("__isa");
+ const CompilerType isa_type =
+ clang_ast_context->GetBasicType(lldb::eBasicTypeObjCClass);
+ const char *const flags_name("__flags");
+ const CompilerType flags_type =
+ clang_ast_context->GetBasicType(lldb::eBasicTypeInt);
+ const char *const reserved_name("__reserved");
+ const CompilerType reserved_type =
+ clang_ast_context->GetBasicType(lldb::eBasicTypeInt);
+ const char *const FuncPtr_name("__FuncPtr");
+ const CompilerType FuncPtr_type =
+ clang_ast_importer->CopyType(*clang_ast_context, function_pointer_type);
+
+ m_block_struct_type = clang_ast_context->CreateStructForIdentifier(
+ ConstString(), {{isa_name, isa_type},
+ {flags_name, flags_type},
+ {reserved_name, reserved_type},
+ {FuncPtr_name, FuncPtr_type}});
+ }
+
+ ~BlockPointerSyntheticFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override {
+ const bool omit_empty_base_classes = false;
+ return m_block_struct_type.GetNumChildren(omit_empty_base_classes);
+ }
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
+ if (!m_block_struct_type.IsValid()) {
+ return lldb::ValueObjectSP();
}
+ if (idx >= CalculateNumChildren()) {
+ return lldb::ValueObjectSP();
+ }
+
+ const bool thread_and_frame_only_if_stopped = true;
+ ExecutionContext exe_ctx = m_backend.GetExecutionContextRef().Lock(
+ thread_and_frame_only_if_stopped);
+ const bool transparent_pointers = false;
+ const bool omit_empty_base_classes = false;
+ const bool ignore_array_bounds = false;
+ ValueObject *value_object = nullptr;
+
+ std::string child_name;
+ uint32_t child_byte_size = 0;
+ int32_t child_byte_offset = 0;
+ uint32_t child_bitfield_bit_size = 0;
+ uint32_t child_bitfield_bit_offset = 0;
+ bool child_is_base_class = false;
+ bool child_is_deref_of_parent = false;
+ uint64_t language_flags = 0;
+
+ const CompilerType child_type =
+ m_block_struct_type.GetChildCompilerTypeAtIndex(
+ &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
+ ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
+ child_bitfield_bit_size, child_bitfield_bit_offset,
+ child_is_base_class, child_is_deref_of_parent, value_object,
+ language_flags);
+
+ ValueObjectSP struct_pointer_sp =
+ m_backend.Cast(m_block_struct_type.GetPointerType());
+
+ if (!struct_pointer_sp) {
+ return lldb::ValueObjectSP();
+ }
+
+ Error err;
+ ValueObjectSP struct_sp = struct_pointer_sp->Dereference(err);
+
+ if (!struct_sp || !err.Success()) {
+ return lldb::ValueObjectSP();
+ }
+
+ ValueObjectSP child_sp(struct_sp->GetSyntheticChildAtOffset(
+ child_byte_offset, child_type, true,
+ ConstString(child_name.c_str(), child_name.size())));
+
+ return child_sp;
+ }
+
+ // return true if this object is now safe to use forever without
+ // ever updating again; the typical (and tested) answer here is
+ // 'false'
+ bool Update() override { return false; }
+
+ // maybe return false if the block pointer is, say, null
+ bool MightHaveChildren() override { return true; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ if (!m_block_struct_type.IsValid())
+ return UINT32_MAX;
+
+ const bool omit_empty_base_classes = false;
+ return m_block_struct_type.GetIndexOfChildWithName(name.AsCString(),
+ omit_empty_base_classes);
+ }
+
private:
- CompilerType m_block_struct_type;
+ CompilerType m_block_struct_type;
};
} // namespace formatters
} // namespace lldb_private
-bool
-lldb_private::formatters::BlockPointerSummaryProvider(ValueObject &valobj, Stream &s, const TypeSummaryOptions &)
-{
- lldb_private::SyntheticChildrenFrontEnd *synthetic_children = BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
- if (!synthetic_children)
- {
- return false;
- }
+bool lldb_private::formatters::BlockPointerSummaryProvider(
+ ValueObject &valobj, Stream &s, const TypeSummaryOptions &) {
+ lldb_private::SyntheticChildrenFrontEnd *synthetic_children =
+ BlockPointerSyntheticFrontEndCreator(nullptr, valobj.GetSP());
+ if (!synthetic_children) {
+ return false;
+ }
- synthetic_children->Update();
+ synthetic_children->Update();
- static const ConstString s_FuncPtr_name("__FuncPtr");
-
- lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex(synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name));
-
- if (!child_sp)
- {
- return false;
- }
-
- lldb::ValueObjectSP qualified_child_representation_sp = child_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true);
+ static const ConstString s_FuncPtr_name("__FuncPtr");
+
+ lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex(
+ synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name));
+
+ if (!child_sp) {
+ return false;
+ }
+
+ lldb::ValueObjectSP qualified_child_representation_sp =
+ child_sp->GetQualifiedRepresentationIfAvailable(
+ lldb::eDynamicDontRunTarget, true);
- const char *child_value = qualified_child_representation_sp->GetValueAsCString();
+ const char *child_value =
+ qualified_child_representation_sp->GetValueAsCString();
- s.Printf("%s", child_value);
+ s.Printf("%s", child_value);
- return true;
+ return true;
}
lldb_private::SyntheticChildrenFrontEnd *
-lldb_private::formatters::BlockPointerSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
-{
- if (!valobj_sp)
- return nullptr;
- return new BlockPointerSyntheticFrontEnd(valobj_sp);
+lldb_private::formatters::BlockPointerSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ if (!valobj_sp)
+ return nullptr;
+ return new BlockPointerSyntheticFrontEnd(valobj_sp);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/BlockPointer.h Tue Sep 6 15:57:50 2016
@@ -12,15 +12,14 @@
#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
-namespace formatters
-{
-bool
-BlockPointerSummaryProvider(ValueObject &, Stream &, const TypeSummaryOptions &);
+namespace lldb_private {
+namespace formatters {
+bool BlockPointerSummaryProvider(ValueObject &, Stream &,
+ const TypeSummaryOptions &);
SyntheticChildrenFrontEnd *
-BlockPointerSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
+BlockPointerSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
} // namespace formatters
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Tue Sep 6 15:57:50 2016
@@ -11,8 +11,8 @@
// C Includes
// C++ Includes
-#include <cstring>
#include <cctype>
+#include <cstring>
#include <functional>
#include <mutex>
@@ -39,822 +39,987 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-void
-CPlusPlusLanguage::Initialize()
-{
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- "C++ Language",
- CreateInstance);
-}
-
-void
-CPlusPlusLanguage::Terminate()
-{
- PluginManager::UnregisterPlugin (CreateInstance);
-}
-
-lldb_private::ConstString
-CPlusPlusLanguage::GetPluginNameStatic()
-{
- static ConstString g_name("cplusplus");
- return g_name;
+void CPlusPlusLanguage::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), "C++ Language",
+ CreateInstance);
+}
+
+void CPlusPlusLanguage::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString CPlusPlusLanguage::GetPluginNameStatic() {
+ static ConstString g_name("cplusplus");
+ return g_name;
}
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
-lldb_private::ConstString
-CPlusPlusLanguage::GetPluginName()
-{
- return GetPluginNameStatic();
+lldb_private::ConstString CPlusPlusLanguage::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-CPlusPlusLanguage::GetPluginVersion()
-{
- return 1;
-}
+uint32_t CPlusPlusLanguage::GetPluginVersion() { return 1; }
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-Language *
-CPlusPlusLanguage::CreateInstance (lldb::LanguageType language)
-{
- if (Language::LanguageIsCPlusPlus(language))
- return new CPlusPlusLanguage();
- return nullptr;
-}
-
-void
-CPlusPlusLanguage::MethodName::Clear()
-{
- m_full.Clear();
- m_basename = llvm::StringRef();
- m_context = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_type = eTypeInvalid;
- m_parsed = false;
- m_parse_error = false;
-}
-
-bool
-ReverseFindMatchingChars (const llvm::StringRef &s,
- const llvm::StringRef &left_right_chars,
- size_t &left_pos,
- size_t &right_pos,
- size_t pos = llvm::StringRef::npos)
-{
- assert (left_right_chars.size() == 2);
- left_pos = llvm::StringRef::npos;
- const char left_char = left_right_chars[0];
- const char right_char = left_right_chars[1];
+Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
+ if (Language::LanguageIsCPlusPlus(language))
+ return new CPlusPlusLanguage();
+ return nullptr;
+}
+
+void CPlusPlusLanguage::MethodName::Clear() {
+ m_full.Clear();
+ m_basename = llvm::StringRef();
+ m_context = llvm::StringRef();
+ m_arguments = llvm::StringRef();
+ m_qualifiers = llvm::StringRef();
+ m_type = eTypeInvalid;
+ m_parsed = false;
+ m_parse_error = false;
+}
+
+bool ReverseFindMatchingChars(const llvm::StringRef &s,
+ const llvm::StringRef &left_right_chars,
+ size_t &left_pos, size_t &right_pos,
+ size_t pos = llvm::StringRef::npos) {
+ assert(left_right_chars.size() == 2);
+ left_pos = llvm::StringRef::npos;
+ const char left_char = left_right_chars[0];
+ const char right_char = left_right_chars[1];
+ pos = s.find_last_of(left_right_chars, pos);
+ if (pos == llvm::StringRef::npos || s[pos] == left_char)
+ return false;
+ right_pos = pos;
+ uint32_t depth = 1;
+ while (pos > 0 && depth > 0) {
pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos || s[pos] == left_char)
- return false;
- right_pos = pos;
- uint32_t depth = 1;
- while (pos > 0 && depth > 0)
- {
- pos = s.find_last_of(left_right_chars, pos);
- if (pos == llvm::StringRef::npos)
- return false;
- if (s[pos] == left_char)
- {
- if (--depth == 0)
- {
- left_pos = pos;
- return left_pos < right_pos;
- }
- }
- else if (s[pos] == right_char)
- {
- ++depth;
- }
+ if (pos == llvm::StringRef::npos)
+ return false;
+ if (s[pos] == left_char) {
+ if (--depth == 0) {
+ left_pos = pos;
+ return left_pos < right_pos;
+ }
+ } else if (s[pos] == right_char) {
+ ++depth;
}
- return false;
+ }
+ return false;
}
-static bool
-IsValidBasename(const llvm::StringRef& basename)
-{
- // Check that the basename matches with the following regular expression or is an operator name:
- // "^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$"
- // We are using a hand written implementation because it is significantly more efficient then
- // using the general purpose regular expression library.
- size_t idx = 0;
- if (basename.size() > 0 && basename[0] == '~')
- idx = 1;
+static bool IsValidBasename(const llvm::StringRef &basename) {
+ // Check that the basename matches with the following regular expression or is
+ // an operator name:
+ // "^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$"
+ // We are using a hand written implementation because it is significantly more
+ // efficient then
+ // using the general purpose regular expression library.
+ size_t idx = 0;
+ if (basename.size() > 0 && basename[0] == '~')
+ idx = 1;
+
+ if (basename.size() <= idx)
+ return false; // Empty string or "~"
+
+ if (!std::isalpha(basename[idx]) && basename[idx] != '_')
+ return false; // First charater (after removing the possible '~'') isn't in
+ // [A-Za-z_]
+
+ // Read all characters matching [A-Za-z_0-9]
+ ++idx;
+ while (idx < basename.size()) {
+ if (!std::isalnum(basename[idx]) && basename[idx] != '_')
+ break;
+ ++idx;
+ }
- if (basename.size() <= idx)
- return false; // Empty string or "~"
+ // We processed all characters. It is a vaild basename.
+ if (idx == basename.size())
+ return true;
+
+ // Check for basename with template arguments
+ // TODO: Improve the quality of the validation with validating the template
+ // arguments
+ if (basename[idx] == '<' && basename.back() == '>')
+ return true;
- if (!std::isalpha(basename[idx]) && basename[idx] != '_')
- return false; // First charater (after removing the possible '~'') isn't in [A-Za-z_]
+ // Check if the basename is a vaild C++ operator name
+ if (!basename.startswith("operator"))
+ return false;
- // Read all characters matching [A-Za-z_0-9]
- ++idx;
- while (idx < basename.size())
- {
- if (!std::isalnum(basename[idx]) && basename[idx] != '_')
- break;
- ++idx;
- }
+ static RegularExpression g_operator_regex("^(operator)( "
+ "?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|"
+ "\\[\\]|[\\^<>=!\\/"
+ "*+-]+)(<.*>)?(\\[\\])?$");
+ std::string basename_str(basename.str());
+ return g_operator_regex.Execute(basename_str.c_str(), nullptr);
+}
- // We processed all characters. It is a vaild basename.
- if (idx == basename.size())
- return true;
-
- // Check for basename with template arguments
- // TODO: Improve the quality of the validation with validating the template arguments
- if (basename[idx] == '<' && basename.back() == '>')
- return true;
-
- // Check if the basename is a vaild C++ operator name
- if (!basename.startswith("operator"))
- return false;
-
- static RegularExpression g_operator_regex("^(operator)( ?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|\\[\\]|[\\^<>=!\\/*+-]+)(<.*>)?(\\[\\])?$");
- std::string basename_str(basename.str());
- return g_operator_regex.Execute(basename_str.c_str(), nullptr);
-}
-
-void
-CPlusPlusLanguage::MethodName::Parse()
-{
- if (!m_parsed && m_full)
- {
-// ConstString mangled;
-// m_full.GetMangledCounterpart(mangled);
-// printf ("\n parsing = '%s'\n", m_full.GetCString());
-// if (mangled)
-// printf (" mangled = '%s'\n", mangled.GetCString());
- m_parse_error = false;
- m_parsed = true;
- llvm::StringRef full (m_full.GetCString());
-
- size_t arg_start, arg_end;
- llvm::StringRef parens("()", 2);
- if (ReverseFindMatchingChars (full, parens, arg_start, arg_end))
- {
- m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
- if (arg_end + 1 < full.size())
- m_qualifiers = full.substr(arg_end + 1);
- if (arg_start > 0)
- {
- size_t basename_end = arg_start;
- size_t context_start = 0;
- size_t context_end = llvm::StringRef::npos;
- if (basename_end > 0 && full[basename_end-1] == '>')
- {
- // TODO: handle template junk...
- // Templated function
- size_t template_start, template_end;
- llvm::StringRef lt_gt("<>", 2);
- if (ReverseFindMatchingChars (full, lt_gt, template_start, template_end, basename_end))
- {
- // Check for templated functions that include return type like: 'void foo<Int>()'
- context_start = full.rfind(' ', template_start);
- if (context_start == llvm::StringRef::npos)
- context_start = 0;
- else
- ++context_start;
-
- context_end = full.rfind(':', template_start);
- if (context_end == llvm::StringRef::npos || context_end < context_start)
- context_end = context_start;
- }
- else
- {
- context_end = full.rfind(':', basename_end);
- }
- }
- else if (context_end == llvm::StringRef::npos)
- {
- context_end = full.rfind(':', basename_end);
- }
-
- if (context_end == llvm::StringRef::npos)
- m_basename = full.substr(0, basename_end);
- else
- {
- if (context_start < context_end)
- m_context = full.substr(context_start, context_end - 1 - context_start);
- const size_t basename_begin = context_end + 1;
- m_basename = full.substr(basename_begin, basename_end - basename_begin);
- }
- m_type = eTypeUnknownMethod;
- }
+void CPlusPlusLanguage::MethodName::Parse() {
+ if (!m_parsed && m_full) {
+ // ConstString mangled;
+ // m_full.GetMangledCounterpart(mangled);
+ // printf ("\n parsing = '%s'\n", m_full.GetCString());
+ // if (mangled)
+ // printf (" mangled = '%s'\n", mangled.GetCString());
+ m_parse_error = false;
+ m_parsed = true;
+ llvm::StringRef full(m_full.GetCString());
+
+ size_t arg_start, arg_end;
+ llvm::StringRef parens("()", 2);
+ if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) {
+ m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
+ if (arg_end + 1 < full.size())
+ m_qualifiers = full.substr(arg_end + 1);
+ if (arg_start > 0) {
+ size_t basename_end = arg_start;
+ size_t context_start = 0;
+ size_t context_end = llvm::StringRef::npos;
+ if (basename_end > 0 && full[basename_end - 1] == '>') {
+ // TODO: handle template junk...
+ // Templated function
+ size_t template_start, template_end;
+ llvm::StringRef lt_gt("<>", 2);
+ if (ReverseFindMatchingChars(full, lt_gt, template_start,
+ template_end, basename_end)) {
+ // Check for templated functions that include return type like:
+ // 'void foo<Int>()'
+ context_start = full.rfind(' ', template_start);
+ if (context_start == llvm::StringRef::npos)
+ context_start = 0;
else
- {
- m_parse_error = true;
- return;
- }
-
- if (!IsValidBasename(m_basename))
- {
- // The C++ basename doesn't match our regular expressions so this can't
- // be a valid C++ method, clear everything out and indicate an error
- m_context = llvm::StringRef();
- m_basename = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_parse_error = true;
- }
+ ++context_start;
+
+ context_end = full.rfind(':', template_start);
+ if (context_end == llvm::StringRef::npos ||
+ context_end < context_start)
+ context_end = context_start;
+ } else {
+ context_end = full.rfind(':', basename_end);
+ }
+ } else if (context_end == llvm::StringRef::npos) {
+ context_end = full.rfind(':', basename_end);
}
- else
- {
- m_parse_error = true;
+
+ if (context_end == llvm::StringRef::npos)
+ m_basename = full.substr(0, basename_end);
+ else {
+ if (context_start < context_end)
+ m_context =
+ full.substr(context_start, context_end - 1 - context_start);
+ const size_t basename_begin = context_end + 1;
+ m_basename =
+ full.substr(basename_begin, basename_end - basename_begin);
}
+ m_type = eTypeUnknownMethod;
+ } else {
+ m_parse_error = true;
+ return;
+ }
+
+ if (!IsValidBasename(m_basename)) {
+ // The C++ basename doesn't match our regular expressions so this can't
+ // be a valid C++ method, clear everything out and indicate an error
+ m_context = llvm::StringRef();
+ m_basename = llvm::StringRef();
+ m_arguments = llvm::StringRef();
+ m_qualifiers = llvm::StringRef();
+ m_parse_error = true;
+ }
+ } else {
+ m_parse_error = true;
}
+ }
}
-llvm::StringRef
-CPlusPlusLanguage::MethodName::GetBasename ()
-{
- if (!m_parsed)
- Parse();
- return m_basename;
-}
-
-llvm::StringRef
-CPlusPlusLanguage::MethodName::GetContext ()
-{
- if (!m_parsed)
- Parse();
- return m_context;
-}
-
-llvm::StringRef
-CPlusPlusLanguage::MethodName::GetArguments ()
-{
- if (!m_parsed)
- Parse();
- return m_arguments;
-}
-
-llvm::StringRef
-CPlusPlusLanguage::MethodName::GetQualifiers ()
-{
- if (!m_parsed)
- Parse();
- return m_qualifiers;
-}
-
-std::string
-CPlusPlusLanguage::MethodName::GetScopeQualifiedName ()
-{
- if (!m_parsed)
- Parse();
- if (m_basename.empty() || m_context.empty())
- return std::string();
-
- std::string res;
- res += m_context;
- res += "::";
- res += m_basename;
-
- return res;
-}
-
-bool
-CPlusPlusLanguage::IsCPPMangledName (const char *name)
-{
- // FIXME, we should really run through all the known C++ Language plugins and ask each one if
- // this is a C++ mangled name, but we can put that off till there is actually more than one
- // we care about.
-
- return (name != nullptr && name[0] == '_' && name[1] == 'Z');
-}
-
-bool
-CPlusPlusLanguage::ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier)
-{
- static RegularExpression g_basename_regex("^(([A-Za-z_][A-Za-z_0-9]*::)*)(~?[A-Za-z_~][A-Za-z_0-9]*)$");
- RegularExpression::Match match(4);
- if (g_basename_regex.Execute (name, &match))
- {
- match.GetMatchAtIndex(name, 1, context);
- match.GetMatchAtIndex(name, 3, identifier);
- return true;
- }
- return false;
+llvm::StringRef CPlusPlusLanguage::MethodName::GetBasename() {
+ if (!m_parsed)
+ Parse();
+ return m_basename;
+}
+
+llvm::StringRef CPlusPlusLanguage::MethodName::GetContext() {
+ if (!m_parsed)
+ Parse();
+ return m_context;
+}
+
+llvm::StringRef CPlusPlusLanguage::MethodName::GetArguments() {
+ if (!m_parsed)
+ Parse();
+ return m_arguments;
+}
+
+llvm::StringRef CPlusPlusLanguage::MethodName::GetQualifiers() {
+ if (!m_parsed)
+ Parse();
+ return m_qualifiers;
+}
+
+std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
+ if (!m_parsed)
+ Parse();
+ if (m_basename.empty() || m_context.empty())
+ return std::string();
+
+ std::string res;
+ res += m_context;
+ res += "::";
+ res += m_basename;
+
+ return res;
+}
+
+bool CPlusPlusLanguage::IsCPPMangledName(const char *name) {
+ // FIXME, we should really run through all the known C++ Language plugins and
+ // ask each one if
+ // this is a C++ mangled name, but we can put that off till there is actually
+ // more than one
+ // we care about.
+
+ return (name != nullptr && name[0] == '_' && name[1] == 'Z');
}
-class CPPRuntimeEquivalents
-{
+bool CPlusPlusLanguage::ExtractContextAndIdentifier(
+ const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
+ static RegularExpression g_basename_regex(
+ "^(([A-Za-z_][A-Za-z_0-9]*::)*)(~?[A-Za-z_~][A-Za-z_0-9]*)$");
+ RegularExpression::Match match(4);
+ if (g_basename_regex.Execute(name, &match)) {
+ match.GetMatchAtIndex(name, 1, context);
+ match.GetMatchAtIndex(name, 3, identifier);
+ return true;
+ }
+ return false;
+}
+
+class CPPRuntimeEquivalents {
public:
- CPPRuntimeEquivalents ()
- {
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("basic_string<char>"));
-
- // these two (with a prefixed std::) occur when c++stdlib string class occurs as a template argument in some STL container
- m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >").AsCString(), ConstString("std::basic_string<char>"));
-
- m_impl.Sort();
- }
-
- void
- Add (ConstString& type_name,
- ConstString& type_equivalent)
- {
- m_impl.Insert(type_name.AsCString(), type_equivalent);
+ CPPRuntimeEquivalents() {
+ m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, "
+ "std::allocator<char> >")
+ .AsCString(),
+ ConstString("basic_string<char>"));
+
+ // these two (with a prefixed std::) occur when c++stdlib string class
+ // occurs as a template argument in some STL container
+ m_impl.Append(ConstString("std::basic_string<char, std::char_traits<char>, "
+ "std::allocator<char> >")
+ .AsCString(),
+ ConstString("std::basic_string<char>"));
+
+ m_impl.Sort();
+ }
+
+ void Add(ConstString &type_name, ConstString &type_equivalent) {
+ m_impl.Insert(type_name.AsCString(), type_equivalent);
+ }
+
+ uint32_t FindExactMatches(ConstString &type_name,
+ std::vector<ConstString> &equivalents) {
+ uint32_t count = 0;
+
+ for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
+ match != nullptr; match = m_impl.FindNextValueForName(match)) {
+ equivalents.push_back(match->value);
+ count++;
}
-
- uint32_t
- FindExactMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(type_name.AsCString());
- match != nullptr;
- match = m_impl.FindNextValueForName(match))
- {
- equivalents.push_back(match->value);
- count++;
- }
- return count;
- }
-
- // partial matches can occur when a name with equivalents is a template argument.
- // e.g. we may have "class Foo" be a match for "struct Bar". if we have a typename
- // such as "class Templatized<class Foo, Anything>" we want this to be replaced with
- // "class Templatized<struct Bar, Anything>". Since partial matching is time consuming
- // once we get a partial match, we add it to the exact matches list for faster retrieval
- uint32_t
- FindPartialMatches (ConstString& type_name,
- std::vector<ConstString>& equivalents)
- {
- uint32_t count = 0;
-
- const char* type_name_cstr = type_name.AsCString();
-
- size_t items_count = m_impl.GetSize();
-
- for (size_t item = 0; item < items_count; item++)
- {
- const char* key_cstr = m_impl.GetCStringAtIndex(item);
- if ( strstr(type_name_cstr,key_cstr) )
- {
- count += AppendReplacements(type_name_cstr,
- key_cstr,
- equivalents);
- }
- }
-
- return count;
+ return count;
+ }
+
+ // partial matches can occur when a name with equivalents is a template
+ // argument.
+ // e.g. we may have "class Foo" be a match for "struct Bar". if we have a
+ // typename
+ // such as "class Templatized<class Foo, Anything>" we want this to be
+ // replaced with
+ // "class Templatized<struct Bar, Anything>". Since partial matching is time
+ // consuming
+ // once we get a partial match, we add it to the exact matches list for faster
+ // retrieval
+ uint32_t FindPartialMatches(ConstString &type_name,
+ std::vector<ConstString> &equivalents) {
+ uint32_t count = 0;
+
+ const char *type_name_cstr = type_name.AsCString();
+
+ size_t items_count = m_impl.GetSize();
+
+ for (size_t item = 0; item < items_count; item++) {
+ const char *key_cstr = m_impl.GetCStringAtIndex(item);
+ if (strstr(type_name_cstr, key_cstr)) {
+ count += AppendReplacements(type_name_cstr, key_cstr, equivalents);
+ }
}
-
+
+ return count;
+ }
+
private:
- std::string& replace (std::string& target,
- std::string& pattern,
- std::string& with)
- {
- size_t pos;
- size_t pattern_len = pattern.size();
-
- while ( (pos = target.find(pattern)) != std::string::npos )
- target.replace(pos, pattern_len, with);
-
- return target;
- }
-
- uint32_t
- AppendReplacements (const char* original,
- const char *matching_key,
- std::vector<ConstString>& equivalents)
- {
- std::string matching_key_str(matching_key);
- ConstString original_const(original);
-
- uint32_t count = 0;
-
- for (ImplData match = m_impl.FindFirstValueForName(matching_key);
- match != nullptr;
- match = m_impl.FindNextValueForName(match))
- {
- std::string target(original);
- std::string equiv_class(match->value.AsCString());
-
- replace (target, matching_key_str, equiv_class);
-
- ConstString target_const(target.c_str());
+ std::string &replace(std::string &target, std::string &pattern,
+ std::string &with) {
+ size_t pos;
+ size_t pattern_len = pattern.size();
+
+ while ((pos = target.find(pattern)) != std::string::npos)
+ target.replace(pos, pattern_len, with);
+
+ return target;
+ }
+
+ uint32_t AppendReplacements(const char *original, const char *matching_key,
+ std::vector<ConstString> &equivalents) {
+ std::string matching_key_str(matching_key);
+ ConstString original_const(original);
+
+ uint32_t count = 0;
-// you will most probably want to leave this off since it might make this map grow indefinitely
+ for (ImplData match = m_impl.FindFirstValueForName(matching_key);
+ match != nullptr; match = m_impl.FindNextValueForName(match)) {
+ std::string target(original);
+ std::string equiv_class(match->value.AsCString());
+
+ replace(target, matching_key_str, equiv_class);
+
+ ConstString target_const(target.c_str());
+
+// you will most probably want to leave this off since it might make this map
+// grow indefinitely
#ifdef ENABLE_CPP_EQUIVALENTS_MAP_TO_GROW
- Add(original_const, target_const);
+ Add(original_const, target_const);
#endif
- equivalents.push_back(target_const);
-
- count++;
- }
-
- return count;
+ equivalents.push_back(target_const);
+
+ count++;
}
-
- typedef UniqueCStringMap<ConstString> Impl;
- typedef const Impl::Entry* ImplData;
- Impl m_impl;
+
+ return count;
+ }
+
+ typedef UniqueCStringMap<ConstString> Impl;
+ typedef const Impl::Entry *ImplData;
+ Impl m_impl;
};
-static CPPRuntimeEquivalents&
-GetEquivalentsMap ()
-{
- static CPPRuntimeEquivalents g_equivalents_map;
- return g_equivalents_map;
+static CPPRuntimeEquivalents &GetEquivalentsMap() {
+ static CPPRuntimeEquivalents g_equivalents_map;
+ return g_equivalents_map;
}
uint32_t
-CPlusPlusLanguage::FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents)
-{
- uint32_t count = GetEquivalentsMap().FindExactMatches(type_name, equivalents);
-
- bool might_have_partials=
- ( count == 0 ) // if we have a full name match just use it
- && (strchr(type_name.AsCString(), '<') != nullptr // we should only have partial matches when templates are involved, check that we have
- && strchr(type_name.AsCString(), '>') != nullptr); // angle brackets in the type_name before trying to scan for partial matches
-
- if ( might_have_partials )
- count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents);
-
- return count;
-}
+CPlusPlusLanguage::FindEquivalentNames(ConstString type_name,
+ std::vector<ConstString> &equivalents) {
+ uint32_t count = GetEquivalentsMap().FindExactMatches(type_name, equivalents);
+
+ bool might_have_partials =
+ (count == 0) // if we have a full name match just use it
+ && (strchr(type_name.AsCString(), '<') !=
+ nullptr // we should only have partial matches when templates are
+ // involved, check that we have
+ && strchr(type_name.AsCString(), '>') != nullptr); // angle brackets
+ // in the type_name
+ // before trying to
+ // scan for partial
+ // matches
+
+ if (might_have_partials)
+ count = GetEquivalentsMap().FindPartialMatches(type_name, equivalents);
+
+ return count;
+}
+
+static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags stl_summary_flags;
+ stl_summary_flags.SetCascades(true)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
-static void
-LoadLibCxxFormatters (lldb::TypeCategoryImplSP cpp_category_sp)
-{
- if (!cpp_category_sp)
- return;
-
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
#ifndef LLDB_DISABLE_PYTHON
- lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider, "std::string summary provider"));
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider, "std::wstring summary provider"));
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::string"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__ndk1::string"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >"),
- std_string_summary_sp);
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::wstring"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__ndk1::wstring"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__ndk1::basic_string<wchar_t, std::__ndk1::char_traits<wchar_t>, std::__ndk1::allocator<wchar_t> >"),
- std_wstring_summary_sp);
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("^std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator, "libc++ std::vector synthetic children", ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator, "libc++ std::list synthetic children", ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::map synthetic children", ConstString("^std::__(ndk)?1::map<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__(ndk)?1::vector<std::__(ndk)?1::allocator<bool> >"), stl_synth_flags);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator, "libc++ std::vector<bool> synthetic children", ConstString("std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"), stl_synth_flags);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::set synthetic children", ConstString("^std::__(ndk)?1::set<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multiset synthetic children", ConstString("^std::__(ndk)?1::multiset<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator, "libc++ std::multimap synthetic children", ConstString("^std::__(ndk)?1::multimap<.+> >(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator, "libc++ std::unordered containers synthetic children", ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator, "libc++ std::initializer_list synthetic children", ConstString("^std::initializer_list<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator, "libc++ std::atomic synthetic children", ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_synth_flags, true);
-
- cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^(std::__(ndk)?1::)deque<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "shared_ptr synthetic children", ConstString("^(std::__(ndk)?1::)shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator, "weak_ptr synthetic children", ConstString("^(std::__(ndk)?1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
-
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(false);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector summary provider", ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::list summary provider", ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::map summary provider", ConstString("^std::__(ndk)?1::map<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::deque summary provider", ConstString("^std::__(ndk)?1::deque<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::set summary provider", ConstString("^std::__(ndk)?1::set<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multiset summary provider", ConstString("^std::__(ndk)?1::multiset<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::multimap summary provider", ConstString("^std::__(ndk)?1::multimap<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::unordered containers summary provider", ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider, "libc++ std::atomic summary provider", ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_summary_flags, true);
-
- stl_summary_flags.SetSkipPointers(true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::shared_ptr summary provider", ConstString("^std::__(ndk)?1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::weak_ptr summary provider", ConstString("^std::__(ndk)?1::weak_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^std::__(ndk)?1::__wrap_iter<.+>$"), stl_synth_flags, true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::vector<bool> summary provider", ConstString("std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"), stl_summary_flags);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::__(ndk)?1::__map_iterator<.+>$"), stl_synth_flags, true);
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibcxxFunctionFrontEndCreator, "std::function synthetic value provider", ConstString("^std::__1::function<.+>$"), stl_synth_flags, true);
+ lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider,
+ "std::string summary provider"));
+ lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider,
+ "std::wstring summary provider"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__1::string"), std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__ndk1::string"), std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, "
+ "std::__1::allocator<char> >"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__ndk1::basic_string<char, "
+ "std::__ndk1::char_traits<char>, "
+ "std::__ndk1::allocator<char> >"),
+ std_string_summary_sp);
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__1::wstring"), std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__ndk1::wstring"), std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__1::basic_string<wchar_t, "
+ "std::__1::char_traits<wchar_t>, "
+ "std::__1::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__ndk1::basic_string<wchar_t, "
+ "std::__ndk1::char_traits<wchar_t>, "
+ "std::__ndk1::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+
+ SyntheticChildren::Flags stl_synth_flags;
+ stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
+ false);
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
+ "libc++ std::vector<bool> synthetic children",
+ ConstString(
+ "^std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >$"),
+ stl_synth_flags, true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
+ "libc++ std::vector synthetic children",
+ ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
+ "libc++ std::list synthetic children",
+ ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
+ "libc++ std::map synthetic children",
+ ConstString("^std::__(ndk)?1::map<.+> >(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
+ "libc++ std::vector<bool> synthetic children",
+ ConstString("std::__(ndk)?1::vector<std::__(ndk)?1::allocator<bool> >"),
+ stl_synth_flags);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
+ "libc++ std::vector<bool> synthetic children",
+ ConstString(
+ "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
+ stl_synth_flags);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
+ "libc++ std::set synthetic children",
+ ConstString("^std::__(ndk)?1::set<.+> >(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
+ "libc++ std::multiset synthetic children",
+ ConstString("^std::__(ndk)?1::multiset<.+> >(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
+ "libc++ std::multimap synthetic children",
+ ConstString("^std::__(ndk)?1::multimap<.+> >(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
+ "libc++ std::unordered containers synthetic children",
+ ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"),
+ stl_synth_flags, true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
+ "libc++ std::initializer_list synthetic children",
+ ConstString("^std::initializer_list<.+>(( )?&)?$"), stl_synth_flags,
+ true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator,
+ "libc++ std::atomic synthetic children",
+ ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_synth_flags, true);
+
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+ RegularExpressionSP(
+ new RegularExpression("^(std::__(ndk)?1::)deque<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(
+ stl_synth_flags,
+ "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
+ "shared_ptr synthetic children",
+ ConstString("^(std::__(ndk)?1::)shared_ptr<.+>(( )?&)?$"),
+ stl_synth_flags, true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
+ "weak_ptr synthetic children",
+ ConstString("^(std::__(ndk)?1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags,
+ true);
+
+ stl_summary_flags.SetDontShowChildren(false);
+ stl_summary_flags.SetSkipPointers(false);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::vector<bool> summary provider",
+ ConstString(
+ "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::vector summary provider",
+ ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::list summary provider",
+ ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::map summary provider",
+ ConstString("^std::__(ndk)?1::map<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::deque summary provider",
+ ConstString("^std::__(ndk)?1::deque<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::set summary provider",
+ ConstString("^std::__(ndk)?1::set<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::multiset summary provider",
+ ConstString("^std::__(ndk)?1::multiset<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::multimap summary provider",
+ ConstString("^std::__(ndk)?1::multimap<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::unordered containers summary provider",
+ ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"),
+ stl_summary_flags, true);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider,
+ "libc++ std::atomic summary provider",
+ ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_summary_flags, true);
+
+ stl_summary_flags.SetSkipPointers(true);
+
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
+ "libc++ std::shared_ptr summary provider",
+ ConstString("^std::__(ndk)?1::shared_ptr<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
+ "libc++ std::weak_ptr summary provider",
+ ConstString("^std::__(ndk)?1::weak_ptr<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator,
+ "std::vector iterator synthetic children",
+ ConstString("^std::__(ndk)?1::__wrap_iter<.+>$"), stl_synth_flags, true);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
+ "libc++ std::vector<bool> summary provider",
+ ConstString(
+ "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
+ stl_summary_flags);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
+ "std::map iterator synthetic children",
+ ConstString("^std::__(ndk)?1::__map_iterator<.+>$"), stl_synth_flags,
+ true);
+
+ AddCXXSynthetic(
+ cpp_category_sp, lldb_private::formatters::LibcxxFunctionFrontEndCreator,
+ "std::function synthetic value provider",
+ ConstString("^std::__1::function<.+>$"), stl_synth_flags, true);
#endif
}
-static void
-LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
-{
- if (!cpp_category_sp)
- return;
-
- TypeSummaryImpl::Flags stl_summary_flags;
- stl_summary_flags.SetCascades(true)
- .SetSkipPointers(false)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p}"));
-
- lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags,
- LibStdcppStringSummaryProvider,
- "libstdc++ c++11 std::string summary provider"));
- lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat(stl_summary_flags,
- LibStdcppWStringSummaryProvider,
- "libstdc++ c++11 std::wstring summary provider"));
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char>"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
- std_string_summary_sp);
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::string"),
- cxx11_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >"),
- cxx11_string_summary_sp);
-
- // making sure we force-pick the summary for printing wstring (_M_p is a wchar_t*)
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new StringSummaryFormat(stl_summary_flags,
- "${var._M_dataplus._M_p%S}"));
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t>"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
- std_wstring_summary_sp);
-
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::wstring"),
- cxx11_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
- cxx11_wstring_summary_sp);
+static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags stl_summary_flags;
+ stl_summary_flags.SetCascades(true)
+ .SetSkipPointers(false)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ lldb::TypeSummaryImplSP std_string_summary_sp(
+ new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p}"));
+
+ lldb::TypeSummaryImplSP cxx11_string_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags, LibStdcppStringSummaryProvider,
+ "libstdc++ c++11 std::string summary provider"));
+ lldb::TypeSummaryImplSP cxx11_wstring_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags, LibStdcppWStringSummaryProvider,
+ "libstdc++ c++11 std::wstring summary provider"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::string"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<char>"), std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<char,std::char_traits<char>,std::"
+ "allocator<char> >"),
+ std_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<char, std::char_traits<char>, "
+ "std::allocator<char> >"),
+ std_string_summary_sp);
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__cxx11::string"), cxx11_string_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__cxx11::basic_string<char, std::char_traits<char>, "
+ "std::allocator<char> >"),
+ cxx11_string_summary_sp);
+
+ // making sure we force-pick the summary for printing wstring (_M_p is a
+ // wchar_t*)
+ lldb::TypeSummaryImplSP std_wstring_summary_sp(
+ new StringSummaryFormat(stl_summary_flags, "${var._M_dataplus._M_p%S}"));
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(ConstString("std::wstring"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<wchar_t>"), std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<wchar_t,std::char_traits<wchar_t>,std::"
+ "allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
+ "std::allocator<wchar_t> >"),
+ std_wstring_summary_sp);
+
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__cxx11::wstring"), cxx11_wstring_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString("std::__cxx11::basic_string<wchar_t, "
+ "std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
+ cxx11_wstring_summary_sp);
#ifndef LLDB_DISABLE_PYTHON
-
- SyntheticChildren::Flags stl_synth_flags;
- stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false);
-
- cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
- cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
- cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(RegularExpressionSP(new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
- SyntheticChildrenSP(new ScriptedSyntheticChildren(stl_synth_flags,
- "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
- stl_summary_flags.SetDontShowChildren(false);stl_summary_flags.SetSkipPointers(true);
- cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
- cpp_category_sp->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
- TypeSummaryImplSP(new StringSummaryFormat(stl_summary_flags,
- "size=${svar%#}")));
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^__gnu_cxx::__normal_iterator<.+>$"), stl_synth_flags, true);
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator, "std::map iterator synthetic children", ConstString("^std::_Rb_tree_iterator<.+>$"), stl_synth_flags, true);
-
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
- "std::shared_ptr synthetic children", ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_synth_flags,
- true);
- AddCXXSynthetic(cpp_category_sp, lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
- "std::weak_ptr synthetic children", ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_synth_flags,
- true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
- "libstdc++ std::shared_ptr summary provider", ConstString("^std::shared_ptr<.+>(( )?&)?$"),
- stl_summary_flags, true);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
- "libstdc++ std::weak_ptr summary provider", ConstString("^std::weak_ptr<.+>(( )?&)?$"),
- stl_summary_flags, true);
+
+ SyntheticChildren::Flags stl_synth_flags;
+ stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
+ false);
+
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+ RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(
+ stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+ RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(
+ stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
+ cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
+ RegularExpressionSP(
+ new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
+ SyntheticChildrenSP(new ScriptedSyntheticChildren(
+ stl_synth_flags,
+ "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
+ stl_summary_flags.SetDontShowChildren(false);
+ stl_summary_flags.SetSkipPointers(true);
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+ RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
+ TypeSummaryImplSP(
+ new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+ RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
+ TypeSummaryImplSP(
+ new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+ cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+ RegularExpressionSP(
+ new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
+ TypeSummaryImplSP(
+ new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator,
+ "std::vector iterator synthetic children",
+ ConstString("^__gnu_cxx::__normal_iterator<.+>$"), stl_synth_flags, true);
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator,
+ "std::map iterator synthetic children",
+ ConstString("^std::_Rb_tree_iterator<.+>$"), stl_synth_flags, true);
+
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
+ "std::shared_ptr synthetic children",
+ ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator,
+ "std::weak_ptr synthetic children",
+ ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_synth_flags, true);
+
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
+ "libstdc++ std::shared_ptr summary provider",
+ ConstString("^std::shared_ptr<.+>(( )?&)?$"), stl_summary_flags,
+ true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
+ "libstdc++ std::weak_ptr summary provider",
+ ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_summary_flags,
+ true);
#endif
}
-static void
-LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp)
-{
- if (!cpp_category_sp)
- return;
-
- TypeSummaryImpl::Flags string_flags;
- string_flags.SetCascades(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(false)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
- TypeSummaryImpl::Flags string_array_flags;
- string_array_flags.SetCascades(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetDontShowChildren(true)
- .SetDontShowValue(true)
- .SetShowMembersOneLiner(false)
- .SetHideItemNames(false);
-
+static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
+ if (!cpp_category_sp)
+ return;
+
+ TypeSummaryImpl::Flags string_flags;
+ string_flags.SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(false)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
+ TypeSummaryImpl::Flags string_array_flags;
+ string_array_flags.SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetDontShowChildren(true)
+ .SetDontShowValue(true)
+ .SetShowMembersOneLiner(false)
+ .SetHideItemNames(false);
+
#ifndef LLDB_DISABLE_PYTHON
- // FIXME because of a bug in the FormattersContainer we need to add a summary for both X* and const X* (<rdar://problem/12717717>)
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("char16_t *"), string_flags);
- AddCXXSummary(cpp_category_sp,
- lldb_private::formatters::Char16StringSummaryProvider,
- "char16_t [] summary provider",
- ConstString("char16_t \\[[0-9]+\\]"),
- string_array_flags,
- true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
- AddCXXSummary(cpp_category_sp,
- lldb_private::formatters::Char32StringSummaryProvider,
- "char32_t [] summary provider",
- ConstString("char32_t \\[[0-9]+\\]"),
- string_array_flags,
- true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
-
- TypeSummaryImpl::Flags widechar_flags;
- widechar_flags.SetDontShowValue(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false)
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(false);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16SummaryProvider, "char16_t summary provider", ConstString("char16_t"), widechar_flags);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char32SummaryProvider, "char32_t summary provider", ConstString("char32_t"), widechar_flags);
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharSummaryProvider, "wchar_t summary provider", ConstString("wchar_t"), widechar_flags);
-
- AddCXXSummary(cpp_category_sp, lldb_private::formatters::Char16SummaryProvider, "unichar summary provider", ConstString("unichar"), widechar_flags);
+ // FIXME because of a bug in the FormattersContainer we need to add a summary
+ // for both X* and const X* (<rdar://problem/12717717>)
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider,
+ "char16_t * summary provider", ConstString("char16_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::Char16StringSummaryProvider,
+ "char16_t [] summary provider",
+ ConstString("char16_t \\[[0-9]+\\]"), string_array_flags, true);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char32StringSummaryProvider,
+ "char32_t * summary provider", ConstString("char32_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::Char32StringSummaryProvider,
+ "char32_t [] summary provider",
+ ConstString("char32_t \\[[0-9]+\\]"), string_array_flags, true);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::WCharStringSummaryProvider,
+ "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::WCharStringSummaryProvider,
+ "wchar_t * summary provider",
+ ConstString("wchar_t \\[[0-9]+\\]"), string_array_flags, true);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char16StringSummaryProvider,
+ "unichar * summary provider", ConstString("unichar *"), string_flags);
+
+ TypeSummaryImpl::Flags widechar_flags;
+ widechar_flags.SetDontShowValue(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false)
+ .SetCascades(true)
+ .SetDontShowChildren(true)
+ .SetHideItemNames(true)
+ .SetShowMembersOneLiner(false);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char16SummaryProvider,
+ "char16_t summary provider", ConstString("char16_t"), widechar_flags);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char32SummaryProvider,
+ "char32_t summary provider", ConstString("char32_t"), widechar_flags);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::WCharSummaryProvider,
+ "wchar_t summary provider", ConstString("wchar_t"),
+ widechar_flags);
+
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::Char16SummaryProvider,
+ "unichar summary provider", ConstString("unichar"), widechar_flags);
#endif
}
-lldb::TypeCategoryImplSP
-CPlusPlusLanguage::GetFormatters ()
-{
- static std::once_flag g_initialize;
- static TypeCategoryImplSP g_category;
-
- std::call_once(g_initialize, [this] () -> void {
- DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
- if (g_category)
- {
- LoadLibCxxFormatters(g_category);
- LoadLibStdcppFormatters(g_category);
- LoadSystemFormatters(g_category);
- }
- });
- return g_category;
+lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
+ static std::once_flag g_initialize;
+ static TypeCategoryImplSP g_category;
+
+ std::call_once(g_initialize, [this]() -> void {
+ DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
+ if (g_category) {
+ LoadLibCxxFormatters(g_category);
+ LoadLibStdcppFormatters(g_category);
+ LoadSystemFormatters(g_category);
+ }
+ });
+ return g_category;
}
HardcodedFormatters::HardcodedSummaryFinder
-CPlusPlusLanguage::GetHardcodedSummaries ()
-{
- static std::once_flag g_initialize;
- static ConstString g_vectortypes("VectorTypes");
- static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
-
- std::call_once(g_initialize, [] () -> void {
- g_formatters.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager&) -> TypeSummaryImpl::SharedPointer {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags(), lldb_private::formatters::CXXFunctionPointerSummaryProvider, "Function pointer summary provider"));
- if (valobj.GetCompilerType().IsFunctionPointerType())
- {
- return formatter_sp;
- }
- return nullptr;
- });
- g_formatters.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false),
- lldb_private::formatters::VectorTypeSummaryProvider,
- "vector_type pointer summary provider"));
- if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
- {
- if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
- return formatter_sp;
- }
- return nullptr;
- });
- g_formatters.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags()
- .SetCascades(true)
- .SetDontShowChildren(true)
- .SetHideItemNames(true)
- .SetShowMembersOneLiner(true)
- .SetSkipPointers(true)
- .SetSkipReferences(false),
- lldb_private::formatters::BlockPointerSummaryProvider,
- "block pointer summary provider"));
- if (valobj.GetCompilerType().IsBlockPointerType(nullptr))
- {
- return formatter_sp;
- }
- return nullptr;
- });
- });
-
- return g_formatters;
+CPlusPlusLanguage::GetHardcodedSummaries() {
+ static std::once_flag g_initialize;
+ static ConstString g_vectortypes("VectorTypes");
+ static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
+ new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags(),
+ lldb_private::formatters::CXXFunctionPointerSummaryProvider,
+ "Function pointer summary provider"));
+ if (valobj.GetCompilerType().IsFunctionPointerType()) {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &fmt_mgr) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
+ new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags()
+ .SetCascades(true)
+ .SetDontShowChildren(true)
+ .SetHideItemNames(true)
+ .SetShowMembersOneLiner(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false),
+ lldb_private::formatters::VectorTypeSummaryProvider,
+ "vector_type pointer summary provider"));
+ if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
+ if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &fmt_mgr) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
+ new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags()
+ .SetCascades(true)
+ .SetDontShowChildren(true)
+ .SetHideItemNames(true)
+ .SetShowMembersOneLiner(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(false),
+ lldb_private::formatters::BlockPointerSummaryProvider,
+ "block pointer summary provider"));
+ if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+
+ return g_formatters;
}
HardcodedFormatters::HardcodedSyntheticFinder
-CPlusPlusLanguage::GetHardcodedSynthetics ()
-{
- static std::once_flag g_initialize;
- static ConstString g_vectortypes("VectorTypes");
- static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
-
- std::call_once(g_initialize, [] () -> void {
- g_formatters.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
- static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
- "vector_type synthetic children",
- lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
- if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr))
- {
- if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
- return formatter_sp;
- }
- return nullptr;
- });
- g_formatters.push_back(
- [](lldb_private::ValueObject& valobj,
- lldb::DynamicValueType,
- FormatManager& fmt_mgr) -> SyntheticChildren::SharedPointer {
- static CXXSyntheticChildren::SharedPointer formatter_sp(new CXXSyntheticChildren(SyntheticChildren::Flags().SetCascades(true).SetSkipPointers(true).SetSkipReferences(true).SetNonCacheable(true),
- "block pointer synthetic children",
- lldb_private::formatters::BlockPointerSyntheticFrontEndCreator));
- if (valobj.GetCompilerType().IsBlockPointerType(nullptr))
- {
- return formatter_sp;
- }
- return nullptr;
- });
-
+CPlusPlusLanguage::GetHardcodedSynthetics() {
+ static std::once_flag g_initialize;
+ static ConstString g_vectortypes("VectorTypes");
+ static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void {
+ g_formatters.push_back([](lldb_private::ValueObject &valobj,
+ lldb::DynamicValueType,
+ FormatManager &
+ fmt_mgr) -> SyntheticChildren::SharedPointer {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(
+ new CXXSyntheticChildren(
+ SyntheticChildren::Flags()
+ .SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(true)
+ .SetNonCacheable(true),
+ "vector_type synthetic children",
+ lldb_private::formatters::VectorTypeSyntheticFrontEndCreator));
+ if (valobj.GetCompilerType().IsVectorType(nullptr, nullptr)) {
+ if (fmt_mgr.GetCategory(g_vectortypes)->IsEnabled())
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back([](lldb_private::ValueObject &valobj,
+ lldb::DynamicValueType,
+ FormatManager &
+ fmt_mgr) -> SyntheticChildren::SharedPointer {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(
+ new CXXSyntheticChildren(
+ SyntheticChildren::Flags()
+ .SetCascades(true)
+ .SetSkipPointers(true)
+ .SetSkipReferences(true)
+ .SetNonCacheable(true),
+ "block pointer synthetic children",
+ lldb_private::formatters::BlockPointerSyntheticFrontEndCreator));
+ if (valobj.GetCompilerType().IsBlockPointerType(nullptr)) {
+ return formatter_sp;
+ }
+ return nullptr;
});
-
- return g_formatters;
+
+ });
+
+ return g_formatters;
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h Tue Sep 6 15:57:50 2016
@@ -18,172 +18,136 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-
-class CPlusPlusLanguage :
- public Language
-{
+
+class CPlusPlusLanguage : public Language {
public:
- class MethodName
- {
- public:
- enum Type
- {
- eTypeInvalid,
- eTypeUnknownMethod,
- eTypeClassMethod,
- eTypeInstanceMethod
- };
-
- MethodName () :
- m_full(),
- m_basename(),
- m_context(),
- m_arguments(),
- m_qualifiers(),
- m_type (eTypeInvalid),
- m_parsed (false),
- m_parse_error (false)
- {
- }
-
- MethodName (const ConstString &s) :
- m_full(s),
- m_basename(),
- m_context(),
- m_arguments(),
- m_qualifiers(),
- m_type (eTypeInvalid),
- m_parsed (false),
- m_parse_error (false)
- {
- }
-
- void
- Clear();
-
- bool
- IsValid ()
- {
- if (!m_parsed)
- Parse();
- if (m_parse_error)
- return false;
- if (m_type == eTypeInvalid)
- return false;
- return (bool)m_full;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- const ConstString &
- GetFullName () const
- {
- return m_full;
- }
-
- std::string
- GetScopeQualifiedName ();
-
- llvm::StringRef
- GetBasename ();
-
- llvm::StringRef
- GetContext ();
-
- llvm::StringRef
- GetArguments ();
-
- llvm::StringRef
- GetQualifiers ();
+ class MethodName {
+ public:
+ enum Type {
+ eTypeInvalid,
+ eTypeUnknownMethod,
+ eTypeClassMethod,
+ eTypeInstanceMethod
+ };
- protected:
- void
+ MethodName()
+ : m_full(), m_basename(), m_context(), m_arguments(), m_qualifiers(),
+ m_type(eTypeInvalid), m_parsed(false), m_parse_error(false) {}
+
+ MethodName(const ConstString &s)
+ : m_full(s), m_basename(), m_context(), m_arguments(), m_qualifiers(),
+ m_type(eTypeInvalid), m_parsed(false), m_parse_error(false) {}
+
+ void Clear();
+
+ bool IsValid() {
+ if (!m_parsed)
Parse();
+ if (m_parse_error)
+ return false;
+ if (m_type == eTypeInvalid)
+ return false;
+ return (bool)m_full;
+ }
- ConstString m_full; // Full name: "lldb::SBTarget::GetBreakpointAtIndex(unsigned int) const"
- llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
- llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
- llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
- llvm::StringRef m_qualifiers; // Qualifiers: "const"
- Type m_type;
- bool m_parsed;
- bool m_parse_error;
- };
+ Type GetType() const { return m_type; }
- CPlusPlusLanguage() = default;
+ const ConstString &GetFullName() const { return m_full; }
- ~CPlusPlusLanguage() override = default;
+ std::string GetScopeQualifiedName();
- lldb::LanguageType
- GetLanguageType () const override
- {
- return lldb::eLanguageTypeC_plus_plus;
- }
-
- lldb::TypeCategoryImplSP
- GetFormatters () override;
-
- HardcodedFormatters::HardcodedSummaryFinder
- GetHardcodedSummaries () override;
-
- HardcodedFormatters::HardcodedSyntheticFinder
- GetHardcodedSynthetics () override;
-
- //------------------------------------------------------------------
- // Static Functions
- //------------------------------------------------------------------
- static void
- Initialize();
-
- static void
- Terminate();
-
- static lldb_private::Language *
- CreateInstance (lldb::LanguageType language);
-
- static lldb_private::ConstString
- GetPluginNameStatic();
-
- static bool
- IsCPPMangledName(const char *name);
-
- // Extract C++ context and identifier from a string using heuristic matching (as opposed to
- // CPlusPlusLanguage::MethodName which has to have a fully qualified C++ name with parens and arguments.
- // If the name is a lone C identifier (e.g. C) or a qualified C identifier (e.g. A::B::C) it will return true,
- // and identifier will be the identifier (C and C respectively) and the context will be "" and "A::B::" respectively.
- // If the name fails the heuristic matching for a qualified or unqualified C/C++ identifier, then it will return false
- // and identifier and context will be unchanged.
-
- static bool
- ExtractContextAndIdentifier (const char *name, llvm::StringRef &context, llvm::StringRef &identifier);
-
- // in some cases, compilers will output different names for one same type. when that happens, it might be impossible
- // to construct SBType objects for a valid type, because the name that is available is not the same as the name that
- // can be used as a search key in FindTypes(). the equivalents map here is meant to return possible alternative names
- // for a type through which a search can be conducted. Currently, this is only enabled for C++ but can be extended
- // to ObjC or other languages if necessary
- static uint32_t
- FindEquivalentNames(ConstString type_name, std::vector<ConstString>& equivalents);
-
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- ConstString
- GetPluginName() override;
-
- uint32_t
- GetPluginVersion() override;
+ llvm::StringRef GetBasename();
+
+ llvm::StringRef GetContext();
+
+ llvm::StringRef GetArguments();
+
+ llvm::StringRef GetQualifiers();
+
+ protected:
+ void Parse();
+
+ ConstString m_full; // Full name:
+ // "lldb::SBTarget::GetBreakpointAtIndex(unsigned int)
+ // const"
+ llvm::StringRef m_basename; // Basename: "GetBreakpointAtIndex"
+ llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
+ llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
+ llvm::StringRef m_qualifiers; // Qualifiers: "const"
+ Type m_type;
+ bool m_parsed;
+ bool m_parse_error;
+ };
+
+ CPlusPlusLanguage() = default;
+
+ ~CPlusPlusLanguage() override = default;
+
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeC_plus_plus;
+ }
+
+ lldb::TypeCategoryImplSP GetFormatters() override;
+
+ HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
+
+ HardcodedFormatters::HardcodedSyntheticFinder
+ GetHardcodedSynthetics() override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static bool IsCPPMangledName(const char *name);
+
+ // Extract C++ context and identifier from a string using heuristic matching
+ // (as opposed to
+ // CPlusPlusLanguage::MethodName which has to have a fully qualified C++ name
+ // with parens and arguments.
+ // If the name is a lone C identifier (e.g. C) or a qualified C identifier
+ // (e.g. A::B::C) it will return true,
+ // and identifier will be the identifier (C and C respectively) and the
+ // context will be "" and "A::B::" respectively.
+ // If the name fails the heuristic matching for a qualified or unqualified
+ // C/C++ identifier, then it will return false
+ // and identifier and context will be unchanged.
+
+ static bool ExtractContextAndIdentifier(const char *name,
+ llvm::StringRef &context,
+ llvm::StringRef &identifier);
+
+ // in some cases, compilers will output different names for one same type.
+ // when that happens, it might be impossible
+ // to construct SBType objects for a valid type, because the name that is
+ // available is not the same as the name that
+ // can be used as a search key in FindTypes(). the equivalents map here is
+ // meant to return possible alternative names
+ // for a type through which a search can be conducted. Currently, this is only
+ // enabled for C++ but can be extended
+ // to ObjC or other languages if necessary
+ static uint32_t FindEquivalentNames(ConstString type_name,
+ std::vector<ConstString> &equivalents);
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
};
-
+
} // namespace lldb_private
#endif // liblldb_CPlusPlusLanguage_h_
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp Tue Sep 6 15:57:50 2016
@@ -16,6 +16,7 @@
#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Endian.h"
@@ -24,7 +25,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ProcessStructReader.h"
-#include "lldb/DataFormatters/FormattersHelpers.h"
#include <algorithm>
@@ -38,187 +38,191 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-bool
-lldb_private::formatters::Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
- if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken("u");
-
- if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
+bool lldb_private::formatters::Char16StringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("u");
+
+ if (!StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options)) {
+ stream.Printf("Summary Unavailable");
return true;
+ }
+
+ return true;
}
-bool
-lldb_private::formatters::Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
- if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken("U");
-
- if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
-
+bool lldb_private::formatters::Char32StringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("U");
+
+ if (!StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF32>(options)) {
+ stream.Printf("Summary Unavailable");
return true;
+ }
+
+ return true;
}
-bool
-lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
- if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- // Get a wchar_t basic type from the current type system
- CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
-
- if (!wchar_compiler_type)
- return false;
-
- const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetPrefixToken("L");
-
- switch (wchar_size)
- {
- case 8:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
- case 16:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
- case 32:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
+bool lldb_private::formatters::WCharStringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
+ if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ // Get a wchar_t basic type from the current type system
+ CompilerType wchar_compiler_type =
+ valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
+
+ if (!wchar_compiler_type)
+ return false;
+
+ const uint32_t wchar_size = wchar_compiler_type.GetBitSize(
+ nullptr); // Safe to pass NULL for exe_scope here
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+
+ switch (wchar_size) {
+ case 8:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF8>(options);
+ case 16:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options);
+ case 32:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF32>(options);
+ default:
+ stream.Printf("size for wchar_t is not valid");
return true;
+ }
+ return true;
}
-bool
-lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken("u");
- options.SetQuote('\'');
- options.SetSourceSize(1);
- options.SetBinaryZeroIsTerminator(false);
-
- return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
-}
-
-bool
-lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- std::string value;
- valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
- if (!value.empty())
- stream.Printf("%s ", value.c_str());
-
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken("U");
- options.SetQuote('\'');
- options.SetSourceSize(1);
- options.SetBinaryZeroIsTerminator(false);
-
- return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
-}
-
-bool
-lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
-{
- DataExtractor data;
- Error error;
- valobj.GetData(data, error);
-
- if (error.Fail())
- return false;
-
- // Get a wchar_t basic type from the current type system
- CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
-
- if (!wchar_compiler_type)
- return false;
-
- const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
-
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
- options.SetData(data);
- options.SetStream(&stream);
- options.SetPrefixToken("L");
- options.SetQuote('\'');
- options.SetSourceSize(1);
- options.SetBinaryZeroIsTerminator(false);
-
- switch (wchar_size)
- {
- case 8:
- return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
- case 16:
- return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
- case 32:
- return StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
+bool lldb_private::formatters::Char16SummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ std::string value;
+ valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
+ if (!value.empty())
+ stream.Printf("%s ", value.c_str());
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("u");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ return StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options);
+}
+
+bool lldb_private::formatters::Char32SummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ std::string value;
+ valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
+ if (!value.empty())
+ stream.Printf("%s ", value.c_str());
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("U");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ return StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::UTF32>(options);
+}
+
+bool lldb_private::formatters::WCharSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &) {
+ DataExtractor data;
+ Error error;
+ valobj.GetData(data, error);
+
+ if (error.Fail())
+ return false;
+
+ // Get a wchar_t basic type from the current type system
+ CompilerType wchar_compiler_type =
+ valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
+
+ if (!wchar_compiler_type)
+ return false;
+
+ const uint32_t wchar_size = wchar_compiler_type.GetBitSize(
+ nullptr); // Safe to pass NULL for exe_scope here
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+ options.SetData(data);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+ options.SetQuote('\'');
+ options.SetSourceSize(1);
+ options.SetBinaryZeroIsTerminator(false);
+
+ switch (wchar_size) {
+ case 8:
+ return StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::UTF8>(options);
+ case 16:
+ return StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options);
+ case 32:
+ return StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::UTF32>(options);
+ default:
+ stream.Printf("size for wchar_t is not valid");
return true;
+ }
+ return true;
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CxxStringTypes.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- CxxStringTypes.h ----------------------------------------------*- C++ -*-===//
+//===-- CxxStringTypes.h ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,27 +16,29 @@
#include "lldb/DataFormatters/TypeSummary.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar*
-
- bool
- Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t*
-
- bool
- WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t*
-
- bool
- Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar
-
- bool
- Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t
-
- bool
- WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t
-
- } // namespace formatters
+namespace formatters {
+bool Char16StringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // char16_t* and unichar*
+
+bool Char32StringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // char32_t*
+
+bool WCharStringSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // wchar_t*
+
+bool Char16SummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // char16_t and unichar
+
+bool Char32SummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // char32_t
+
+bool WCharSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // wchar_t
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_CxxStringTypes_h_
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp Tue Sep 6 15:57:50 2016
@@ -32,197 +32,204 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-bool
-lldb_private::formatters::LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
- if (!valobj_sp)
- return false;
- ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
- ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_owners_")} ));
- ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_weak_owners_")} ));
-
- if (!ptr_sp)
- return false;
-
- if (ptr_sp->GetValueAsUnsigned(0) == 0)
- {
- stream.Printf("nullptr");
- return true;
- }
- else
- {
- bool print_pointee = false;
- Error error;
- ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
- if (pointee_sp && error.Success())
- {
- if (pointee_sp->DumpPrintableRepresentation(stream,
- ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
- ValueObject::ePrintableRepresentationSpecialCasesDisable,
- false))
- print_pointee = true;
- }
- if (!print_pointee)
- stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
- }
-
- if (count_sp)
- stream.Printf(" strong=%" PRIu64, 1+count_sp->GetValueAsUnsigned(0));
-
- if (weakcount_sp)
- stream.Printf(" weak=%" PRIu64, 1+weakcount_sp->GetValueAsUnsigned(0));
-
- return true;
-}
+bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+ ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
+ {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
+ ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
+ {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_bool_type(),
- m_exe_ctx_ref(),
- m_count(0),
- m_base_data_address(0),
- m_children()
-{
- if (valobj_sp)
- {
- Update();
- m_bool_type = valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
- }
-}
+ if (!ptr_sp)
+ return false;
-size_t
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::CalculateNumChildren ()
-{
- return m_count;
+ if (ptr_sp->GetValueAsUnsigned(0) == 0) {
+ stream.Printf("nullptr");
+ return true;
+ } else {
+ bool print_pointee = false;
+ Error error;
+ ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
+ if (pointee_sp && error.Success()) {
+ if (pointee_sp->DumpPrintableRepresentation(
+ stream, ValueObject::eValueObjectRepresentationStyleSummary,
+ lldb::eFormatInvalid,
+ ValueObject::ePrintableRepresentationSpecialCasesDisable, false))
+ print_pointee = true;
+ }
+ if (!print_pointee)
+ stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
+ }
+
+ if (count_sp)
+ stream.Printf(" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
+
+ if (weakcount_sp)
+ stream.Printf(" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
+
+ return true;
+}
+
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_bool_type(), m_exe_ctx_ref(),
+ m_count(0), m_base_data_address(0), m_children() {
+ if (valobj_sp) {
+ Update();
+ m_bool_type =
+ valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
+ }
+}
+
+size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return m_count;
}
lldb::ValueObjectSP
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- auto iter = m_children.find(idx),
- end = m_children.end();
- if (iter != end)
- return iter->second;
- if (idx >= m_count)
- return ValueObjectSP();
- if (m_base_data_address == 0 || m_count == 0)
- return ValueObjectSP();
- if (!m_bool_type)
- return ValueObjectSP();
- size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
- size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
- lldb::addr_t byte_location = m_base_data_address + byte_idx;
- ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
- if (!process_sp)
- return ValueObjectSP();
- uint8_t byte = 0;
- uint8_t mask = 0;
- Error err;
- size_t bytes_read = process_sp->ReadMemory(byte_location, &byte, 1, err);
- if (err.Fail() || bytes_read == 0)
- return ValueObjectSP();
- switch (bit_index)
- {
- case 0:
- mask = 1; break;
- case 1:
- mask = 2; break;
- case 2:
- mask = 4; break;
- case 3:
- mask = 8; break;
- case 4:
- mask = 16; break;
- case 5:
- mask = 32; break;
- case 6:
- mask = 64; break;
- case 7:
- mask = 128; break;
- default:
- return ValueObjectSP();
- }
- bool bit_set = ((byte & mask) != 0);
- DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(nullptr), 0));
- if (bit_set && buffer_sp && buffer_sp->GetBytes())
- *(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true
- StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- ValueObjectSP retval_sp(CreateValueObjectFromData(name.GetData(), DataExtractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()), m_exe_ctx_ref, m_bool_type));
- if (retval_sp)
- m_children[idx] = retval_sp;
- return retval_sp;
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ auto iter = m_children.find(idx), end = m_children.end();
+ if (iter != end)
+ return iter->second;
+ if (idx >= m_count)
+ return ValueObjectSP();
+ if (m_base_data_address == 0 || m_count == 0)
+ return ValueObjectSP();
+ if (!m_bool_type)
+ return ValueObjectSP();
+ size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
+ size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
+ lldb::addr_t byte_location = m_base_data_address + byte_idx;
+ ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
+ if (!process_sp)
+ return ValueObjectSP();
+ uint8_t byte = 0;
+ uint8_t mask = 0;
+ Error err;
+ size_t bytes_read = process_sp->ReadMemory(byte_location, &byte, 1, err);
+ if (err.Fail() || bytes_read == 0)
+ return ValueObjectSP();
+ switch (bit_index) {
+ case 0:
+ mask = 1;
+ break;
+ case 1:
+ mask = 2;
+ break;
+ case 2:
+ mask = 4;
+ break;
+ case 3:
+ mask = 8;
+ break;
+ case 4:
+ mask = 16;
+ break;
+ case 5:
+ mask = 32;
+ break;
+ case 6:
+ mask = 64;
+ break;
+ case 7:
+ mask = 128;
+ break;
+ default:
+ return ValueObjectSP();
+ }
+ bool bit_set = ((byte & mask) != 0);
+ DataBufferSP buffer_sp(
+ new DataBufferHeap(m_bool_type.GetByteSize(nullptr), 0));
+ if (bit_set && buffer_sp && buffer_sp->GetBytes())
+ *(buffer_sp->GetBytes()) =
+ 1; // regardless of endianness, anything non-zero is true
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ ValueObjectSP retval_sp(CreateValueObjectFromData(
+ name.GetData(), DataExtractor(buffer_sp, process_sp->GetByteOrder(),
+ process_sp->GetAddressByteSize()),
+ m_exe_ctx_ref, m_bool_type));
+ if (retval_sp)
+ m_children[idx] = retval_sp;
+ return retval_sp;
}
/*(std::__1::vector<std::__1::allocator<bool> >) vBool = {
__begin_ = 0x00000001001000e0
__size_ = 56
__cap_alloc_ = {
- std::__1::__libcpp_compressed_pair_imp<unsigned long, std::__1::allocator<unsigned long> > = {
+ std::__1::__libcpp_compressed_pair_imp<unsigned long,
+ std::__1::allocator<unsigned long> > = {
__first_ = 1
}
}
}*/
-bool
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update()
-{
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- ValueObjectSP size_sp(valobj_sp->GetChildMemberWithName(ConstString("__size_"), true));
- if (!size_sp)
- return false;
- m_count = size_sp->GetValueAsUnsigned(0);
- if (!m_count)
- return true;
- ValueObjectSP begin_sp(valobj_sp->GetChildMemberWithName(ConstString("__begin_"), true));
- if (!begin_sp)
- {
- m_count = 0;
- return false;
- }
- m_base_data_address = begin_sp->GetValueAsUnsigned(0);
- if (!m_base_data_address)
- {
- m_count = 0;
- return false;
- }
+bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+ ValueObjectSP size_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__size_"), true));
+ if (!size_sp)
return false;
+ m_count = size_sp->GetValueAsUnsigned(0);
+ if (!m_count)
+ return true;
+ ValueObjectSP begin_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__begin_"), true));
+ if (!begin_sp) {
+ m_count = 0;
+ return false;
+ }
+ m_base_data_address = begin_sp->GetValueAsUnsigned(0);
+ if (!m_base_data_address) {
+ m_count = 0;
+ return false;
+ }
+ return false;
}
-bool
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
+bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (!m_count || !m_base_data_address)
+ return UINT32_MAX;
+ const char *item_name = name.GetCString();
+ uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
}
-size_t
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_count || !m_base_data_address)
- return UINT32_MAX;
- const char* item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::~LibcxxVectorBoolSyntheticFrontEnd() = default;
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp) : nullptr);
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ ~LibcxxVectorBoolSyntheticFrontEnd() = default;
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
/*
(lldb) fr var ibeg --raw --ptr-depth 1
- (std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::__tree_node<std::__1::pair<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, void *> *, long> >) ibeg = {
+ (std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int,
+ std::__1::basic_string<char, std::__1::char_traits<char>,
+ std::__1::allocator<char> > >, std::__1::__tree_node<std::__1::pair<int,
+ std::__1::basic_string<char, std::__1::char_traits<char>,
+ std::__1::allocator<char> > >, void *> *, long> >) ibeg = {
__i_ = {
__ptr_ = 0x0000000100103870 {
std::__1::__tree_node_base<void *> = {
@@ -238,82 +245,84 @@ lldb_private::formatters::LibcxxVectorBo
second = { std::string }
*/
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_pair_ptr()
-{
- if (valobj_sp)
- Update();
+lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
+ LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr() {
+ if (valobj_sp)
+ Update();
}
-bool
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update()
-{
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- TargetSP target_sp(valobj_sp->GetTargetSP());
-
- if (!target_sp)
- return false;
-
- if (!valobj_sp)
- return false;
-
- // this must be a ValueObject* because it is a child of the ValueObject we are producing children for
- // it if were a ValueObjectSP, we would end up with a loop (iterator -> synthetic -> child -> parent == iterator)
- // and that would in turn leak memory by never allowing the ValueObjects to die and free their memory
- m_pair_ptr = valobj_sp->GetValueForExpressionPath(".__i_.__ptr_->__value_",
- nullptr,
- nullptr,
- nullptr,
- ValueObject::GetValueForExpressionPathOptions().DontCheckDotVsArrowSyntax().SetSyntheticChildrenTraversal(ValueObject::GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None),
- nullptr).get();
-
+bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
return false;
-}
-size_t
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::CalculateNumChildren ()
-{
- return 2;
-}
+ TargetSP target_sp(valobj_sp->GetTargetSP());
-lldb::ValueObjectSP
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_pair_ptr)
- return lldb::ValueObjectSP();
- return m_pair_ptr->GetChildAtIndex(idx, true);
-}
-
-bool
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
+ if (!target_sp)
+ return false;
-size_t
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (name == ConstString("first"))
- return 0;
- if (name == ConstString("second"))
- return 1;
- return UINT32_MAX;
-}
+ if (!valobj_sp)
+ return false;
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::~LibCxxMapIteratorSyntheticFrontEnd ()
-{
- // this will be deleted when its parent dies (since it's a child object)
- //delete m_pair_ptr;
+ // this must be a ValueObject* because it is a child of the ValueObject we are
+ // producing children for
+ // it if were a ValueObjectSP, we would end up with a loop (iterator ->
+ // synthetic -> child -> parent == iterator)
+ // and that would in turn leak memory by never allowing the ValueObjects to
+ // die and free their memory
+ m_pair_ptr = valobj_sp
+ ->GetValueForExpressionPath(
+ ".__i_.__ptr_->__value_", nullptr, nullptr, nullptr,
+ ValueObject::GetValueForExpressionPathOptions()
+ .DontCheckDotVsArrowSyntax()
+ .SetSyntheticChildrenTraversal(
+ ValueObject::GetValueForExpressionPathOptions::
+ SyntheticChildrenTraversal::None),
+ nullptr)
+ .get();
+
+ return false;
+}
+
+size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return 2;
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibCxxMapIteratorSyntheticFrontEnd(valobj_sp) : nullptr);
+lldb::ValueObjectSP
+lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ if (!m_pair_ptr)
+ return lldb::ValueObjectSP();
+ return m_pair_ptr->GetChildAtIndex(idx, true);
+}
+
+bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (name == ConstString("first"))
+ return 0;
+ if (name == ConstString("second"))
+ return 1;
+ return UINT32_MAX;
+}
+
+lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
+ ~LibCxxMapIteratorSyntheticFrontEnd() {
+ // this will be deleted when its parent dies (since it's a child object)
+ // delete m_pair_ptr;
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibCxxMapIteratorSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
/*
@@ -325,346 +334,341 @@ lldb_private::formatters::LibCxxMapItera
}
*/
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- static ConstString g_item_name;
- if (!g_item_name)
- g_item_name.SetCString("__i");
- return (valobj_sp ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name) : nullptr);
-}
-
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_cntrl(nullptr),
- m_count_sp(),
- m_weak_count_sp(),
- m_ptr_size(0),
- m_byte_order(lldb::eByteOrderInvalid)
-{
- if (valobj_sp)
- Update();
-}
-
-size_t
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::CalculateNumChildren ()
-{
- return (m_cntrl ? 1 : 0);
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ static ConstString g_item_name;
+ if (!g_item_name)
+ g_item_name.SetCString("__i");
+ return (valobj_sp
+ ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name)
+ : nullptr);
+}
+
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+ LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr), m_count_sp(),
+ m_weak_count_sp(), m_ptr_size(0), m_byte_order(lldb::eByteOrderInvalid) {
+ if (valobj_sp)
+ Update();
+}
+
+size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return (m_cntrl ? 1 : 0);
}
lldb::ValueObjectSP
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_cntrl)
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ if (!m_cntrl)
+ return lldb::ValueObjectSP();
+
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return lldb::ValueObjectSP();
+
+ if (idx == 0)
+ return valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true);
+
+ if (idx > 2)
+ return lldb::ValueObjectSP();
+
+ if (idx == 1) {
+ if (!m_count_sp) {
+ ValueObjectSP shared_owners_sp(m_cntrl->GetChildMemberWithName(
+ ConstString("__shared_owners_"), true));
+ if (!shared_owners_sp)
return lldb::ValueObjectSP();
-
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
+ uint64_t count = 1 + shared_owners_sp->GetValueAsUnsigned(0);
+ DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
+ m_count_sp = CreateValueObjectFromData(
+ "count", data, valobj_sp->GetExecutionContextRef(),
+ shared_owners_sp->GetCompilerType());
+ }
+ return m_count_sp;
+ } else /* if (idx == 2) */
+ {
+ if (!m_weak_count_sp) {
+ ValueObjectSP shared_weak_owners_sp(m_cntrl->GetChildMemberWithName(
+ ConstString("__shared_weak_owners_"), true));
+ if (!shared_weak_owners_sp)
return lldb::ValueObjectSP();
+ uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0);
+ DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
+ m_weak_count_sp = CreateValueObjectFromData(
+ "count", data, valobj_sp->GetExecutionContextRef(),
+ shared_weak_owners_sp->GetCompilerType());
+ }
+ return m_weak_count_sp;
+ }
+}
+
+bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
+ m_count_sp.reset();
+ m_weak_count_sp.reset();
+ m_cntrl = nullptr;
- if (idx == 0)
- return valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true);
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
- if (idx > 2)
- return lldb::ValueObjectSP();
+ TargetSP target_sp(valobj_sp->GetTargetSP());
+ if (!target_sp)
+ return false;
- if (idx == 1)
- {
- if (!m_count_sp)
- {
- ValueObjectSP shared_owners_sp(m_cntrl->GetChildMemberWithName(ConstString("__shared_owners_"),true));
- if (!shared_owners_sp)
- return lldb::ValueObjectSP();
- uint64_t count = 1 + shared_owners_sp->GetValueAsUnsigned(0);
- DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
- m_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_owners_sp->GetCompilerType());
- }
- return m_count_sp;
- }
- else /* if (idx == 2) */
- {
- if (!m_weak_count_sp)
- {
- ValueObjectSP shared_weak_owners_sp(m_cntrl->GetChildMemberWithName(ConstString("__shared_weak_owners_"),true));
- if (!shared_weak_owners_sp)
- return lldb::ValueObjectSP();
- uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0);
- DataExtractor data(&count, 8, m_byte_order, m_ptr_size);
- m_weak_count_sp = CreateValueObjectFromData("count", data, valobj_sp->GetExecutionContextRef(), shared_weak_owners_sp->GetCompilerType());
- }
- return m_weak_count_sp;
- }
-}
+ m_byte_order = target_sp->GetArchitecture().GetByteOrder();
+ m_ptr_size = target_sp->GetArchitecture().GetAddressByteSize();
-bool
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update()
-{
- m_count_sp.reset();
- m_weak_count_sp.reset();
- m_cntrl = nullptr;
-
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- TargetSP target_sp(valobj_sp->GetTargetSP());
- if (!target_sp)
- return false;
-
- m_byte_order = target_sp->GetArchitecture().GetByteOrder();
- m_ptr_size = target_sp->GetArchitecture().GetAddressByteSize();
-
- lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName(ConstString("__cntrl_"),true));
-
- m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular dependency
- return false;
+ lldb::ValueObjectSP cntrl_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__cntrl_"), true));
+
+ m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular
+ // dependency
+ return false;
}
-bool
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
+bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
}
-size_t
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (name == ConstString("__ptr_"))
- return 0;
- if (name == ConstString("count"))
- return 1;
- if (name == ConstString("weak_count"))
- return 2;
- return UINT32_MAX;
+size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (name == ConstString("__ptr_"))
+ return 0;
+ if (name == ConstString("count"))
+ return 1;
+ if (name == ConstString("weak_count"))
+ return 2;
+ return UINT32_MAX;
}
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::~LibcxxSharedPtrSyntheticFrontEnd() = default;
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+ ~LibcxxSharedPtrSyntheticFrontEnd() = default;
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxSharedPtrSyntheticFrontEnd(valobj_sp) : nullptr);
-}
-
-bool
-lldb_private::formatters::LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- if (valobj.IsPointerType())
- {
- uint64_t value = valobj.GetValueAsUnsigned(0);
- if (!value)
- return false;
- stream.Printf("0x%016" PRIx64 " ", value);
- }
- return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr, nullptr, nullptr, &valobj, false, false);
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxSharedPtrSyntheticFrontEnd(valobj_sp)
+ : nullptr);
+}
+
+bool lldb_private::formatters::LibcxxContainerSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ if (valobj.IsPointerType()) {
+ uint64_t value = valobj.GetValueAsUnsigned(0);
+ if (!value)
+ return false;
+ stream.Printf("0x%016" PRIx64 " ", value);
+ }
+ return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr,
+ nullptr, nullptr, &valobj, false, false);
}
// the field layout in a libc++ string (cap, side, data or data, size, cap)
-enum LibcxxStringLayoutMode
-{
- eLibcxxStringLayoutModeCSD = 0,
- eLibcxxStringLayoutModeDSC = 1,
- eLibcxxStringLayoutModeInvalid = 0xffff
+enum LibcxxStringLayoutMode {
+ eLibcxxStringLayoutModeCSD = 0,
+ eLibcxxStringLayoutModeDSC = 1,
+ eLibcxxStringLayoutModeInvalid = 0xffff
};
// this function abstracts away the layout and mode details of a libc++ string
// and returns the address of the data and the size ready for callers to consume
-static bool
-ExtractLibcxxStringInfo (ValueObject& valobj,
- ValueObjectSP &location_sp,
- uint64_t& size)
-{
- ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
- if (!D)
- return false;
-
- ValueObjectSP layout_decider(D->GetChildAtIndexPath({0,0}));
-
- // this child should exist
- if (!layout_decider)
+static bool ExtractLibcxxStringInfo(ValueObject &valobj,
+ ValueObjectSP &location_sp,
+ uint64_t &size) {
+ ValueObjectSP D(valobj.GetChildAtIndexPath({0, 0, 0, 0}));
+ if (!D)
+ return false;
+
+ ValueObjectSP layout_decider(D->GetChildAtIndexPath({0, 0}));
+
+ // this child should exist
+ if (!layout_decider)
+ return false;
+
+ ConstString g_data_name("__data_");
+ ConstString g_size_name("__size_");
+ bool short_mode = false; // this means the string is in short-mode and the
+ // data is stored inline
+ LibcxxStringLayoutMode layout = (layout_decider->GetName() == g_data_name)
+ ? eLibcxxStringLayoutModeDSC
+ : eLibcxxStringLayoutModeCSD;
+ uint64_t size_mode_value = 0;
+
+ if (layout == eLibcxxStringLayoutModeDSC) {
+ ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 1, 0}));
+ if (!size_mode)
+ return false;
+
+ if (size_mode->GetName() != g_size_name) {
+ // we are hitting the padding structure, move along
+ size_mode = D->GetChildAtIndexPath({1, 1, 1});
+ if (!size_mode)
return false;
-
- ConstString g_data_name("__data_");
- ConstString g_size_name("__size_");
- bool short_mode = false; // this means the string is in short-mode and the data is stored inline
- LibcxxStringLayoutMode layout = (layout_decider->GetName() == g_data_name) ? eLibcxxStringLayoutModeDSC : eLibcxxStringLayoutModeCSD;
- uint64_t size_mode_value = 0;
-
- if (layout == eLibcxxStringLayoutModeDSC)
- {
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,1,0}));
- if (!size_mode)
- return false;
-
- if (size_mode->GetName() != g_size_name)
- {
- // we are hitting the padding structure, move along
- size_mode = D->GetChildAtIndexPath({1,1,1});
- if (!size_mode)
- return false;
- }
-
- size_mode_value = (size_mode->GetValueAsUnsigned(0));
- short_mode = ((size_mode_value & 0x80) == 0);
- }
- else
- {
- ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
- if (!size_mode)
- return false;
-
- size_mode_value = (size_mode->GetValueAsUnsigned(0));
- short_mode = ((size_mode_value & 1) == 0);
- }
-
- if (short_mode)
- {
- ValueObjectSP s(D->GetChildAtIndex(1, true));
- if (!s)
- return false;
- location_sp = s->GetChildAtIndex((layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
- size = (layout == eLibcxxStringLayoutModeDSC) ? size_mode_value : ((size_mode_value >> 1) % 256);
- return (location_sp.get() != nullptr);
- }
- else
- {
- ValueObjectSP l(D->GetChildAtIndex(0, true));
- if (!l)
- return false;
- // we can use the layout_decider object as the data pointer
- location_sp = (layout == eLibcxxStringLayoutModeDSC) ? layout_decider : l->GetChildAtIndex(2, true);
- ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
- if (!size_vo || !location_sp)
- return false;
- size = size_vo->GetValueAsUnsigned(0);
- return true;
}
+
+ size_mode_value = (size_mode->GetValueAsUnsigned(0));
+ short_mode = ((size_mode_value & 0x80) == 0);
+ } else {
+ ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 0, 0}));
+ if (!size_mode)
+ return false;
+
+ size_mode_value = (size_mode->GetValueAsUnsigned(0));
+ short_mode = ((size_mode_value & 1) == 0);
+ }
+
+ if (short_mode) {
+ ValueObjectSP s(D->GetChildAtIndex(1, true));
+ if (!s)
+ return false;
+ location_sp = s->GetChildAtIndex(
+ (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
+ size = (layout == eLibcxxStringLayoutModeDSC)
+ ? size_mode_value
+ : ((size_mode_value >> 1) % 256);
+ return (location_sp.get() != nullptr);
+ } else {
+ ValueObjectSP l(D->GetChildAtIndex(0, true));
+ if (!l)
+ return false;
+ // we can use the layout_decider object as the data pointer
+ location_sp = (layout == eLibcxxStringLayoutModeDSC)
+ ? layout_decider
+ : l->GetChildAtIndex(2, true);
+ ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
+ if (!size_vo || !location_sp)
+ return false;
+ size = size_vo->GetValueAsUnsigned(0);
+ return true;
+ }
}
-bool
-lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp;
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
- if (size == 0)
- {
- stream.Printf("L\"\"");
- return true;
- }
- if (!location_sp)
- return false;
-
- DataExtractor extractor;
-
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
-
- if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
- {
- const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
- if (size > max_size)
- {
- size = max_size;
- options.SetIsTruncated(true);
- }
- }
- location_sp->GetPointeeData(extractor, 0, size);
-
- // std::wstring::size() is measured in 'characters', not bytes
- auto wchar_t_size = valobj.GetTargetSP()->GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
-
- options.SetData(extractor);
- options.SetStream(&stream);
- options.SetPrefixToken("L");
- options.SetQuote('"');
- options.SetSourceSize(size);
- options.SetBinaryZeroIsTerminator(false);
-
- switch (wchar_t_size)
- {
- case 1:
- StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF8>(options);
- break;
-
- case 2:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF16>(options);
- break;
-
- case 4:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::UTF32>(options);
- break;
-
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
-
+bool lldb_private::formatters::LibcxxWStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options) {
+ uint64_t size = 0;
+ ValueObjectSP location_sp;
+ if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ return false;
+ if (size == 0) {
+ stream.Printf("L\"\"");
return true;
+ }
+ if (!location_sp)
+ return false;
+
+ DataExtractor extractor;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
+ if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size) {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
+ location_sp->GetPointeeData(extractor, 0, size);
+
+ // std::wstring::size() is measured in 'characters', not bytes
+ auto wchar_t_size = valobj.GetTargetSP()
+ ->GetScratchClangASTContext()
+ ->GetBasicType(lldb::eBasicTypeWChar)
+ .GetByteSize(nullptr);
+
+ options.SetData(extractor);
+ options.SetStream(&stream);
+ options.SetPrefixToken("L");
+ options.SetQuote('"');
+ options.SetSourceSize(size);
+ options.SetBinaryZeroIsTerminator(false);
+
+ switch (wchar_t_size) {
+ case 1:
+ StringPrinter::ReadBufferAndDumpToStream<
+ lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
+ options);
+ break;
+
+ case 2:
+ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
+ options);
+ break;
+
+ case 4:
+ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
+ options);
+ break;
+
+ default:
+ stream.Printf("size for wchar_t is not valid");
+ return true;
+ }
+
+ return true;
}
-bool
-lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
-{
- uint64_t size = 0;
- ValueObjectSP location_sp;
-
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
- return false;
-
- if (size == 0)
- {
- stream.Printf("\"\"");
- return true;
- }
-
- if (!location_sp)
- return false;
-
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
-
- DataExtractor extractor;
- if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
- {
- const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
- if (size > max_size)
- {
- size = max_size;
- options.SetIsTruncated(true);
- }
- }
- location_sp->GetPointeeData(extractor, 0, size);
-
- options.SetData(extractor);
- options.SetStream(&stream);
- options.SetPrefixToken(nullptr);
- options.SetQuote('"');
- options.SetSourceSize(size);
- options.SetBinaryZeroIsTerminator(false);
- StringPrinter::ReadBufferAndDumpToStream<StringPrinter::StringElementType::ASCII>(options);
-
+bool lldb_private::formatters::LibcxxStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options) {
+ uint64_t size = 0;
+ ValueObjectSP location_sp;
+
+ if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ return false;
+
+ if (size == 0) {
+ stream.Printf("\"\"");
return true;
+ }
+
+ if (!location_sp)
+ return false;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
+ DataExtractor extractor;
+ if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size) {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
+ location_sp->GetPointeeData(extractor, 0, size);
+
+ options.SetData(extractor);
+ options.SetStream(&stream);
+ options.SetPrefixToken(nullptr);
+ options.SetQuote('"');
+ options.SetSourceSize(size);
+ options.SetBinaryZeroIsTerminator(false);
+ StringPrinter::ReadBufferAndDumpToStream<
+ StringPrinter::StringElementType::ASCII>(options);
+
+ return true;
}
-class LibcxxFunctionFrontEnd : public SyntheticValueProviderFrontEnd
-{
+class LibcxxFunctionFrontEnd : public SyntheticValueProviderFrontEnd {
public:
- LibcxxFunctionFrontEnd (ValueObject &backend) :
- SyntheticValueProviderFrontEnd(backend)
- {}
-
- lldb::ValueObjectSP
- GetSyntheticValue() override
- {
- static ConstString g___f_("__f_");
- return m_backend.GetChildMemberWithName(g___f_, true);
- }
+ LibcxxFunctionFrontEnd(ValueObject &backend)
+ : SyntheticValueProviderFrontEnd(backend) {}
+
+ lldb::ValueObjectSP GetSyntheticValue() override {
+ static ConstString g___f_("__f_");
+ return m_backend.GetChildMemberWithName(g___f_, true);
+ }
};
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxFunctionFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- if (valobj_sp)
- return new LibcxxFunctionFrontEnd(*valobj_sp);
- return nullptr;
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxFunctionFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ if (valobj_sp)
+ return new LibcxxFunctionFrontEnd(*valobj_sp);
+ return nullptr;
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- LibCxx.h ---------------------------------------------------*- C++ -*-===//
+//===-- LibCxx.h ---------------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,128 +17,132 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
namespace lldb_private {
- namespace formatters
- {
-
- bool
- LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string
-
- bool
- LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring
-
- bool
- LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<>
-
- class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- ~LibcxxVectorBoolSyntheticFrontEnd() override;
-
- private:
- CompilerType m_bool_type;
- ExecutionContextRef m_exe_ctx_ref;
- uint64_t m_count;
- lldb::addr_t m_base_data_address;
- std::map<size_t,lldb::ValueObjectSP> m_children;
- };
-
- SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- bool
- LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- ~LibCxxMapIteratorSyntheticFrontEnd() override;
-
- private:
- ValueObject *m_pair_ptr;
- };
-
- SyntheticChildrenFrontEnd* LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- ~LibcxxSharedPtrSyntheticFrontEnd() override;
-
- private:
- ValueObject* m_cntrl;
- lldb::ValueObjectSP m_count_sp;
- lldb::ValueObjectSP m_weak_count_sp;
- uint8_t m_ptr_size;
- lldb::ByteOrder m_byte_order;
- };
-
- SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibcxxFunctionFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
+namespace formatters {
- } // namespace formatters
+bool LibcxxStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libc++ std::string
+
+bool LibcxxWStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libc++ std::wstring
+
+bool LibcxxSmartPointerSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions
+ &options); // libc++ std::shared_ptr<> and std::weak_ptr<>
+
+class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibcxxVectorBoolSyntheticFrontEnd() override;
+
+private:
+ CompilerType m_bool_type;
+ ExecutionContextRef m_exe_ctx_ref;
+ uint64_t m_count;
+ lldb::addr_t m_base_data_address;
+ std::map<size_t, lldb::ValueObjectSP> m_children;
+};
+
+SyntheticChildrenFrontEnd *
+LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
+class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibCxxMapIteratorSyntheticFrontEnd() override;
+
+private:
+ ValueObject *m_pair_ptr;
+};
+
+SyntheticChildrenFrontEnd *
+LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ ~LibcxxSharedPtrSyntheticFrontEnd() override;
+
+private:
+ ValueObject *m_cntrl;
+ lldb::ValueObjectSP m_count_sp;
+ lldb::ValueObjectSP m_weak_count_sp;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_byte_order;
+};
+
+SyntheticChildrenFrontEnd *
+LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *LibcxxFunctionFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_LibCxx_h_
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- LibCxxAtomic.cpp ------------------------------------------*- C++ -*-===//
+//===-- LibCxxAtomic.cpp ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,109 +14,92 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-bool
-lldb_private::formatters::LibCxxAtomicSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- static ConstString g___a_("__a_");
-
- if (ValueObjectSP child = valobj.GetChildMemberWithName(g___a_, true))
- {
- std::string summary;
- if (child->GetSummaryAsCString(summary, options) && summary.size() > 0)
- {
- stream.Printf("%s", summary.c_str());
- return true;
- }
+bool lldb_private::formatters::LibCxxAtomicSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ static ConstString g___a_("__a_");
+
+ if (ValueObjectSP child = valobj.GetChildMemberWithName(g___a_, true)) {
+ std::string summary;
+ if (child->GetSummaryAsCString(summary, options) && summary.size() > 0) {
+ stream.Printf("%s", summary.c_str());
+ return true;
}
-
- return false;
+ }
+
+ return false;
}
namespace lldb_private {
- namespace formatters {
- class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdAtomicSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxStdAtomicSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- lldb::ValueObjectSP
- GetSyntheticValue () override;
- private:
- ValueObject *m_real_child;
- };
- } // namespace formatters
-} // namespace lldb_private
+namespace formatters {
+class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::LibcxxStdAtomicSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_real_child(nullptr)
-{
-}
+ ~LibcxxStdAtomicSyntheticFrontEnd() override = default;
-bool
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update()
-{
- static ConstString g___a_("__a_");
+ size_t CalculateNumChildren() override;
- m_real_child = m_backend.GetChildMemberWithName(g___a_, true).get();
-
- return false;
-}
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
-bool
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::MightHaveChildren()
-{
- return true;
-}
+ bool Update() override;
-size_t
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::CalculateNumChildren()
-{
- return m_real_child ? m_real_child->GetNumChildren() : 0;
-}
+ bool MightHaveChildren() override;
-lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(size_t idx)
-{
- return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
-}
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ lldb::ValueObjectSP GetSyntheticValue() override;
-size_t
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetIndexOfChildWithName(const ConstString &name)
-{
- return m_real_child ? m_real_child->GetIndexOfChildWithName(name) : UINT32_MAX;
+private:
+ ValueObject *m_real_child;
+};
+} // namespace formatters
+} // namespace lldb_private
+
+lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+ LibcxxStdAtomicSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_real_child(nullptr) {}
+
+bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() {
+ static ConstString g___a_("__a_");
+
+ m_real_child = m_backend.GetChildMemberWithName(g___a_, true).get();
+
+ return false;
}
-lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetSyntheticValue ()
-{
- if (m_real_child && m_real_child->CanProvideValue())
- return m_real_child->GetSP();
- return nullptr;
+bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- if (valobj_sp)
- return new LibcxxStdAtomicSyntheticFrontEnd(valobj_sp);
- return nullptr;
+size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return m_real_child ? m_real_child->GetNumChildren() : 0;
}
+lldb::ValueObjectSP
+lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+}
+
+size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
+ : UINT32_MAX;
+}
+
+lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+ GetSyntheticValue() {
+ if (m_real_child && m_real_child->CanProvideValue())
+ return m_real_child->GetSP();
+ return nullptr;
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ if (valobj_sp)
+ return new LibcxxStdAtomicSyntheticFrontEnd(valobj_sp);
+ return nullptr;
+}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- LibCxxAtomic.h -------------------------------------------*- C++ -*-===//
+//===-- LibCxxAtomic.h -------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,14 +17,15 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- LibCxxAtomicSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- SyntheticChildrenFrontEnd* LibcxxAtomicSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- } // namespace formatters
+namespace formatters {
+bool LibCxxAtomicSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
+SyntheticChildrenFrontEnd *
+LibcxxAtomicSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_LibCxxAtomic_h_
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp Tue Sep 6 15:57:50 2016
@@ -22,115 +22,108 @@ using namespace lldb_private;
using namespace lldb_private::formatters;
namespace lldb_private {
- namespace formatters {
- class LibcxxInitializerListSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxInitializerListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxInitializerListSyntheticFrontEnd() override;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- ValueObject* m_start;
- CompilerType m_element_type;
- uint32_t m_element_size;
- size_t m_num_elements;
- };
- } // namespace formatters
-} // namespace lldb_private
+namespace formatters {
+class LibcxxInitializerListSyntheticFrontEnd
+ : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxInitializerListSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxInitializerListSyntheticFrontEnd() override;
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::LibcxxInitializerListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_start(nullptr),
- m_element_type(),
- m_element_size(0),
- m_num_elements(0)
-{
- if (valobj_sp)
- Update();
-}
-
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::~LibcxxInitializerListSyntheticFrontEnd()
-{
- // this needs to stay around because it's a child object who will follow its parent's life cycle
- // delete m_start;
-}
-
-size_t
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::CalculateNumChildren ()
-{
- static ConstString g___size_("__size_");
- m_num_elements = 0;
- ValueObjectSP size_sp(m_backend.GetChildMemberWithName(g___size_, true));
- if (size_sp)
- m_num_elements = size_sp->GetValueAsUnsigned(0);
- return m_num_elements;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_start)
- return lldb::ValueObjectSP();
-
- uint64_t offset = idx * m_element_size;
- offset = offset + m_start->GetValueAsUnsigned(0);
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- return CreateValueObjectFromAddress(name.GetData(), offset, m_backend.GetExecutionContextRef(), m_element_type);
-}
-
-bool
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update()
-{
- static ConstString g___begin_("__begin_");
-
- m_start = nullptr;
- m_num_elements = 0;
- lldb::TemplateArgumentKind kind;
- m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind);
- if (kind != lldb::eTemplateArgumentKindType || !m_element_type.IsValid())
- return false;
-
- m_element_size = m_element_type.GetByteSize(nullptr);
-
- if (m_element_size > 0)
- m_start = m_backend.GetChildMemberWithName(g___begin_,true).get(); // store raw pointers or end up with a circular dependency
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ ValueObject *m_start;
+ CompilerType m_element_type;
+ uint32_t m_element_size;
+ size_t m_num_elements;
+};
+} // namespace formatters
+} // namespace lldb_private
+lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ LibcxxInitializerListSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_start(nullptr), m_element_type(),
+ m_element_size(0), m_num_elements(0) {
+ if (valobj_sp)
+ Update();
+}
+
+lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ ~LibcxxInitializerListSyntheticFrontEnd() {
+ // this needs to stay around because it's a child object who will follow its
+ // parent's life cycle
+ // delete m_start;
+}
+
+size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ CalculateNumChildren() {
+ static ConstString g___size_("__size_");
+ m_num_elements = 0;
+ ValueObjectSP size_sp(m_backend.GetChildMemberWithName(g___size_, true));
+ if (size_sp)
+ m_num_elements = size_sp->GetValueAsUnsigned(0);
+ return m_num_elements;
+}
+
+lldb::ValueObjectSP lldb_private::formatters::
+ LibcxxInitializerListSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+ if (!m_start)
+ return lldb::ValueObjectSP();
+
+ uint64_t offset = idx * m_element_size;
+ offset = offset + m_start->GetValueAsUnsigned(0);
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ return CreateValueObjectFromAddress(name.GetData(), offset,
+ m_backend.GetExecutionContextRef(),
+ m_element_type);
+}
+
+bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ Update() {
+ static ConstString g___begin_("__begin_");
+
+ m_start = nullptr;
+ m_num_elements = 0;
+ lldb::TemplateArgumentKind kind;
+ m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind);
+ if (kind != lldb::eTemplateArgumentKindType || !m_element_type.IsValid())
return false;
+
+ m_element_size = m_element_type.GetByteSize(nullptr);
+
+ if (m_element_size > 0)
+ m_start =
+ m_backend.GetChildMemberWithName(g___begin_, true)
+ .get(); // store raw pointers or end up with a circular dependency
+
+ return false;
+}
+
+bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (!m_start)
+ return UINT32_MAX;
+ return ExtractIndexFromString(name.GetCString());
}
-bool
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_start)
- return UINT32_MAX;
- return ExtractIndexFromString(name.GetCString());
-}
-
-lldb_private::SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxInitializerListSyntheticFrontEnd(valobj_sp) : nullptr);
+lldb_private::SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxInitializerListSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp Tue Sep 6 15:57:50 2016
@@ -29,404 +29,330 @@ using namespace lldb_private::formatters
namespace {
- class ListEntry
- {
- public:
- ListEntry() = default;
- ListEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
- ListEntry(const ListEntry& rhs) = default;
- ListEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
-
- ListEntry
- next ()
- {
- static ConstString g_next("__next_");
-
- if (!m_entry_sp)
- return ListEntry();
- return ListEntry(m_entry_sp->GetChildMemberWithName(g_next, true));
- }
-
- ListEntry
- prev ()
- {
- static ConstString g_prev("__prev_");
-
- if (!m_entry_sp)
- return ListEntry();
- return ListEntry(m_entry_sp->GetChildMemberWithName(g_prev, true));
- }
-
- uint64_t
- value () const
- {
- if (!m_entry_sp)
- return 0;
- return m_entry_sp->GetValueAsUnsigned(0);
- }
-
- bool
- null()
- {
- return (value() == 0);
- }
-
- explicit operator bool ()
- {
- return GetEntry() && !null();
- }
-
- ValueObjectSP
- GetEntry ()
- {
- return m_entry_sp;
- }
-
- void
- SetEntry (ValueObjectSP entry)
- {
- m_entry_sp = entry;
- }
-
- bool
- operator == (const ListEntry& rhs) const
- {
- return value() == rhs.value();
- }
-
- bool
- operator != (const ListEntry& rhs) const
- {
- return !(*this == rhs);
- }
-
- private:
- ValueObjectSP m_entry_sp;
- };
-
- class ListIterator
- {
- public:
- ListIterator() = default;
- ListIterator (ListEntry entry) : m_entry(entry) {}
- ListIterator (ValueObjectSP entry) : m_entry(entry) {}
- ListIterator(const ListIterator& rhs) = default;
- ListIterator (ValueObject* entry) : m_entry(entry) {}
-
- ValueObjectSP
- value ()
- {
- return m_entry.GetEntry();
- }
-
- ValueObjectSP
- advance (size_t count)
- {
- if (count == 0)
- return m_entry.GetEntry();
- if (count == 1)
- {
- next ();
- return m_entry.GetEntry();
- }
- while (count > 0)
- {
- next ();
- count--;
- if (m_entry.null())
- return lldb::ValueObjectSP();
- }
- return m_entry.GetEntry();
- }
-
- bool
- operator == (const ListIterator& rhs) const
- {
- return (rhs.m_entry == m_entry);
- }
-
- protected:
- void
- next ()
- {
- m_entry = m_entry.next();
- }
-
- void
- prev ()
- {
- m_entry = m_entry.prev();
- }
-
- private:
- ListEntry m_entry;
- };
+class ListEntry {
+public:
+ ListEntry() = default;
+ ListEntry(ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
+ ListEntry(const ListEntry &rhs) = default;
+ ListEntry(ValueObject *entry)
+ : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
+
+ ListEntry next() {
+ static ConstString g_next("__next_");
+
+ if (!m_entry_sp)
+ return ListEntry();
+ return ListEntry(m_entry_sp->GetChildMemberWithName(g_next, true));
+ }
+
+ ListEntry prev() {
+ static ConstString g_prev("__prev_");
+
+ if (!m_entry_sp)
+ return ListEntry();
+ return ListEntry(m_entry_sp->GetChildMemberWithName(g_prev, true));
+ }
+
+ uint64_t value() const {
+ if (!m_entry_sp)
+ return 0;
+ return m_entry_sp->GetValueAsUnsigned(0);
+ }
+
+ bool null() { return (value() == 0); }
+
+ explicit operator bool() { return GetEntry() && !null(); }
+
+ ValueObjectSP GetEntry() { return m_entry_sp; }
+
+ void SetEntry(ValueObjectSP entry) { m_entry_sp = entry; }
+
+ bool operator==(const ListEntry &rhs) const { return value() == rhs.value(); }
+
+ bool operator!=(const ListEntry &rhs) const { return !(*this == rhs); }
+
+private:
+ ValueObjectSP m_entry_sp;
+};
+
+class ListIterator {
+public:
+ ListIterator() = default;
+ ListIterator(ListEntry entry) : m_entry(entry) {}
+ ListIterator(ValueObjectSP entry) : m_entry(entry) {}
+ ListIterator(const ListIterator &rhs) = default;
+ ListIterator(ValueObject *entry) : m_entry(entry) {}
+
+ ValueObjectSP value() { return m_entry.GetEntry(); }
+
+ ValueObjectSP advance(size_t count) {
+ if (count == 0)
+ return m_entry.GetEntry();
+ if (count == 1) {
+ next();
+ return m_entry.GetEntry();
+ }
+ while (count > 0) {
+ next();
+ count--;
+ if (m_entry.null())
+ return lldb::ValueObjectSP();
+ }
+ return m_entry.GetEntry();
+ }
+
+ bool operator==(const ListIterator &rhs) const {
+ return (rhs.m_entry == m_entry);
+ }
+
+protected:
+ void next() { m_entry = m_entry.next(); }
+
+ void prev() { m_entry = m_entry.prev(); }
+
+private:
+ ListEntry m_entry;
+};
} // end anonymous namespace
namespace lldb_private {
- namespace formatters {
- class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxStdListSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- bool
- HasLoop(size_t count);
-
- size_t m_list_capping_size;
- static const bool g_use_loop_detect = true;
-
- size_t m_loop_detected; // The number of elements that have had loop detection run over them.
- ListEntry m_slow_runner; // Used for loop detection
- ListEntry m_fast_runner; // Used for loop detection
-
- lldb::addr_t m_node_address;
- ValueObject* m_head;
- ValueObject* m_tail;
- CompilerType m_element_type;
- size_t m_count;
- std::map<size_t, ListIterator> m_iterators;
- };
- } // namespace formatters
+namespace formatters {
+class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxStdListSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdListSyntheticFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ bool HasLoop(size_t count);
+
+ size_t m_list_capping_size;
+ static const bool g_use_loop_detect = true;
+
+ size_t m_loop_detected; // The number of elements that have had loop detection
+ // run over them.
+ ListEntry m_slow_runner; // Used for loop detection
+ ListEntry m_fast_runner; // Used for loop detection
+
+ lldb::addr_t m_node_address;
+ ValueObject *m_head;
+ ValueObject *m_tail;
+ CompilerType m_element_type;
+ size_t m_count;
+ std::map<size_t, ListIterator> m_iterators;
+};
+} // namespace formatters
} // namespace lldb_private
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_list_capping_size(0),
- m_loop_detected(0),
- m_node_address(),
- m_head(nullptr),
- m_tail(nullptr),
- m_element_type(),
- m_count(UINT32_MAX),
- m_iterators()
-{
- if (valobj_sp)
- Update();
+lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::
+ LibcxxStdListSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_list_capping_size(0),
+ m_loop_detected(0), m_node_address(), m_head(nullptr), m_tail(nullptr),
+ m_element_type(), m_count(UINT32_MAX), m_iterators() {
+ if (valobj_sp)
+ Update();
}
-bool
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::HasLoop(size_t count)
-{
- if (!g_use_loop_detect)
- return false;
- // don't bother checking for a loop if we won't actually need to jump nodes
- if (m_count < 2)
- return false;
-
- if (m_loop_detected == 0)
- {
- // This is the first time we are being run (after the last update). Set up the loop
- // invariant for the first element.
- m_slow_runner = ListEntry(m_head).next();
- m_fast_runner = m_slow_runner.next();
- m_loop_detected = 1;
- }
+bool lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::HasLoop(
+ size_t count) {
+ if (!g_use_loop_detect)
+ return false;
+ // don't bother checking for a loop if we won't actually need to jump nodes
+ if (m_count < 2)
+ return false;
- // Loop invariant:
- // Loop detection has been run over the first m_loop_detected elements. If m_slow_runner ==
- // m_fast_runner then the loop has been detected after m_loop_detected elements.
- const size_t steps_to_run = std::min(count,m_count);
- while (m_loop_detected < steps_to_run
- && m_slow_runner
- && m_fast_runner
- && m_slow_runner != m_fast_runner) {
-
- m_slow_runner = m_slow_runner.next();
- m_fast_runner = m_fast_runner.next().next();
- m_loop_detected++;
- }
- if (count <= m_loop_detected)
- return false; // No loop in the first m_loop_detected elements.
- if (!m_slow_runner || !m_fast_runner)
- return false; // Reached the end of the list. Definitely no loops.
- return m_slow_runner == m_fast_runner;
+ if (m_loop_detected == 0) {
+ // This is the first time we are being run (after the last update). Set up
+ // the loop
+ // invariant for the first element.
+ m_slow_runner = ListEntry(m_head).next();
+ m_fast_runner = m_slow_runner.next();
+ m_loop_detected = 1;
+ }
+
+ // Loop invariant:
+ // Loop detection has been run over the first m_loop_detected elements. If
+ // m_slow_runner ==
+ // m_fast_runner then the loop has been detected after m_loop_detected
+ // elements.
+ const size_t steps_to_run = std::min(count, m_count);
+ while (m_loop_detected < steps_to_run && m_slow_runner && m_fast_runner &&
+ m_slow_runner != m_fast_runner) {
+
+ m_slow_runner = m_slow_runner.next();
+ m_fast_runner = m_fast_runner.next().next();
+ m_loop_detected++;
+ }
+ if (count <= m_loop_detected)
+ return false; // No loop in the first m_loop_detected elements.
+ if (!m_slow_runner || !m_fast_runner)
+ return false; // Reached the end of the list. Definitely no loops.
+ return m_slow_runner == m_fast_runner;
}
-size_t
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (m_count != UINT32_MAX)
- return m_count;
- if (!m_head || !m_tail || m_node_address == 0)
- return 0;
- ValueObjectSP size_alloc(m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
- if (size_alloc)
- {
- ValueObjectSP first(size_alloc->GetChildMemberWithName(ConstString("__first_"), true));
- if (first)
- {
- m_count = first->GetValueAsUnsigned(UINT32_MAX);
- }
- }
- if (m_count != UINT32_MAX)
- {
- return m_count;
+size_t lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::
+ CalculateNumChildren() {
+ if (m_count != UINT32_MAX)
+ return m_count;
+ if (!m_head || !m_tail || m_node_address == 0)
+ return 0;
+ ValueObjectSP size_alloc(
+ m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
+ if (size_alloc) {
+ ValueObjectSP first(
+ size_alloc->GetChildMemberWithName(ConstString("__first_"), true));
+ if (first) {
+ m_count = first->GetValueAsUnsigned(UINT32_MAX);
}
- else
- {
- uint64_t next_val = m_head->GetValueAsUnsigned(0);
- uint64_t prev_val = m_tail->GetValueAsUnsigned(0);
- if (next_val == 0 || prev_val == 0)
- return 0;
- if (next_val == m_node_address)
- return 0;
- if (next_val == prev_val)
- return 1;
- uint64_t size = 2;
- ListEntry current(m_head);
- while (current.next() && current.next().value() != m_node_address)
- {
- size++;
- current = current.next();
- if (size > m_list_capping_size)
- break;
- }
- return m_count = (size-1);
+ }
+ if (m_count != UINT32_MAX) {
+ return m_count;
+ } else {
+ uint64_t next_val = m_head->GetValueAsUnsigned(0);
+ uint64_t prev_val = m_tail->GetValueAsUnsigned(0);
+ if (next_val == 0 || prev_val == 0)
+ return 0;
+ if (next_val == m_node_address)
+ return 0;
+ if (next_val == prev_val)
+ return 1;
+ uint64_t size = 2;
+ ListEntry current(m_head);
+ while (current.next() && current.next().value() != m_node_address) {
+ size++;
+ current = current.next();
+ if (size > m_list_capping_size)
+ break;
}
+ return m_count = (size - 1);
+ }
}
lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- static ConstString g_value("__value_");
- static ConstString g_next("__next_");
-
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
-
- if (!m_head || !m_tail || m_node_address == 0)
- return lldb::ValueObjectSP();
-
- if (HasLoop(idx+1))
- return lldb::ValueObjectSP();
-
- size_t actual_advance = idx;
-
- ListIterator current(m_head);
- if (idx > 0)
- {
- auto cached_iterator = m_iterators.find(idx-1);
- if (cached_iterator != m_iterators.end())
- {
- current = cached_iterator->second;
- actual_advance = 1;
- }
- }
-
- ValueObjectSP current_sp(current.advance(actual_advance));
- if (!current_sp)
- return lldb::ValueObjectSP();
-
- m_iterators[idx] = current;
-
- current_sp = current_sp->GetChildAtIndex(1, true); // get the __value_ child
- if (!current_sp)
- return lldb::ValueObjectSP();
-
- if (current_sp->GetName() == g_next)
- {
- ProcessSP process_sp(current_sp->GetProcessSP());
- if (!process_sp)
- return nullptr;
-
- // if we grabbed the __next_ pointer, then the child is one pointer deep-er
- lldb::addr_t addr = current_sp->GetParent()->GetPointerValue();
- addr = addr + 2*process_sp->GetAddressByteSize();
- ExecutionContext exe_ctx(process_sp);
- current_sp = CreateValueObjectFromAddress("__value_",
- addr,
- exe_ctx,
- m_element_type);
+lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ static ConstString g_value("__value_");
+ static ConstString g_next("__next_");
+
+ if (idx >= CalculateNumChildren())
+ return lldb::ValueObjectSP();
+
+ if (!m_head || !m_tail || m_node_address == 0)
+ return lldb::ValueObjectSP();
+
+ if (HasLoop(idx + 1))
+ return lldb::ValueObjectSP();
+
+ size_t actual_advance = idx;
+
+ ListIterator current(m_head);
+ if (idx > 0) {
+ auto cached_iterator = m_iterators.find(idx - 1);
+ if (cached_iterator != m_iterators.end()) {
+ current = cached_iterator->second;
+ actual_advance = 1;
}
-
- // we need to copy current_sp into a new object otherwise we will end up with all items named __value_
- DataExtractor data;
- Error error;
- current_sp->GetData(data, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
-
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- return CreateValueObjectFromData(name.GetData(),
- data,
- m_backend.GetExecutionContextRef(),
- m_element_type);
+ }
+
+ ValueObjectSP current_sp(current.advance(actual_advance));
+ if (!current_sp)
+ return lldb::ValueObjectSP();
+
+ m_iterators[idx] = current;
+
+ current_sp = current_sp->GetChildAtIndex(1, true); // get the __value_ child
+ if (!current_sp)
+ return lldb::ValueObjectSP();
+
+ if (current_sp->GetName() == g_next) {
+ ProcessSP process_sp(current_sp->GetProcessSP());
+ if (!process_sp)
+ return nullptr;
+
+ // if we grabbed the __next_ pointer, then the child is one pointer deep-er
+ lldb::addr_t addr = current_sp->GetParent()->GetPointerValue();
+ addr = addr + 2 * process_sp->GetAddressByteSize();
+ ExecutionContext exe_ctx(process_sp);
+ current_sp =
+ CreateValueObjectFromAddress("__value_", addr, exe_ctx, m_element_type);
+ }
+
+ // we need to copy current_sp into a new object otherwise we will end up with
+ // all items named __value_
+ DataExtractor data;
+ Error error;
+ current_sp->GetData(data, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ return CreateValueObjectFromData(
+ name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type);
}
-bool
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update()
-{
- m_iterators.clear();
- m_head = m_tail = nullptr;
- m_node_address = 0;
- m_count = UINT32_MAX;
- m_loop_detected = 0;
- m_slow_runner.SetEntry(nullptr);
- m_fast_runner.SetEntry(nullptr);
-
- Error err;
- ValueObjectSP backend_addr(m_backend.AddressOf(err));
- m_list_capping_size = 0;
- if (m_backend.GetTargetSP())
- m_list_capping_size = m_backend.GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
- if (m_list_capping_size == 0)
- m_list_capping_size = 255;
- if (err.Fail() || !backend_addr)
- return false;
- m_node_address = backend_addr->GetValueAsUnsigned(0);
- if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS)
- return false;
- ValueObjectSP impl_sp(m_backend.GetChildMemberWithName(ConstString("__end_"),true));
- if (!impl_sp)
- return false;
- CompilerType list_type = m_backend.GetCompilerType();
- if (list_type.IsReferenceType())
- list_type = list_type.GetNonReferenceType();
-
- if (list_type.GetNumTemplateArguments() == 0)
- return false;
- lldb::TemplateArgumentKind kind;
- m_element_type = list_type.GetTemplateArgument(0, kind);
- m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
- m_tail = impl_sp->GetChildMemberWithName(ConstString("__prev_"), true).get();
+bool lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update() {
+ m_iterators.clear();
+ m_head = m_tail = nullptr;
+ m_node_address = 0;
+ m_count = UINT32_MAX;
+ m_loop_detected = 0;
+ m_slow_runner.SetEntry(nullptr);
+ m_fast_runner.SetEntry(nullptr);
+
+ Error err;
+ ValueObjectSP backend_addr(m_backend.AddressOf(err));
+ m_list_capping_size = 0;
+ if (m_backend.GetTargetSP())
+ m_list_capping_size =
+ m_backend.GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
+ if (m_list_capping_size == 0)
+ m_list_capping_size = 255;
+ if (err.Fail() || !backend_addr)
+ return false;
+ m_node_address = backend_addr->GetValueAsUnsigned(0);
+ if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS)
+ return false;
+ ValueObjectSP impl_sp(
+ m_backend.GetChildMemberWithName(ConstString("__end_"), true));
+ if (!impl_sp)
+ return false;
+ CompilerType list_type = m_backend.GetCompilerType();
+ if (list_type.IsReferenceType())
+ list_type = list_type.GetNonReferenceType();
+
+ if (list_type.GetNumTemplateArguments() == 0)
return false;
+ lldb::TemplateArgumentKind kind;
+ m_element_type = list_type.GetTemplateArgument(0, kind);
+ m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
+ m_tail = impl_sp->GetChildMemberWithName(ConstString("__prev_"), true).get();
+ return false;
}
-bool
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
+bool lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
}
-size_t
-lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return ExtractIndexFromString(name.GetCString());
+size_t lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ return ExtractIndexFromString(name.GetCString());
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxStdListSyntheticFrontEnd(valobj_sp) : nullptr);
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxStdListSyntheticFrontEnd(valobj_sp) : nullptr);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Tue Sep 6 15:57:50 2016
@@ -27,442 +27,367 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-class MapEntry
-{
+class MapEntry {
public:
- MapEntry() = default;
- explicit MapEntry (ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
- MapEntry(const MapEntry& rhs) = default;
- explicit MapEntry (ValueObject* entry) : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
-
- ValueObjectSP
- left () const
- {
- static ConstString g_left("__left_");
- if (!m_entry_sp)
- return m_entry_sp;
- return m_entry_sp->GetChildMemberWithName(g_left, true);
- }
-
- ValueObjectSP
- right () const
- {
- static ConstString g_right("__right_");
- if (!m_entry_sp)
- return m_entry_sp;
- return m_entry_sp->GetChildMemberWithName(g_right, true);
- }
-
- ValueObjectSP
- parent () const
- {
- static ConstString g_parent("__parent_");
- if (!m_entry_sp)
- return m_entry_sp;
- return m_entry_sp->GetChildMemberWithName(g_parent, true);
- }
-
- uint64_t
- value () const
- {
- if (!m_entry_sp)
- return 0;
- return m_entry_sp->GetValueAsUnsigned(0);
- }
-
- bool
- error () const
- {
- if (!m_entry_sp)
- return true;
- return m_entry_sp->GetError().Fail();
- }
-
- bool
- null() const
- {
- return (value() == 0);
- }
-
- ValueObjectSP
- GetEntry () const
- {
- return m_entry_sp;
- }
-
- void
- SetEntry (ValueObjectSP entry)
- {
- m_entry_sp = entry;
- }
-
- bool
- operator == (const MapEntry& rhs) const
- {
- return (rhs.m_entry_sp.get() == m_entry_sp.get());
- }
-
+ MapEntry() = default;
+ explicit MapEntry(ValueObjectSP entry_sp) : m_entry_sp(entry_sp) {}
+ MapEntry(const MapEntry &rhs) = default;
+ explicit MapEntry(ValueObject *entry)
+ : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
+
+ ValueObjectSP left() const {
+ static ConstString g_left("__left_");
+ if (!m_entry_sp)
+ return m_entry_sp;
+ return m_entry_sp->GetChildMemberWithName(g_left, true);
+ }
+
+ ValueObjectSP right() const {
+ static ConstString g_right("__right_");
+ if (!m_entry_sp)
+ return m_entry_sp;
+ return m_entry_sp->GetChildMemberWithName(g_right, true);
+ }
+
+ ValueObjectSP parent() const {
+ static ConstString g_parent("__parent_");
+ if (!m_entry_sp)
+ return m_entry_sp;
+ return m_entry_sp->GetChildMemberWithName(g_parent, true);
+ }
+
+ uint64_t value() const {
+ if (!m_entry_sp)
+ return 0;
+ return m_entry_sp->GetValueAsUnsigned(0);
+ }
+
+ bool error() const {
+ if (!m_entry_sp)
+ return true;
+ return m_entry_sp->GetError().Fail();
+ }
+
+ bool null() const { return (value() == 0); }
+
+ ValueObjectSP GetEntry() const { return m_entry_sp; }
+
+ void SetEntry(ValueObjectSP entry) { m_entry_sp = entry; }
+
+ bool operator==(const MapEntry &rhs) const {
+ return (rhs.m_entry_sp.get() == m_entry_sp.get());
+ }
+
private:
- ValueObjectSP m_entry_sp;
+ ValueObjectSP m_entry_sp;
};
-class MapIterator
-{
+class MapIterator {
public:
- MapIterator() = default;
- MapIterator (MapEntry entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {}
- MapIterator (ValueObjectSP entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {}
- MapIterator (const MapIterator& rhs) : m_entry(rhs.m_entry),m_max_depth(rhs.m_max_depth), m_error(false) {}
- MapIterator (ValueObject* entry, size_t depth = 0) : m_entry(entry), m_max_depth(depth), m_error(false) {}
-
- ValueObjectSP
- value ()
- {
- return m_entry.GetEntry();
- }
-
- ValueObjectSP
- advance (size_t count)
- {
- ValueObjectSP fail;
- if (m_error)
- return fail;
- size_t steps = 0;
- while (count > 0)
- {
- next();
- count--, steps++;
- if (m_error ||
- m_entry.null() ||
- (steps > m_max_depth))
- return fail;
- }
- return m_entry.GetEntry();
+ MapIterator() = default;
+ MapIterator(MapEntry entry, size_t depth = 0)
+ : m_entry(entry), m_max_depth(depth), m_error(false) {}
+ MapIterator(ValueObjectSP entry, size_t depth = 0)
+ : m_entry(entry), m_max_depth(depth), m_error(false) {}
+ MapIterator(const MapIterator &rhs)
+ : m_entry(rhs.m_entry), m_max_depth(rhs.m_max_depth), m_error(false) {}
+ MapIterator(ValueObject *entry, size_t depth = 0)
+ : m_entry(entry), m_max_depth(depth), m_error(false) {}
+
+ ValueObjectSP value() { return m_entry.GetEntry(); }
+
+ ValueObjectSP advance(size_t count) {
+ ValueObjectSP fail;
+ if (m_error)
+ return fail;
+ size_t steps = 0;
+ while (count > 0) {
+ next();
+ count--, steps++;
+ if (m_error || m_entry.null() || (steps > m_max_depth))
+ return fail;
}
-
+ return m_entry.GetEntry();
+ }
+
protected:
- void
- next ()
- {
- if (m_entry.null())
- return;
- MapEntry right(m_entry.right());
- if (!right.null())
- {
- m_entry = tree_min(std::move(right));
- return;
- }
- size_t steps = 0;
- while (!is_left_child(m_entry))
- {
- if (m_entry.error())
- {
- m_error = true;
- return;
- }
- m_entry.SetEntry(m_entry.parent());
- steps++;
- if (steps > m_max_depth)
- {
- m_entry = MapEntry();
- return;
- }
- }
- m_entry = MapEntry(m_entry.parent());
+ void next() {
+ if (m_entry.null())
+ return;
+ MapEntry right(m_entry.right());
+ if (!right.null()) {
+ m_entry = tree_min(std::move(right));
+ return;
+ }
+ size_t steps = 0;
+ while (!is_left_child(m_entry)) {
+ if (m_entry.error()) {
+ m_error = true;
+ return;
+ }
+ m_entry.SetEntry(m_entry.parent());
+ steps++;
+ if (steps > m_max_depth) {
+ m_entry = MapEntry();
+ return;
+ }
}
-
+ m_entry = MapEntry(m_entry.parent());
+ }
+
private:
- MapEntry
- tree_min (MapEntry&& x)
- {
- if (x.null())
- return MapEntry();
- MapEntry left(x.left());
- size_t steps = 0;
- while (!left.null())
- {
- if (left.error())
- {
- m_error = true;
- return MapEntry();
- }
- x = left;
- left.SetEntry(x.left());
- steps++;
- if (steps > m_max_depth)
- return MapEntry();
- }
- return x;
- }
-
- bool
- is_left_child (const MapEntry& x)
- {
- if (x.null())
- return false;
- MapEntry rhs(x.parent());
- rhs.SetEntry(rhs.left());
- return x.value() == rhs.value();
- }
-
- MapEntry m_entry;
- size_t m_max_depth;
- bool m_error;
+ MapEntry tree_min(MapEntry &&x) {
+ if (x.null())
+ return MapEntry();
+ MapEntry left(x.left());
+ size_t steps = 0;
+ while (!left.null()) {
+ if (left.error()) {
+ m_error = true;
+ return MapEntry();
+ }
+ x = left;
+ left.SetEntry(x.left());
+ steps++;
+ if (steps > m_max_depth)
+ return MapEntry();
+ }
+ return x;
+ }
+
+ bool is_left_child(const MapEntry &x) {
+ if (x.null())
+ return false;
+ MapEntry rhs(x.parent());
+ rhs.SetEntry(rhs.left());
+ return x.value() == rhs.value();
+ }
+
+ MapEntry m_entry;
+ size_t m_max_depth;
+ bool m_error;
};
namespace lldb_private {
- namespace formatters {
- class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxStdMapSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- bool
- GetDataType();
-
- void
- GetValueOffset (const lldb::ValueObjectSP& node);
-
- ValueObject* m_tree;
- ValueObject* m_root_node;
- CompilerType m_element_type;
- uint32_t m_skip_size;
- size_t m_count;
- std::map<size_t, MapIterator> m_iterators;
- };
- } // namespace formatters
+namespace formatters {
+class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxStdMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdMapSyntheticFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ bool GetDataType();
+
+ void GetValueOffset(const lldb::ValueObjectSP &node);
+
+ ValueObject *m_tree;
+ ValueObject *m_root_node;
+ CompilerType m_element_type;
+ uint32_t m_skip_size;
+ size_t m_count;
+ std::map<size_t, MapIterator> m_iterators;
+};
+} // namespace formatters
} // namespace lldb_private
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_tree(nullptr),
- m_root_node(nullptr),
- m_element_type(),
- m_skip_size(UINT32_MAX),
- m_count(UINT32_MAX),
- m_iterators()
-{
- if (valobj_sp)
- Update();
+lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
+ LibcxxStdMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_tree(nullptr),
+ m_root_node(nullptr), m_element_type(), m_skip_size(UINT32_MAX),
+ m_count(UINT32_MAX), m_iterators() {
+ if (valobj_sp)
+ Update();
}
-size_t
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::CalculateNumChildren ()
-{
- static ConstString g___pair3_("__pair3_");
- static ConstString g___first_("__first_");
-
- if (m_count != UINT32_MAX)
- return m_count;
- if (m_tree == nullptr)
- return 0;
- ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true));
- if (!m_item)
- return 0;
- m_item = m_item->GetChildMemberWithName(g___first_, true);
- if (!m_item)
- return 0;
- m_count = m_item->GetValueAsUnsigned(0);
+size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
+ CalculateNumChildren() {
+ static ConstString g___pair3_("__pair3_");
+ static ConstString g___first_("__first_");
+
+ if (m_count != UINT32_MAX)
return m_count;
+ if (m_tree == nullptr)
+ return 0;
+ ValueObjectSP m_item(m_tree->GetChildMemberWithName(g___pair3_, true));
+ if (!m_item)
+ return 0;
+ m_item = m_item->GetChildMemberWithName(g___first_, true);
+ if (!m_item)
+ return 0;
+ m_count = m_item->GetValueAsUnsigned(0);
+ return m_count;
}
-bool
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType()
-{
- static ConstString g___value_("__value_");
-
- if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem())
- return true;
- m_element_type.Clear();
- ValueObjectSP deref;
- Error error;
- deref = m_root_node->Dereference(error);
- if (!deref || error.Fail())
- return false;
- deref = deref->GetChildMemberWithName(g___value_, true);
- if (!deref)
- return false;
- m_element_type = deref->GetCompilerType();
+bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
+ static ConstString g___value_("__value_");
+
+ if (m_element_type.GetOpaqueQualType() && m_element_type.GetTypeSystem())
return true;
+ m_element_type.Clear();
+ ValueObjectSP deref;
+ Error error;
+ deref = m_root_node->Dereference(error);
+ if (!deref || error.Fail())
+ return false;
+ deref = deref->GetChildMemberWithName(g___value_, true);
+ if (!deref)
+ return false;
+ m_element_type = deref->GetCompilerType();
+ return true;
}
-void
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset (const lldb::ValueObjectSP& node)
-{
- if (m_skip_size != UINT32_MAX)
- return;
- if (!node)
- return;
- CompilerType node_type(node->GetCompilerType());
- uint64_t bit_offset;
- if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) == UINT32_MAX)
- return;
- m_skip_size = bit_offset / 8u;
+void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
+ const lldb::ValueObjectSP &node) {
+ if (m_skip_size != UINT32_MAX)
+ return;
+ if (!node)
+ return;
+ CompilerType node_type(node->GetCompilerType());
+ uint64_t bit_offset;
+ if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) ==
+ UINT32_MAX)
+ return;
+ m_skip_size = bit_offset / 8u;
}
lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- static ConstString g___cc("__cc");
- static ConstString g___nc("__nc");
- static ConstString g___value_("__value_");
-
- if (idx >= CalculateNumChildren())
+lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ static ConstString g___cc("__cc");
+ static ConstString g___nc("__nc");
+ static ConstString g___value_("__value_");
+
+ if (idx >= CalculateNumChildren())
+ return lldb::ValueObjectSP();
+ if (m_tree == nullptr || m_root_node == nullptr)
+ return lldb::ValueObjectSP();
+
+ MapIterator iterator(m_root_node, CalculateNumChildren());
+
+ const bool need_to_skip = (idx > 0);
+ size_t actual_advancde = idx;
+ if (need_to_skip) {
+ auto cached_iterator = m_iterators.find(idx - 1);
+ if (cached_iterator != m_iterators.end()) {
+ iterator = cached_iterator->second;
+ actual_advancde = 1;
+ }
+ }
+
+ ValueObjectSP iterated_sp(iterator.advance(actual_advancde));
+ if (!iterated_sp) {
+ // this tree is garbage - stop
+ m_tree =
+ nullptr; // this will stop all future searches until an Update() happens
+ return iterated_sp;
+ }
+ if (GetDataType()) {
+ if (!need_to_skip) {
+ Error error;
+ iterated_sp = iterated_sp->Dereference(error);
+ if (!iterated_sp || error.Fail()) {
+ m_tree = nullptr;
return lldb::ValueObjectSP();
- if (m_tree == nullptr || m_root_node == nullptr)
+ }
+ GetValueOffset(iterated_sp);
+ iterated_sp = iterated_sp->GetChildMemberWithName(g___value_, true);
+ if (!iterated_sp) {
+ m_tree = nullptr;
return lldb::ValueObjectSP();
-
- MapIterator iterator(m_root_node, CalculateNumChildren());
-
- const bool need_to_skip = (idx > 0);
- size_t actual_advancde = idx;
- if (need_to_skip)
- {
- auto cached_iterator = m_iterators.find(idx-1);
- if (cached_iterator != m_iterators.end())
- {
- iterator = cached_iterator->second;
- actual_advancde = 1;
- }
- }
-
- ValueObjectSP iterated_sp(iterator.advance(actual_advancde));
- if (!iterated_sp)
- {
- // this tree is garbage - stop
- m_tree = nullptr; // this will stop all future searches until an Update() happens
- return iterated_sp;
- }
- if (GetDataType())
- {
- if (!need_to_skip)
- {
- Error error;
- iterated_sp = iterated_sp->Dereference(error);
- if (!iterated_sp || error.Fail())
- {
- m_tree = nullptr;
- return lldb::ValueObjectSP();
- }
- GetValueOffset(iterated_sp);
- iterated_sp = iterated_sp->GetChildMemberWithName(g___value_, true);
- if (!iterated_sp)
- {
- m_tree = nullptr;
- return lldb::ValueObjectSP();
- }
- }
- else
- {
- // because of the way our debug info is made, we need to read item 0 first
- // so that we can cache information used to generate other elements
- if (m_skip_size == UINT32_MAX)
- GetChildAtIndex(0);
- if (m_skip_size == UINT32_MAX)
- {
- m_tree = nullptr;
- return lldb::ValueObjectSP();
- }
- iterated_sp = iterated_sp->GetSyntheticChildAtOffset(m_skip_size, m_element_type, true);
- if (!iterated_sp)
- {
- m_tree = nullptr;
- return lldb::ValueObjectSP();
- }
- }
- }
- else
- {
+ }
+ } else {
+ // because of the way our debug info is made, we need to read item 0 first
+ // so that we can cache information used to generate other elements
+ if (m_skip_size == UINT32_MAX)
+ GetChildAtIndex(0);
+ if (m_skip_size == UINT32_MAX) {
m_tree = nullptr;
return lldb::ValueObjectSP();
- }
- // at this point we have a valid
- // we need to copy current_sp into a new object otherwise we will end up with all items named __value_
- DataExtractor data;
- Error error;
- iterated_sp->GetData(data, error);
- if (error.Fail())
- {
+ }
+ iterated_sp = iterated_sp->GetSyntheticChildAtOffset(
+ m_skip_size, m_element_type, true);
+ if (!iterated_sp) {
m_tree = nullptr;
return lldb::ValueObjectSP();
+ }
}
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- auto potential_child_sp = CreateValueObjectFromData(name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type);
- if (potential_child_sp)
- {
- switch (potential_child_sp->GetNumChildren())
- {
- case 1:
- {
- auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
- if (child0_sp && child0_sp->GetName() == g___cc)
- potential_child_sp = child0_sp;
- break;
- }
- case 2:
- {
- auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
- auto child1_sp = potential_child_sp->GetChildAtIndex(1, true);
- if (child0_sp && child0_sp->GetName() == g___cc &&
- child1_sp && child1_sp->GetName() == g___nc)
- potential_child_sp = child0_sp;
- break;
- }
- }
- potential_child_sp->SetName(ConstString(name.GetData()));
- }
- m_iterators[idx] = iterator;
- return potential_child_sp;
+ } else {
+ m_tree = nullptr;
+ return lldb::ValueObjectSP();
+ }
+ // at this point we have a valid
+ // we need to copy current_sp into a new object otherwise we will end up with
+ // all items named __value_
+ DataExtractor data;
+ Error error;
+ iterated_sp->GetData(data, error);
+ if (error.Fail()) {
+ m_tree = nullptr;
+ return lldb::ValueObjectSP();
+ }
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ auto potential_child_sp = CreateValueObjectFromData(
+ name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type);
+ if (potential_child_sp) {
+ switch (potential_child_sp->GetNumChildren()) {
+ case 1: {
+ auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
+ if (child0_sp && child0_sp->GetName() == g___cc)
+ potential_child_sp = child0_sp;
+ break;
+ }
+ case 2: {
+ auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
+ auto child1_sp = potential_child_sp->GetChildAtIndex(1, true);
+ if (child0_sp && child0_sp->GetName() == g___cc && child1_sp &&
+ child1_sp->GetName() == g___nc)
+ potential_child_sp = child0_sp;
+ break;
+ }
+ }
+ potential_child_sp->SetName(ConstString(name.GetData()));
+ }
+ m_iterators[idx] = iterator;
+ return potential_child_sp;
}
-bool
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update()
-{
- static ConstString g___tree_("__tree_");
- static ConstString g___begin_node_("__begin_node_");
- m_count = UINT32_MAX;
- m_tree = m_root_node = nullptr;
- m_iterators.clear();
- m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get();
- if (!m_tree)
- return false;
- m_root_node = m_tree->GetChildMemberWithName(g___begin_node_, true).get();
+bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() {
+ static ConstString g___tree_("__tree_");
+ static ConstString g___begin_node_("__begin_node_");
+ m_count = UINT32_MAX;
+ m_tree = m_root_node = nullptr;
+ m_iterators.clear();
+ m_tree = m_backend.GetChildMemberWithName(g___tree_, true).get();
+ if (!m_tree)
return false;
+ m_root_node = m_tree->GetChildMemberWithName(g___begin_node_, true).get();
+ return false;
}
-bool
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
+bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
}
-size_t
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return ExtractIndexFromString(name.GetCString());
+size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ return ExtractIndexFromString(name.GetCString());
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxStdMapSyntheticFrontEnd(valobj_sp) : nullptr);
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxStdMapSyntheticFrontEnd(valobj_sp) : nullptr);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp Tue Sep 6 15:57:50 2016
@@ -28,136 +28,136 @@ using namespace lldb_private;
using namespace lldb_private::formatters;
namespace lldb_private {
- namespace formatters {
- class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxStdUnorderedMapSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- ValueObject* m_tree;
- size_t m_num_elements;
- ValueObject* m_next_element;
- std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache;
- };
- } // namespace formatters
+namespace formatters {
+class LibcxxStdUnorderedMapSyntheticFrontEnd
+ : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxStdUnorderedMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdUnorderedMapSyntheticFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ ValueObject *m_tree;
+ size_t m_num_elements;
+ ValueObject *m_next_element;
+ std::vector<std::pair<ValueObject *, uint64_t>> m_elements_cache;
+};
+} // namespace formatters
} // namespace lldb_private
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_tree(nullptr),
- m_num_elements(0),
- m_next_element(nullptr),
- m_elements_cache()
-{
- if (valobj_sp)
- Update();
-}
-
-size_t
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (m_num_elements != UINT32_MAX)
- return m_num_elements;
- return 0;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (idx >= CalculateNumChildren())
- return lldb::ValueObjectSP();
- if (m_tree == nullptr)
- return lldb::ValueObjectSP();
-
- while (idx >= m_elements_cache.size())
- {
- if (m_next_element == nullptr)
- return lldb::ValueObjectSP();
-
- Error error;
- ValueObjectSP node_sp = m_next_element->Dereference(error);
- if (!node_sp || error.Fail())
- return lldb::ValueObjectSP();
-
- ValueObjectSP value_sp = node_sp->GetChildMemberWithName(ConstString("__value_"), true);
- ValueObjectSP hash_sp = node_sp->GetChildMemberWithName(ConstString("__hash_"), true);
- if (!hash_sp || !value_sp)
- return lldb::ValueObjectSP();
- m_elements_cache.push_back({value_sp.get(),hash_sp->GetValueAsUnsigned(0)});
- m_next_element = node_sp->GetChildMemberWithName(ConstString("__next_"),true).get();
- if (!m_next_element || m_next_element->GetValueAsUnsigned(0) == 0)
- m_next_element = nullptr;
- }
-
- std::pair<ValueObject*, uint64_t> val_hash = m_elements_cache[idx];
- if (!val_hash.first)
- return lldb::ValueObjectSP();
- StreamString stream;
- stream.Printf("[%" PRIu64 "]", (uint64_t)idx);
- DataExtractor data;
+lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
+ LibcxxStdUnorderedMapSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_tree(nullptr), m_num_elements(0),
+ m_next_element(nullptr), m_elements_cache() {
+ if (valobj_sp)
+ Update();
+}
+
+size_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
+ CalculateNumChildren() {
+ if (m_num_elements != UINT32_MAX)
+ return m_num_elements;
+ return 0;
+}
+
+lldb::ValueObjectSP lldb_private::formatters::
+ LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+ if (idx >= CalculateNumChildren())
+ return lldb::ValueObjectSP();
+ if (m_tree == nullptr)
+ return lldb::ValueObjectSP();
+
+ while (idx >= m_elements_cache.size()) {
+ if (m_next_element == nullptr)
+ return lldb::ValueObjectSP();
+
Error error;
- val_hash.first->GetData(data, error);
- if (error.Fail())
- return lldb::ValueObjectSP();
- const bool thread_and_frame_only_if_stopped = true;
- ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(thread_and_frame_only_if_stopped);
- return CreateValueObjectFromData(stream.GetData(),
- data,
- exe_ctx,
- val_hash.first->GetCompilerType());
-}
-
-bool
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::Update()
-{
- m_num_elements = UINT32_MAX;
- m_next_element = nullptr;
- m_elements_cache.clear();
- ValueObjectSP table_sp = m_backend.GetChildMemberWithName(ConstString("__table_"), true);
- if (!table_sp)
- return false;
- ValueObjectSP num_elements_sp = table_sp->GetChildAtNamePath({ConstString("__p2_"),ConstString("__first_")});
- if (!num_elements_sp)
- return false;
- m_num_elements = num_elements_sp->GetValueAsUnsigned(0);
- m_tree = table_sp->GetChildAtNamePath({ConstString("__p1_"),ConstString("__first_"),ConstString("__next_")}).get();
- if (m_num_elements > 0)
- m_next_element = table_sp->GetChildAtNamePath({ConstString("__p1_"),ConstString("__first_"),ConstString("__next_")}).get();
+ ValueObjectSP node_sp = m_next_element->Dereference(error);
+ if (!node_sp || error.Fail())
+ return lldb::ValueObjectSP();
+
+ ValueObjectSP value_sp =
+ node_sp->GetChildMemberWithName(ConstString("__value_"), true);
+ ValueObjectSP hash_sp =
+ node_sp->GetChildMemberWithName(ConstString("__hash_"), true);
+ if (!hash_sp || !value_sp)
+ return lldb::ValueObjectSP();
+ m_elements_cache.push_back(
+ {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});
+ m_next_element =
+ node_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
+ if (!m_next_element || m_next_element->GetValueAsUnsigned(0) == 0)
+ m_next_element = nullptr;
+ }
+
+ std::pair<ValueObject *, uint64_t> val_hash = m_elements_cache[idx];
+ if (!val_hash.first)
+ return lldb::ValueObjectSP();
+ StreamString stream;
+ stream.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ DataExtractor data;
+ Error error;
+ val_hash.first->GetData(data, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+ const bool thread_and_frame_only_if_stopped = true;
+ ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
+ thread_and_frame_only_if_stopped);
+ return CreateValueObjectFromData(stream.GetData(), data, exe_ctx,
+ val_hash.first->GetCompilerType());
+}
+
+bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
+ Update() {
+ m_num_elements = UINT32_MAX;
+ m_next_element = nullptr;
+ m_elements_cache.clear();
+ ValueObjectSP table_sp =
+ m_backend.GetChildMemberWithName(ConstString("__table_"), true);
+ if (!table_sp)
return false;
-}
-
-bool
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- return ExtractIndexFromString(name.GetCString());
-}
-
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxStdUnorderedMapSyntheticFrontEnd(valobj_sp) : nullptr);
+ ValueObjectSP num_elements_sp = table_sp->GetChildAtNamePath(
+ {ConstString("__p2_"), ConstString("__first_")});
+ if (!num_elements_sp)
+ return false;
+ m_num_elements = num_elements_sp->GetValueAsUnsigned(0);
+ m_tree =
+ table_sp
+ ->GetChildAtNamePath({ConstString("__p1_"), ConstString("__first_"),
+ ConstString("__next_")})
+ .get();
+ if (m_num_elements > 0)
+ m_next_element =
+ table_sp
+ ->GetChildAtNamePath({ConstString("__p1_"), ConstString("__first_"),
+ ConstString("__next_")})
+ .get();
+ return false;
+}
+
+bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ return ExtractIndexFromString(name.GetCString());
+}
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxStdUnorderedMapSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp Tue Sep 6 15:57:50 2016
@@ -22,130 +22,120 @@ using namespace lldb_private;
using namespace lldb_private::formatters;
namespace lldb_private {
- namespace formatters {
- class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
- {
- public:
- LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp);
-
- ~LibcxxStdVectorSyntheticFrontEnd() override;
-
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- private:
- ValueObject* m_start;
- ValueObject* m_finish;
- CompilerType m_element_type;
- uint32_t m_element_size;
- };
- } // namespace formatters
+namespace formatters {
+class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxStdVectorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ ~LibcxxStdVectorSyntheticFrontEnd() override;
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ ValueObject *m_start;
+ ValueObject *m_finish;
+ CompilerType m_element_type;
+ uint32_t m_element_size;
+};
+} // namespace formatters
} // namespace lldb_private
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_start(nullptr),
- m_finish(nullptr),
- m_element_type(),
- m_element_size(0)
-{
- if (valobj_sp)
- Update();
-}
-
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::~LibcxxStdVectorSyntheticFrontEnd()
-{
- // these need to stay around because they are child objects who will follow their parent's life cycle
- // delete m_start;
- // delete m_finish;
-}
-
-size_t
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::CalculateNumChildren ()
-{
- if (!m_start || !m_finish)
- return 0;
- uint64_t start_val = m_start->GetValueAsUnsigned(0);
- uint64_t finish_val = m_finish->GetValueAsUnsigned(0);
-
- if (start_val == 0 || finish_val == 0)
- return 0;
-
- if (start_val >= finish_val)
- return 0;
-
- size_t num_children = (finish_val - start_val);
- if (num_children % m_element_size)
- return 0;
- return num_children/m_element_size;
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+ LibcxxStdVectorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_start(nullptr),
+ m_finish(nullptr), m_element_type(), m_element_size(0) {
+ if (valobj_sp)
+ Update();
+}
+
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+ ~LibcxxStdVectorSyntheticFrontEnd() {
+ // these need to stay around because they are child objects who will follow
+ // their parent's life cycle
+ // delete m_start;
+ // delete m_finish;
+}
+
+size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+ CalculateNumChildren() {
+ if (!m_start || !m_finish)
+ return 0;
+ uint64_t start_val = m_start->GetValueAsUnsigned(0);
+ uint64_t finish_val = m_finish->GetValueAsUnsigned(0);
+
+ if (start_val == 0 || finish_val == 0)
+ return 0;
+
+ if (start_val >= finish_val)
+ return 0;
+
+ size_t num_children = (finish_val - start_val);
+ if (num_children % m_element_size)
+ return 0;
+ return num_children / m_element_size;
}
lldb::ValueObjectSP
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (!m_start || !m_finish)
- return lldb::ValueObjectSP();
-
- uint64_t offset = idx * m_element_size;
- offset = offset + m_start->GetValueAsUnsigned(0);
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- return CreateValueObjectFromAddress(name.GetData(),
- offset,
- m_backend.GetExecutionContextRef(),
- m_element_type);
-}
-
-bool
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update()
-{
- m_start = m_finish = nullptr;
- ValueObjectSP data_type_finder_sp(m_backend.GetChildMemberWithName(ConstString("__end_cap_"),true));
- if (!data_type_finder_sp)
- return false;
- data_type_finder_sp = data_type_finder_sp->GetChildMemberWithName(ConstString("__first_"),true);
- if (!data_type_finder_sp)
- return false;
- m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
- m_element_size = m_element_type.GetByteSize(nullptr);
-
- if (m_element_size > 0)
- {
- // store raw pointers or end up with a circular dependency
- m_start = m_backend.GetChildMemberWithName(ConstString("__begin_"),true).get();
- m_finish = m_backend.GetChildMemberWithName(ConstString("__end_"),true).get();
- }
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ if (!m_start || !m_finish)
+ return lldb::ValueObjectSP();
+
+ uint64_t offset = idx * m_element_size;
+ offset = offset + m_start->GetValueAsUnsigned(0);
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ return CreateValueObjectFromAddress(name.GetData(), offset,
+ m_backend.GetExecutionContextRef(),
+ m_element_type);
+}
+
+bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
+ m_start = m_finish = nullptr;
+ ValueObjectSP data_type_finder_sp(
+ m_backend.GetChildMemberWithName(ConstString("__end_cap_"), true));
+ if (!data_type_finder_sp)
return false;
-}
+ data_type_finder_sp = data_type_finder_sp->GetChildMemberWithName(
+ ConstString("__first_"), true);
+ if (!data_type_finder_sp)
+ return false;
+ m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
+ m_element_size = m_element_type.GetByteSize(nullptr);
-bool
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
-}
-
-size_t
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (!m_start || !m_finish)
- return UINT32_MAX;
- return ExtractIndexFromString(name.GetCString());
-}
-
-lldb_private::SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibcxxStdVectorSyntheticFrontEnd(valobj_sp) : nullptr);
+ if (m_element_size > 0) {
+ // store raw pointers or end up with a circular dependency
+ m_start =
+ m_backend.GetChildMemberWithName(ConstString("__begin_"), true).get();
+ m_finish =
+ m_backend.GetChildMemberWithName(ConstString("__end_"), true).get();
+ }
+ return false;
+}
+
+bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (!m_start || !m_finish)
+ return UINT32_MAX;
+ return ExtractIndexFromString(name.GetCString());
+}
+
+lldb_private::SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxStdVectorSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp Tue Sep 6 15:57:50 2016
@@ -28,449 +28,403 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-namespace
-{
+namespace {
-class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd
-{
- /*
- (std::_Rb_tree_iterator<std::pair<const int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) ibeg = {
- (_Base_ptr) _M_node = 0x0000000100103910 {
- (std::_Rb_tree_color) _M_color = _S_black
- (std::_Rb_tree_node_base::_Base_ptr) _M_parent = 0x00000001001038c0
- (std::_Rb_tree_node_base::_Base_ptr) _M_left = 0x0000000000000000
- (std::_Rb_tree_node_base::_Base_ptr) _M_right = 0x0000000000000000
- }
- }
- */
+class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+ /*
+ (std::_Rb_tree_iterator<std::pair<const int, std::basic_string<char,
+ std::char_traits<char>, std::allocator<char> > > >) ibeg = {
+ (_Base_ptr) _M_node = 0x0000000100103910 {
+ (std::_Rb_tree_color) _M_color = _S_black
+ (std::_Rb_tree_node_base::_Base_ptr) _M_parent = 0x00000001001038c0
+ (std::_Rb_tree_node_base::_Base_ptr) _M_left = 0x0000000000000000
+ (std::_Rb_tree_node_base::_Base_ptr) _M_right = 0x0000000000000000
+ }
+ }
+ */
public:
- explicit LibstdcppMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+ explicit LibstdcppMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
- size_t
- CalculateNumChildren() override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
-
- bool
- Update() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- GetIndexOfChildWithName (const ConstString &name) override;
-
private:
- ExecutionContextRef m_exe_ctx_ref;
- lldb::addr_t m_pair_address;
- CompilerType m_pair_type;
- lldb::ValueObjectSP m_pair_sp;
+ ExecutionContextRef m_exe_ctx_ref;
+ lldb::addr_t m_pair_address;
+ CompilerType m_pair_type;
+ lldb::ValueObjectSP m_pair_sp;
};
-class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd
-{
+class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
- explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+ explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
- size_t
- CalculateNumChildren() override;
+ size_t CalculateNumChildren() override;
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override;
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
- bool
- Update() override;
+ bool Update() override;
- bool
- MightHaveChildren() override;
+ bool MightHaveChildren() override;
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
};
} // end of anonymous namespace
-LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_exe_ctx_ref(),
- m_pair_address(0),
- m_pair_type(),
- m_pair_sp()
-{
- if (valobj_sp)
- Update();
-}
-
-bool
-LibstdcppMapIteratorSyntheticFrontEnd::Update()
-{
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- TargetSP target_sp(valobj_sp->GetTargetSP());
-
- if (!target_sp)
- return false;
-
- bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
-
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-
- ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName(ConstString("_M_node"), true));
- if (!_M_node_sp)
- return false;
-
- m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
- if (m_pair_address == 0)
- return false;
-
- m_pair_address += (is_64bit ? 32 : 16);
-
- CompilerType my_type(valobj_sp->GetCompilerType());
- if (my_type.GetNumTemplateArguments() >= 1)
- {
- TemplateArgumentKind kind;
- CompilerType pair_type = my_type.GetTemplateArgument(0, kind);
- if (kind != eTemplateArgumentKindType && kind != eTemplateArgumentKindTemplate && kind != eTemplateArgumentKindTemplateExpansion)
- return false;
- m_pair_type = pair_type;
- }
- else
- return false;
-
- return true;
+LibstdcppMapIteratorSyntheticFrontEnd::LibstdcppMapIteratorSyntheticFrontEnd(
+ lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_pair_address(0),
+ m_pair_type(), m_pair_sp() {
+ if (valobj_sp)
+ Update();
}
-size_t
-LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren ()
-{
- return 2;
-}
+bool LibstdcppMapIteratorSyntheticFrontEnd::Update() {
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
-lldb::ValueObjectSP
-LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
-{
- if (m_pair_address != 0 && m_pair_type)
- {
- if (!m_pair_sp)
- m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address, m_exe_ctx_ref, m_pair_type);
- if (m_pair_sp)
- return m_pair_sp->GetChildAtIndex(idx, true);
- }
- return lldb::ValueObjectSP();
+ TargetSP target_sp(valobj_sp->GetTargetSP());
+
+ if (!target_sp)
+ return false;
+
+ bool is_64bit = (target_sp->GetArchitecture().GetAddressByteSize() == 8);
+
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ ValueObjectSP _M_node_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("_M_node"), true));
+ if (!_M_node_sp)
+ return false;
+
+ m_pair_address = _M_node_sp->GetValueAsUnsigned(0);
+ if (m_pair_address == 0)
+ return false;
+
+ m_pair_address += (is_64bit ? 32 : 16);
+
+ CompilerType my_type(valobj_sp->GetCompilerType());
+ if (my_type.GetNumTemplateArguments() >= 1) {
+ TemplateArgumentKind kind;
+ CompilerType pair_type = my_type.GetTemplateArgument(0, kind);
+ if (kind != eTemplateArgumentKindType &&
+ kind != eTemplateArgumentKindTemplate &&
+ kind != eTemplateArgumentKindTemplateExpansion)
+ return false;
+ m_pair_type = pair_type;
+ } else
+ return false;
+
+ return true;
}
-bool
-LibstdcppMapIteratorSyntheticFrontEnd::MightHaveChildren ()
-{
- return true;
+size_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
+ return 2;
}
-size_t
-LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
-{
- if (name == ConstString("first"))
- return 0;
- if (name == ConstString("second"))
- return 1;
- return UINT32_MAX;
+lldb::ValueObjectSP
+LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+ if (m_pair_address != 0 && m_pair_type) {
+ if (!m_pair_sp)
+ m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address,
+ m_exe_ctx_ref, m_pair_type);
+ if (m_pair_sp)
+ return m_pair_sp->GetChildAtIndex(idx, true);
+ }
+ return lldb::ValueObjectSP();
+}
+
+bool LibstdcppMapIteratorSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+size_t LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
+ const ConstString &name) {
+ if (name == ConstString("first"))
+ return 0;
+ if (name == ConstString("second"))
+ return 1;
+ return UINT32_MAX;
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp) : nullptr);
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibstdcppMapIteratorSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
/*
(lldb) fr var ibeg --ptr-depth 1
- (__gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int> > >) ibeg = {
+ (__gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int> > >)
+ ibeg = {
_M_current = 0x00000001001037a0 {
*_M_current = 1
}
}
*/
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- static ConstString g_item_name;
- if (!g_item_name)
- g_item_name.SetCString("_M_current");
- return (valobj_sp ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name) : nullptr);
-}
-
-lldb_private::formatters::VectorIteratorSyntheticFrontEnd::VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
- ConstString item_name) :
- SyntheticChildrenFrontEnd(*valobj_sp),
- m_exe_ctx_ref(),
- m_item_name(item_name),
- m_item_sp()
-{
- if (valobj_sp)
- Update();
-}
-
-bool
-VectorIteratorSyntheticFrontEnd::Update()
-{
- m_item_sp.reset();
-
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
-
- if (!valobj_sp)
- return false;
-
- ValueObjectSP item_ptr(valobj_sp->GetChildMemberWithName(m_item_name,true));
- if (!item_ptr)
- return false;
- if (item_ptr->GetValueAsUnsigned(0) == 0)
- return false;
- Error err;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- m_item_sp = CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, item_ptr->GetCompilerType().GetPointeeType());
- if (err.Fail())
- m_item_sp.reset();
- return false;
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibStdcppVectorIteratorSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ static ConstString g_item_name;
+ if (!g_item_name)
+ g_item_name.SetCString("_M_current");
+ return (valobj_sp
+ ? new VectorIteratorSyntheticFrontEnd(valobj_sp, g_item_name)
+ : nullptr);
+}
+
+lldb_private::formatters::VectorIteratorSyntheticFrontEnd::
+ VectorIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp,
+ ConstString item_name)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(),
+ m_item_name(item_name), m_item_sp() {
+ if (valobj_sp)
+ Update();
}
-size_t
-VectorIteratorSyntheticFrontEnd::CalculateNumChildren()
-{
- return 1;
-}
+bool VectorIteratorSyntheticFrontEnd::Update() {
+ m_item_sp.reset();
-lldb::ValueObjectSP
-VectorIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx)
-{
- if (idx == 0)
- return m_item_sp;
- return lldb::ValueObjectSP();
-}
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
-bool
-VectorIteratorSyntheticFrontEnd::MightHaveChildren()
-{
- return true;
-}
+ if (!valobj_sp)
+ return false;
-size_t
-VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(const ConstString &name)
-{
- if (name == ConstString("item"))
- return 0;
- return UINT32_MAX;
-}
-
-bool
-lldb_private::formatters::LibStdcppStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- const bool scalar_is_load_addr = true;
- AddressType addr_type;
- lldb::addr_t addr_of_string = valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
- if (addr_of_string != LLDB_INVALID_ADDRESS)
- {
- switch (addr_type)
- {
- case eAddressTypeLoad:
- {
- ProcessSP process_sp(valobj.GetProcessSP());
- if (!process_sp)
- return false;
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- Error error;
- lldb::addr_t addr_of_data = process_sp->ReadPointerFromMemory(addr_of_string, error);
- if (error.Fail() || addr_of_data == 0 || addr_of_data == LLDB_INVALID_ADDRESS)
- return false;
- options.SetLocation(addr_of_data);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetNeedsZeroTermination(false);
- options.SetBinaryZeroIsTerminator(true);
- lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(addr_of_string + process_sp->GetAddressByteSize(), error);
- if (error.Fail())
- return false;
- options.SetSourceSize(size_of_data);
-
- if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
- else
- return true;
- }
- break;
- case eAddressTypeHost:
- break;
- case eAddressTypeInvalid:
- case eAddressTypeFile:
- break;
- }
- }
+ ValueObjectSP item_ptr(valobj_sp->GetChildMemberWithName(m_item_name, true));
+ if (!item_ptr)
+ return false;
+ if (item_ptr->GetValueAsUnsigned(0) == 0)
return false;
+ Error err;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+ m_item_sp = CreateValueObjectFromAddress(
+ "item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref,
+ item_ptr->GetCompilerType().GetPointeeType());
+ if (err.Fail())
+ m_item_sp.reset();
+ return false;
}
-bool
-lldb_private::formatters::LibStdcppWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- const bool scalar_is_load_addr = true;
- AddressType addr_type;
- lldb::addr_t addr_of_string = valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
- if (addr_of_string != LLDB_INVALID_ADDRESS)
- {
- switch (addr_type)
- {
- case eAddressTypeLoad:
- {
- ProcessSP process_sp(valobj.GetProcessSP());
- if (!process_sp)
- return false;
-
- CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
-
- if (!wchar_compiler_type)
- return false;
-
- const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- Error error;
- lldb::addr_t addr_of_data = process_sp->ReadPointerFromMemory(addr_of_string, error);
- if (error.Fail() || addr_of_data == 0 || addr_of_data == LLDB_INVALID_ADDRESS)
- return false;
- options.SetLocation(addr_of_data);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetNeedsZeroTermination(false);
- options.SetBinaryZeroIsTerminator(false);
- lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(addr_of_string + process_sp->GetAddressByteSize(), error);
- if (error.Fail())
- return false;
- options.SetSourceSize(size_of_data);
- options.SetPrefixToken("L");
-
- switch (wchar_size)
- {
- case 8:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
- case 16:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
- case 32:
- return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
- }
- return true;
- }
- break;
- case eAddressTypeHost:
- break;
- case eAddressTypeInvalid:
- case eAddressTypeFile:
- break;
- }
+size_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; }
+
+lldb::ValueObjectSP
+VectorIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+ if (idx == 0)
+ return m_item_sp;
+ return lldb::ValueObjectSP();
+}
+
+bool VectorIteratorSyntheticFrontEnd::MightHaveChildren() { return true; }
+
+size_t VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
+ const ConstString &name) {
+ if (name == ConstString("item"))
+ return 0;
+ return UINT32_MAX;
+}
+
+bool lldb_private::formatters::LibStdcppStringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ const bool scalar_is_load_addr = true;
+ AddressType addr_type;
+ lldb::addr_t addr_of_string =
+ valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
+ if (addr_of_string != LLDB_INVALID_ADDRESS) {
+ switch (addr_type) {
+ case eAddressTypeLoad: {
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ Error error;
+ lldb::addr_t addr_of_data =
+ process_sp->ReadPointerFromMemory(addr_of_string, error);
+ if (error.Fail() || addr_of_data == 0 ||
+ addr_of_data == LLDB_INVALID_ADDRESS)
+ return false;
+ options.SetLocation(addr_of_data);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetNeedsZeroTermination(false);
+ options.SetBinaryZeroIsTerminator(true);
+ lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(
+ addr_of_string + process_sp->GetAddressByteSize(), error);
+ if (error.Fail())
+ return false;
+ options.SetSourceSize(size_of_data);
+
+ if (!StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF8>(options)) {
+ stream.Printf("Summary Unavailable");
+ return true;
+ } else
+ return true;
+ } break;
+ case eAddressTypeHost:
+ break;
+ case eAddressTypeInvalid:
+ case eAddressTypeFile:
+ break;
}
- return false;
+ }
+ return false;
}
-LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
- : SyntheticChildrenFrontEnd(*valobj_sp)
-{
- if (valobj_sp)
- Update();
+bool lldb_private::formatters::LibStdcppWStringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ const bool scalar_is_load_addr = true;
+ AddressType addr_type;
+ lldb::addr_t addr_of_string =
+ valobj.GetAddressOf(scalar_is_load_addr, &addr_type);
+ if (addr_of_string != LLDB_INVALID_ADDRESS) {
+ switch (addr_type) {
+ case eAddressTypeLoad: {
+ ProcessSP process_sp(valobj.GetProcessSP());
+ if (!process_sp)
+ return false;
+
+ CompilerType wchar_compiler_type =
+ valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
+
+ if (!wchar_compiler_type)
+ return false;
+
+ const uint32_t wchar_size = wchar_compiler_type.GetBitSize(
+ nullptr); // Safe to pass NULL for exe_scope here
+
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ Error error;
+ lldb::addr_t addr_of_data =
+ process_sp->ReadPointerFromMemory(addr_of_string, error);
+ if (error.Fail() || addr_of_data == 0 ||
+ addr_of_data == LLDB_INVALID_ADDRESS)
+ return false;
+ options.SetLocation(addr_of_data);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetNeedsZeroTermination(false);
+ options.SetBinaryZeroIsTerminator(false);
+ lldb::addr_t size_of_data = process_sp->ReadPointerFromMemory(
+ addr_of_string + process_sp->GetAddressByteSize(), error);
+ if (error.Fail())
+ return false;
+ options.SetSourceSize(size_of_data);
+ options.SetPrefixToken("L");
+
+ switch (wchar_size) {
+ case 8:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF8>(options);
+ case 16:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options);
+ case 32:
+ return StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF32>(options);
+ default:
+ stream.Printf("size for wchar_t is not valid");
+ return true;
+ }
+ return true;
+ } break;
+ case eAddressTypeHost:
+ break;
+ case eAddressTypeInvalid:
+ case eAddressTypeFile:
+ break;
+ }
+ }
+ return false;
}
-size_t
-LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren()
-{
- return 1;
+LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
+ lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp) {
+ if (valobj_sp)
+ Update();
}
+size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; }
+
lldb::ValueObjectSP
-LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx)
-{
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return lldb::ValueObjectSP();
+LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return lldb::ValueObjectSP();
- if (idx == 0)
- return valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
- else
- return lldb::ValueObjectSP();
+ if (idx == 0)
+ return valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
+ else
+ return lldb::ValueObjectSP();
}
-bool
-LibStdcppSharedPtrSyntheticFrontEnd::Update()
-{
- return false;
-}
+bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { return false; }
-bool
-LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren()
-{
- return true;
-}
+bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
-size_t
-LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(const ConstString &name)
-{
- if (name == ConstString("_M_ptr"))
- return 0;
- return UINT32_MAX;
+size_t LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
+ const ConstString &name) {
+ if (name == ConstString("_M_ptr"))
+ return 0;
+ return UINT32_MAX;
}
SyntheticChildrenFrontEnd *
-lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
- lldb::ValueObjectSP valobj_sp)
-{
- return (valobj_sp ? new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp) : nullptr);
+lldb_private::formatters::LibStdcppSharedPtrSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibStdcppSharedPtrSyntheticFrontEnd(valobj_sp)
+ : nullptr);
}
-bool
-lldb_private::formatters::LibStdcppSmartPointerSummaryProvider(ValueObject &valobj, Stream &stream,
- const TypeSummaryOptions &options)
-{
- ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
- if (!valobj_sp)
- return false;
+bool lldb_private::formatters::LibStdcppSmartPointerSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
- ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true));
- if (!ptr_sp)
- return false;
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true));
+ if (!ptr_sp)
+ return false;
- ValueObjectSP usecount_sp(
- valobj_sp->GetChildAtNamePath({ConstString("_M_refcount"), ConstString("_M_pi"), ConstString("_M_use_count")}));
- if (!usecount_sp)
- return false;
+ ValueObjectSP usecount_sp(valobj_sp->GetChildAtNamePath(
+ {ConstString("_M_refcount"), ConstString("_M_pi"),
+ ConstString("_M_use_count")}));
+ if (!usecount_sp)
+ return false;
- if (ptr_sp->GetValueAsUnsigned(0) == 0 || usecount_sp->GetValueAsUnsigned(0) == 0)
- {
- stream.Printf("nullptr");
- return true;
- }
+ if (ptr_sp->GetValueAsUnsigned(0) == 0 ||
+ usecount_sp->GetValueAsUnsigned(0) == 0) {
+ stream.Printf("nullptr");
+ return true;
+ }
- Error error;
- ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
- if (pointee_sp && error.Success())
- {
- if (pointee_sp->DumpPrintableRepresentation(stream, ValueObject::eValueObjectRepresentationStyleSummary,
- lldb::eFormatInvalid,
- ValueObject::ePrintableRepresentationSpecialCasesDisable, false))
- {
- return true;
- }
+ Error error;
+ ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
+ if (pointee_sp && error.Success()) {
+ if (pointee_sp->DumpPrintableRepresentation(
+ stream, ValueObject::eValueObjectRepresentationStyleSummary,
+ lldb::eFormatInvalid,
+ ValueObject::ePrintableRepresentationSpecialCasesDisable, false)) {
+ return true;
}
+ }
- stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
- return true;
+ stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
+ return true;
}
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcpp.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- LibStdCpp.h ---------------------------------------------------*- C++ -*-===//
+//===-- LibStdCpp.h ---------------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,23 +17,32 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- LibStdcppStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libcstdc++ c++11 std::string
-
- bool
- LibStdcppWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libcstdc++ c++11 std::wstring
-
- bool
- LibStdcppSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libstdc++ std::shared_ptr<> and std::weak_ptr<>
-
- SyntheticChildrenFrontEnd* LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
-
- SyntheticChildrenFrontEnd* LibStdcppSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP);
- } // namespace formatters
+namespace formatters {
+bool LibStdcppStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libcstdc++ c++11 std::string
+
+bool LibStdcppWStringSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libcstdc++ c++11 std::wstring
+
+bool LibStdcppSmartPointerSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions
+ &options); // libstdc++ std::shared_ptr<> and std::weak_ptr<>
+
+SyntheticChildrenFrontEnd *
+LibstdcppMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibStdcppVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
+LibStdcppSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_LibStdCpp_h_
Modified: lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.cpp (original)
+++ lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.cpp Tue Sep 6 15:57:50 2016
@@ -21,153 +21,132 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-namespace
-{
-class GoSliceSyntheticFrontEnd : public SyntheticChildrenFrontEnd
-{
- public:
- GoSliceSyntheticFrontEnd(ValueObject &valobj)
- : SyntheticChildrenFrontEnd(valobj)
- {
- Update();
- }
-
- ~GoSliceSyntheticFrontEnd() override = default;
-
- size_t
- CalculateNumChildren() override
- {
- return m_len;
- }
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override
- {
- if (idx < m_len)
- {
- ValueObjectSP &cached = m_children[idx];
- if (!cached)
- {
- StreamString idx_name;
- idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- lldb::addr_t object_at_idx = m_base_data_address;
- object_at_idx += idx * m_type.GetByteSize(nullptr);
- cached = CreateValueObjectFromAddress(idx_name.GetData(), object_at_idx,
- m_backend.GetExecutionContextRef(), m_type);
- }
- return cached;
- }
- return ValueObjectSP();
- }
-
- bool
- Update() override
- {
- size_t old_count = m_len;
-
- ConstString array_const_str("array");
- ValueObjectSP array_sp = m_backend.GetChildMemberWithName(array_const_str, true);
- if (!array_sp)
- {
- m_children.clear();
- return old_count == 0;
- }
- m_type = array_sp->GetCompilerType().GetPointeeType();
- m_base_data_address = array_sp->GetPointerValue();
-
- ConstString len_const_str("len");
- ValueObjectSP len_sp = m_backend.GetChildMemberWithName(len_const_str, true);
- if (len_sp)
- {
- m_len = len_sp->GetValueAsUnsigned(0);
- m_children.clear();
- }
-
- return old_count == m_len;
- }
-
- bool
- MightHaveChildren() override
- {
- return true;
- }
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override
- {
- return ExtractIndexFromString(name.AsCString());
- }
-
- private:
- CompilerType m_type;
- lldb::addr_t m_base_data_address;
- size_t m_len;
- std::map<size_t, lldb::ValueObjectSP> m_children;
+namespace {
+class GoSliceSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ GoSliceSyntheticFrontEnd(ValueObject &valobj)
+ : SyntheticChildrenFrontEnd(valobj) {
+ Update();
+ }
+
+ ~GoSliceSyntheticFrontEnd() override = default;
+
+ size_t CalculateNumChildren() override { return m_len; }
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
+ if (idx < m_len) {
+ ValueObjectSP &cached = m_children[idx];
+ if (!cached) {
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ lldb::addr_t object_at_idx = m_base_data_address;
+ object_at_idx += idx * m_type.GetByteSize(nullptr);
+ cached = CreateValueObjectFromAddress(
+ idx_name.GetData(), object_at_idx,
+ m_backend.GetExecutionContextRef(), m_type);
+ }
+ return cached;
+ }
+ return ValueObjectSP();
+ }
+
+ bool Update() override {
+ size_t old_count = m_len;
+
+ ConstString array_const_str("array");
+ ValueObjectSP array_sp =
+ m_backend.GetChildMemberWithName(array_const_str, true);
+ if (!array_sp) {
+ m_children.clear();
+ return old_count == 0;
+ }
+ m_type = array_sp->GetCompilerType().GetPointeeType();
+ m_base_data_address = array_sp->GetPointerValue();
+
+ ConstString len_const_str("len");
+ ValueObjectSP len_sp =
+ m_backend.GetChildMemberWithName(len_const_str, true);
+ if (len_sp) {
+ m_len = len_sp->GetValueAsUnsigned(0);
+ m_children.clear();
+ }
+
+ return old_count == m_len;
+ }
+
+ bool MightHaveChildren() override { return true; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ return ExtractIndexFromString(name.AsCString());
+ }
+
+private:
+ CompilerType m_type;
+ lldb::addr_t m_base_data_address;
+ size_t m_len;
+ std::map<size_t, lldb::ValueObjectSP> m_children;
};
} // anonymous namespace
-bool
-lldb_private::formatters::GoStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- if (valobj.IsPointerType())
- {
- Error err;
- ValueObjectSP deref = valobj.Dereference(err);
- if (!err.Success())
- return false;
- return GoStringSummaryProvider(*deref, stream, opts);
- }
-
- ConstString str_name("str");
- ConstString len_name("len");
-
- ValueObjectSP data_sp = valobj.GetChildMemberWithName(str_name, true);
- ValueObjectSP len_sp = valobj.GetChildMemberWithName(len_name, true);
- if (!data_sp || !len_sp)
- return false;
- bool success;
- lldb::addr_t valobj_addr = data_sp->GetValueAsUnsigned(0, &success);
-
- if (!success)
- return false;
-
- uint64_t length = len_sp->GetValueAsUnsigned(0);
- if (length == 0)
- {
- stream.Printf("\"\"");
- return true;
- }
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetSourceSize(length);
- options.SetNeedsZeroTermination(false);
- options.SetLanguage(eLanguageTypeGo);
-
- if (!StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options))
- {
- stream.Printf("Summary Unavailable");
- return true;
- }
+bool lldb_private::formatters::GoStringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts) {
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ if (valobj.IsPointerType()) {
+ Error err;
+ ValueObjectSP deref = valobj.Dereference(err);
+ if (!err.Success())
+ return false;
+ return GoStringSummaryProvider(*deref, stream, opts);
+ }
+
+ ConstString str_name("str");
+ ConstString len_name("len");
+
+ ValueObjectSP data_sp = valobj.GetChildMemberWithName(str_name, true);
+ ValueObjectSP len_sp = valobj.GetChildMemberWithName(len_name, true);
+ if (!data_sp || !len_sp)
+ return false;
+ bool success;
+ lldb::addr_t valobj_addr = data_sp->GetValueAsUnsigned(0, &success);
+
+ if (!success)
+ return false;
+
+ uint64_t length = len_sp->GetValueAsUnsigned(0);
+ if (length == 0) {
+ stream.Printf("\"\"");
+ return true;
+ }
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(length);
+ options.SetNeedsZeroTermination(false);
+ options.SetLanguage(eLanguageTypeGo);
+
+ if (!StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF8>(options)) {
+ stream.Printf("Summary Unavailable");
return true;
+ }
+
+ return true;
}
SyntheticChildrenFrontEnd *
-lldb_private::formatters::GoSliceSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
-{
- if (!valobj_sp)
- return nullptr;
-
- lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
- if (!process_sp)
- return nullptr;
- return new GoSliceSyntheticFrontEnd(*valobj_sp);
+lldb_private::formatters::GoSliceSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ if (!valobj_sp)
+ return nullptr;
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return nullptr;
+ return new GoSliceSyntheticFrontEnd(*valobj_sp);
}
Modified: lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.h (original)
+++ lldb/trunk/source/Plugins/Language/Go/GoFormatterFunctions.h Tue Sep 6 15:57:50 2016
@@ -28,14 +28,14 @@
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
-namespace lldb_private
-{
-namespace formatters
-{
+namespace lldb_private {
+namespace formatters {
-bool GoStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options);
+bool GoStringSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
-SyntheticChildrenFrontEnd *GoSliceSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
+SyntheticChildrenFrontEnd *
+GoSliceSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
} // namespace formatters
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp Tue Sep 6 15:57:50 2016
@@ -18,129 +18,109 @@
// Project includes
#include "GoLanguage.h"
+#include "Plugins/Language/Go/GoFormatterFunctions.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/GoASTContext.h"
-#include "Plugins/Language/Go/GoFormatterFunctions.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-void
-GoLanguage::Initialize()
-{
- PluginManager::RegisterPlugin(GetPluginNameStatic(), "Go Language", CreateInstance);
-}
-
-void
-GoLanguage::Terminate()
-{
- PluginManager::UnregisterPlugin(CreateInstance);
-}
-
-lldb_private::ConstString
-GoLanguage::GetPluginNameStatic()
-{
- static ConstString g_name("Go");
- return g_name;
+void GoLanguage::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), "Go Language",
+ CreateInstance);
+}
+
+void GoLanguage::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString GoLanguage::GetPluginNameStatic() {
+ static ConstString g_name("Go");
+ return g_name;
}
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
-lldb_private::ConstString
-GoLanguage::GetPluginName()
-{
- return GetPluginNameStatic();
+lldb_private::ConstString GoLanguage::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-GoLanguage::GetPluginVersion()
-{
- return 1;
-}
+uint32_t GoLanguage::GetPluginVersion() { return 1; }
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
-Language *
-GoLanguage::CreateInstance(lldb::LanguageType language)
-{
- if (language == eLanguageTypeGo)
- return new GoLanguage();
- return nullptr;
+Language *GoLanguage::CreateInstance(lldb::LanguageType language) {
+ if (language == eLanguageTypeGo)
+ return new GoLanguage();
+ return nullptr;
}
HardcodedFormatters::HardcodedSummaryFinder
-GoLanguage::GetHardcodedSummaries()
-{
- static std::once_flag g_initialize;
- static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
-
- std::call_once(g_initialize, []() -> void
- {
- g_formatters.push_back(
- [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
- FormatManager &) -> TypeSummaryImpl::SharedPointer
- {
- static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(
- TypeSummaryImpl::Flags().SetDontShowChildren(true),
- lldb_private::formatters::GoStringSummaryProvider, "Go string summary provider"));
- if (GoASTContext::IsGoString(valobj.GetCompilerType()))
- {
- return formatter_sp;
- }
- if (GoASTContext::IsGoString(valobj.GetCompilerType().GetPointeeType()))
- {
- return formatter_sp;
- }
- return nullptr;
- });
- g_formatters.push_back(
- [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
- FormatManager &) -> TypeSummaryImpl::SharedPointer
- {
- static lldb::TypeSummaryImplSP formatter_sp(
- new StringSummaryFormat(TypeSummaryImpl::Flags().SetHideItemNames(true),
- "(len ${var.len}, cap ${var.cap})"));
- if (GoASTContext::IsGoSlice(valobj.GetCompilerType()))
- {
- return formatter_sp;
- }
- if (GoASTContext::IsGoSlice(valobj.GetCompilerType().GetPointeeType()))
- {
- return formatter_sp;
- }
- return nullptr;
- });
- });
- return g_formatters;
+GoLanguage::GetHardcodedSummaries() {
+ static std::once_flag g_initialize;
+ static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &) -> TypeSummaryImpl::SharedPointer {
+ static CXXFunctionSummaryFormat::SharedPointer formatter_sp(
+ new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags().SetDontShowChildren(true),
+ lldb_private::formatters::GoStringSummaryProvider,
+ "Go string summary provider"));
+ if (GoASTContext::IsGoString(valobj.GetCompilerType())) {
+ return formatter_sp;
+ }
+ if (GoASTContext::IsGoString(
+ valobj.GetCompilerType().GetPointeeType())) {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &) -> TypeSummaryImpl::SharedPointer {
+ static lldb::TypeSummaryImplSP formatter_sp(new StringSummaryFormat(
+ TypeSummaryImpl::Flags().SetHideItemNames(true),
+ "(len ${var.len}, cap ${var.cap})"));
+ if (GoASTContext::IsGoSlice(valobj.GetCompilerType())) {
+ return formatter_sp;
+ }
+ if (GoASTContext::IsGoSlice(
+ valobj.GetCompilerType().GetPointeeType())) {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
+ return g_formatters;
}
HardcodedFormatters::HardcodedSyntheticFinder
-GoLanguage::GetHardcodedSynthetics()
-{
- static std::once_flag g_initialize;
- static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
-
- std::call_once(g_initialize, []() -> void
- {
- g_formatters.push_back(
- [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
- FormatManager &fmt_mgr) -> SyntheticChildren::SharedPointer
- {
- static CXXSyntheticChildren::SharedPointer formatter_sp(
- new CXXSyntheticChildren(SyntheticChildren::Flags(), "slice synthetic children",
- lldb_private::formatters::GoSliceSyntheticFrontEndCreator));
- if (GoASTContext::IsGoSlice(valobj.GetCompilerType()))
- {
- return formatter_sp;
- }
- return nullptr;
- });
- });
+GoLanguage::GetHardcodedSynthetics() {
+ static std::once_flag g_initialize;
+ static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
+
+ std::call_once(g_initialize, []() -> void {
+ g_formatters.push_back(
+ [](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
+ FormatManager &fmt_mgr) -> SyntheticChildren::SharedPointer {
+ static CXXSyntheticChildren::SharedPointer formatter_sp(
+ new CXXSyntheticChildren(
+ SyntheticChildren::Flags(), "slice synthetic children",
+ lldb_private::formatters::GoSliceSyntheticFrontEndCreator));
+ if (GoASTContext::IsGoSlice(valobj.GetCompilerType())) {
+ return formatter_sp;
+ }
+ return nullptr;
+ });
+ });
- return g_formatters;
+ return g_formatters;
}
Modified: lldb/trunk/source/Plugins/Language/Go/GoLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Go/GoLanguage.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Go/GoLanguage.h (original)
+++ lldb/trunk/source/Plugins/Language/Go/GoLanguage.h Tue Sep 6 15:57:50 2016
@@ -18,47 +18,44 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/lldb-private.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class GoLanguage : public Language
-{
- public:
- GoLanguage() = default;
+class GoLanguage : public Language {
+public:
+ GoLanguage() = default;
- ~GoLanguage() override = default;
+ ~GoLanguage() override = default;
- lldb::LanguageType
- GetLanguageType() const override
- {
- return lldb::eLanguageTypeGo;
- }
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeGo;
+ }
- HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
+ HardcodedFormatters::HardcodedSummaryFinder GetHardcodedSummaries() override;
- HardcodedFormatters::HardcodedSyntheticFinder GetHardcodedSynthetics() override;
+ HardcodedFormatters::HardcodedSyntheticFinder
+ GetHardcodedSynthetics() override;
- //------------------------------------------------------------------
- // Static Functions
- //------------------------------------------------------------------
- static void Initialize();
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+ static void Initialize();
- static void Terminate();
+ static void Terminate();
- static lldb_private::Language *CreateInstance(lldb::LanguageType language);
+ static lldb_private::Language *CreateInstance(lldb::LanguageType language);
- static lldb_private::ConstString GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- ConstString GetPluginName() override;
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ ConstString GetPluginName() override;
- uint32_t GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.cpp (original)
+++ lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.cpp Tue Sep 6 15:57:50 2016
@@ -20,167 +20,148 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-namespace
-{
+namespace {
-class JavaArraySyntheticFrontEnd : public SyntheticChildrenFrontEnd
-{
+class JavaArraySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
- JavaArraySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) :
- SyntheticChildrenFrontEnd(*valobj_sp)
- {
- if (valobj_sp)
- Update();
- }
-
- size_t
- CalculateNumChildren() override
- {
- ValueObjectSP valobj = GetDereferencedValueObject();
- if (!valobj)
- return 0;
-
- CompilerType type = valobj->GetCompilerType();
- uint32_t size = JavaASTContext::CalculateArraySize(type, *valobj);
- if (size == UINT32_MAX)
- return 0;
- return size;
- }
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx) override
- {
- ValueObjectSP valobj = GetDereferencedValueObject();
- if (!valobj)
- return nullptr;
-
- ProcessSP process_sp = valobj->GetProcessSP();
- if (!process_sp)
- return nullptr;
-
- CompilerType type = valobj->GetCompilerType();
- CompilerType element_type = type.GetArrayElementType();
- lldb::addr_t address = valobj->GetAddressOf() + JavaASTContext::CalculateArrayElementOffset(type, idx);
-
- Error error;
- size_t byte_size = element_type.GetByteSize(nullptr);
- DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
- size_t bytes_read = process_sp->ReadMemory(address, buffer_sp->GetBytes(), byte_size, error);
- if (error.Fail() || byte_size != bytes_read)
- return nullptr;
-
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
- return CreateValueObjectFromData(name.GetData(), data, valobj->GetExecutionContextRef(),
- element_type);
- }
-
- bool
- Update() override
- {
- return false;
- }
-
- bool
- MightHaveChildren() override
- {
- return true;
- }
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override
- {
- return ExtractIndexFromString(name.GetCString());
- }
+ JavaArraySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp) {
+ if (valobj_sp)
+ Update();
+ }
+
+ size_t CalculateNumChildren() override {
+ ValueObjectSP valobj = GetDereferencedValueObject();
+ if (!valobj)
+ return 0;
+
+ CompilerType type = valobj->GetCompilerType();
+ uint32_t size = JavaASTContext::CalculateArraySize(type, *valobj);
+ if (size == UINT32_MAX)
+ return 0;
+ return size;
+ }
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
+ ValueObjectSP valobj = GetDereferencedValueObject();
+ if (!valobj)
+ return nullptr;
+
+ ProcessSP process_sp = valobj->GetProcessSP();
+ if (!process_sp)
+ return nullptr;
+
+ CompilerType type = valobj->GetCompilerType();
+ CompilerType element_type = type.GetArrayElementType();
+ lldb::addr_t address =
+ valobj->GetAddressOf() +
+ JavaASTContext::CalculateArrayElementOffset(type, idx);
+
+ Error error;
+ size_t byte_size = element_type.GetByteSize(nullptr);
+ DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0));
+ size_t bytes_read = process_sp->ReadMemory(address, buffer_sp->GetBytes(),
+ byte_size, error);
+ if (error.Fail() || byte_size != bytes_read)
+ return nullptr;
+
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ DataExtractor data(buffer_sp, process_sp->GetByteOrder(),
+ process_sp->GetAddressByteSize());
+ return CreateValueObjectFromData(
+ name.GetData(), data, valobj->GetExecutionContextRef(), element_type);
+ }
+
+ bool Update() override { return false; }
+
+ bool MightHaveChildren() override { return true; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ return ExtractIndexFromString(name.GetCString());
+ }
private:
- ValueObjectSP
- GetDereferencedValueObject()
- {
- if (!m_backend.IsPointerOrReferenceType())
- return m_backend.GetSP();
-
- Error error;
- return m_backend.Dereference(error);
- }
+ ValueObjectSP GetDereferencedValueObject() {
+ if (!m_backend.IsPointerOrReferenceType())
+ return m_backend.GetSP();
+
+ Error error;
+ return m_backend.Dereference(error);
+ }
};
} // end of anonymous namespace
-bool
-lldb_private::formatters::JavaStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts)
-{
- if (valobj.IsPointerOrReferenceType())
- {
- Error error;
- ValueObjectSP deref = valobj.Dereference(error);
- if (error.Fail())
- return false;
- return JavaStringSummaryProvider(*deref, stream, opts);
- }
-
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
+bool lldb_private::formatters::JavaStringSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &opts) {
+ if (valobj.IsPointerOrReferenceType()) {
+ Error error;
+ ValueObjectSP deref = valobj.Dereference(error);
+ if (error.Fail())
+ return false;
+ return JavaStringSummaryProvider(*deref, stream, opts);
+ }
+
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ConstString data_name("value");
+ ConstString length_name("count");
+
+ ValueObjectSP length_sp = valobj.GetChildMemberWithName(length_name, true);
+ ValueObjectSP data_sp = valobj.GetChildMemberWithName(data_name, true);
+ if (!data_sp || !length_sp)
+ return false;
+
+ bool success = false;
+ uint64_t length = length_sp->GetValueAsUnsigned(0, &success);
+ if (!success)
+ return false;
- ConstString data_name("value");
- ConstString length_name("count");
-
- ValueObjectSP length_sp = valobj.GetChildMemberWithName(length_name, true);
- ValueObjectSP data_sp = valobj.GetChildMemberWithName(data_name, true);
- if (!data_sp || !length_sp)
- return false;
-
- bool success = false;
- uint64_t length = length_sp->GetValueAsUnsigned(0, &success);
- if (!success)
- return false;
-
- if (length == 0)
- {
- stream.Printf("\"\"");
- return true;
- }
- lldb::addr_t valobj_addr = data_sp->GetAddressOf();
-
- StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
- options.SetLocation(valobj_addr);
- options.SetProcessSP(process_sp);
- options.SetStream(&stream);
- options.SetSourceSize(length);
- options.SetNeedsZeroTermination(false);
- options.SetLanguage(eLanguageTypeJava);
+ if (length == 0) {
+ stream.Printf("\"\"");
+ return true;
+ }
+ lldb::addr_t valobj_addr = data_sp->GetAddressOf();
- if (StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options))
- return true;
+ StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
+ options.SetLocation(valobj_addr);
+ options.SetProcessSP(process_sp);
+ options.SetStream(&stream);
+ options.SetSourceSize(length);
+ options.SetNeedsZeroTermination(false);
+ options.SetLanguage(eLanguageTypeJava);
- stream.Printf("Summary Unavailable");
+ if (StringPrinter::ReadStringAndDumpToStream<
+ StringPrinter::StringElementType::UTF16>(options))
return true;
-}
-bool
-lldb_private::formatters::JavaArraySummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
-{
- if (valobj.IsPointerOrReferenceType())
- {
- Error error;
- ValueObjectSP deref = valobj.Dereference(error);
- if (error.Fail())
- return false;
- return JavaArraySummaryProvider(*deref, stream, options);
- }
+ stream.Printf("Summary Unavailable");
+ return true;
+}
- CompilerType type = valobj.GetCompilerType();
- uint32_t size = JavaASTContext::CalculateArraySize(type, valobj);
- if (size == UINT32_MAX)
- return false;
- stream.Printf("[%u]{...}", size);
- return true;
+bool lldb_private::formatters::JavaArraySummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ if (valobj.IsPointerOrReferenceType()) {
+ Error error;
+ ValueObjectSP deref = valobj.Dereference(error);
+ if (error.Fail())
+ return false;
+ return JavaArraySummaryProvider(*deref, stream, options);
+ }
+
+ CompilerType type = valobj.GetCompilerType();
+ uint32_t size = JavaASTContext::CalculateArraySize(type, valobj);
+ if (size == UINT32_MAX)
+ return false;
+ stream.Printf("[%u]{...}", size);
+ return true;
}
-SyntheticChildrenFrontEnd*
-lldb_private::formatters::JavaArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp)
-{
- return valobj_sp ? new JavaArraySyntheticFrontEnd(valobj_sp) : nullptr;
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::JavaArraySyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return valobj_sp ? new JavaArraySyntheticFrontEnd(valobj_sp) : nullptr;
}
Modified: lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.h (original)
+++ lldb/trunk/source/Plugins/Language/Java/JavaFormatterFunctions.h Tue Sep 6 15:57:50 2016
@@ -16,19 +16,18 @@
// Project includes
#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
-namespace formatters
-{
+namespace lldb_private {
+namespace formatters {
-bool
-JavaStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options);
+bool JavaStringSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
-bool
-JavaArraySummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options);
+bool JavaArraySummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
-SyntheticChildrenFrontEnd*
-JavaArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp);
+SyntheticChildrenFrontEnd *
+JavaArraySyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP valobj_sp);
} // namespace formatters
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp Tue Sep 6 15:57:50 2016
@@ -29,84 +29,72 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-void
-JavaLanguage::Initialize()
-{
- PluginManager::RegisterPlugin(GetPluginNameStatic(), "Java Language", CreateInstance);
+void JavaLanguage::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), "Java Language",
+ CreateInstance);
}
-void
-JavaLanguage::Terminate()
-{
- PluginManager::UnregisterPlugin(CreateInstance);
+void JavaLanguage::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString
-JavaLanguage::GetPluginNameStatic()
-{
- static ConstString g_name("Java");
- return g_name;
+lldb_private::ConstString JavaLanguage::GetPluginNameStatic() {
+ static ConstString g_name("Java");
+ return g_name;
}
-lldb_private::ConstString
-JavaLanguage::GetPluginName()
-{
- return GetPluginNameStatic();
+lldb_private::ConstString JavaLanguage::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-JavaLanguage::GetPluginVersion()
-{
- return 1;
-}
+uint32_t JavaLanguage::GetPluginVersion() { return 1; }
-Language *
-JavaLanguage::CreateInstance(lldb::LanguageType language)
-{
- if (language == eLanguageTypeJava)
- return new JavaLanguage();
- return nullptr;
+Language *JavaLanguage::CreateInstance(lldb::LanguageType language) {
+ if (language == eLanguageTypeJava)
+ return new JavaLanguage();
+ return nullptr;
}
-bool
-JavaLanguage::IsNilReference(ValueObject &valobj)
-{
- if (!valobj.GetCompilerType().IsReferenceType())
- return false;
+bool JavaLanguage::IsNilReference(ValueObject &valobj) {
+ if (!valobj.GetCompilerType().IsReferenceType())
+ return false;
- // If we failed to read the value then it is not a nil reference.
- return valobj.GetValueAsUnsigned(UINT64_MAX) == 0;
+ // If we failed to read the value then it is not a nil reference.
+ return valobj.GetValueAsUnsigned(UINT64_MAX) == 0;
}
-lldb::TypeCategoryImplSP
-JavaLanguage::GetFormatters()
-{
- static std::once_flag g_initialize;
- static TypeCategoryImplSP g_category;
+lldb::TypeCategoryImplSP JavaLanguage::GetFormatters() {
+ static std::once_flag g_initialize;
+ static TypeCategoryImplSP g_category;
- std::call_once(g_initialize, [this]() -> void {
- DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
- if (g_category)
- {
- const char* array_regexp = "^.*\\[\\]&?$";
+ std::call_once(g_initialize, [this]() -> void {
+ DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
+ if (g_category) {
+ const char *array_regexp = "^.*\\[\\]&?$";
- lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat(
- TypeSummaryImpl::Flags().SetDontShowChildren(true), lldb_private::formatters::JavaStringSummaryProvider,
- "java.lang.String summary provider"));
- g_category->GetTypeSummariesContainer()->Add(ConstString("java::lang::String"), string_summary_sp);
+ lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags().SetDontShowChildren(true),
+ lldb_private::formatters::JavaStringSummaryProvider,
+ "java.lang.String summary provider"));
+ g_category->GetTypeSummariesContainer()->Add(
+ ConstString("java::lang::String"), string_summary_sp);
- lldb::TypeSummaryImplSP array_summary_sp(new CXXFunctionSummaryFormat(
- TypeSummaryImpl::Flags().SetDontShowChildren(true), lldb_private::formatters::JavaArraySummaryProvider,
- "Java array summary provider"));
- g_category->GetRegexTypeSummariesContainer()->Add(RegularExpressionSP(new RegularExpression(array_regexp)),
- array_summary_sp);
+ lldb::TypeSummaryImplSP array_summary_sp(new CXXFunctionSummaryFormat(
+ TypeSummaryImpl::Flags().SetDontShowChildren(true),
+ lldb_private::formatters::JavaArraySummaryProvider,
+ "Java array summary provider"));
+ g_category->GetRegexTypeSummariesContainer()->Add(
+ RegularExpressionSP(new RegularExpression(array_regexp)),
+ array_summary_sp);
#ifndef LLDB_DISABLE_PYTHON
- AddCXXSynthetic(g_category, lldb_private::formatters::JavaArraySyntheticFrontEndCreator,
- "Java array synthetic children", ConstString(array_regexp),
- SyntheticChildren::Flags().SetCascades(true), true);
+ AddCXXSynthetic(
+ g_category,
+ lldb_private::formatters::JavaArraySyntheticFrontEndCreator,
+ "Java array synthetic children", ConstString(array_regexp),
+ SyntheticChildren::Flags().SetCascades(true), true);
#endif
- }
- });
- return g_category;
+ }
+ });
+ return g_category;
}
Modified: lldb/trunk/source/Plugins/Language/Java/JavaLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Java/JavaLanguage.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/Java/JavaLanguage.h (original)
+++ lldb/trunk/source/Plugins/Language/Java/JavaLanguage.h Tue Sep 6 15:57:50 2016
@@ -22,41 +22,29 @@
#include "lldb/Target/Language.h"
#include "lldb/lldb-private.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class JavaLanguage : public Language
-{
+class JavaLanguage : public Language {
public:
- lldb::LanguageType
- GetLanguageType() const override
- {
- return lldb::eLanguageTypeJava;
- }
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeJava;
+ }
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- static lldb_private::Language *
- CreateInstance(lldb::LanguageType language);
+ static lldb_private::Language *CreateInstance(lldb::LanguageType language);
- static lldb_private::ConstString
- GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- ConstString
- GetPluginName() override;
+ ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- bool
- IsNilReference(ValueObject &valobj) override;
+ bool IsNilReference(ValueObject &valobj) override;
- lldb::TypeCategoryImplSP
- GetFormatters() override;
+ lldb::TypeCategoryImplSP GetFormatters() override;
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- OCamlLanguage.cpp ----------------------------------------*- C++ -*-===//
+//===-- OCamlLanguage.cpp ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -27,52 +28,36 @@
using namespace lldb;
using namespace lldb_private;
-void
-OCamlLanguage::Initialize()
-{
- PluginManager::RegisterPlugin(GetPluginNameStatic(), "OCaml Language", CreateInstance);
+void OCamlLanguage::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), "OCaml Language",
+ CreateInstance);
}
-void
-OCamlLanguage::Terminate()
-{
- PluginManager::UnregisterPlugin(CreateInstance);
+void OCamlLanguage::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString
-OCamlLanguage::GetPluginNameStatic()
-{
- static ConstString g_name("OCaml");
- return g_name;
+lldb_private::ConstString OCamlLanguage::GetPluginNameStatic() {
+ static ConstString g_name("OCaml");
+ return g_name;
}
-lldb_private::ConstString
-OCamlLanguage::GetPluginName()
-{
- return GetPluginNameStatic();
+lldb_private::ConstString OCamlLanguage::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-OCamlLanguage::GetPluginVersion()
-{
- return 1;
-}
+uint32_t OCamlLanguage::GetPluginVersion() { return 1; }
-Language *
-OCamlLanguage::CreateInstance(lldb::LanguageType language)
-{
- if (language == eLanguageTypeOCaml)
- return new OCamlLanguage();
- return nullptr;
+Language *OCamlLanguage::CreateInstance(lldb::LanguageType language) {
+ if (language == eLanguageTypeOCaml)
+ return new OCamlLanguage();
+ return nullptr;
}
-bool
-OCamlLanguage::IsNilReference(ValueObject &valobj)
-{
- if (!valobj.GetCompilerType().IsReferenceType())
- return false;
+bool OCamlLanguage::IsNilReference(ValueObject &valobj) {
+ if (!valobj.GetCompilerType().IsReferenceType())
+ return false;
- // If we failed to read the value then it is not a nil reference.
- return valobj.GetValueAsUnsigned(UINT64_MAX) == 0;
+ // If we failed to read the value then it is not a nil reference.
+ return valobj.GetValueAsUnsigned(UINT64_MAX) == 0;
}
-
Modified: lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.h (original)
+++ lldb/trunk/source/Plugins/Language/OCaml/OCamlLanguage.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- OCamlLanguage.h ------------------------------------------*- C++ -*-===//
+//===-- OCamlLanguage.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,38 +23,27 @@
#include "lldb/Target/Language.h"
#include "lldb/lldb-private.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class OCamlLanguage : public Language
-{
+class OCamlLanguage : public Language {
public:
- lldb::LanguageType
- GetLanguageType() const override
- {
- return lldb::eLanguageTypeOCaml;
- }
+ lldb::LanguageType GetLanguageType() const override {
+ return lldb::eLanguageTypeOCaml;
+ }
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- static lldb_private::Language *
- CreateInstance(lldb::LanguageType language);
+ static lldb_private::Language *CreateInstance(lldb::LanguageType language);
- static lldb_private::ConstString
- GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- ConstString
- GetPluginName() override;
+ ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- bool
- IsNilReference(ValueObject &valobj) override;
+ bool IsNilReference(ValueObject &valobj) override;
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Language/ObjC/CF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/CF.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/CF.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/CF.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- CF.cpp ----------------------------------------------------*- C++ -*-===//
+//===-- CF.cpp ----------------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,293 +27,277 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
-bool
-lldb_private::formatters::CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)valobj.GetValueAsUnsigned(0);
- tm *tm_date = localtime(&epoch);
- if (!tm_date)
- return false;
- std::string buffer(1024,0);
- if (strftime (&buffer[0], 1023, "%Z", tm_date) == 0)
- return false;
- stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year+1900, tm_date->tm_mon+1, tm_date->tm_mday, tm_date->tm_hour, tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
- return true;
+bool lldb_private::formatters::CFAbsoluteTimeSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ time_t epoch = GetOSXEpoch();
+ epoch = epoch + (time_t)valobj.GetValueAsUnsigned(0);
+ tm *tm_date = localtime(&epoch);
+ if (!tm_date)
+ return false;
+ std::string buffer(1024, 0);
+ if (strftime(&buffer[0], 1023, "%Z", tm_date) == 0)
+ return false;
+ stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year + 1900,
+ tm_date->tm_mon + 1, tm_date->tm_mday, tm_date->tm_hour,
+ tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
+ return true;
}
-bool
-lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- static ConstString g_TypeHint("CFBag");
-
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint32_t count = 0;
-
- bool is_type_ok = false; // check to see if this is a CFBag we know about
- if (descriptor->IsCFType())
- {
- ConstString type_name(valobj.GetTypeName());
-
- static ConstString g___CFBag("__CFBag");
- static ConstString g_conststruct__CFBag("const struct __CFBag");
-
- if (type_name == g___CFBag ||
- type_name == g_conststruct__CFBag)
- {
- if (valobj.IsPointerType())
- is_type_ok = true;
- }
- }
-
- if (is_type_ok)
- {
- lldb::addr_t offset = 2*ptr_size+4 + valobj_addr;
- Error error;
- count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
- if (error.Fail())
- return false;
- }
- else
- return false;
-
- std::string prefix,suffix;
- if (Language* language = Language::FindPlugin(options.GetLanguage()))
- {
- if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
- {
- prefix.clear();
- suffix.clear();
- }
- }
-
- stream.Printf("%s\"%u value%s\"%s",
- prefix.c_str(),
- count,(count == 1 ? "" : "s"),
- suffix.c_str());
- return true;
-}
+bool lldb_private::formatters::CFBagSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ static ConstString g_TypeHint("CFBag");
+
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime *runtime =
+ (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
+ lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(
+ runtime->GetClassDescriptor(valobj));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ uint32_t ptr_size = process_sp->GetAddressByteSize();
+
+ lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-bool
-lldb_private::formatters::CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint32_t count = 0;
-
- bool is_type_ok = false; // check to see if this is a CFBag we know about
- if (descriptor->IsCFType())
- {
- ConstString type_name(valobj.GetTypeName());
- if (type_name == ConstString("__CFMutableBitVector") || type_name == ConstString("__CFBitVector") || type_name == ConstString("CFMutableBitVectorRef") || type_name == ConstString("CFBitVectorRef"))
- {
- if (valobj.IsPointerType())
- is_type_ok = true;
- }
- }
-
- if (is_type_ok == false)
- return false;
-
+ if (!valobj_addr)
+ return false;
+
+ uint32_t count = 0;
+
+ bool is_type_ok = false; // check to see if this is a CFBag we know about
+ if (descriptor->IsCFType()) {
+ ConstString type_name(valobj.GetTypeName());
+
+ static ConstString g___CFBag("__CFBag");
+ static ConstString g_conststruct__CFBag("const struct __CFBag");
+
+ if (type_name == g___CFBag || type_name == g_conststruct__CFBag) {
+ if (valobj.IsPointerType())
+ is_type_ok = true;
+ }
+ }
+
+ if (is_type_ok) {
+ lldb::addr_t offset = 2 * ptr_size + 4 + valobj_addr;
Error error;
- count = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+2*ptr_size, ptr_size, 0, error);
- if (error.Fail())
- return false;
- uint64_t num_bytes = count / 8 + ((count & 7) ? 1 : 0);
- addr_t data_ptr = process_sp->ReadPointerFromMemory(valobj_addr+2*ptr_size+2*ptr_size, error);
+ count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
if (error.Fail())
- return false;
- // make sure we do not try to read huge amounts of data
- if (num_bytes > 1024)
- num_bytes = 1024;
- DataBufferSP buffer_sp(new DataBufferHeap(num_bytes,0));
- num_bytes = process_sp->ReadMemory(data_ptr, buffer_sp->GetBytes(), num_bytes, error);
- if (error.Fail() || num_bytes == 0)
- return false;
- uint8_t *bytes = buffer_sp->GetBytes();
- for (uint64_t byte_idx = 0; byte_idx < num_bytes-1; byte_idx++)
- {
- uint8_t byte = bytes[byte_idx];
- bool bit0 = (byte & 1) == 1;
- bool bit1 = (byte & 2) == 2;
- bool bit2 = (byte & 4) == 4;
- bool bit3 = (byte & 8) == 8;
- bool bit4 = (byte & 16) == 16;
- bool bit5 = (byte & 32) == 32;
- bool bit6 = (byte & 64) == 64;
- bool bit7 = (byte & 128) == 128;
- stream.Printf("%c%c%c%c %c%c%c%c ",
- (bit7 ? '1' : '0'),
- (bit6 ? '1' : '0'),
- (bit5 ? '1' : '0'),
- (bit4 ? '1' : '0'),
- (bit3 ? '1' : '0'),
- (bit2 ? '1' : '0'),
- (bit1 ? '1' : '0'),
- (bit0 ? '1' : '0'));
- count -= 8;
- }
- {
- // print the last byte ensuring we do not print spurious bits
- uint8_t byte = bytes[num_bytes-1];
- bool bit0 = (byte & 1) == 1;
- bool bit1 = (byte & 2) == 2;
- bool bit2 = (byte & 4) == 4;
- bool bit3 = (byte & 8) == 8;
- bool bit4 = (byte & 16) == 16;
- bool bit5 = (byte & 32) == 32;
- bool bit6 = (byte & 64) == 64;
- bool bit7 = (byte & 128) == 128;
- if (count)
- {
- stream.Printf("%c",bit7 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit6 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit5 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit4 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit3 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit2 ? '1' : '0');
- count -= 1;
- }
- if (count)
- {
- stream.Printf("%c",bit1 ? '1' : '0');
- count -= 1;
- }
- if (count)
- stream.Printf("%c",bit0 ? '1' : '0');
+ return false;
+ } else
+ return false;
+
+ std::string prefix, suffix;
+ if (Language *language = Language::FindPlugin(options.GetLanguage())) {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix,
+ suffix)) {
+ prefix.clear();
+ suffix.clear();
}
- return true;
+ }
+
+ stream.Printf("%s\"%u value%s\"%s", prefix.c_str(), count,
+ (count == 1 ? "" : "s"), suffix.c_str());
+ return true;
}
-bool
-lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
-{
- static ConstString g_TypeHint("CFBinaryHeap");
-
- ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- return false;
-
- ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
-
- if (!runtime)
- return false;
-
- ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
-
- if (!descriptor.get() || !descriptor->IsValid())
- return false;
-
- uint32_t ptr_size = process_sp->GetAddressByteSize();
-
- lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
-
- if (!valobj_addr)
- return false;
-
- uint32_t count = 0;
-
- bool is_type_ok = false; // check to see if this is a CFBinaryHeap we know about
- if (descriptor->IsCFType())
- {
- ConstString type_name(valobj.GetTypeName());
-
- static ConstString g___CFBinaryHeap("__CFBinaryHeap");
- static ConstString g_conststruct__CFBinaryHeap("const struct __CFBinaryHeap");
- static ConstString g_CFBinaryHeapRef("CFBinaryHeapRef");
-
- if (type_name == g___CFBinaryHeap ||
- type_name == g_conststruct__CFBinaryHeap ||
- type_name == g_CFBinaryHeapRef)
- {
- if (valobj.IsPointerType())
- is_type_ok = true;
- }
- }
-
- if (is_type_ok)
- {
- lldb::addr_t offset = 2*ptr_size + valobj_addr;
- Error error;
- count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
- if (error.Fail())
- return false;
- }
- else
- return false;
-
- std::string prefix,suffix;
- if (Language* language = Language::FindPlugin(options.GetLanguage()))
- {
- if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix, suffix))
- {
- prefix.clear();
- suffix.clear();
- }
- }
-
- stream.Printf("%s\"%u item%s\"%s",
- prefix.c_str(),
- count,(count == 1 ? "" : "s"),
- suffix.c_str());
- return true;
+bool lldb_private::formatters::CFBitVectorSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime *runtime =
+ (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
+ lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(
+ runtime->GetClassDescriptor(valobj));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ uint32_t ptr_size = process_sp->GetAddressByteSize();
+
+ lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
+
+ if (!valobj_addr)
+ return false;
+
+ uint32_t count = 0;
+
+ bool is_type_ok = false; // check to see if this is a CFBag we know about
+ if (descriptor->IsCFType()) {
+ ConstString type_name(valobj.GetTypeName());
+ if (type_name == ConstString("__CFMutableBitVector") ||
+ type_name == ConstString("__CFBitVector") ||
+ type_name == ConstString("CFMutableBitVectorRef") ||
+ type_name == ConstString("CFBitVectorRef")) {
+ if (valobj.IsPointerType())
+ is_type_ok = true;
+ }
+ }
+
+ if (is_type_ok == false)
+ return false;
+
+ Error error;
+ count = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + 2 * ptr_size,
+ ptr_size, 0, error);
+ if (error.Fail())
+ return false;
+ uint64_t num_bytes = count / 8 + ((count & 7) ? 1 : 0);
+ addr_t data_ptr = process_sp->ReadPointerFromMemory(
+ valobj_addr + 2 * ptr_size + 2 * ptr_size, error);
+ if (error.Fail())
+ return false;
+ // make sure we do not try to read huge amounts of data
+ if (num_bytes > 1024)
+ num_bytes = 1024;
+ DataBufferSP buffer_sp(new DataBufferHeap(num_bytes, 0));
+ num_bytes =
+ process_sp->ReadMemory(data_ptr, buffer_sp->GetBytes(), num_bytes, error);
+ if (error.Fail() || num_bytes == 0)
+ return false;
+ uint8_t *bytes = buffer_sp->GetBytes();
+ for (uint64_t byte_idx = 0; byte_idx < num_bytes - 1; byte_idx++) {
+ uint8_t byte = bytes[byte_idx];
+ bool bit0 = (byte & 1) == 1;
+ bool bit1 = (byte & 2) == 2;
+ bool bit2 = (byte & 4) == 4;
+ bool bit3 = (byte & 8) == 8;
+ bool bit4 = (byte & 16) == 16;
+ bool bit5 = (byte & 32) == 32;
+ bool bit6 = (byte & 64) == 64;
+ bool bit7 = (byte & 128) == 128;
+ stream.Printf("%c%c%c%c %c%c%c%c ", (bit7 ? '1' : '0'), (bit6 ? '1' : '0'),
+ (bit5 ? '1' : '0'), (bit4 ? '1' : '0'), (bit3 ? '1' : '0'),
+ (bit2 ? '1' : '0'), (bit1 ? '1' : '0'), (bit0 ? '1' : '0'));
+ count -= 8;
+ }
+ {
+ // print the last byte ensuring we do not print spurious bits
+ uint8_t byte = bytes[num_bytes - 1];
+ bool bit0 = (byte & 1) == 1;
+ bool bit1 = (byte & 2) == 2;
+ bool bit2 = (byte & 4) == 4;
+ bool bit3 = (byte & 8) == 8;
+ bool bit4 = (byte & 16) == 16;
+ bool bit5 = (byte & 32) == 32;
+ bool bit6 = (byte & 64) == 64;
+ bool bit7 = (byte & 128) == 128;
+ if (count) {
+ stream.Printf("%c", bit7 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit6 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit5 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit4 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit3 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit2 ? '1' : '0');
+ count -= 1;
+ }
+ if (count) {
+ stream.Printf("%c", bit1 ? '1' : '0');
+ count -= 1;
+ }
+ if (count)
+ stream.Printf("%c", bit0 ? '1' : '0');
+ }
+ return true;
+}
+
+bool lldb_private::formatters::CFBinaryHeapSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ static ConstString g_TypeHint("CFBinaryHeap");
+
+ ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ return false;
+
+ ObjCLanguageRuntime *runtime =
+ (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
+ lldb::eLanguageTypeObjC);
+
+ if (!runtime)
+ return false;
+
+ ObjCLanguageRuntime::ClassDescriptorSP descriptor(
+ runtime->GetClassDescriptor(valobj));
+
+ if (!descriptor.get() || !descriptor->IsValid())
+ return false;
+
+ uint32_t ptr_size = process_sp->GetAddressByteSize();
+
+ lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
+
+ if (!valobj_addr)
+ return false;
+
+ uint32_t count = 0;
+
+ bool is_type_ok =
+ false; // check to see if this is a CFBinaryHeap we know about
+ if (descriptor->IsCFType()) {
+ ConstString type_name(valobj.GetTypeName());
+
+ static ConstString g___CFBinaryHeap("__CFBinaryHeap");
+ static ConstString g_conststruct__CFBinaryHeap(
+ "const struct __CFBinaryHeap");
+ static ConstString g_CFBinaryHeapRef("CFBinaryHeapRef");
+
+ if (type_name == g___CFBinaryHeap ||
+ type_name == g_conststruct__CFBinaryHeap ||
+ type_name == g_CFBinaryHeapRef) {
+ if (valobj.IsPointerType())
+ is_type_ok = true;
+ }
+ }
+
+ if (is_type_ok) {
+ lldb::addr_t offset = 2 * ptr_size + valobj_addr;
+ Error error;
+ count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
+ if (error.Fail())
+ return false;
+ } else
+ return false;
+
+ std::string prefix, suffix;
+ if (Language *language = Language::FindPlugin(options.GetLanguage())) {
+ if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix,
+ suffix)) {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ stream.Printf("%s\"%u item%s\"%s", prefix.c_str(), count,
+ (count == 1 ? "" : "s"), suffix.c_str());
+ return true;
}
Modified: lldb/trunk/source/Plugins/Language/ObjC/CF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/CF.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/ObjC/CF.h (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/CF.h Tue Sep 6 15:57:50 2016
@@ -15,20 +15,19 @@
#include "lldb/DataFormatters/TypeSummary.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
-
- bool
- CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
- } // namespace formatters
+namespace formatters {
+bool CFBagSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
+bool CFBinaryHeapSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
+bool CFBitVectorSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
+bool CFAbsoluteTimeSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_CF_h_
More information about the lldb-commits
mailing list