From johnny.chen at apple.com Mon Feb 14 13:08:41 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 19:08:41 -0000 Subject: [Lldb-commits] [lldb] r125508 - /lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Message-ID: <20110214190842.79B7D2A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 13:08:41 2011 New Revision: 125508 URL: http://llvm.org/viewvc/llvm-project?rev=125508&view=rev Log: Enhanced the existing ARMExpandImm() and ThumbExpandImm() functions which expand an imm12 into imm32 for ARM or Thumb so that they now handle carry_in/carry_out. Funnel ARMExpandImm()/ThumbExpandImm() to the enhanced ARMExpandImm_C()/ThumbExpandImm_C() functions. Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125508&r1=125507&r2=125508&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Mon Feb 14 13:08:41 2011 @@ -32,47 +32,78 @@ return (val >> m) | (val << (N - m)); } -static inline uint32_t ARMExpandImm(uint32_t val) +// (imm32, carry_out) = ARMExpandImm_C(imm12, carry_in) +static inline uint32_t ARMExpandImm_C(uint32_t val, uint32_t carry_in, uint32_t &carry_out) { + uint32_t imm32; // the expanded result uint32_t imm = bits(val, 7, 0); // immediate value - uint32_t rot = 2 * bits(val, 11, 8); // rotate amount - return (imm >> rot) | (imm << (32 - rot)); + uint32_t amt = 2 * bits(val, 11, 8); // rotate amount + if (amt == 0) + { + imm32 = imm; + carry_out = carry_in; + } + else + { + imm32 = ror(imm, 32, amt); + carry_out = Bit32(imm32, 31); + } + return imm32; } -static inline uint32_t ThumbExpandImm(uint32_t val) +static inline uint32_t ARMExpandImm(uint32_t val) { - uint32_t imm32 = 0; - const uint32_t i = bit(val, 26); - const uint32_t imm3 = bits(val, 14, 12); - const uint32_t abcdefgh = bits(val, 7, 0); - const uint32_t imm12 = i << 11 | imm3 << 8 | abcdefgh; + // 'carry_in' argument to following function call does not affect the imm32 result. + uint32_t carry_in = 0; + uint32_t carry_out; + return ARMExpandImm_C(val, carry_in, carry_out); +} - if (bits(imm12, 10, 11) == 0) - { - switch (bits(imm12, 8, 9)) { - case 0: - imm32 = abcdefgh; - break; - - case 1: - imm32 = abcdefgh << 16 | abcdefgh; - break; - - case 2: - imm32 = abcdefgh << 24 | abcdefgh << 8; - break; - - case 3: - imm32 = abcdefgh << 24 | abcdefgh << 16 | abcdefgh << 8 | abcdefgh; - break; - } - } - else - { - const uint32_t unrotated_value = 0x80 | bits(imm12, 0, 6); - imm32 = ror(unrotated_value, 32, bits(imm12, 7, 11)); - } - return imm32; +// (imm32, carry_out) = ThumbExpandImm_C(imm12, carry_in) +static inline uint32_t ThumbExpandImm_C(uint32_t val, uint32_t carry_in, uint32_t &carry_out) +{ + uint32_t imm32; + const uint32_t i = bit(val, 26); + const uint32_t imm3 = bits(val, 14, 12); + const uint32_t abcdefgh = bits(val, 7, 0); + const uint32_t imm12 = i << 11 | imm3 << 8 | abcdefgh; + + if (bits(imm12, 11, 10) == 0) + { + switch (bits(imm12, 8, 9)) { + case 0: + imm32 = abcdefgh; + break; + + case 1: + imm32 = abcdefgh << 16 | abcdefgh; + break; + + case 2: + imm32 = abcdefgh << 24 | abcdefgh << 8; + break; + + case 3: + imm32 = abcdefgh << 24 | abcdefgh << 16 | abcdefgh << 8 | abcdefgh; + break; + } + carry_out = carry_in; + } + else + { + const uint32_t unrotated_value = 0x80 | bits(imm12, 6, 0); + imm32 = ror(unrotated_value, 32, bits(imm12, 11, 7)); + carry_out = Bit32(imm32, 31); + } + return imm32; +} + +static inline uint32_t ThumbExpandImm(uint32_t val) +{ + // 'carry_in' argument to following function call does not affect the imm32 result. + uint32_t carry_in = 0; + uint32_t carry_out; + return ThumbExpandImm_C(val, carry_in, carry_out); } // imm32 = ZeroExtend(i:imm3:imm8, 32) From johnny.chen at apple.com Mon Feb 14 13:09:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 19:09:36 -0000 Subject: [Lldb-commits] [lldb] r125509 - /lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Message-ID: <20110214190936.3E2302A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 13:09:36 2011 New Revision: 125509 URL: http://llvm.org/viewvc/llvm-project?rev=125509&view=rev Log: Add comment. Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125509&r1=125508&r2=125509&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Mon Feb 14 13:09:36 2011 @@ -62,7 +62,7 @@ // (imm32, carry_out) = ThumbExpandImm_C(imm12, carry_in) static inline uint32_t ThumbExpandImm_C(uint32_t val, uint32_t carry_in, uint32_t &carry_out) { - uint32_t imm32; + uint32_t imm32; // the expaned result const uint32_t i = bit(val, 26); const uint32_t imm3 = bits(val, 14, 12); const uint32_t abcdefgh = bits(val, 7, 0); From johnny.chen at apple.com Mon Feb 14 14:39:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 20:39:01 -0000 Subject: [Lldb-commits] [lldb] r125518 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110214203901.D4B382A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 14:39:01 2011 New Revision: 125518 URL: http://llvm.org/viewvc/llvm-project?rev=125518&view=rev Log: Add impl for EmulateMvnRdImm() -- "MVN (immediate)". Plus zero out the arg0 field of the context of eContextImmediate type, since the immediate value is known from the argument value to WriteRegisterUnsigned() callback already. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125518&r1=125517&r2=125518&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 14:39:01 2011 @@ -671,7 +671,66 @@ // APSR.V unchanged } #endif - return false; + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + uint32_t Rd; // the destination register + uint32_t imm12; // the first operand to ThumbExpandImm_C or ARMExpandImm_C. + uint32_t imm32; // the output after ThumbExpandImm_C or ARMExpandImm_C. + uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. + bool setflags; + switch (encoding) { + case eEncodingT1: + Rd = Bits32(opcode, 11, 8); + imm12 = Bit32(opcode, 26) << 11 | Bits32(opcode, 14, 12) << 8 | Bits32(opcode, 7, 0); + setflags = BitIsSet(opcode, 20); + imm32 = ThumbExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); + break; + case eEncodingA1: + Rd = Bits32(opcode, 15, 12); + imm12 = Bits32(opcode, 11, 0); + setflags = BitIsSet(opcode, 20); + imm32 = ARMExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); + break; + default: + return false; + } + uint32_t result = ~imm32; + + // The context specifies that an immediate is to be moved into Rd. + EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, + 0, + 0, + 0 }; + + if (Rd == 15) + { + if (!ALUWritePC (context, result)) + return false; + } + else + { + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + return false; + if (setflags) + { + m_new_inst_cpsr = m_inst_cpsr; + SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); + SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); + SetBit32(m_new_inst_cpsr, CPSR_C, carry); + if (m_new_inst_cpsr != m_inst_cpsr) + { + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) + return false; + } + } + } + } + return true; } // PC relative immediate load into register, possibly followed by ADD (SP plus register). @@ -1805,7 +1864,7 @@ result = val1 + val2; EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, - result, + 0, 0, 0 }; @@ -1816,7 +1875,7 @@ } else { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, result)) + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) return false; } } @@ -1858,7 +1917,6 @@ if (!success) return false; - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; AddWithCarryResult res = AddWithCarry(reg_val, ~imm32, 1); m_new_inst_cpsr = m_inst_cpsr; SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(res.result, CPSR_N)); @@ -1867,6 +1925,7 @@ SetBit32(m_new_inst_cpsr, CPSR_V, res.overflow); if (m_new_inst_cpsr != m_inst_cpsr) { + EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) return false; } @@ -1922,7 +1981,6 @@ if (!success) return false; - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; AddWithCarryResult res = AddWithCarry(reg_val1, reg_val2, 1); m_new_inst_cpsr = m_inst_cpsr; SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(res.result, CPSR_N)); @@ -1931,6 +1989,7 @@ SetBit32(m_new_inst_cpsr, CPSR_V, res.overflow); if (m_new_inst_cpsr != m_inst_cpsr) { + EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) return false; } @@ -2523,7 +2582,6 @@ data = ReadMemoryUnsigned(context, address, 4, 0, &success); if (!success) return false; - context.arg0 = data; if (Rt == 15) { From gclayton at apple.com Mon Feb 14 15:08:22 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 14 Feb 2011 21:08:22 -0000 Subject: [Lldb-commits] [lldb] r125520 - /lldb/branches/apple/calcite/lldb/test/dotest.py Message-ID: <20110214210822.6542A2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 14 15:08:22 2011 New Revision: 125520 URL: http://llvm.org/viewvc/llvm-project?rev=125520&view=rev Log: Added support for build directories from Xcode 4 xcworkspaces. Modified: lldb/branches/apple/calcite/lldb/test/dotest.py Modified: lldb/branches/apple/calcite/lldb/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/test/dotest.py?rev=125520&r1=125519&r2=125520&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/test/dotest.py (original) +++ lldb/branches/apple/calcite/lldb/test/dotest.py Mon Feb 14 15:08:22 2011 @@ -498,18 +498,30 @@ base = os.path.abspath(os.path.join(scriptPath, os.pardir)) dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework', 'Resources', 'Python') + dbgPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'Debug', 'LLDB.framework', 'Resources', 'Python') relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework', 'Resources', 'Python') + relPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'Release', 'LLDB.framework', 'Resources', 'Python') baiPath = os.path.join(base, 'build', 'BuildAndIntegration', 'LLDB.framework', 'Resources', 'Python') + baiPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'BuildAndIntegration', 'LLDB.framework', 'Resources', 'Python') lldbPath = None if os.path.isfile(os.path.join(dbgPath, 'lldb.py')): lldbPath = dbgPath + elif os.path.isfile(os.path.join(dbgPath2, 'lldb.py')): + lldbPath = dbgPath2 elif os.path.isfile(os.path.join(relPath, 'lldb.py')): lldbPath = relPath + elif os.path.isfile(os.path.join(relPath2, 'lldb.py')): + lldbPath = relPath2 elif os.path.isfile(os.path.join(baiPath, 'lldb.py')): lldbPath = baiPath + elif os.path.isfile(os.path.join(baiPath2, 'lldb.py')): + lldbPath = baiPath2 if not lldbPath: print 'This script requires lldb.py to be in either ' + dbgPath + ',', From gclayton at apple.com Mon Feb 14 15:17:06 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 14 Feb 2011 21:17:06 -0000 Subject: [Lldb-commits] [lldb] r125522 - /lldb/trunk/test/dotest.py Message-ID: <20110214211706.6069E2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 14 15:17:06 2011 New Revision: 125522 URL: http://llvm.org/viewvc/llvm-project?rev=125522&view=rev Log: Added support for Xcode 4 build directories. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=125522&r1=125521&r2=125522&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Feb 14 15:17:06 2011 @@ -498,18 +498,30 @@ base = os.path.abspath(os.path.join(scriptPath, os.pardir)) dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework', 'Resources', 'Python') + dbgPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'Debug', 'LLDB.framework', 'Resources', 'Python') relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework', 'Resources', 'Python') + relPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'Release', 'LLDB.framework', 'Resources', 'Python') baiPath = os.path.join(base, 'build', 'BuildAndIntegration', 'LLDB.framework', 'Resources', 'Python') + baiPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', + 'BuildAndIntegration', 'LLDB.framework', 'Resources', 'Python') lldbPath = None if os.path.isfile(os.path.join(dbgPath, 'lldb.py')): lldbPath = dbgPath + elif os.path.isfile(os.path.join(dbgPath2, 'lldb.py')): + lldbPath = dbgPath2 elif os.path.isfile(os.path.join(relPath, 'lldb.py')): lldbPath = relPath + elif os.path.isfile(os.path.join(relPath2, 'lldb.py')): + lldbPath = relPath2 elif os.path.isfile(os.path.join(baiPath, 'lldb.py')): lldbPath = baiPath + elif os.path.isfile(os.path.join(baiPath2, 'lldb.py')): + lldbPath = baiPath2 if not lldbPath: print 'This script requires lldb.py to be in either ' + dbgPath + ',', From johnny.chen at apple.com Mon Feb 14 16:04:26 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 22:04:26 -0000 Subject: [Lldb-commits] [lldb] r125524 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110214220426.1BFF72A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 16:04:25 2011 New Revision: 125524 URL: http://llvm.org/viewvc/llvm-project?rev=125524&view=rev Log: Add entries for EmulateMovRdImm() -- "MOV (immediate)" -- Encodings T1 & T2 into g_thumb_opcodes table. Modify EmulateInstructionARM::EvaluateInstruction() so that if the cpsr has changed during evaluate instruction, we flush out the change into m_inst_cpsr in preparation for the next instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125524&r1=125523&r2=125524&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 16:04:25 2011 @@ -647,6 +647,91 @@ return true; } +// Move (immediate) writes an immediate value to the destination register. It +// can optionally update the condition flags based on the value. +// MOV (immediate) +bool +EmulateInstructionARM::EmulateMovRdImm (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if (ConditionPassed()) + { + EncodingSpecificOperations(); + result = imm32; + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged + } +#endif + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + uint32_t Rd; // the destination register + uint32_t imm12; // some intermediate result + uint32_t imm32; // the immediate value to be written to Rd + uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. + bool setflags; + switch (encoding) { + case eEncodingT1: + Rd = Bits32(opcode, 11, 8); + setflags = !InITBlock(); + imm32 = Bits32(opcode, 7, 0); // imm32 = ZeroExtend(imm8, 32) + carry = Bit32(m_inst_cpsr, CPSR_C); + break; + case eEncodingT2: + Rd = Bits32(opcode, 15, 12); + setflags = BitIsSet(opcode, 20); + imm12 = Bit32(opcode, 26) << 11 | Bits32(opcode, 14, 12) << 8 | Bits32(opcode, 7, 0); + imm32 = ThumbExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); + break; + default: + return false; + } + uint32_t result = imm32; + + // The context specifies that an immediate is to be moved into Rd. + EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, + 0, + 0, + 0 }; + + if (Rd == 15) + { + if (!ALUWritePC (context, result)) + return false; + } + else + { + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + return false; + if (setflags) + { + m_new_inst_cpsr = m_inst_cpsr; + SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); + SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); + SetBit32(m_new_inst_cpsr, CPSR_C, carry); + if (m_new_inst_cpsr != m_inst_cpsr) + { + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) + return false; + } + } + } + } + return true; +} + // Bitwise NOT (immediate) writes the bitwise inverse of an immediate value to // the destination register. It can optionally update the condition flags based // on the value. @@ -679,21 +764,21 @@ if (ConditionPassed()) { uint32_t Rd; // the destination register - uint32_t imm12; // the first operand to ThumbExpandImm_C or ARMExpandImm_C. - uint32_t imm32; // the output after ThumbExpandImm_C or ARMExpandImm_C. - uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. + uint32_t imm12; // the first operand to ThumbExpandImm_C or ARMExpandImm_C + uint32_t imm32; // the output after ThumbExpandImm_C or ARMExpandImm_C + uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C bool setflags; switch (encoding) { case eEncodingT1: Rd = Bits32(opcode, 11, 8); - imm12 = Bit32(opcode, 26) << 11 | Bits32(opcode, 14, 12) << 8 | Bits32(opcode, 7, 0); setflags = BitIsSet(opcode, 20); + imm12 = Bit32(opcode, 26) << 11 | Bits32(opcode, 14, 12) << 8 | Bits32(opcode, 7, 0); imm32 = ThumbExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); break; case eEncodingA1: Rd = Bits32(opcode, 15, 12); - imm12 = Bits32(opcode, 11, 0); setflags = BitIsSet(opcode, 20); + imm12 = Bits32(opcode, 11, 0); imm32 = ARMExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); break; default: @@ -2935,6 +3020,9 @@ { 0xffffff00, 0x00004600, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateMovRdRm, "mov , "}, // move from low register to low register { 0xffffffc0, 0x00000000, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateMovRdRm, "movs , "}, + // move immediate + { 0xfffff800, 0x00002000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateMovRdImm, "movs|mov , #imm8"}, + { 0xfbef8000, 0xf04f0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateMovRdImm, "mov{s}.w , #"}, // move bitwise not { 0xfbef8000, 0xf06f0000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateMvnRdImm, "mvn{s} , #"}, // compare a register with immediate @@ -3298,5 +3386,9 @@ if (m_inst_mode == eModeThumb && m_it_session.InITBlock()) m_it_session.ITAdvance(); + // If the flags have changed, flush it out. + if (m_new_inst_cpsr != m_inst_cpsr) + m_inst_cpsr = m_new_inst_cpsr; + return false; } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125524&r1=125523&r2=125524&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Feb 14 16:04:25 2011 @@ -290,6 +290,10 @@ bool EmulateMovRdRm (ARMEncoding encoding); + // MOV (immediate) + bool + EmulateMovRdImm (ARMEncoding encoding); + // MVN (immediate) bool EmulateMvnRdImm (ARMEncoding encoding); From johnny.chen at apple.com Mon Feb 14 16:25:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 22:25:44 -0000 Subject: [Lldb-commits] [lldb] r125527 - /lldb/trunk/utils/emacs/README Message-ID: <20110214222544.4B97B2A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 16:25:44 2011 New Revision: 125527 URL: http://llvm.org/viewvc/llvm-project?rev=125527&view=rev Log: Updated README file. Modified: lldb/trunk/utils/emacs/README Modified: lldb/trunk/utils/emacs/README URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/emacs/README?rev=125527&r1=125526&r2=125527&view=diff ============================================================================== --- lldb/trunk/utils/emacs/README (original) +++ lldb/trunk/utils/emacs/README Mon Feb 14 16:25:44 2011 @@ -1,8 +1,6 @@ The lldb-enhanced gud.el is based on the emacs 22.3.1 version from Aquamacs 1.8c distribution. -The gud-diffs.txt is the diff from the gud.el file from emacs 22.3.1. - To use it, load the file from within emacs and type 'M-x lldb' to invoke lldb. The lldb-gud-window.png is a screen capture of the gud (with lldb) at work on From ctice at apple.com Mon Feb 14 17:03:21 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 14 Feb 2011 23:03:21 -0000 Subject: [Lldb-commits] [lldb] r125528 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110214230321.8CDF32A6C12C@llvm.org> Author: ctice Date: Mon Feb 14 17:03:21 2011 New Revision: 125528 URL: http://llvm.org/viewvc/llvm-project?rev=125528&view=rev Log: - Rearrange instruction emulation contexts to use a union for the various types and numbers of arguments rather than trying to keep a constant number of arguments for all the types. - Also create a Register type within the instructions, to hold register type and number. - Modify EmulateInstructionArm.cpp to use the new register and context types in all the instruction emulation functions. - Add code to emulate the STM Arm instruction. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125528&r1=125527&r2=125528&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Mon Feb 14 17:03:21 2011 @@ -165,12 +165,183 @@ eContextWriteMemoryRandomBits }; + enum InfoType { + eInfoTypeRegisterPlusOffset, + eInfoTypeRegisterPlusIndirectOffset, + eInfoTypeRegisterToRegisterPlusOffset, + eInfoTypeOffset, + eInfoTypeRegister, + eInfoTypeImmediate, + eInfoTypeImmediateSigned, + eInfoTypeAddress, + eInfoTypeModeAndImmediate, + eInfoTypeModeAndImmediateSigned, + eInfoTypeModeAndRegister, + eInfoTypeNoArgs + } InfoType; + + struct Register + { + uint32_t kind; + uint32_t num; + + + void + SetRegister (uint32_t reg_kind, uint32_t reg_num) + { + kind = reg_kind; + num = reg_num; + } + }; + struct Context { ContextType type; - lldb::addr_t arg0; // Register kind. - lldb::addr_t arg1; // Register spec. - int64_t arg2; // Possible negative value. + enum InfoType info_type; + union + { + struct RegisterPlusOffset + { + Register reg; // base register + int64_t signed_offset; // signed offset added to base register + } RegisterPlusOffset; + + struct RegisterPlusIndirectOffset + { + Register base_reg; // base register number + Register offset_reg; // offset register kind + } RegisterPlusIndirectOffset; + + struct RegisterToRegisterPlusOffset + { + Register data_reg; // source/target register for data + Register base_reg; // base register for address calculation + int64_t offset; // offset for address calculation + } RegisterToRegisterPlusOffset; + + int64_t signed_offset; // signed offset by which to adjust self (for registers only) + + Register reg; // plain register + + uint64_t immediate; // immediate value + + int64_t signed_immediate; // signed immediate value + + lldb::addr_t address; // direct address + + struct ModeAndImmediate + { + uint32_t mode; // eModeARM or eModeThumb + uint32_t data_value; //immdiate data + } ModeAndImmediate; + + struct ModeAndImmediateSigned + { + uint32_t mode; // eModeARM or eModeThumb + int32_t signed_data_value; // signed immdiate data + } ModeAndImmediateSigned; + + struct ModeAndRegister + { + uint32_t mode; // eModeARM or eModeThumb + Register reg; + } ModeAndRegister; + + } info; + + void + SetRegisterPlusOffset (Register base_reg, + int64_t signed_offset) + { + info_type = eInfoTypeRegisterPlusOffset; + info.RegisterPlusOffset.reg = base_reg; + info.RegisterPlusOffset.signed_offset = signed_offset; + } + + void + SetRegisterPlusIndirectOffset (Register base_reg, + Register offset_reg) + { + info_type = eInfoTypeRegisterPlusIndirectOffset; + info.RegisterPlusIndirectOffset.base_reg = base_reg; + info.RegisterPlusIndirectOffset.offset_reg = offset_reg; + } + + void + SetRegisterToRegisterPlusOffset (Register data_reg, + Register base_reg, + int64_t offset) + { + info_type = eInfoTypeRegisterToRegisterPlusOffset; + info.RegisterToRegisterPlusOffset.data_reg = data_reg; + info.RegisterToRegisterPlusOffset.base_reg = base_reg; + info.RegisterToRegisterPlusOffset.offset = offset; + } + + void + SetOffset (int64_t signed_offset) + { + info_type = eInfoTypeOffset; + info.signed_offset = signed_offset; + } + + void + SetRegister (Register reg) + { + info_type = eInfoTypeRegister; + info.reg = reg; + } + + void + SetImmediate (uint64_t immediate) + { + info_type = eInfoTypeImmediate; + info.immediate = immediate; + } + + void + SetImmediateSigned (int64_t signed_immediate) + { + info_type = eInfoTypeImmediateSigned; + info.signed_immediate = signed_immediate; + } + + void + SetAddress (lldb::addr_t address) + { + info_type = eInfoTypeAddress; + info.address = address; + } + void + SetModeAndImmediate (uint32_t mode, uint32_t data_value) + { + info_type = eInfoTypeModeAndImmediate; + info.ModeAndImmediate.mode = mode; + info.ModeAndImmediate.data_value = data_value; + } + + void + SetModeAndImmediateSigned (uint32_t mode, int32_t signed_data_value) + { + info_type = eInfoTypeModeAndImmediateSigned; + info.ModeAndImmediateSigned.mode = mode; + info.ModeAndImmediateSigned.signed_data_value = signed_data_value; + } + + void + SetModeAndRegister (uint32_t mode, Register reg) + { + info_type = eInfoTypeModeAndRegister; + info.ModeAndRegister.mode = mode; + info.ModeAndRegister.reg = reg; + } + + void + SetNoArgs () + { + info_type = eInfoTypeNoArgs; + } + }; union Opcode Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125528&r1=125527&r2=125528&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 17:03:21 2011 @@ -147,10 +147,9 @@ bool EmulateInstructionARM::WriteBits32UnknownToMemory (addr_t address) { - EmulateInstruction::Context context = { EmulateInstruction::eContextWriteMemoryRandomBits, - address, - 0, - 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextWriteMemoryRandomBits; + context.SetNoArgs (); uint32_t random_data = rand (); const uint32_t addr_byte_size = GetAddressByteSize(); @@ -165,10 +164,9 @@ bool EmulateInstructionARM::WriteBits32Unknown (int n) { - EmulateInstruction::Context context = { EmulateInstruction::eContextWriteRegisterRandomBits, - eRegisterKindDWARF, - dwarf_r0 + n, - 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextWriteRegisterRandomBits; + context.SetNoArgs (); bool success; uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); @@ -272,14 +270,17 @@ addr_t addr = sp - sp_offset; uint32_t i; - EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextPushRegisterOnStack; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, 0); for (i=0; i<15; ++i) { if (BitIsSet (registers, i)) { - context.arg1 = dwarf_r0 + i; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset - uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, context.arg1, 0, &success); + dwarf_reg.num = dwarf_r0 + i; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); + uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_reg.num, 0, &success); if (!success) return false; if (!WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size)) @@ -290,8 +291,8 @@ if (BitIsSet (registers, 15)) { - context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset + dwarf_reg.num = dwarf_pc; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; @@ -300,9 +301,7 @@ } context.type = EmulateInstruction::eContextAdjustStackPointer; - context.arg0 = eRegisterKindGeneric; - context.arg1 = LLDB_REGNUM_GENERIC_SP; - context.arg2 = -sp_offset; + context.SetImmediateSigned (-sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp - sp_offset)) return false; @@ -401,17 +400,20 @@ addr_t addr = sp; uint32_t i, data; - EmulateInstruction::Context context = { EmulateInstruction::eContextPopRegisterOffStack, eRegisterKindDWARF, 0, 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextPopRegisterOffStack; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, 0); for (i=0; i<15; ++i) { if (BitIsSet (registers, i)) { - context.arg1 = dwarf_r0 + i; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset + dwarf_reg.num = dwarf_r0 + i; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); data = ReadMemoryUnsigned(context, addr, 4, 0, &success); if (!success) return false; - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, context.arg1, data)) + if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_reg.num, data)) return false; addr += addr_byte_size; } @@ -419,21 +421,19 @@ if (BitIsSet (registers, 15)) { - context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset + dwarf_reg.num = dwarf_pc; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); data = ReadMemoryUnsigned(context, addr, 4, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dwarf_reg)) return false; addr += addr_byte_size; } context.type = EmulateInstruction::eContextAdjustStackPointer; - context.arg0 = eRegisterKindGeneric; - context.arg1 = LLDB_REGNUM_GENERIC_SP; - context.arg2 = sp_offset; + context.SetImmediateSigned (sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp + sp_offset)) return false; @@ -491,10 +491,11 @@ addr_t sp_offset = imm32; addr_t addr = sp + sp_offset; // a pointer to the stack area - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - sp_offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register sp_reg; + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + context.SetRegisterPlusOffset (sp_reg, sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, addr)) return false; @@ -546,10 +547,12 @@ default: return false; } - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - 0 }; + + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register sp_reg; + sp_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + context.SetRegisterPlusOffset (sp_reg, 0); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, sp)) return false; @@ -617,14 +620,15 @@ return false; // The context specifies that Rm is to be moved into Rd. - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + Rm, - 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + context.SetRegisterPlusOffset (dwarf_reg, 0); if (Rd == 15) { - if (!ALUWritePC (context, reg_value)) + if (!ALUWritePC (context, reg_value, dwarf_reg)) return false; } else @@ -701,14 +705,16 @@ uint32_t result = imm32; // The context specifies that an immediate is to be moved into Rd. - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, - 0, - 0, - 0 }; - + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + + Register dummy_reg; + dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); + if (Rd == 15) { - if (!ALUWritePC (context, result)) + if (!ALUWritePC (context, result, dummy_reg)) return false; } else @@ -787,14 +793,14 @@ uint32_t result = ~imm32; // The context specifies that an immediate is to be moved into Rd. - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, - 0, - 0, - 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); if (Rd == 15) { - if (!ALUWritePC (context, result)) + Register dummy_reg; + if (!ALUWritePC (context, result, dummy_reg)) return false; } else @@ -855,10 +861,12 @@ return false; // PC relative immediate load context - EmulateInstruction::Context context = {EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_PC, - 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register pc_reg; + pc_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); + context.SetRegisterPlusOffset (pc_reg, 0); + uint32_t Rt; // the destination register uint32_t imm32; // immediate offset from the PC bool add; // +imm32 or -imm32? @@ -871,7 +879,7 @@ imm32 = Bits32(opcode, 7, 0) << 2; // imm32 = ZeroExtend(imm8:'00', 32); add = true; base = Align(pc + 4, 4); - context.arg2 = 4 + imm32; + context.SetRegisterPlusOffset (pc_reg, 4 + imm32); break; case eEncodingT2: Rt = Bits32(opcode, 15, 12); @@ -880,7 +888,7 @@ if (Rt == 15 && InITBlock() && !LastInITBlock()) return false; base = Align(pc + 4, 4); - context.arg2 = 4 + imm32; + context.SetRegisterPlusOffset (pc_reg, 4 + imm32); break; default: return false; @@ -899,7 +907,7 @@ if (Bits32(address, 1, 0) == 0) { // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, pc_reg)) return false; } else @@ -963,10 +971,9 @@ addr_t sp_offset = imm32; addr_t addr = sp + sp_offset; // the adjusted stack pointer value - EmulateInstruction::Context context = { EmulateInstruction::eContextAdjustStackPointer, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - sp_offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextAdjustStackPointer; + context.SetImmediateSigned (sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr)) return false; @@ -1022,10 +1029,9 @@ addr_t addr = (int32_t)sp + reg_value; // the adjusted stack pointer value - EmulateInstruction::Context context = { EmulateInstruction::eContextAdjustStackPointer, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - reg_value }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextAdjustStackPointer; + context.SetImmediateSigned (reg_value); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr)) return false; @@ -1065,7 +1071,8 @@ if (ConditionPassed()) { - EmulateInstruction::Context context = { EmulateInstruction::eContextRelativeBranchImmediate, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRelativeBranchImmediate; const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; @@ -1086,8 +1093,7 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<25>(imm25); target = pc + 4 + imm32; - context.arg1 = 4 + imm32; // signed offset - context.arg2 = eModeThumb; // target instruction set + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); if (InITBlock() && !LastInITBlock()) return false; break; @@ -1105,8 +1111,7 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10H << 12) | (imm10L << 2); imm32 = llvm::SignExtend32<25>(imm25); target = Align(pc + 4, 4) + imm32; - context.arg1 = 4 + imm32; // signed offset - context.arg2 = eModeARM; // target instruction set + context.SetModeAndImmediateSigned (eModeARM, 4 + imm32); if (InITBlock() && !LastInITBlock()) return false; break; @@ -1115,15 +1120,13 @@ lr = pc + 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); target = Align(pc + 8, 4) + imm32; - context.arg1 = 8 + imm32; // signed offset - context.arg2 = eModeARM; // target instruction set + context.SetModeAndImmediateSigned (eModeARM, 8 + imm32); break; case eEncodingA2: lr = pc + 4; // return address imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2 | Bits32(opcode, 24, 24) << 1); target = pc + 8 + imm32; - context.arg1 = 8 + imm32; // signed offset - context.arg2 = eModeThumb; // target instruction set + context.SetModeAndImmediateSigned (eModeThumb, 8 + imm32); break; default: return false; @@ -1165,7 +1168,8 @@ if (ConditionPassed()) { - EmulateInstruction::Context context = { EmulateInstruction::eContextAbsoluteBranchRegister, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextAbsoluteBranchRegister; const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); addr_t lr; // next instruction address if (!success) @@ -1194,11 +1198,12 @@ addr_t target = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); if (!success) return false; - context.arg0 = eRegisterKindDWARF; - context.arg1 = dwarf_r0 + Rm; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + context.SetRegister (dwarf_reg); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, lr)) return false; - if (!BXWritePC(context, target)) + if (!BXWritePC(context, target, dwarf_reg)) return false; } return true; @@ -1225,7 +1230,8 @@ if (ConditionPassed()) { - EmulateInstruction::Context context = { EmulateInstruction::eContextAbsoluteBranchRegister, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextAbsoluteBranchRegister; uint32_t Rm; // the register with the target address switch (encoding) { case eEncodingT1: @@ -1242,9 +1248,10 @@ addr_t target = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); if (!success) return false; - context.arg0 = eRegisterKindDWARF; - context.arg1 = dwarf_r0 + Rm; - if (!BXWritePC(context, target)) + + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); + if (!BXWritePC(context, target, dwarf_reg)) return false; } return true; @@ -1294,10 +1301,11 @@ addr_t ip_offset = imm32; addr_t addr = ip - ip_offset; // the adjusted ip value - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r12, - -ip_offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r12); + context.SetRegisterPlusOffset (dwarf_reg, -ip_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r7, addr)) return false; @@ -1349,10 +1357,11 @@ addr_t sp_offset = imm32; addr_t addr = sp - sp_offset; // the adjusted stack pointer value - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - -sp_offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); + context.SetRegisterPlusOffset (dwarf_reg, -sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r12, addr)) return false; @@ -1411,10 +1420,9 @@ addr_t sp_offset = imm32; addr_t addr = sp - sp_offset; // the adjusted stack pointer value - EmulateInstruction::Context context = { EmulateInstruction::eContextAdjustStackPointer, - eRegisterKindGeneric, - LLDB_REGNUM_GENERIC_SP, - -sp_offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextAdjustStackPointer; + context.SetImmediateSigned (-sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr)) return false; @@ -1462,12 +1470,15 @@ addr_t sp_offset = imm12; addr_t addr = sp - sp_offset; - EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextPushRegisterOnStack; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, 0); if (Rt != 15) { - context.arg1 = dwarf_r0 + Rt; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset - uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, context.arg1, 0, &success); + dwarf_reg.num = dwarf_r0 + Rt; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); + uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_reg.num, 0, &success); if (!success) return false; if (!WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size)) @@ -1475,8 +1486,8 @@ } else { - context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number - context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset + dwarf_reg.num = dwarf_pc; + context.SetRegisterPlusOffset (dwarf_reg, addr - sp); const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; @@ -1485,9 +1496,7 @@ } context.type = EmulateInstruction::eContextAdjustStackPointer; - context.arg0 = eRegisterKindGeneric; - context.arg1 = LLDB_REGNUM_GENERIC_SP; - context.arg2 = -sp_offset; + context.SetImmediateSigned (-sp_offset); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp - sp_offset)) return false; @@ -1565,13 +1574,16 @@ addr_t addr = sp - sp_offset; uint32_t i; - EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextPushRegisterOnStack; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, 0); for (i=d; i(Bits32(opcode, 7, 0) << 1); target = pc + 4 + imm32; - context.arg1 = 4 + imm32; // signed offset - context.arg2 = eModeThumb; // target instruction set + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); break; case eEncodingT2: imm32 = llvm::SignExtend32<12>(Bits32(opcode, 10, 0)); target = pc + 4 + imm32; - context.arg1 = 4 + imm32; // signed offset - context.arg2 = eModeThumb; // target instruction set + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); break; case eEncodingT3: // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). @@ -1801,8 +1814,7 @@ uint32_t imm21 = (S << 20) | (J2 << 19) | (J1 << 18) | (imm6 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<21>(imm21); target = pc + 4 + imm32; - context.arg1 = eModeThumb; // target instruction set - context.arg2 = 4 + imm32; // signed offset + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); break; } case eEncodingT4: @@ -1817,15 +1829,13 @@ uint32_t imm25 = (S << 24) | (I1 << 23) | (I2 << 22) | (imm10 << 12) | (imm11 << 1); imm32 = llvm::SignExtend32<25>(imm25); target = pc + 4 + imm32; - context.arg1 = eModeThumb; // target instruction set - context.arg2 = 4 + imm32; // signed offset + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); break; } case eEncodingA1: imm32 = llvm::SignExtend32<26>(Bits32(opcode, 23, 0) << 2); target = pc + 8 + imm32; - context.arg1 = eModeARM; // target instruction set - context.arg2 = 8 + imm32; // signed offset + context.SetModeAndImmediateSigned (eModeARM, 8 + imm32); break; default: return false; @@ -1859,7 +1869,8 @@ if (!success) return false; - EmulateInstruction::Context context = { EmulateInstruction::eContextRelativeBranchImmediate, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRelativeBranchImmediate; const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; @@ -1872,8 +1883,7 @@ imm32 = Bit32(opcode, 9) << 6 | Bits32(opcode, 7, 3) << 1; nonzero = BitIsSet(opcode, 11); target = pc + 4 + imm32; - context.arg1 = 4 + imm32; // signed offset - context.arg2 = eModeThumb; // target instruction set + context.SetModeAndImmediateSigned (eModeThumb, 4 + imm32); break; default: return false; @@ -1948,14 +1958,16 @@ return false; result = val1 + val2; - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, - 0, - 0, - 0 }; + + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + Register dummy_reg; + dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); if (Rd == 15) { - if (!ALUWritePC (context, result)) + if (!ALUWritePC (context, result, dummy_reg)) return false; } else @@ -2002,6 +2014,10 @@ if (!success) return false; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + AddWithCarryResult res = AddWithCarry(reg_val, ~imm32, 1); m_new_inst_cpsr = m_inst_cpsr; SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(res.result, CPSR_N)); @@ -2010,7 +2026,9 @@ SetBit32(m_new_inst_cpsr, CPSR_V, res.overflow); if (m_new_inst_cpsr != m_inst_cpsr) { - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) return false; } @@ -2066,6 +2084,10 @@ if (!success) return false; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs(); + AddWithCarryResult res = AddWithCarry(reg_val1, reg_val2, 1); m_new_inst_cpsr = m_inst_cpsr; SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(res.result, CPSR_N)); @@ -2074,7 +2096,9 @@ SetBit32(m_new_inst_cpsr, CPSR_V, res.overflow); if (m_new_inst_cpsr != m_inst_cpsr) { - EmulateInstruction::Context context = { EmulateInstruction::eContextImmediate, 0, 0, 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) return false; } @@ -2156,17 +2180,18 @@ if (!success) return false; - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + n, - offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + context.SetRegisterPlusOffset (dwarf_reg, offset); for (int i = 0; i < 14; ++i) { if (BitIsSet (registers, i)) { context.type = EmulateInstruction::eContextRegisterPlusOffset; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); if (wback && (n == 13)) // Pop Instruction context.type = EmulateInstruction::eContextPopRegisterOffStack; @@ -2186,12 +2211,12 @@ { //LoadWritePC (MemA [address, 4]); context.type = EmulateInstruction::eContextRegisterPlusOffset; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, base_address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dwarf_reg)) return false; } @@ -2200,7 +2225,7 @@ // R[n] = R[n] + 4 * BitCount (registers) int32_t offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, base_address + offset)) return false; @@ -2275,10 +2300,11 @@ address = address - (addr_byte_size * BitCount (registers)) + addr_byte_size; - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + n, - offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + context.SetRegisterPlusOffset (dwarf_reg, offset); // for i = 0 to 14 for (int i = 0; i < 14; ++i) @@ -2287,7 +2313,7 @@ if (BitIsSet (registers, i)) { // R[i] = MemA[address,4]; address = address + 4; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2301,12 +2327,12 @@ // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dwarf_reg)) return false; } @@ -2319,7 +2345,7 @@ offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; - context.arg2 = offset; + context.SetImmediateSigned (offset); addr = addr + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; @@ -2414,17 +2440,18 @@ return false; address = address - (addr_byte_size * BitCount (registers)); - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + n, - offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + context.SetRegisterPlusOffset (dwarf_reg, offset); for (int i = 0; i < 14; ++i) { if (BitIsSet (registers, i)) { // R[i] = MemA[address,4]; address = address + 4; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2440,12 +2467,12 @@ // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dwarf_reg)) return false; } @@ -2458,7 +2485,7 @@ offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; - context.arg2 = offset; + context.SetImmediateSigned (offset); addr = addr + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; @@ -2529,10 +2556,11 @@ address = address + addr_byte_size; - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + n, - offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + context.SetRegisterPlusOffset (dwarf_reg, offset); for (int i = 0; i < 14; ++i) { @@ -2540,7 +2568,7 @@ { // R[i] = MemA[address,4]; address = address + 4; - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2556,12 +2584,12 @@ // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { - context.arg2 = offset; + context.SetRegisterPlusOffset (dwarf_reg, offset); uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dwarf_reg)) return false; } @@ -2574,7 +2602,7 @@ offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; - context.arg2 = offset; + context.SetImmediateSigned (offset); addr = addr + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; @@ -2649,19 +2677,22 @@ if (wback) { - EmulateInstruction::Context ctx = { EmulateInstruction::eContextRegisterPlusOffset, - eRegisterKindDWARF, - dwarf_r0 + Rn, - (int32_t) (offset_addr - base)}; + EmulateInstruction::Context ctx; + ctx.type = EmulateInstruction::eContextRegisterPlusOffset; + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rn); + ctx.SetRegisterPlusOffset (dwarf_reg, (int32_t) (offset_addr - base)); + if (!WriteRegisterUnsigned (ctx, eRegisterKindDWARF, dwarf_r0 + Rn, offset_addr)) return false; } // Prepare to write to the Rt register. - EmulateInstruction::Context context = {EmulateInstruction::eContextImmediate, - 0, - 0, - 0}; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + Register dummy_reg; + dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); // Read memory from the address. data = ReadMemoryUnsigned(context, address, 4, 0, &success); @@ -2672,7 +2703,7 @@ { if (Bits32(address, 1, 0) == 0) { - if (!LoadWritePC(context, data)) + if (!LoadWritePC(context, data, dummy_reg)) return false; } else @@ -2778,10 +2809,10 @@ if (!success) return false; - EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterStore, - eRegisterKindDWARF, - dwarf_r0 + n, - offset }; + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterStore; + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); // for i = 0 to 14 for (int i = 0; i < 14; ++i) @@ -2803,8 +2834,9 @@ if (!success) return false; - context.arg1 = dwarf_r0 + i; - context.arg2 = address + offset; + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) return false; } @@ -2821,9 +2853,10 @@ const addr_t sp = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success); if (!success) return false; - - context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number - context.arg2 = address + offset - sp; // arg2 in the context is the stack pointer offset + + Register pc_reg; + pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + context.SetRegisterPlusOffset (pc_reg, 8); const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; @@ -2837,8 +2870,7 @@ { offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; - context.arg1 = dwarf_r0 + n; - context.arg2 = offset; + context.SetImmediateSigned (offset); addr_t data = address + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) return false; @@ -3107,7 +3139,10 @@ addr_t pc = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success); if (success) { - Context read_inst_context = {eContextReadOpcode, 0, 0}; + Context read_inst_context; + read_inst_context.type = eContextReadOpcode; + read_inst_context.SetNoArgs (); + if (m_inst_cpsr & MASK_CPSR_T) { m_inst_mode = eModeThumb; @@ -3258,7 +3293,7 @@ // As a side effect, BXWritePC sets context.arg2 to eModeARM or eModeThumb by inspecting addr. bool -EmulateInstructionARM::BXWritePC (Context &context, uint32_t addr) +EmulateInstructionARM::BXWritePC (Context &context, uint32_t addr, Register ®) { addr_t target; // If the CPSR is changed due to switching between ARM and Thumb ISETSTATE, @@ -3274,7 +3309,7 @@ cpsr_changed = true; } target = addr & 0xfffffffe; - context.arg2 = eModeThumb; + context.SetModeAndRegister (eModeThumb, reg); } else if (BitIsClear(addr, 1)) { @@ -3284,7 +3319,7 @@ cpsr_changed = true; } target = addr & 0xfffffffc; - context.arg2 = eModeARM; + context.SetModeAndRegister (eModeARM, reg); } else return false; // address<1:0> == '10' => UNPREDICTABLE @@ -3302,20 +3337,20 @@ // Dispatches to either BXWritePC or BranchWritePC based on architecture versions. bool -EmulateInstructionARM::LoadWritePC (Context &context, uint32_t addr) +EmulateInstructionARM::LoadWritePC (Context &context, uint32_t addr, Register ®) { if (ArchVersion() >= ARMv5T) - return BXWritePC(context, addr); + return BXWritePC(context, addr, reg); else return BranchWritePC((const Context)context, addr); } // Dispatches to either BXWritePC or BranchWritePC based on architecture versions and current instruction set. bool -EmulateInstructionARM::ALUWritePC (Context &context, uint32_t addr) +EmulateInstructionARM::ALUWritePC (Context &context, uint32_t addr, Register ®) { if (ArchVersion() >= ARMv7 && CurrentInstrSet() == eModeARM) - return BXWritePC(context, addr); + return BXWritePC(context, addr, reg); else return BranchWritePC((const Context)context, addr); } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125528&r1=125527&r2=125528&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Feb 14 17:03:21 2011 @@ -158,13 +158,13 @@ BranchWritePC(const Context &context, uint32_t addr); bool - BXWritePC(Context &context, uint32_t addr); + BXWritePC(Context &context, uint32_t addr, Register ®); bool - LoadWritePC(Context &context, uint32_t addr); + LoadWritePC(Context &context, uint32_t addr, Register ®); bool - ALUWritePC(Context &context, uint32_t addr); + ALUWritePC(Context &context, uint32_t addr, Register ®); Mode CurrentInstrSet(); From johnny.chen at apple.com Mon Feb 14 17:21:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 23:21:24 -0000 Subject: [Lldb-commits] [lldb] r125531 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110214232124.7569D2A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 17:21:24 2011 New Revision: 125531 URL: http://llvm.org/viewvc/llvm-project?rev=125531&view=rev Log: Fix build warning (unused variable). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125531&r1=125530&r2=125531&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 17:21:24 2011 @@ -2850,10 +2850,6 @@ // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { - const addr_t sp = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success); - if (!success) - return false; - Register pc_reg; pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); context.SetRegisterPlusOffset (pc_reg, 8); From johnny.chen at apple.com Mon Feb 14 17:33:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Feb 2011 23:33:58 -0000 Subject: [Lldb-commits] [lldb] r125533 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110214233358.E1BDC2A6C12C@llvm.org> Author: johnny Date: Mon Feb 14 17:33:58 2011 New Revision: 125533 URL: http://llvm.org/viewvc/llvm-project?rev=125533&view=rev Log: Add missing logic (if BadReg(d) then UNPREDICTABLE;) for Encoding T2 of EmulateMovRdImm(). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125533&r1=125532&r2=125533&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 17:33:58 2011 @@ -698,6 +698,8 @@ setflags = BitIsSet(opcode, 20); imm12 = Bit32(opcode, 26) << 11 | Bits32(opcode, 14, 12) << 8 | Bits32(opcode, 7, 0); imm32 = ThumbExpandImm_C(imm12, Bit32(m_inst_cpsr, CPSR_C), carry); + if (BadReg(Rd)) + return false; break; default: return false; From gclayton at apple.com Mon Feb 14 18:19:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Feb 2011 00:19:15 -0000 Subject: [Lldb-commits] [lldb] r125541 - in /lldb/trunk: include/lldb/ include/lldb/Symbol/ include/lldb/Utility/ source/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Utility/ Message-ID: <20110215001915.CBDCD2A6C12C@llvm.org> Author: gclayton Date: Mon Feb 14 18:19:15 2011 New Revision: 125541 URL: http://llvm.org/viewvc/llvm-project?rev=125541&view=rev Log: All UnwindPlan objects are now passed around as shared pointers. ArchDefaultUnwindPlan plug-in interfaces are now cached per architecture instead of being leaked for every frame. Split the ArchDefaultUnwindPlan_x86 into ArchDefaultUnwindPlan_x86_64 and ArchDefaultUnwindPlan_i386 interfaces. There were sporadic crashes that were due to something leaking or being destroyed when doing stack crawls. This patch should clear up these issues. Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Symbol/FuncUnwinders.cpp lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original) +++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Mon Feb 14 18:19:15 2011 @@ -43,16 +43,16 @@ // On architectures where the pc points to the next instruction that will execute, this // offset value will have already been decremented by 1 to stay within the bounds of the // correct function body. - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanAtCallSite (int current_offset); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanFastUnwind (lldb_private::Thread& Thread); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread); Address& @@ -74,10 +74,10 @@ AddressRange m_range; Mutex m_mutex; - std::auto_ptr m_unwind_at_call_site_ap; - std::auto_ptr m_unwind_at_non_call_site_ap; - std::auto_ptr m_unwind_fast_ap; - UnwindPlan *m_unwind_arch_default; + lldb::UnwindPlanSP m_unwind_plan_call_site_sp; + lldb::UnwindPlanSP m_unwind_plan_non_call_site_sp; + lldb::UnwindPlanSP m_unwind_plan_fast_sp; + lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; bool m_tried_unwind_at_call_site:1, m_tried_unwind_at_non_call_site:1, Modified: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h Mon Feb 14 18:19:15 2011 @@ -23,10 +23,10 @@ virtual ~ArchDefaultUnwindPlan(); - virtual lldb_private::UnwindPlan* + virtual lldb::UnwindPlanSP GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) = 0; - static ArchDefaultUnwindPlan* + static lldb::ArchDefaultUnwindPlanSP FindPlugin (const ArchSpec &arch); protected: Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Mon Feb 14 18:19:15 2011 @@ -21,6 +21,7 @@ typedef SharedPtr::Type ABISP; typedef SharedPtr::Type AddressResolverSP; + typedef SharedPtr::Type ArchDefaultUnwindPlanSP; typedef SharedPtr::Type BatonSP; typedef SharedPtr::Type BlockSP; typedef SharedPtr::Type BreakpointSP; @@ -66,6 +67,7 @@ typedef SharedPtr::Type TypeSP; typedef SharedPtr::Type FuncUnwindersSP; typedef SharedPtr::Type UserSettingsControllerSP; + typedef SharedPtr::Type UnwindPlanSP; typedef SharedPtr::Type ValueObjectSP; typedef SharedPtr::Type VariableSP; typedef SharedPtr::Type VariableListSP; Modified: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp Mon Feb 14 18:19:15 2011 @@ -8,115 +8,182 @@ //===----------------------------------------------------------------------===// #include "ArchDefaultUnwindPlan-x86.h" -#include "llvm/Support/MachO.h" -#include "lldb/lldb-private.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/lldb-enumerations.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; -lldb_private::UnwindPlan* -ArchDefaultUnwindPlan_x86::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - if (m_cpu == llvm::MachO::CPUTypeX86_64) - { - return &m_64bit_default; - } - if (m_cpu == llvm::MachO::CPUTypeI386) - { - return &m_32bit_default; - } - return NULL; -} - lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_x86::CreateInstance (const lldb_private::ArchSpec &arch) +ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch) { - uint32_t cpu = arch.GetCPUType (); - if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386) - return NULL; - - return new ArchDefaultUnwindPlan_x86 (cpu); + if (arch.GetGenericCPUType () == ArchSpec::eCPU_x86_64) + return new ArchDefaultUnwindPlan_x86_64 (); + return NULL; } -ArchDefaultUnwindPlan_x86::ArchDefaultUnwindPlan_x86(int cpu) : +ArchDefaultUnwindPlan_x86_64::ArchDefaultUnwindPlan_x86_64() : lldb_private::ArchDefaultUnwindPlan(), - m_cpu(cpu), - m_32bit_default(), - m_64bit_default() + m_unwind_plan_sp (new UnwindPlan) { UnwindPlan::Row row; UnwindPlan::Row::RegisterLocation regloc; - m_32bit_default.SetRegisterKind (eRegisterKindGeneric); + m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 4); + row.SetCFAOffset (2 * 8); row.SetOffset (0); - regloc.SetAtCFAPlusOffset (2 * -4); + regloc.SetAtCFAPlusOffset (2 * -8); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -4); + regloc.SetAtCFAPlusOffset (1 * -8); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); regloc.SetIsCFAPlusOffset (0); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - m_32bit_default.AppendRow (row); - m_32bit_default.SetSourceName ("architectural default"); + m_unwind_plan_sp->AppendRow (row); + m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); +} + +//------------------------------------------------------------------ +// PluginInterface protocol in UnwindAssemblyParser_x86 +//------------------------------------------------------------------ - row.Clear(); +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginName() +{ + return "ArchDefaultUnwindPlan_x86_64"; +} - m_64bit_default.SetRegisterKind (eRegisterKindGeneric); +const char * +ArchDefaultUnwindPlan_x86_64::GetShortPluginName() +{ + return "lldb.arch-default-unwind-plan.x86-64"; +} + + +uint32_t +ArchDefaultUnwindPlan_x86_64::GetPluginVersion() +{ + return 1; +} + +void +ArchDefaultUnwindPlan_x86_64::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +ArchDefaultUnwindPlan_x86_64::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +ArchDefaultUnwindPlan_x86_64::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +void +ArchDefaultUnwindPlan_x86_64::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +ArchDefaultUnwindPlan_x86_64::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginNameStatic() +{ + return "ArchDefaultUnwindPlan_x86_64"; +} + +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginDescriptionStatic() +{ + return "x86_64 architecture default unwind plan assembly plugin."; +} + +UnwindPlanSP +ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) +{ + return m_unwind_plan_sp; +} + + + +lldb_private::ArchDefaultUnwindPlan * +ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch) +{ + if (arch.GetGenericCPUType () == ArchSpec::eCPU_i386) + return new ArchDefaultUnwindPlan_i386 (); + return NULL; +} + +ArchDefaultUnwindPlan_i386::ArchDefaultUnwindPlan_i386() : + lldb_private::ArchDefaultUnwindPlan(), + m_unwind_plan_sp (new UnwindPlan) +{ + UnwindPlan::Row row; + UnwindPlan::Row::RegisterLocation regloc; + + m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 8); + row.SetCFAOffset (2 * 4); row.SetOffset (0); - regloc.SetAtCFAPlusOffset (2 * -8); + regloc.SetAtCFAPlusOffset (2 * -4); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -8); + regloc.SetAtCFAPlusOffset (1 * -4); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); regloc.SetIsCFAPlusOffset (0); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - m_64bit_default.AppendRow (row); - m_64bit_default.SetSourceName ("architectural default"); + m_unwind_plan_sp->AppendRow (row); + m_unwind_plan_sp->SetSourceName ("i386 architectural default"); } - - - //------------------------------------------------------------------ // PluginInterface protocol in UnwindAssemblyParser_x86 //------------------------------------------------------------------ const char * -ArchDefaultUnwindPlan_x86::GetPluginName() +ArchDefaultUnwindPlan_i386::GetPluginName() { - return "ArchDefaultUnwindPlan_x86"; + return "ArchDefaultUnwindPlan_i386"; } const char * -ArchDefaultUnwindPlan_x86::GetShortPluginName() +ArchDefaultUnwindPlan_i386::GetShortPluginName() { return "archdefaultunwindplan.x86"; } uint32_t -ArchDefaultUnwindPlan_x86::GetPluginVersion() +ArchDefaultUnwindPlan_i386::GetPluginVersion() { return 1; } void -ArchDefaultUnwindPlan_x86::GetPluginCommandHelp (const char *command, Stream *strm) +ArchDefaultUnwindPlan_i386::GetPluginCommandHelp (const char *command, Stream *strm) { } Error -ArchDefaultUnwindPlan_x86::ExecutePluginCommand (Args &command, Stream *strm) +ArchDefaultUnwindPlan_i386::ExecutePluginCommand (Args &command, Stream *strm) { Error error; error.SetErrorString("No plug-in command are currently supported."); @@ -124,13 +191,13 @@ } Log * -ArchDefaultUnwindPlan_x86::EnablePluginLogging (Stream *strm, Args &command) +ArchDefaultUnwindPlan_i386::EnablePluginLogging (Stream *strm, Args &command) { return NULL; } void -ArchDefaultUnwindPlan_x86::Initialize() +ArchDefaultUnwindPlan_i386::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), GetPluginDescriptionStatic(), @@ -138,20 +205,27 @@ } void -ArchDefaultUnwindPlan_x86::Terminate() +ArchDefaultUnwindPlan_i386::Terminate() { PluginManager::UnregisterPlugin (CreateInstance); } const char * -ArchDefaultUnwindPlan_x86::GetPluginNameStatic() +ArchDefaultUnwindPlan_i386::GetPluginNameStatic() { - return "ArchDefaultUnwindPlan_x86"; + return "ArchDefaultUnwindPlan_i386"; } const char * -ArchDefaultUnwindPlan_x86::GetPluginDescriptionStatic() +ArchDefaultUnwindPlan_i386::GetPluginDescriptionStatic() +{ + return "i386 architecture default unwind plan assembly plugin."; +} + +UnwindPlanSP +ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) { - return "i386 and x86_64 architecture default unwind plan assembly plugin."; + return m_unwind_plan_sp; } + Modified: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h Mon Feb 14 18:19:15 2011 @@ -17,13 +17,13 @@ namespace lldb_private { -class ArchDefaultUnwindPlan_x86 : public lldb_private::ArchDefaultUnwindPlan +class ArchDefaultUnwindPlan_x86_64 : public lldb_private::ArchDefaultUnwindPlan { public: - ~ArchDefaultUnwindPlan_x86 () { } + ~ArchDefaultUnwindPlan_x86_64 () { } - virtual lldb_private::UnwindPlan* + virtual lldb::UnwindPlanSP GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); static lldb_private::ArchDefaultUnwindPlan * @@ -63,11 +63,60 @@ EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); private: - ArchDefaultUnwindPlan_x86(int cpu); // Call CreateInstance instead. + ArchDefaultUnwindPlan_x86_64(); // Call CreateInstance instead. - int m_cpu; - lldb_private::UnwindPlan m_32bit_default; - lldb_private::UnwindPlan m_64bit_default; + lldb::UnwindPlanSP m_unwind_plan_sp; +}; + +class ArchDefaultUnwindPlan_i386 : public lldb_private::ArchDefaultUnwindPlan +{ +public: + + ~ArchDefaultUnwindPlan_i386 () { } + + virtual lldb::UnwindPlanSP + GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); + + static lldb_private::ArchDefaultUnwindPlan * + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + +private: + ArchDefaultUnwindPlan_i386(); // Call CreateInstance instead. + + lldb::UnwindPlanSP m_unwind_plan_sp; }; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Feb 14 18:19:15 2011 @@ -34,7 +34,7 @@ RegisterContextLLDB::RegisterContextLLDB ( Thread& thread, - const RegisterContextSP &next_frame, + const SharedPtr &next_frame, SymbolContext& sym_ctx, uint32_t frame_number ) : @@ -48,8 +48,8 @@ m_start_pc (), m_current_pc (), m_frame_number (frame_number), - m_full_unwind_plan(NULL), - m_fast_unwind_plan(NULL), + m_full_unwind_plan_sp (), + m_fast_unwind_plan_sp (), m_frame_type (-1), m_current_offset (0), m_current_offset_backed_up_one (0), @@ -68,20 +68,9 @@ } // This same code exists over in the GetFullUnwindPlanForFrame() but it may not have been executed yet - bool behaves_like_zeroth_frame = false; - if (IsFrameZero()) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero() && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eSigtrampFrame) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero() && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eDebuggerFrame) - { - behaves_like_zeroth_frame = true; - } - if (behaves_like_zeroth_frame) + if (IsFrameZero() + || m_next_frame->m_frame_type == eSigtrampFrame + || m_next_frame->m_frame_type == eDebuggerFrame) { m_all_registers_available = true; } @@ -124,6 +113,7 @@ if (addr_range.GetBaseAddress().IsValid()) { m_start_pc = addr_range.GetBaseAddress(); + assert (frame_sp->GetFrameCodeAddress().GetSection() == m_start_pc.GetSection()); m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset(); m_current_offset_backed_up_one = m_current_offset; } @@ -136,16 +126,16 @@ // We've set m_frame_type and m_sym_ctx before these calls. - m_fast_unwind_plan = GetFastUnwindPlanForFrame (); - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - + m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame (); + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + const UnwindPlan::Row *active_row = NULL; int cfa_offset = 0; int row_register_kind; - if (m_full_unwind_plan && m_full_unwind_plan->PlanValidAtAddress (m_current_pc)) + if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_full_unwind_plan->GetRegisterKind (); + active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); } if (active_row == NULL) @@ -189,7 +179,7 @@ m_frame_number, (uint64_t) m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()), (uint64_t) m_cfa, - m_full_unwind_plan->GetSourceName().GetCString()); + m_full_unwind_plan_sp->GetSourceName().GetCString()); } } @@ -205,7 +195,8 @@ m_frame_type = eNotAValidFrame; return; } - if (!((RegisterContextLLDB*)m_next_frame.get())->IsValid()) + + if (!m_next_frame->IsValid()) { m_frame_type = eNotAValidFrame; return; @@ -244,20 +235,20 @@ log->Printf("%*sFrame %u using architectural default unwind method", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); + if (arch_default_sp) { - m_fast_unwind_plan = NULL; - m_full_unwind_plan = arch_default->GetArchDefaultUnwindPlan (m_thread, m_current_pc); + m_fast_unwind_plan_sp.reset(); + m_full_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); m_frame_type = eNormalFrame; m_all_registers_available = false; m_current_offset = -1; m_current_offset_backed_up_one = -1; addr_t cfa_regval; - int row_register_kind = m_full_unwind_plan->GetRegisterKind (); - uint32_t cfa_regnum = m_full_unwind_plan->GetRowForFunctionOffset(0)->GetCFARegister(); - int cfa_offset = m_full_unwind_plan->GetRowForFunctionOffset(0)->GetCFAOffset(); + int row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); + uint32_t cfa_regnum = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFARegister(); + int cfa_offset = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFAOffset(); if (!ReadGPRValue (row_register_kind, cfa_regnum, cfa_regval)) { if (log) @@ -315,8 +306,8 @@ // Or if we're in the middle of the stack (and not "above" an asynchronous event like sigtramp), // and our "current" pc is the start of a function... if (m_sym_ctx_valid - && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eSigtrampFrame - && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eDebuggerFrame + && m_next_frame->m_frame_type != eSigtrampFrame + && m_next_frame->m_frame_type != eDebuggerFrame && addr_range.GetBaseAddress().IsValid() && addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection() && addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset()) @@ -374,7 +365,7 @@ } // We've set m_frame_type and m_sym_ctx before this call. - m_fast_unwind_plan = GetFastUnwindPlanForFrame (); + m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame (); const UnwindPlan::Row *active_row = NULL; int cfa_offset = 0; @@ -383,18 +374,18 @@ // Try to get by with just the fast UnwindPlan if possible - the full UnwindPlan may be expensive to get // (e.g. if we have to parse the entire eh_frame section of an ObjectFile for the first time.) - if (m_fast_unwind_plan && m_fast_unwind_plan->PlanValidAtAddress (m_current_pc)) + if (m_fast_unwind_plan_sp && m_fast_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_fast_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_fast_unwind_plan->GetRegisterKind (); + active_row = m_fast_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_fast_unwind_plan_sp->GetRegisterKind (); } else { - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - if (m_full_unwind_plan && m_full_unwind_plan->PlanValidAtAddress (m_current_pc)) + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_full_unwind_plan->GetRegisterKind (); + active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); } } @@ -460,49 +451,47 @@ // 3. m_current_pc should have the current pc value for this frame // 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown -UnwindPlan * +UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame () { + UnwindPlanSP unwind_plan_sp; if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) - { - return NULL; - } + return unwind_plan_sp; if (IsFrameZero ()) - { - return NULL; - } + return unwind_plan_sp; - FuncUnwindersSP fu; - fu = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); - if (fu.get() == NULL) - { - return NULL; - } + FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx)); + if (!func_unwinders_sp) + return unwind_plan_sp; // If we're in _sigtramp(), unwinding past this frame requires special knowledge. if (m_frame_type == eSigtrampFrame || m_frame_type == eDebuggerFrame) - { - return NULL; - } + return unwind_plan_sp; - if (fu->GetUnwindPlanFastUnwind (m_thread) - && fu->GetUnwindPlanFastUnwind (m_thread)->PlanValidAtAddress (m_current_pc)) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanFastUnwind (m_thread); + if (unwind_plan_sp) { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose()) + if (unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - const char *has_fast = ""; - if (m_fast_unwind_plan) - has_fast = ", and has a fast UnwindPlan"; - log->Printf("%*sFrame %u frame has a fast UnwindPlan", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + if (log && IsLogVerbose()) + { + const char *has_fast = ""; + if (m_fast_unwind_plan_sp) + has_fast = ", and has a fast UnwindPlan"; + log->Printf("%*sFrame %u frame has a fast UnwindPlan", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + } + m_frame_type = eNormalFrame; + return unwind_plan_sp; + } + else + { + unwind_plan_sp.reset(); } - m_frame_type = eNormalFrame; - return fu->GetUnwindPlanFastUnwind (m_thread); } - - return NULL; + return unwind_plan_sp; } // On entry to this method, @@ -512,37 +501,25 @@ // 3. m_current_pc should have the current pc value for this frame // 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown -UnwindPlan * +UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame () { + UnwindPlanSP unwind_plan_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - UnwindPlan *up; - UnwindPlan *arch_default_up = NULL; - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) - { - arch_default_up = arch_default->GetArchDefaultUnwindPlan (m_thread, m_current_pc); - } + UnwindPlanSP arch_default_unwind_plan_sp; + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); + if (arch_default_sp) + arch_default_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); bool behaves_like_zeroth_frame = false; - if (IsFrameZero ()) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero () && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eSigtrampFrame) + if (IsFrameZero () + || m_next_frame->m_frame_type == eSigtrampFrame + || m_next_frame->m_frame_type == eDebuggerFrame) { behaves_like_zeroth_frame = true; - } - if (!IsFrameZero () && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eDebuggerFrame) - { - behaves_like_zeroth_frame = true; - } - - // If this frame behaves like a 0th frame (currently executing or interrupted asynchronously), all registers - // can be retrieved. - if (behaves_like_zeroth_frame) - { + // If this frame behaves like a 0th frame (currently executing or + // interrupted asynchronously), all registers can be retrieved. m_all_registers_available = true; } @@ -550,20 +527,20 @@ if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) { m_frame_type = eNormalFrame; - return arch_default_up; + return arch_default_unwind_plan_sp; } - FuncUnwindersSP fu; + FuncUnwindersSP func_unwinders_sp; if (m_sym_ctx_valid) { - fu = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); + func_unwinders_sp = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); } // No FuncUnwinders available for this pc, try using architectural default unwind. - if (fu.get() == NULL) + if (!func_unwinders_sp) { m_frame_type = eNormalFrame; - return arch_default_up; + return arch_default_unwind_plan_sp; } // If we're in _sigtramp(), unwinding past this frame requires special knowledge. On Mac OS X this knowledge @@ -572,53 +549,54 @@ // how to unwind out of sigtramp. if (m_frame_type == eSigtrampFrame) { - m_fast_unwind_plan = NULL; - up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); - if (up && up->PlanValidAtAddress (m_current_pc)) - { - return up; - } + m_fast_unwind_plan_sp.reset(); + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) + return unwind_plan_sp; } // Typically the NonCallSite UnwindPlan is the unwind created by inspecting the assembly language instructions - up = fu->GetUnwindPlanAtNonCallSite (m_thread); - if (behaves_like_zeroth_frame && up && up->PlanValidAtAddress (m_current_pc)) + if (behaves_like_zeroth_frame) { - if (log && IsLogVerbose()) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + if (log && IsLogVerbose()) + { + log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + unwind_plan_sp->GetSourceName().GetCString()); + } + return unwind_plan_sp; } - return up; } // Typically this is unwind info from an eh_frame section intended for exception handling; only valid at call sites - up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); - if (up && up->PlanValidAtAddress (m_current_pc)) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { if (log && IsLogVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + unwind_plan_sp->GetSourceName().GetCString()); } - return up; + return unwind_plan_sp; } // We'd prefer to use an UnwindPlan intended for call sites when we're at a call site but if we've // struck out on that, fall back to using the non-call-site assembly inspection UnwindPlan if possible. - up = fu->GetUnwindPlanAtNonCallSite (m_thread); - if (up && up->PlanValidAtAddress (m_current_pc)) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { if (log && IsLogVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + unwind_plan_sp->GetSourceName().GetCString()); } - return up; + return unwind_plan_sp; } // If nothing else, use the architectural default UnwindPlan and hope that does the job. @@ -626,9 +604,9 @@ { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - arch_default_up->GetSourceName().GetCString()); + arch_default_unwind_plan_sp->GetSourceName().GetCString()); } - return arch_default_up; + return arch_default_unwind_plan_sp; } @@ -812,9 +790,9 @@ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); // Have we already found this register location? - std::map::const_iterator iterator; - if (m_registers.size() > 0) + if (!m_registers.empty()) { + std::map::const_iterator iterator; iterator = m_registers.find (lldb_regnum); if (iterator != m_registers.end()) { @@ -843,10 +821,10 @@ bool have_unwindplan_regloc = false; int unwindplan_registerkind = -1; - if (m_fast_unwind_plan) + if (m_fast_unwind_plan_sp) { - const UnwindPlan::Row *active_row = m_fast_unwind_plan->GetRowForFunctionOffset (m_current_offset); - unwindplan_registerkind = m_fast_unwind_plan->GetRegisterKind (); + const UnwindPlan::Row *active_row = m_fast_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + unwindplan_registerkind = m_fast_unwind_plan_sp->GetRegisterKind (); uint32_t row_regnum; if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum)) { @@ -872,15 +850,14 @@ if (!have_unwindplan_regloc) { - // m_full_unwind_plan being NULL means that we haven't tried to find a full UnwindPlan yet - if (m_full_unwind_plan == NULL) - { - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - } - if (m_full_unwind_plan) + // m_full_unwind_plan_sp being NULL means that we haven't tried to find a full UnwindPlan yet + if (!m_full_unwind_plan_sp) + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + + if (m_full_unwind_plan_sp) { - const UnwindPlan::Row *active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - unwindplan_registerkind = m_full_unwind_plan->GetRegisterKind (); + const UnwindPlan::Row *active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + unwindplan_registerkind = m_full_unwind_plan_sp->GetRegisterKind (); uint32_t row_regnum; if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum)) { @@ -905,7 +882,7 @@ { log->Printf("%*sFrame %u supplying caller's saved reg %d's location using %s UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString()); + lldb_regnum, m_full_unwind_plan_sp->GetSourceName().GetCString()); } } } @@ -915,7 +892,7 @@ { // If a volatile register is being requested, we don't want to forward m_next_frame's register contents // up the stack -- the register is not retrievable at this frame. - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); ArchVolatileRegs *volatile_regs = ArchVolatileRegs::FindPlugin (arch); if (volatile_regs && volatile_regs->RegisterIsVolatile (m_thread, lldb_regnum)) { @@ -928,11 +905,7 @@ return false; } - if (!IsFrameZero ()) - { - return ((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc); - } - else + if (IsFrameZero ()) { // This is frame 0 - we should return the actual live register context value RegisterLocation new_regloc; @@ -942,6 +915,10 @@ regloc = new_regloc; return true; } + else + { + return m_next_frame->SavedLocationForRegister (lldb_regnum, regloc); + } if (log) { log->Printf("%*sFrame %u could not supply caller's reg %d location", @@ -968,11 +945,7 @@ if (unwindplan_regloc.IsSame()) { - if (!IsFrameZero ()) - { - return ((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc); - } - else + if (IsFrameZero ()) { if (log) { @@ -982,6 +955,10 @@ } return false; } + else + { + return m_next_frame->SavedLocationForRegister (lldb_regnum, regloc); + } } if (unwindplan_regloc.IsCFAPlusOffset()) @@ -1116,14 +1093,11 @@ value = data.GetAddress (&offset); return true; } - else - { - return false; - } + return false; } RegisterLocation regloc; - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc)) { return false; } @@ -1166,7 +1140,7 @@ RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) return false; return ReadRegisterBytesFromRegisterLocation (lldb_reg, regloc, data); @@ -1200,7 +1174,7 @@ RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) return false; return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset); Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon Feb 14 18:19:15 2011 @@ -20,8 +20,10 @@ class RegisterContextLLDB : public lldb_private::RegisterContext { public: + typedef lldb::SharedPtr::Type SharedPtr; + RegisterContextLLDB (lldb_private::Thread &thread, - const lldb::RegisterContextSP& next_frame, + const SharedPtr& next_frame, lldb_private::SymbolContext& sym_ctx, uint32_t frame_number); @@ -147,22 +149,23 @@ bool ReadGPRValue (int register_kind, uint32_t regnum, lldb::addr_t &value); - lldb_private::UnwindPlan * + lldb::UnwindPlanSP GetFastUnwindPlanForFrame (); - lldb_private::UnwindPlan * + lldb::UnwindPlanSP GetFullUnwindPlanForFrame (); lldb_private::Thread& m_thread; - lldb::RegisterContextSP m_next_frame; + + SharedPtr m_next_frame; /// // The following tell us how to retrieve the CALLER's register values (ie the "previous" frame, aka the frame above) // i.e. where THIS frame saved them /// - lldb_private::UnwindPlan *m_fast_unwind_plan; // may be NULL - lldb_private::UnwindPlan *m_full_unwind_plan; + lldb::UnwindPlanSP m_fast_unwind_plan_sp; // may be NULL + lldb::UnwindPlanSP m_full_unwind_plan_sp; bool m_all_registers_available; // Can we retrieve all regs or just nonvolatile regs? int m_frame_type; // enum FrameType Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Mon Feb 14 18:19:15 2011 @@ -15,10 +15,12 @@ #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/Function.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" -#include "UnwindLLDB.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Core/Log.h" +#include "UnwindLLDB.h" +#include "RegisterContextLLDB.h" + using namespace lldb; using namespace lldb_private; @@ -65,8 +67,10 @@ { // First, set up the 0th (initial) frame CursorSP first_cursor_sp(new Cursor ()); - RegisterContextSP no_frame; - std::auto_ptr first_register_ctx_ap (new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0)); + std::auto_ptr first_register_ctx_ap (new RegisterContextLLDB (m_thread, + RegisterContextLLDB::SharedPtr(), + first_cursor_sp->sctx, + 0)); if (first_register_ctx_ap.get() == NULL) return false; @@ -150,8 +154,8 @@ return false; } } - RegisterContextSP register_ctx_sp(register_ctx_ap.release()); - cursor_sp->reg_ctx = register_ctx_sp; + RegisterContextLLDB::SharedPtr reg_ctx_sp(register_ctx_ap.release()); + cursor_sp->reg_ctx = reg_ctx_sp; m_frames.push_back (cursor_sp); return true; } Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Mon Feb 14 18:19:15 2011 @@ -10,15 +10,15 @@ #ifndef lldb_UnwindLLDB_h_ #define lldb_UnwindLLDB_h_ -#include "lldb/lldb-private.h" -#include "lldb/lldb-types.h" -#include "lldb/Target/Unwind.h" +#include + +#include "lldb/lldb-include.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/UnwindPlan.h" -#include "RegisterContextLLDB.h" #include "lldb/Target/RegisterContext.h" -#include +#include "lldb/Target/Unwind.h" +#include "RegisterContextLLDB.h" namespace lldb_private { @@ -53,7 +53,7 @@ lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown lldb::addr_t cfa; // The canonical frame address for this stack frame lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation - lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's + RegisterContextLLDB::SharedPtr reg_ctx; // These are all RegisterContextLLDB's Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } private: Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon Feb 14 18:19:15 2011 @@ -178,11 +178,12 @@ return false; } -void +bool GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - assert (reg_info); + if (reg_info == NULL) + return false; // Invalidate if needed InvalidateIfNeeded(false); @@ -200,6 +201,7 @@ // leave it as it was. m_reg_valid[reg] = false; } + return success; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Mon Feb 14 18:19:15 2011 @@ -228,7 +228,7 @@ protected: friend class ThreadGDBRemote; - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); void Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Feb 14 18:19:15 2011 @@ -642,7 +642,6 @@ StreamString strm; - ; // See if the GDB server supports the qHostInfo information const char *vendor = m_gdb_comm.GetVendorString().AsCString(); const char *os_type = m_gdb_comm.GetOSString().AsCString(); @@ -1176,6 +1175,18 @@ case 'T': case 'S': { + if (GetStopID() == 0) + { + // Our first stop, make sure we have a process ID, and also make + // sure we know about our registers + if (GetID() == LLDB_INVALID_PROCESS_ID) + { + lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID (1); + if (pid != LLDB_INVALID_PROCESS_ID) + SetID (pid); + } + BuildDynamicRegisterInfo (true); + } // Stop with signal and thread info const uint8_t signo = stop_packet.GetHexU8(); std::string name; @@ -1209,7 +1220,14 @@ { // thread in big endian hex tid = Args::StringToUInt32 (value.c_str(), 0, 16); + Mutex::Locker locker (m_thread_list.GetMutex ()); thread_sp = m_thread_list.FindThreadByID(tid, false); + if (!thread_sp) + { + // Create the thread if we need to + thread_sp.reset (new ThreadGDBRemote (*this, tid)); + m_thread_list.AddThread(thread_sp); + } } else if (name.compare("hexname") == 0) { @@ -1242,7 +1260,15 @@ StringExtractor reg_value_extractor; // Swap "value" over into "reg_value_extractor" reg_value_extractor.GetStringRef().swap(value); - static_cast (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor); + if (!static_cast (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor)) + { + Host::SetCrashDescriptionWithFormat("Setting thread register '%s' (decoded to %u (0x%x)) with value '%s' for stop packet: '%s'", + name.c_str(), + reg, + reg, + reg_value_extractor.GetStringRef().c_str(), + stop_packet.GetStringRef().c_str()); + } } } } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Mon Feb 14 18:19:15 2011 @@ -26,7 +26,7 @@ #include "Plugins/Process/Utility/UnwindLLDB.h" #include "Utility/StringExtractorGDBRemote.h" -#ifdef __APPLE__ +#if defined(__APPLE__) #include "UnwindMacOSXFrameBackchain.h" #endif @@ -98,6 +98,7 @@ { case eStateSuspended: case eStateStopped: + // Don't append anything for threads that should stay stopped. break; case eStateRunning: @@ -145,7 +146,7 @@ { m_unwinder_ap.reset (new UnwindLLDB (*this)); } -#ifdef __APPLE__ +#if defined(__APPLE__) else { m_unwinder_ap.reset (new UnwindMacOSXFrameBackchain (*this)); @@ -207,12 +208,12 @@ return reg_ctx_sp; } -void +bool ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { GDBRemoteRegisterContext *gdb_reg_ctx = static_cast(GetRegisterContext ().get()); assert (gdb_reg_ctx); - gdb_reg_ctx->PrivateSetRegisterValue (reg, response); + return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } bool Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Mon Feb 14 18:19:15 2011 @@ -105,7 +105,7 @@ virtual bool RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Feb 14 18:19:15 2011 @@ -197,6 +197,14 @@ return g_dwarf_section_name; } +UniqueDWARFASTTypeMap & +SymbolFileDWARF::GetUniqueDWARFASTTypeMap () +{ + if (m_debug_map_symfile) + return m_debug_map_symfile->GetUniqueDWARFASTTypeMap (); + return m_unique_ast_type_map; +} + ClangASTContext & SymbolFileDWARF::GetClangASTContext () { @@ -3172,10 +3180,10 @@ UniqueDWARFASTType unique_ast_entry; if (decl.IsValid()) { - if (m_unique_ast_type_map.Find (type_name_const_str, - die, - decl, - unique_ast_entry)) + if (GetUniqueDWARFASTTypeMap().Find (type_name_const_str, + die, + decl, + unique_ast_entry)) { // We have already parsed this type or from another // compile unit. GCC loves to use the "one definition @@ -3273,8 +3281,8 @@ unique_ast_entry.m_type_sp = type_sp; unique_ast_entry.m_die = die; unique_ast_entry.m_declaration = decl; - m_unique_ast_type_map.Insert (type_name_const_str, - unique_ast_entry); + GetUniqueDWARFASTTypeMap().Insert (type_name_const_str, + unique_ast_entry); if (die->HasChildren() == false && is_forward_declaration == false) { @@ -3824,14 +3832,6 @@ type_sp->SetSymbolContextScope(symbol_context_scope); } -// if (udt_sp.get()) -// { -// if (is_forward_declaration) -// udt_sp->GetFlags().Set(UserDefType::flagIsForwardDefinition); -// type_sp->SetUserDefinedType(udt_sp); -// } - - //printf ("Adding type to map: 0x%8.8x for %s\n", die->GetOffset(), type_sp->GetName().GetCString()); // We are ready to put this type into the uniqued list up at the module level type_list->Insert (type_sp); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Feb 14 18:19:15 2011 @@ -321,6 +321,9 @@ clang::NamespaceDecl * ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die); + UniqueDWARFASTTypeMap & + GetUniqueDWARFASTTypeMap (); + SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Mon Feb 14 18:19:15 2011 @@ -15,6 +15,8 @@ #include #include "lldb/Symbol/SymbolFile.h" +#include "UniqueDWARFASTType.h" + class SymbolFileDWARF; class DWARFCompileUnit; class DWARFDebugInfoEntry; @@ -211,6 +213,11 @@ const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + UniqueDWARFASTTypeMap & + GetUniqueDWARFASTTypeMap () + { + return m_unique_ast_type_map; + } //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ @@ -218,6 +225,7 @@ std::vector m_compile_unit_infos; std::vector m_func_indexes; // Sorted by address std::vector m_glob_indexes; + UniqueDWARFASTTypeMap m_unique_ast_type_map; }; #endif // #ifndef liblldb_SymbolFileDWARFDebugMap_h_ Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Mon Feb 14 18:19:15 2011 @@ -34,10 +34,10 @@ m_assembly_profiler(assembly_profiler), m_range(range), m_mutex (Mutex::eMutexTypeNormal), - m_unwind_at_call_site_ap (), - m_unwind_at_non_call_site_ap (), - m_unwind_fast_ap (), - m_unwind_arch_default (NULL), + m_unwind_plan_call_site_sp (), + m_unwind_plan_non_call_site_sp (), + m_unwind_plan_fast_sp (), + m_unwind_plan_arch_default_sp (), m_tried_unwind_at_call_site (false), m_tried_unwind_at_non_call_site (false), m_tried_unwind_fast (false), @@ -50,15 +50,15 @@ { } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite (int current_offset) { // Lock the mutex to ensure we can always give out the most appropriate // information. We want to make sure if someone requests a call site unwind // plan, that they get one and don't run into a race condition where one // thread has started to create the unwind plan and has put it into - // m_unwind_at_call_site_ap, and have another thread enter this function - // and return the partially filled in m_unwind_at_call_site_ap pointer. + // m_unwind_plan_call_site_sp, and have another thread enter this function + // and return the partially filled in m_unwind_plan_call_site_sp pointer. // We also want to make sure that we lock out other unwind plans from // being accessed until this one is done creating itself in case someone // had some code like: @@ -66,7 +66,7 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_call_site == false && m_unwind_at_call_site_ap.get() == NULL) + if (m_tried_unwind_at_call_site == false && m_unwind_plan_call_site_sp.get() == NULL) { m_tried_unwind_at_call_site = true; // We have cases (e.g. with _sigtramp on Mac OS X) where the hand-written eh_frame unwind info for a @@ -84,16 +84,16 @@ DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); if (eh_frame) { - m_unwind_at_call_site_ap.reset (new UnwindPlan); - if (!eh_frame->GetUnwindPlan (current_pc, *m_unwind_at_call_site_ap)) - m_unwind_at_call_site_ap.reset(); + m_unwind_plan_call_site_sp.reset (new UnwindPlan); + if (!eh_frame->GetUnwindPlan (current_pc, *m_unwind_plan_call_site_sp)) + m_unwind_plan_call_site_sp.reset(); } } } - return m_unwind_at_call_site_ap.get(); + return m_unwind_plan_call_site_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -109,17 +109,17 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_non_call_site == false && m_unwind_at_non_call_site_ap.get() == NULL) + if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == NULL) { m_tried_unwind_at_non_call_site = true; - m_unwind_at_non_call_site_ap.reset (new UnwindPlan); - if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_at_non_call_site_ap)) - m_unwind_at_non_call_site_ap.reset(); + m_unwind_plan_non_call_site_sp.reset (new UnwindPlan); + if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp)) + m_unwind_plan_non_call_site_sp.reset(); } - return m_unwind_at_non_call_site_ap.get(); + return m_unwind_plan_non_call_site_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanFastUnwind (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -135,17 +135,17 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_fast == false && m_unwind_fast_ap.get() == NULL) + if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == NULL) { m_tried_unwind_fast = true; - m_unwind_fast_ap.reset (new UnwindPlan); - if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_fast_ap)) - m_unwind_fast_ap.reset(); + m_unwind_plan_fast_sp.reset (new UnwindPlan); + if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp)) + m_unwind_plan_fast_sp.reset(); } - return m_unwind_fast_ap.get(); + return m_unwind_plan_fast_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanArchitectureDefault (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -161,21 +161,20 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_arch_default == false && m_unwind_arch_default == NULL) + if (m_tried_unwind_arch_default == false && m_unwind_plan_arch_default_sp.get() == NULL) { m_tried_unwind_arch_default = true; Address current_pc; Target *target = thread.CalculateTarget(); if (target) { - ArchSpec arch = target->GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) - m_unwind_arch_default = arch_default->GetArchDefaultUnwindPlan (thread, current_pc); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (target->GetArchitecture ())); + if (arch_default_sp) + m_unwind_plan_arch_default_sp = arch_default_sp->GetArchDefaultUnwindPlan (thread, current_pc); } } - return m_unwind_arch_default; + return m_unwind_plan_arch_default_sp; } Address& Modified: lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (original) +++ lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp Mon Feb 14 18:19:15 2011 @@ -7,28 +7,42 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" + +#include + +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Host/Mutex.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; -ArchDefaultUnwindPlan* +ArchDefaultUnwindPlanSP ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch) { ArchDefaultUnwindPlanCreateInstance create_callback; + typedef std::map ArchDefaultUnwindPlanMap; + static ArchDefaultUnwindPlanMap g_plugin_map; + static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); + Mutex::Locker locker (g_plugin_map_mutex); + ArchDefaultUnwindPlanMap::iterator pos = g_plugin_map.find (arch); + if (pos != g_plugin_map.end()) + return pos->second; for (uint32_t idx = 0; (create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL; ++idx) { - std::auto_ptr default_unwind_plan_ap (create_callback (arch)); - if (default_unwind_plan_ap.get ()) - return default_unwind_plan_ap.release (); + ArchDefaultUnwindPlanSP default_unwind_plan_sp (create_callback (arch)); + if (default_unwind_plan_sp) + { + g_plugin_map[arch] = default_unwind_plan_sp; + return default_unwind_plan_sp; + } } - return NULL; + return ArchDefaultUnwindPlanSP(); } ArchDefaultUnwindPlan::ArchDefaultUnwindPlan () Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=125541&r1=125540&r2=125541&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Mon Feb 14 18:19:15 2011 @@ -76,7 +76,8 @@ SymbolFileDWARF::Initialize(); SymbolFileSymtab::Initialize(); UnwindAssemblyProfiler_x86::Initialize(); - ArchDefaultUnwindPlan_x86::Initialize(); + ArchDefaultUnwindPlan_x86_64::Initialize(); + ArchDefaultUnwindPlan_i386::Initialize(); ArchVolatileRegs_x86::Initialize(); ScriptInterpreter::Initialize (); @@ -123,7 +124,8 @@ SymbolFileDWARF::Terminate(); SymbolFileSymtab::Terminate(); UnwindAssemblyProfiler_x86::Terminate(); - ArchDefaultUnwindPlan_x86::Terminate(); + ArchDefaultUnwindPlan_i386::Terminate(); + ArchDefaultUnwindPlan_x86_64::Terminate(); ArchVolatileRegs_x86::Terminate(); ScriptInterpreter::Terminate (); From ctice at apple.com Mon Feb 14 18:19:42 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 15 Feb 2011 00:19:42 -0000 Subject: [Lldb-commits] [lldb] r125542 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110215001942.952E02A6C12C@llvm.org> Author: ctice Date: Mon Feb 14 18:19:42 2011 New Revision: 125542 URL: http://llvm.org/viewvc/llvm-project?rev=125542&view=rev Log: Add code to emulate the STMDA Arm instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125542&r1=125541&r2=125542&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Feb 14 18:19:42 2011 @@ -2877,6 +2877,134 @@ return true; } +// STMDA stores multiple registers to consecutive memory locations using an address from a base register. The +// consecutive memory locations end at this address, and the address just below the lowest of those locations can +// optionally be written back to the base register. +bool +EmulateInstructionARM::EmulateSTMDA (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); + address = R[n] - 4*BitCount(registers) + 4; + + for i = 0 to 14 + if registers == ???1??? then + if i == n && wback && i != LowestSetBit(registers) then + MemA[address,4] = bits(32) UNKNOWN; + else + MemA[address,4] = R[i]; + address = address + 4; + + if registers<15> == ???1??? then + MemA[address,4] = PCStoreValue(); + + if wback then R[n] = R[n] - 4*BitCount(registers); +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed ()) + { + uint32_t n; + uint32_t registers = 0; + bool wback; + const uint32_t addr_byte_size = GetAddressByteSize(); + + // EncodingSpecificOperations(); + switch (encoding) + { + case eEncodingA1: + // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + n = Bits32 (opcode, 19, 16); + registers = Bits32 (opcode, 15, 0); + wback = BitIsSet (opcode, 21); + + // if n == 15 || BitCount(registers) < 1 then UNPREDICTABLE; + if ((n == 15) || (BitCount (registers) < 1)) + return false; + break; + default: + return false; + } + + // address = R[n] - 4*BitCount(registers) + 4; + int32_t offset = 0; + addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + address = address - (addr_byte_size * BitCount (registers)) + 4; + + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterStore; + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + // for i = 0 to 14 + for (int i = 0; i < 14; ++i) + { + int lowest_bit_set = 14; + // if registers == ???1??? then + if (BitIsSet (registers, i)) + { + if (i < lowest_bit_set) + lowest_bit_set = i; + //if i == n && wback && i != LowestSetBit(registers) then + if ((i == n) && wback && (i != lowest_bit_set)) + // MemA[address,4] = bits(32) UNKNOWN; + WriteBits32UnknownToMemory (address + offset); + else + { + // MemA[address,4] = R[i]; + uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + i, 0, &success); + if (!success) + return false; + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + return false; + } + + // address = address + 4; + offset += addr_byte_size; + } + } + + // if registers<15> == ???1??? then + // MemA[address,4] = PCStoreValue(); + if (BitIsSet (registers, 15)) + { + Register pc_reg; + pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + context.SetRegisterPlusOffset (pc_reg, 8); + const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + if (!success) + return false; + + if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + return false; + } + + // if wback then R[n] = R[n] - 4*BitCount(registers); + if (wback) + { + offset = addr_byte_size * BitCount (registers); + context.type = EmulateInstruction::eContextAdjustBaseRegister; + context.SetImmediateSigned (offset); + addr_t data = address + offset; + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) + return false; + } + } + return true; +} + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) { @@ -2952,7 +3080,9 @@ //---------------------------------------------------------------------- // Store instructions //---------------------------------------------------------------------- - { 0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTM, "stm {!} " } + { 0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, + { 0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDA, "stmda {!} " } + }; static const size_t k_num_arm_opcodes = sizeof(g_arm_opcodes)/sizeof(ARMOpcode); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125542&r1=125541&r2=125542&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon Feb 14 18:19:42 2011 @@ -322,6 +322,9 @@ bool EmulateSTM (ARMEncoding encoding); + bool + EmulateSTMDA (ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From johnny.chen at apple.com Tue Feb 15 11:31:33 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 17:31:33 -0000 Subject: [Lldb-commits] [lldb] r125569 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110215173133.BAC692A6C12D@llvm.org> Author: johnny Date: Tue Feb 15 11:31:33 2011 New Revision: 125569 URL: http://llvm.org/viewvc/llvm-project?rev=125569&view=rev Log: Remove the unnecessary assignment of m_inst_cpsr inside EvaluateInstruction(), because it's already been done within ReadInstruction(). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125569&r1=125568&r2=125569&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 11:31:33 2011 @@ -3549,9 +3549,5 @@ if (m_inst_mode == eModeThumb && m_it_session.InITBlock()) m_it_session.ITAdvance(); - // If the flags have changed, flush it out. - if (m_new_inst_cpsr != m_inst_cpsr) - m_inst_cpsr = m_new_inst_cpsr; - return false; } From johnny.chen at apple.com Tue Feb 15 11:52:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 17:52:22 -0000 Subject: [Lldb-commits] [lldb] r125575 - /lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Message-ID: <20110215175222.97F472A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 11:52:22 2011 New Revision: 125575 URL: http://llvm.org/viewvc/llvm-project?rev=125575&view=rev Log: Add a bunch of utilities and an enum (ARM_ShifterType) for shift and rotate operations pertaining to: o A2.2.1 Pseudocode details of shift and rotate operations o A8.4.3 Pseudocode details of instruction-specified shifts and rotates Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125575&r1=125574&r2=125575&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Tue Feb 15 11:52:22 2011 @@ -11,11 +11,181 @@ #define lldb_ARMUtils_h_ #include "InstructionUtils.h" +#include "llvm/Support/MathExtras.h" // for SignExtend64 template function // Common utilities for the ARM/Thumb Instruction Set Architecture. namespace lldb_private { +typedef enum +{ + SRType_LSL, + SRType_LSR, + SRType_ASR, + SRType_ROR, + SRType_RRX +} ARM_ShifterType; + +static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5, ARM_ShifterType &shift_t) +{ + switch (type) { + default: + assert(0 && "Invalid shift type"); + case 0: + shift_t = SRType_LSL; + return imm5; + case 1: + shift_t = SRType_LSR; + return (imm5 == 0 ? 32 : imm5); + case 2: + shift_t = SRType_ASR; + return (imm5 == 0 ? 32 : imm5); + case 3: + if (imm5 == 0) + { + shift_t = SRType_RRX; + return 1; + } + else + { + shift_t = SRType_ROR; + return imm5; + } + } +} + +static inline ARM_ShifterType DecodeRegShift(const uint32_t type) +{ + switch (type) { + default: + assert(0 && "Invalid shift type"); + case 0: + return SRType_LSL; + case 1: + return SRType_LSR; + case 2: + return SRType_ASR; + case 3: + return SRType_ROR; + } +} + +static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +{ + assert(amount > 0 && amount < 32); + carry_out = Bit32(value, 32 - amount); + return value << amount; +} + +static inline uint32_t LSL(const uint32_t value, const uint32_t amount) +{ + assert(amount >= 0 && amount < 32); + if (amount == 0) + return value; + uint32_t dont_care; + return LSL_C(value, amount, dont_care); +} + +static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +{ + assert(amount > 0 && amount <= 32); + carry_out = Bit32(value, amount - 1); + return value >> amount; +} + +static inline uint32_t LSR(const uint32_t value, const uint32_t amount) +{ + assert(amount >= 0 && amount <= 32); + if (amount == 0) + return value; + uint32_t dont_care; + return LSR_C(value, amount, dont_care); +} + +static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +{ + assert(amount > 0 && amount <= 32); + carry_out = Bit32(value, amount - 1); + int64_t extended = llvm::SignExtend64<32>(value); + return UnsignedBits(extended, amount + 31, amount); +} + +static inline uint32_t ASR(const uint32_t value, const uint32_t amount) +{ + assert(amount >= 0 && amount <= 32); + if (amount == 0) + return value; + uint32_t dont_care; + return ASR_C(value, amount, dont_care); +} + +static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +{ + assert(amount > 0 && amount < 32); + uint32_t result = Rotr32(value, amount); + carry_out = Bit32(value, 31); + return result; +} + +static inline uint32_t ROR(const uint32_t value, const uint32_t amount) +{ + assert(amount >= 0 && amount < 32); + if (amount == 0) + return value; + uint32_t dont_care; + return ROR_C(value, amount, dont_care); +} + +static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in, uint32_t &carry_out) +{ + carry_out = Bit32(value, 0); + return Bit32(carry_in, 0) << 31 | Bits32(value, 31, 1); +} + +static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in) +{ + uint32_t dont_care; + return RRX_C(value, carry_in, dont_care); +} + +static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type, const uint32_t amount, + const uint32_t carry_in, uint32_t &carry_out) +{ + assert(type != SRType_RRX || amount == 1); + if (amount == 0) + { + carry_out = carry_in; + return value; + } + uint32_t result; + switch (type) { + case SRType_LSL: + result = LSL_C(value, amount, carry_out); + break; + case SRType_LSR: + result = LSR_C(value, amount, carry_out); + break; + case SRType_ASR: + result = ASR_C(value, amount, carry_out); + break; + case SRType_ROR: + result = ROR_C(value, amount, carry_out); + break; + case SRType_RRX: + result = RRX_C(value, amount, carry_out); + break; + } + return result; +} + +static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type, const uint32_t amount, + const uint32_t carry_in) +{ + // Don't care about carry out in this case. + uint32_t dont_care; + return Shift_C(value, type, amount, carry_in, dont_care); +} + static inline uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit) { return Bits32(val, msbit, lsbit); From ctice at apple.com Tue Feb 15 12:10:01 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 15 Feb 2011 18:10:01 -0000 Subject: [Lldb-commits] [lldb] r125578 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110215181001.7733D2A6C12C@llvm.org> Author: ctice Date: Tue Feb 15 12:10:01 2011 New Revision: 125578 URL: http://llvm.org/viewvc/llvm-project?rev=125578&view=rev Log: Add code to emulate STMDB Arm instruction. Add some bit-mask fixes to code for getting register bits for various LDM and STM instructions. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125578&r1=125577&r2=125578&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 12:10:01 2011 @@ -2144,27 +2144,39 @@ switch (encoding) { case eEncodingT1: + // n = UInt(Rn); registers = ???00000000???:register_list; wback = (registers == ???0???); n = Bits32 (opcode, 10, 8); registers = Bits32 (opcode, 7, 0); + registers = registers & 0x00ff; // Make sure the top 8 bits are zeros. wback = BitIsClear (registers, n); // if BitCount(registers) < 1 then UNPREDICTABLE; if (BitCount(registers) < 1) return false; break; case eEncodingT2: + // if W == ???1??? && Rn == ???1101??? then SEE POP; + // n = UInt(Rn); registers = P:M:???0???:register_list; wback = (W == ???1???); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); + registers = registers & 0xdfff; // Make sure bit 13 is zero. wback = BitIsSet (opcode, 21); + + // if n == 15 || BitCount(registers) < 2 || (P == ???1??? && M == ???1???) then UNPREDICTABLE; if ((n == 15) || (BitCount (registers) < 2) || (BitIsSet (opcode, 14) && BitIsSet (opcode, 15))) return false; + + // if registers<15> == ???1??? && InITBlock() && !LastInITBlock() then UNPREDICTABLE; if (BitIsSet (registers, 15) && InITBlock() && !LastInITBlock()) return false; + + // if wback && registers == ???1??? then UNPREDICTABLE; if (wback && BitIsSet (registers, n)) return false; break; + case eEncodingA1: n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); @@ -2399,6 +2411,7 @@ // n = UInt(Rn); registers = P:M:???0???:register_list; wback = (W == ???1???); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); + registers = registers & 0xdfff; // Make sure bit 13 is a zero. wback = BitIsSet (opcode, 21); // if n == 15 || BitCount(registers) < 2 || (P == ???1??? && M == ???1???) then UNPREDICTABLE; @@ -2765,6 +2778,7 @@ // n = UInt(Rn); registers = ???00000000???:register_list; wback = TRUE; n = Bits32 (opcode, 10, 8); registers = Bits32 (opcode, 7, 0); + registers = registers & 0x00ff; // Make sure the top 8 bits are zeros. wback = true; // if BitCount(registers) < 1 then UNPREDICTABLE; @@ -2777,6 +2791,7 @@ // n = UInt(Rn); registers = ???0???:M:???0???:register_list; wback = (W == ???1???); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); + registers = registers & 0x5fff; // Make sure bits 15 & 13 are zeros. wback = BitIsSet (opcode, 21); // if n == 15 || BitCount(registers) < 2 then UNPREDICTABLE; @@ -3005,6 +3020,160 @@ return true; } +// STMDB stores multiple registers to consecutive memory locations using an address from a base register. The +// consecutive memory locations end just below this address, and the address of the first of those locations can +// optionally be written back to the base register. +bool +EmulateInstructionARM::EmulateSTMDB (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); NullCheckIfThumbEE(n); + address = R[n] - 4*BitCount(registers); + + for i = 0 to 14 + if registers == ???1??? then + if i == n && wback && i != LowestSetBit(registers) then + MemA[address,4] = bits(32) UNKNOWN; // Only possible for encoding A1 + else + MemA[address,4] = R[i]; + address = address + 4; + + if registers<15> == ???1??? then // Only possible for encoding A1 + MemA[address,4] = PCStoreValue(); + + if wback then R[n] = R[n] - 4*BitCount(registers); +#endif + + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed ()) + { + uint32_t n; + uint32_t registers = 0; + bool wback; + const uint32_t addr_byte_size = GetAddressByteSize(); + + // EncodingSpecificOperations(); NullCheckIfThumbEE(n); + switch (encoding) + { + case eEncodingT1: + // if W == ???1??? && Rn == ???1101??? then SEE PUSH; + if ((BitIsSet (opcode, 21)) && (Bits32 (opcode, 19, 16) == 13)) + { + // See PUSH + } + // n = UInt(Rn); registers = ???0???:M:???0???:register_list; wback = (W == ???1???); + n = Bits32 (opcode, 19, 16); + registers = Bits32 (opcode, 15, 0); + registers = registers & 0x5fff; // Make sure bits 15 & 13 are zeros. + wback = BitIsSet (opcode, 21); + // if n == 15 || BitCount(registers) < 2 then UNPREDICTABLE; + if ((n == 15) || BitCount (registers) < 2) + return false; + // if wback && registers == ???1??? then UNPREDICTABLE; + if (wback && BitIsSet (registers, n)) + return false; + break; + + case eEncodingA1: + // if W == ???1??? && Rn == ???1101??? && BitCount(register_list) >= 2 then SEE PUSH; + if (BitIsSet (opcode, 21) && (Bits32 (opcode, 19, 16) == 13) && BitCount (Bits32 (opcode, 15, 0)) >= 2) + { + // See Push + } + // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + n = Bits32 (opcode, 19, 16); + registers = Bits32 (opcode, 15, 0); + wback = BitIsSet (opcode, 21); + // if n == 15 || BitCount(registers) < 1 then UNPREDICTABLE; + if ((n == 15) || BitCount (registers) < 1) + return false; + break; + + default: + return false; + } + + // address = R[n] - 4*BitCount(registers); + + int32_t offset = 0; + addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + address = address - (addr_byte_size * BitCount (registers)); + + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterStore; + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + // for i = 0 to 14 + for (int i = 0; i < 14; ++i) + { + uint32_t lowest_set_bit = 14; + // if registers == ???1??? then + if (BitIsSet (registers, i)) + { + if (i < lowest_set_bit) + lowest_set_bit = i; + // if i == n && wback && i != LowestSetBit(registers) then + if ((i == n) && wback && (i != lowest_set_bit)) + // MemA[address,4] = bits(32) UNKNOWN; // Only possible for encoding A1 + WriteBits32UnknownToMemory (address + offset); + else + { + // MemA[address,4] = R[i]; + uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + i, 0, &success); + if (!success) + return false; + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + return false; + } + + // address = address + 4; + offset += addr_byte_size; + } + } + + // if registers<15> == ???1??? then // Only possible for encoding A1 + // MemA[address,4] = PCStoreValue(); + if (BitIsSet (registers, 15)) + { + Register pc_reg; + pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + context.SetRegisterPlusOffset (pc_reg, 8); + const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + if (!success) + return false; + + if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + return false; + } + + // if wback then R[n] = R[n] - 4*BitCount(registers); + if (wback) + { + offset = addr_byte_size * BitCount (registers); + context.type = EmulateInstruction::eContextAdjustBaseRegister; + context.SetImmediateSigned (offset); + addr_t data = address + offset; + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) + return false; + } + } + return true; +} + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) { @@ -3081,7 +3250,8 @@ // Store instructions //---------------------------------------------------------------------- { 0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, - { 0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDA, "stmda {!} " } + { 0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDA, "stmda {!} " }, + { 0x0fd00000, 0x09000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " } }; @@ -3206,7 +3376,8 @@ // Store instructions //---------------------------------------------------------------------- { 0xfffff800, 0x0000c000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, - { 0xffd00000, 0xe8800000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTM, "stm.w {!} " } + { 0xffd00000, 0xe8800000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTM, "stm.w {!} " }, + { 0xffd00000, 0xe9000000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " } }; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125578&r1=125577&r2=125578&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 12:10:01 2011 @@ -325,6 +325,9 @@ bool EmulateSTMDA (ARMEncoding encoding); + bool + EmulateSTMDB (ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From ctice at apple.com Tue Feb 15 12:42:15 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 15 Feb 2011 18:42:15 -0000 Subject: [Lldb-commits] [lldb] r125580 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110215184215.D594A2A6C12C@llvm.org> Author: ctice Date: Tue Feb 15 12:42:15 2011 New Revision: 125580 URL: http://llvm.org/viewvc/llvm-project?rev=125580&view=rev Log: Add code to emulate STMIB Arm instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125580&r1=125579&r2=125580&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 12:42:15 2011 @@ -2735,9 +2735,9 @@ return true; } -// STM stores multiple registers to consecutive memory locations using an address from a base register. The -// consecutive memory locations start at this address, and teh address just above the last of those locations can -// optionally be written back to the base register. +// STM (Store Multiple Increment After) stores multiple registers to consecutive memory locations using an address +// from a base register. The consecutive memory locations start at this address, and teh address just above the last +// of those locations can optionally be written back to the base register. bool EmulateInstructionARM::EmulateSTM (ARMEncoding encoding) { @@ -2892,9 +2892,9 @@ return true; } -// STMDA stores multiple registers to consecutive memory locations using an address from a base register. The -// consecutive memory locations end at this address, and the address just below the lowest of those locations can -// optionally be written back to the base register. +// STMDA (Store Multiple Decrement After) stores multiple registers to consecutive memory locations using an address +// from a base register. The consecutive memory locations end at this address, and the address just below the lowest +// of those locations can optionally be written back to the base register. bool EmulateInstructionARM::EmulateSTMDA (ARMEncoding encoding) { @@ -3009,7 +3009,7 @@ // if wback then R[n] = R[n] - 4*BitCount(registers); if (wback) { - offset = addr_byte_size * BitCount (registers); + offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); addr_t data = address + offset; @@ -3020,9 +3020,9 @@ return true; } -// STMDB stores multiple registers to consecutive memory locations using an address from a base register. The -// consecutive memory locations end just below this address, and the address of the first of those locations can -// optionally be written back to the base register. +// STMDB (Store Multiple Decrement Before) stores multiple registers to consecutive memory locations using an address +// from a base register. The consecutive memory locations end just below this address, and the address of the first of +// those locations can optionally be written back to the base register. bool EmulateInstructionARM::EmulateSTMDB (ARMEncoding encoding) { @@ -3163,6 +3163,135 @@ // if wback then R[n] = R[n] - 4*BitCount(registers); if (wback) { + offset = (addr_byte_size * BitCount (registers)) * -1; + context.type = EmulateInstruction::eContextAdjustBaseRegister; + context.SetImmediateSigned (offset); + addr_t data = address + offset; + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) + return false; + } + } + return true; +} + +// STMIB (Store Multiple Increment Before) stores multiple registers to consecutive memory locations using an address +// from a base register. The consecutive memory locations start just above this address, and the address of the last +// of those locations can optionally be written back to the base register. +bool +EmulateInstructionARM::EmulateSTMIB (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); + address = R[n] + 4; + + for i = 0 to 14 + if registers == ???1??? then + if i == n && wback && i != LowestSetBit(registers) then + MemA[address,4] = bits(32) UNKNOWN; + else + MemA[address,4] = R[i]; + address = address + 4; + + if registers<15> == ???1??? then + MemA[address,4] = PCStoreValue(); + + if wback then R[n] = R[n] + 4*BitCount(registers); +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + uint32_t n; + uint32_t registers = 0; + bool wback; + const uint32_t addr_byte_size = GetAddressByteSize(); + + // EncodingSpecificOperations(); + switch (encoding) + { + case eEncodingA1: + // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + n = Bits32 (opcode, 19, 16); + registers = Bits32 (opcode, 15, 0); + wback = BitIsSet (opcode, 21); + + // if n == 15 || BitCount(registers) < 1 then UNPREDICTABLE; + if ((n == 15) && (BitCount (registers) < 1)) + return false; + break; + default: + return false; + } + // address = R[n] + 4; + + int32_t offset = 0; + addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + address = address + addr_byte_size; + + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextRegisterStore; + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + uint32_t lowest_set_bit = 14; + // for i = 0 to 14 + for (int i = 0; i < 14; ++i) + { + // if registers == ???1??? then + if (BitIsSet (registers, i)) + { + if (i < lowest_set_bit) + lowest_set_bit = i; + // if i == n && wback && i != LowestSetBit(registers) then + if ((i == n) && wback && (i != lowest_set_bit)) + // MemA[address,4] = bits(32) UNKNOWN; + WriteBits32UnknownToMemory (address + offset); + // else + else + { + // MemA[address,4] = R[i]; + uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + i, 0, &success); + if (!success) + return false; + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + return false; + } + + // address = address + 4; + offset += addr_byte_size; + } + } + + // if registers<15> == ???1??? then + // MemA[address,4] = PCStoreValue(); + if (BitIsSet (registers, 15)) + { + Register pc_reg; + pc_reg.SetRegister (eRegisterKindDWARF, dwarf_pc); + context.SetRegisterPlusOffset (pc_reg, 8); + const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + if (!success) + return false; + + if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + return false; + } + + // if wback then R[n] = R[n] + 4*BitCount(registers); + if (wback) + { offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); @@ -3174,6 +3303,7 @@ return true; } + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) { @@ -3251,7 +3381,8 @@ //---------------------------------------------------------------------- { 0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, { 0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDA, "stmda {!} " }, - { 0x0fd00000, 0x09000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " } + { 0x0fd00000, 0x09000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " }, + { 0x0fd00000, 0x09800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMIB, "stmib {!} " } }; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125580&r1=125579&r2=125580&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 12:42:15 2011 @@ -328,6 +328,9 @@ bool EmulateSTMDB (ARMEncoding encoding); + bool + EmulateSTMIB (ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From johnny.chen at apple.com Tue Feb 15 12:50:19 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 18:50:19 -0000 Subject: [Lldb-commits] [lldb] r125584 - /lldb/trunk/test/dotest.py Message-ID: <20110215185020.0ACA12A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 12:50:19 2011 New Revision: 125584 URL: http://llvm.org/viewvc/llvm-project?rev=125584&view=rev Log: Refactored the test driver to abstract out the Python sys.path specification for different build configurations. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=125584&r1=125583&r2=125584&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Feb 15 12:50:19 2011 @@ -496,18 +496,19 @@ return base = os.path.abspath(os.path.join(scriptPath, os.pardir)) - dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework', - 'Resources', 'Python') - dbgPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', - 'Debug', 'LLDB.framework', 'Resources', 'Python') - relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework', - 'Resources', 'Python') - relPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', - 'Release', 'LLDB.framework', 'Resources', 'Python') - baiPath = os.path.join(base, 'build', 'BuildAndIntegration', - 'LLDB.framework', 'Resources', 'Python') - baiPath2 = os.path.join(base, 'build', 'lldb', 'Build', 'Products', - 'BuildAndIntegration', 'LLDB.framework', 'Resources', 'Python') + + xcode3_build_dir = ['build'] + xcode4_build_dir = ['build', 'lldb', 'Build', 'Products'] + dbg = ['Debug'] + rel = ['Release'] + bai = ['BuildAndIntegration'] + python_resource_dir = ['LLDB.framework', 'Resources', 'Python'] + dbgPath = os.path.join(base, *(xcode3_build_dir + dbg + python_resource_dir)) + dbgPath2 = os.path.join(base, *(xcode4_build_dir + dbg + python_resource_dir)) + relPath = os.path.join(base, *(xcode3_build_dir + rel + python_resource_dir)) + relPath2 = os.path.join(base, *(xcode4_build_dir + rel + python_resource_dir)) + baiPath = os.path.join(base, *(xcode3_build_dir + bai + python_resource_dir)) + baiPath2 = os.path.join(base, *(xcode4_build_dir + bai + python_resource_dir)) lldbPath = None if os.path.isfile(os.path.join(dbgPath, 'lldb.py')): From johnny.chen at apple.com Tue Feb 15 14:10:55 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 20:10:55 -0000 Subject: [Lldb-commits] [lldb] r125592 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Instruction/ARM/EmulateInstructionARM.h Process/Utility/ARMUtils.h Message-ID: <20110215201056.088672A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 14:10:55 2011 New Revision: 125592 URL: http://llvm.org/viewvc/llvm-project?rev=125592&view=rev Log: A8.6.14 ASR (immediate) Add EmulateASRImm() Encodings T1, T2, and A1 to the opcodes tables. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125592&r1=125591&r2=125592&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 14:10:55 2011 @@ -2107,6 +2107,109 @@ return true; } +// Arithmetic Shift Right (immediate) shifts a register value right by an immediate number of bits, +// shifting in copies of its sign bit, and writes the result to the destination register. It can +// optionally update the condition flags based on the result. +bool +EmulateInstructionARM::EmulateASRImm (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + (result, carry) = Shift_C(R[m], SRType_ASR, shift_n, APSR.C); + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + uint32_t Rd; // the destination register + uint32_t Rm; // the first operand register + uint32_t imm5; // encoding for the shift amount + uint32_t carry; // the carry bit after the shift operation + bool setflags; + switch (encoding) { + case eEncodingT1: + Rd = Bits32(opcode, 2, 0); + Rm = Bits32(opcode, 5, 3); + setflags = !InITBlock(); + imm5 = Bits32(opcode, 10, 6); + break; + case eEncodingT2: + Rd = Bits32(opcode, 11, 8); + Rm = Bits32(opcode, 3, 0); + setflags = BitIsSet(opcode, 20); + imm5 = Bits32(opcode, 14, 12) << 2 | Bits32(opcode, 7, 6); + if (BadReg(Rd) || BadReg(Rm)) + return false; + break; + case eEncodingA1: + Rd = Bits32(opcode, 15, 12); + Rm = Bits32(opcode, 3, 0); + setflags = BitIsSet(opcode, 20); + imm5 = Bits32(opcode, 11, 7); + break; + default: + return false; + } + + // Get the first operand. + uint32_t value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); + if (!success) + return false; + + // Decode the shift amount. + uint32_t amt = DecodeImmShift(SRType_ASR, imm5); + + uint32_t result = Shift_C(value, SRType_ASR, amt, Bit32(m_inst_cpsr, CPSR_C), carry); + + // The context specifies that an immediate is to be moved into Rd. + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + + Register dummy_reg; + dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); + + if (Rd == 15) + { + if (!ALUWritePC (context, result, dummy_reg)) + return false; + } + else + { + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + return false; + if (setflags) + { + m_new_inst_cpsr = m_inst_cpsr; + SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); + SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); + SetBit32(m_new_inst_cpsr, CPSR_C, carry); + if (m_new_inst_cpsr != m_inst_cpsr) + { + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) + return false; + } + } + } + } + return true; +} + // LDM loads multiple registers from consecutive memory locations, using an // address from a base register. Optionally the address just above the highest of those locations // can be written back to the base register. @@ -3367,6 +3470,8 @@ //---------------------------------------------------------------------- // move bitwise not { 0x0fef0000, 0x03e00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateMvnRdImm, "mvn{s} , #"}, + // asr (immediate) + { 0x0fef0070, 0x01a00040, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s} , , #imm"}, //---------------------------------------------------------------------- // Load instructions @@ -3492,6 +3597,9 @@ { 0xffffffc0, 0x00004280, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateCmpRnRm, "cmp , "}, // compare Rn with Rm (Rn and Rm not both from r0-r7) { 0xffffff00, 0x00004500, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateCmpRnRm, "cmp , "}, + // asr (immediate) + { 0xfffff800, 0x00001000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateASRImm, "asrs|asr , , #imm"}, + { 0x0fef0070, 0x01a00040, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s}.w , , #imm"}, //---------------------------------------------------------------------- // Load instructions Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125592&r1=125591&r2=125592&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 14:10:55 2011 @@ -304,6 +304,10 @@ bool EmulateCmpRnRm (ARMEncoding encoding); + // A8.6.14 ASR (immediate) + bool + EmulateASRImm (ARMEncoding encoding); + bool EmulateLDM (ARMEncoding encoding); Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125592&r1=125591&r2=125592&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Tue Feb 15 14:10:55 2011 @@ -54,6 +54,12 @@ } } +static inline uint32_t DecodeImmShift(const ARM_ShifterType shift_t, const uint32_t imm5) +{ + ARM_ShifterType dont_care; + return DecodeImmShift(shift_t, imm5, dont_care); +} + static inline ARM_ShifterType DecodeRegShift(const uint32_t type) { switch (type) { From johnny.chen at apple.com Tue Feb 15 14:14:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 20:14:02 -0000 Subject: [Lldb-commits] [lldb] r125593 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110215201402.4A7802A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 14:14:02 2011 New Revision: 125593 URL: http://llvm.org/viewvc/llvm-project?rev=125593&view=rev Log: Fix wrong mask and encoding for T2 of ASR (immediate). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125593&r1=125592&r2=125593&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 14:14:02 2011 @@ -3599,7 +3599,7 @@ { 0xffffff00, 0x00004500, ARMvAll, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateCmpRnRm, "cmp , "}, // asr (immediate) { 0xfffff800, 0x00001000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateASRImm, "asrs|asr , , #imm"}, - { 0x0fef0070, 0x01a00040, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s}.w , , #imm"}, + { 0xffef8030, 0xea4f0020, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s}.w , , #imm"}, //---------------------------------------------------------------------- // Load instructions From johnny.chen at apple.com Tue Feb 15 15:08:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 21:08:58 -0000 Subject: [Lldb-commits] [lldb] r125596 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110215210858.C3FD52A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 15:08:58 2011 New Revision: 125596 URL: http://llvm.org/viewvc/llvm-project?rev=125596&view=rev Log: Remove the "Register ®" parameter from the BXWritePC(), LoadWritePC(), and ALUWritePC() methods of EmulateInstructionARM class. The context data structure should provide sufficient information already. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125596&r1=125595&r2=125596&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Feb 15 15:08:58 2011 @@ -176,7 +176,7 @@ eInfoTypeAddress, eInfoTypeModeAndImmediate, eInfoTypeModeAndImmediateSigned, - eInfoTypeModeAndRegister, + eInfoTypeMode, eInfoTypeNoArgs } InfoType; @@ -232,7 +232,7 @@ struct ModeAndImmediate { uint32_t mode; // eModeARM or eModeThumb - uint32_t data_value; //immdiate data + uint32_t data_value; // immdiate data } ModeAndImmediate; struct ModeAndImmediateSigned @@ -241,11 +241,7 @@ int32_t signed_data_value; // signed immdiate data } ModeAndImmediateSigned; - struct ModeAndRegister - { - uint32_t mode; // eModeARM or eModeThumb - Register reg; - } ModeAndRegister; + uint32_t mode; // eModeARM or eModeThumb } info; @@ -329,11 +325,10 @@ } void - SetModeAndRegister (uint32_t mode, Register reg) + SetMode (uint32_t mode) { - info_type = eInfoTypeModeAndRegister; - info.ModeAndRegister.mode = mode; - info.ModeAndRegister.reg = reg; + info_type = eInfoTypeMode; + info.mode = mode; } void Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125596&r1=125595&r2=125596&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 15:08:58 2011 @@ -427,7 +427,7 @@ if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, dwarf_reg)) + if (!LoadWritePC(context, data)) return false; addr += addr_byte_size; } @@ -628,7 +628,7 @@ if (Rd == 15) { - if (!ALUWritePC (context, reg_value, dwarf_reg)) + if (!ALUWritePC (context, reg_value)) return false; } else @@ -711,12 +711,9 @@ context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - Register dummy_reg; - dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); - if (Rd == 15) { - if (!ALUWritePC (context, result, dummy_reg)) + if (!ALUWritePC (context, result)) return false; } else @@ -801,8 +798,7 @@ if (Rd == 15) { - Register dummy_reg; - if (!ALUWritePC (context, result, dummy_reg)) + if (!ALUWritePC (context, result)) return false; } else @@ -909,7 +905,7 @@ if (Bits32(address, 1, 0) == 0) { // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, pc_reg)) + if (!LoadWritePC(context, data)) return false; } else @@ -1205,7 +1201,7 @@ context.SetRegister (dwarf_reg); if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, lr)) return false; - if (!BXWritePC(context, target, dwarf_reg)) + if (!BXWritePC(context, target)) return false; } return true; @@ -1253,7 +1249,8 @@ Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); - if (!BXWritePC(context, target, dwarf_reg)) + context.SetRegister (dwarf_reg); + if (!BXWritePC(context, target)) return false; } return true; @@ -1964,12 +1961,10 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - Register dummy_reg; - dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); if (Rd == 15) { - if (!ALUWritePC (context, result, dummy_reg)) + if (!ALUWritePC (context, result)) return false; } else @@ -2180,13 +2175,10 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - - Register dummy_reg; - dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); if (Rd == 15) { - if (!ALUWritePC (context, result, dummy_reg)) + if (!ALUWritePC (context, result)) return false; } else @@ -2333,7 +2325,7 @@ if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, dwarf_reg)) + if (!LoadWritePC(context, data)) return false; } @@ -2449,7 +2441,7 @@ if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, dwarf_reg)) + if (!LoadWritePC(context, data)) return false; } @@ -2590,7 +2582,7 @@ if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, dwarf_reg)) + if (!LoadWritePC(context, data)) return false; } @@ -2707,7 +2699,7 @@ if (!success) return false; // In ARMv5T and above, this is an interworking branch. - if (!LoadWritePC(context, data, dwarf_reg)) + if (!LoadWritePC(context, data)) return false; } @@ -2809,8 +2801,6 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - Register dummy_reg; - dummy_reg.SetRegister (eRegisterKindDWARF, dwarf_r0); // Read memory from the address. data = ReadMemoryUnsigned(context, address, 4, 0, &success); @@ -2821,7 +2811,7 @@ { if (Bits32(address, 1, 0) == 0) { - if (!LoadWritePC(context, data, dummy_reg)) + if (!LoadWritePC(context, data)) return false; } else @@ -3831,7 +3821,7 @@ // As a side effect, BXWritePC sets context.arg2 to eModeARM or eModeThumb by inspecting addr. bool -EmulateInstructionARM::BXWritePC (Context &context, uint32_t addr, Register ®) +EmulateInstructionARM::BXWritePC (Context &context, uint32_t addr) { addr_t target; // If the CPSR is changed due to switching between ARM and Thumb ISETSTATE, @@ -3847,7 +3837,7 @@ cpsr_changed = true; } target = addr & 0xfffffffe; - context.SetModeAndRegister (eModeThumb, reg); + context.SetMode (eModeThumb); } else if (BitIsClear(addr, 1)) { @@ -3857,7 +3847,7 @@ cpsr_changed = true; } target = addr & 0xfffffffc; - context.SetModeAndRegister (eModeARM, reg); + context.SetMode (eModeARM); } else return false; // address<1:0> == '10' => UNPREDICTABLE @@ -3875,20 +3865,20 @@ // Dispatches to either BXWritePC or BranchWritePC based on architecture versions. bool -EmulateInstructionARM::LoadWritePC (Context &context, uint32_t addr, Register ®) +EmulateInstructionARM::LoadWritePC (Context &context, uint32_t addr) { if (ArchVersion() >= ARMv5T) - return BXWritePC(context, addr, reg); + return BXWritePC(context, addr); else return BranchWritePC((const Context)context, addr); } // Dispatches to either BXWritePC or BranchWritePC based on architecture versions and current instruction set. bool -EmulateInstructionARM::ALUWritePC (Context &context, uint32_t addr, Register ®) +EmulateInstructionARM::ALUWritePC (Context &context, uint32_t addr) { if (ArchVersion() >= ARMv7 && CurrentInstrSet() == eModeARM) - return BXWritePC(context, addr, reg); + return BXWritePC(context, addr); else return BranchWritePC((const Context)context, addr); } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125596&r1=125595&r2=125596&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 15:08:58 2011 @@ -158,13 +158,13 @@ BranchWritePC(const Context &context, uint32_t addr); bool - BXWritePC(Context &context, uint32_t addr, Register ®); + BXWritePC(Context &context, uint32_t addr); bool - LoadWritePC(Context &context, uint32_t addr, Register ®); + LoadWritePC(Context &context, uint32_t addr); bool - ALUWritePC(Context &context, uint32_t addr, Register ®); + ALUWritePC(Context &context, uint32_t addr); Mode CurrentInstrSet(); From gclayton at apple.com Tue Feb 15 15:59:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Feb 2011 21:59:32 -0000 Subject: [Lldb-commits] [lldb] r125602 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Host/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/xcshareddata/xcschemes/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Host/common/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Instruction/ARM/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/ObjectFile/ELF/ source/Plugins... Message-ID: <20110215215933.350022A6C12C@llvm.org> Author: gclayton Date: Tue Feb 15 15:59:32 2011 New Revision: 125602 URL: http://llvm.org/viewvc/llvm-project?rev=125602&view=rev Log: Made lldb_private::ArchSpec contain much more than just an architecture. It now, in addition to cpu type/subtype and architecture flavor, contains: - byte order (big endian, little endian) - address size in bytes - llvm::Triple for true target triple support and for more powerful plug-in selection. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/include/lldb/Expression/ClangExpressionParser.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/ObjectFile.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/UnwindTable.cpp lldb/trunk/source/Target/ABI.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Tue Feb 15 15:59:32 2011 @@ -13,6 +13,7 @@ #if defined(__cplusplus) #include "lldb/lldb-private.h" +#include "llvm/ADT/Triple.h" namespace lldb_private { @@ -40,6 +41,9 @@ eCPU_ppc64, eCPU_sparc }; + + static void + Initialize(); //------------------------------------------------------------------ /// Default constructor. @@ -140,6 +144,11 @@ uint32_t GetAddressByteSize () const; + void + SetAddressByteSize (uint32_t byte_size) + { + m_addr_byte_size = byte_size; + } CPU GetGenericCPUType () const; @@ -262,11 +271,42 @@ /// @param[in] subtype The new CPU subtype //------------------------------------------------------------------ void - SetMachOArch (uint32_t cpu, uint32_t sub) + SetMachOArch (uint32_t cpu, uint32_t sub); + + //------------------------------------------------------------------ + /// Returns the byte order for the architecture specification. + /// + /// @return The endian enumeration for the current endianness of + /// the architecture specification + //------------------------------------------------------------------ + lldb::ByteOrder + GetByteOrder () const { - m_type = lldb::eArchTypeMachO; - m_cpu = cpu; - m_sub = sub; + return m_byte_order; + } + + void + SetByteOrder (lldb::ByteOrder b) + { + m_byte_order = b; + } + + llvm::Triple & + GetTriple () + { + return m_triple; + } + + const llvm::Triple & + GetTriple () const + { + return m_triple; + } + + void + SetTriple (const llvm::Triple &triple) + { + m_triple = triple; } void @@ -301,6 +341,17 @@ // m_type => eArchTypeMachO eArchTypeELF uint32_t m_cpu; // cpu type ELF header e_machine uint32_t m_sub; // cpu subtype nothing + llvm::Triple m_triple; + lldb::ByteOrder m_byte_order; + uint32_t m_addr_byte_size; + +private: + + void + MachOArchUpdated (size_t macho_idx = SIZE_T_MAX); + + void + ELFArchUpdated (size_t idx = SIZE_T_MAX); }; Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Feb 15 15:59:32 2011 @@ -81,7 +81,7 @@ public: static EmulateInstruction* - FindPlugin (const ConstString &triple, const char *plugin_name); + FindPlugin (const ArchSpec &arch, const char *plugin_name); enum ContextType { @@ -403,7 +403,7 @@ } virtual bool - SetTargetTriple (const ConstString &triple) = 0; + SetTargetTriple (const ArchSpec &arch) = 0; virtual bool ReadInstruction () = 0; Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Tue Feb 15 15:59:32 2011 @@ -11,6 +11,7 @@ #define liblldb_ClangExpressionParser_h_ #include "lldb/lldb-include.h" +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/Error.h" @@ -40,19 +41,15 @@ /// /// Initializes class variabes. /// - /// @param[in] target_triple - /// The LLVM-friendly target triple for use in initializing the - /// compiler. - /// - /// @param[in process - /// If non-NULL, the process to customize the expression for - /// (e.g., by tuning Objective-C runtime support). May be NULL. + /// @param[in] exe_scope, + /// If non-NULL, an execution context scope that can help to + /// correctly create an expression with a valid process for + /// optional tuning Objective-C runtime support. Can be NULL. /// /// @param[in] expr /// The expression to be parsed. //------------------------------------------------------------------ - ClangExpressionParser (const char *target_triple, - Process *process, + ClangExpressionParser (ExecutionContextScope *exe_scope, ClangExpression &expr); //------------------------------------------------------------------ @@ -181,7 +178,6 @@ ClangExpression &m_expr; ///< The expression to be parsed - std::string m_target_triple; ///< The target triple used to initialize LLVM std::auto_ptr m_file_manager; ///< The Clang file manager object used by the compiler std::auto_ptr m_compiler; ///< The Clang compiler used to parse expressions into IR std::auto_ptr m_builtin_context; ///< Context for Clang built-ins Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Tue Feb 15 15:59:32 2011 @@ -18,6 +18,7 @@ // Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Address.h" +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Expression/ClangExpression.h" @@ -69,9 +70,9 @@ //------------------------------------------------------------------ /// Constructor /// - /// @param[in] target_triple - /// The LLVM-style target triple for the target in which the - /// function is to be executed. + /// @param[in] exe_scope + /// An execution context scope that gets us a target and/or + /// process (possibly neither.). /// /// @param[in] function_ptr /// The default function to be called. Can be overridden using @@ -84,17 +85,17 @@ /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). //------------------------------------------------------------------ - ClangFunction(const char *target_triple, - Function &function_ptr, - ClangASTContext *ast_context, - const ValueList &arg_value_list); + ClangFunction (ExecutionContextScope *exe_scope, + Function &function_ptr, + ClangASTContext *ast_context, + const ValueList &arg_value_list); //------------------------------------------------------------------ /// Constructor /// - /// @param[in] target_triple - /// The LLVM-style target triple for the target in which the - /// function is to be executed. + /// @param[in] exe_scope + /// An execution context scope that gets us a target and/or + /// process (possibly neither.). /// /// @param[in] ast_context /// The AST context to evaluate argument types in. @@ -110,11 +111,11 @@ /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). //------------------------------------------------------------------ - ClangFunction(const char *target_triple, - ClangASTContext *ast_context, - void *return_qualtype, - const Address& function_address, - const ValueList &arg_value_list); + ClangFunction (ExecutionContextScope *exe_scope, + ClangASTContext *ast_context, + void *return_qualtype, + const Address& function_address, + const ValueList &arg_value_list); //------------------------------------------------------------------ /// Destructor @@ -613,7 +614,7 @@ Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type. void *m_function_return_qual_type; ///< The opaque clang qual type for the function return type. ClangASTContext *m_clang_ast_context; ///< This is the clang_ast_context that we're getting types from the and value, and the function return the function pointer is NULL. - std::string m_target_triple; ///< The target triple to compile the wrapper function for. + ArchSpec m_arch; ///< The target triple to compile the wrapper function for. std::string m_wrapper_function_name; ///< The name of the wrapper function. std::string m_wrapper_function_text; ///< The contents of the wrapper function. Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Feb 15 15:59:32 2011 @@ -97,14 +97,21 @@ GetByteOrder (); //------------------------------------------------------------------ - /// Gets the host kernel architecture. + /// Gets the host architecture. /// /// @return - /// A const architecture object that represents the host kernel + /// A const architecture object that represents the host /// architecture. //------------------------------------------------------------------ + enum SystemDefaultArchitecture + { + eSystemDefaultArchitecture, // The overall default architecture that applications will run on this host + eSystemDefaultArchitecture32, // If this host supports 32 bit programs, return the default 32 bit arch + eSystemDefaultArchitecture64 // If this host supports 64 bit programs, return the default 64 bit arch + }; + static const ArchSpec & - GetArchitecture (); + GetArchitecture (SystemDefaultArchitecture arch_kind = eSystemDefaultArchitecture); //------------------------------------------------------------------ /// Gets the host vendor string. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Feb 15 15:59:32 2011 @@ -104,6 +104,9 @@ void SetTargetTriple (const char *target_triple); + void + SetArchitecture (const ArchSpec &arch); + bool HasExternalSource (); Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Feb 15 15:59:32 2011 @@ -238,7 +238,7 @@ /// false otherwise. //------------------------------------------------------------------ virtual bool - GetTargetTriple(ConstString &target_triple) = 0; + GetArchitecture (ArchSpec &arch) = 0; //------------------------------------------------------------------ /// Gets the section list for the currently selected architecture Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Tue Feb 15 15:59:32 2011 @@ -47,7 +47,7 @@ Value &value) const = 0; static ABI* - FindPlugin (const ConstString &triple); + FindPlugin (const ArchSpec &arch); protected: //------------------------------------------------------------------ // Classes that inherit from ABI can see and modify these Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Feb 15 15:59:32 2011 @@ -417,6 +417,7 @@ void UpdateInstanceName (); + //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. //------------------------------------------------------------------ @@ -474,6 +475,12 @@ int signo, // Zero for no signal int status); // Exit value of process if signal is zero + lldb::ByteOrder + GetByteOrder () const; + + uint32_t + GetAddressByteSize () const; + //------------------------------------------------------------------ /// Check if a plug-in instance can debug the file in \a module. /// @@ -649,15 +656,6 @@ virtual ArchSpec GetArchSpecForExistingProcess (const char *process_name); - uint32_t - GetAddressByteSize(); - - void - SetAddressByteSize (uint32_t addr_byte_size) - { - m_addr_byte_size = addr_byte_size; - } - //------------------------------------------------------------------ /// Get the image information address for the current process. /// @@ -821,8 +819,10 @@ Signal (int signal); virtual UnixSignals & - GetUnixSignals (); - + GetUnixSignals () + { + return m_unix_signals; + } //================================================================== // Plug-in Process Control Overrides @@ -1179,7 +1179,10 @@ /// module. //------------------------------------------------------------------ Target & - GetTarget (); + GetTarget () + { + return m_target; + } //------------------------------------------------------------------ /// Get the const target object pointer for this module. @@ -1189,7 +1192,11 @@ /// module. //------------------------------------------------------------------ const Target & - GetTarget () const; + GetTarget () const + { + return m_target; + } + //------------------------------------------------------------------ /// Get accessor for the current process state. @@ -1652,10 +1659,16 @@ UpdateThreadListIfNeeded () = 0; ThreadList & - GetThreadList (); + GetThreadList () + { + return m_thread_list; + } const ThreadList & - GetThreadList () const; + GetThreadList () const + { + return m_thread_list; + } uint32_t GetNextThreadIndexID (); @@ -1739,30 +1752,6 @@ ShouldBroadcastEvent (Event *event_ptr); public: - //------------------------------------------------------------------ - /// Gets the byte order for this process. - /// - /// @return - /// A valid ByteOrder enumeration, or eByteOrderInvalid. - //------------------------------------------------------------------ - lldb::ByteOrder - GetByteOrder () const - { - return m_byte_order; - } - - void - SetByteOrder (lldb::ByteOrder byte_order) - { - m_byte_order = byte_order; - } - - const ConstString & - GetTargetTriple () - { - return m_target_triple; - } - const ABI * GetABI (); @@ -1807,16 +1796,28 @@ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ virtual Target * - CalculateTarget (); + CalculateTarget () + { + return &m_target; + } virtual Process * - CalculateProcess (); + CalculateProcess () + { + return this; + } virtual Thread * - CalculateThread (); + CalculateThread () + { + return NULL; + } virtual StackFrame * - CalculateStackFrame (); + CalculateStackFrame () + { + return NULL; + } virtual void CalculateExecutionContext (ExecutionContext &exe_ctx); @@ -1941,9 +1942,6 @@ ///< to insert in the target. std::auto_ptr m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. UnixSignals m_unix_signals; /// This is the current signal set for this process. - ConstString m_target_triple; - lldb::ByteOrder m_byte_order; /// The byte order of the process. Should be set in DidLaunch/DidAttach. - uint32_t m_addr_byte_size; /// The size in bytes of an address/pointer for the inferior process. Should be set in DidLaunch/DidAttach. lldb::ABISP m_abi_sp; lldb::InputReaderSP m_process_input_reader; lldb_private::Communication m_stdio_communication; Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Feb 15 15:59:32 2011 @@ -365,10 +365,28 @@ /// A list of Module objects in a module list. //------------------------------------------------------------------ ModuleList& - GetImages (); + GetImages () + { + return m_images; + } + + const ModuleList& + GetImages () const + { + return m_images; + } - ArchSpec - GetArchitecture () const; + ArchSpec & + GetArchitecture () + { + return m_arch_spec; + } + + const ArchSpec & + GetArchitecture () const + { + return m_arch_spec; + } //------------------------------------------------------------------ /// Set the architecture for this target. @@ -397,9 +415,6 @@ return m_debugger; } - bool - GetTargetTriple (ConstString &target_triple); - size_t ReadMemoryFromFileCache (const Address& addr, void *dst, @@ -505,7 +520,6 @@ // we can correctly tear down everything that we need to, so the only // class that knows about the process lifespan is this target class. lldb::ProcessSP m_process_sp; - ConstString m_triple; ///< The target triple ("x86_64-apple-darwin10") lldb::SearchFilterSP m_search_filter_sp; PathMappingList m_image_search_paths; std::auto_ptr m_scratch_ast_context_ap; Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Tue Feb 15 15:59:32 2011 @@ -16,13 +16,13 @@ namespace lldb_private { - typedef ABI* (*ABICreateInstance) (const ConstString &triple); + typedef ABI* (*ABICreateInstance) (const ArchSpec &arch); typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch); typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process); typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length); typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length); typedef LogChannel* (*LogChannelCreateInstance) (); - typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ConstString &triple); + typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch); typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language); typedef Process* (*ProcessCreateInstance) (Target &target, Listener &listener); typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file); Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Feb 15 15:59:32 2011 @@ -31,6 +31,10 @@ + + @@ -89,6 +93,10 @@ argument = "/Volumes/work/gclayton/Documents/src/attach/a.out" isEnabled = "YES"> + + + + Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Tue Feb 15 15:59:32 2011 @@ -371,7 +371,7 @@ { uint32_t size = 0; if (m_opaque_sp) - size = m_opaque_sp->GetAddressByteSize(); + size = m_opaque_sp->GetTarget().GetArchitecture().GetAddressByteSize(); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Feb 15 15:59:32 2011 @@ -342,7 +342,7 @@ int addr_size = sizeof (addr_t); Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) - addr_size = process->GetAddressByteSize(); + addr_size = process->GetTarget().GetArchitecture().GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) strm.Address (vm_addr, addr_size); else Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Feb 15 15:59:32 2011 @@ -260,7 +260,7 @@ if (item_byte_size == 0) { if (m_options.m_format == eFormatPointer) - item_byte_size = process->GetAddressByteSize(); + item_byte_size = process->GetTarget().GetArchitecture().GetAddressByteSize(); else item_byte_size = 1; } @@ -334,7 +334,9 @@ result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr); result.SetStatus(eReturnStatusSuccessFinishResult); - DataExtractor data(data_sp, process->GetByteOrder(), process->GetAddressByteSize()); + DataExtractor data (data_sp, + process->GetTarget().GetArchitecture().GetByteOrder(), + process->GetTarget().GetArchitecture().GetAddressByteSize()); StreamFile outfile_stream; Stream *output_stream = NULL; @@ -616,8 +618,8 @@ } StreamString buffer (Stream::eBinary, - process->GetAddressByteSize(), - process->GetByteOrder()); + process->GetTarget().GetArchitecture().GetAddressByteSize(), + process->GetTarget().GetArchitecture().GetByteOrder()); size_t item_byte_size = m_options.m_byte_size; Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Feb 15 15:59:32 2011 @@ -328,6 +328,10 @@ if (synchronous_execution) { state = process->WaitForProcessToStop (NULL); + if (!StateIsStoppedState(state)); + { + result.AppendErrorWithFormat ("Process isn't stopped: %s", StateAsCString(state)); + } result.SetDidChangeProcessState (true); result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -336,9 +340,24 @@ result.SetStatus (eReturnStatusSuccessContinuingNoResult); } } + else + { + result.AppendErrorWithFormat ("Process resume at entry point failed: %s", error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } } + else + { + result.AppendErrorWithFormat ("Initial process state wasn't stopped: %s", StateAsCString(state)); + result.SetStatus (eReturnStatusFailed); + } } } + else + { + result.AppendErrorWithFormat ("Process launch failed: %s", error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } return result.Succeeded(); } Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue Feb 15 15:59:32 2011 @@ -42,11 +42,11 @@ if (exe_scope == NULL) return false; - Process *process = exe_scope->CalculateProcess(); - if (process) + Target *target = exe_scope->CalculateTarget(); + if (target) { - byte_order = process->GetByteOrder(); - addr_size = process->GetAddressByteSize(); + byte_order = target->GetArchitecture().GetByteOrder(); + addr_size = target->GetArchitecture().GetAddressByteSize(); } if (byte_order == eByteOrderInvalid || addr_size == 0) @@ -54,7 +54,7 @@ Module *module = address.GetModule(); if (module) { - byte_order = module->GetArchitecture().GetDefaultEndian(); + byte_order = module->GetArchitecture().GetByteOrder(); addr_size = module->GetArchitecture().GetAddressByteSize(); } } @@ -313,7 +313,7 @@ if (addr_size == UINT32_MAX) { if (process) - addr_size = process->GetAddressByteSize (); + addr_size = target->GetArchitecture().GetAddressByteSize (); else addr_size = sizeof(addr_t); } @@ -387,8 +387,8 @@ uint32_t pointer_size = 4; Module *module = GetModule(); - if (process) - pointer_size = process->GetAddressByteSize(); + if (target) + pointer_size = target->GetArchitecture().GetAddressByteSize(); else if (module) pointer_size = module->GetArchitecture().GetAddressByteSize(); Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Tue Feb 15 15:59:32 2011 @@ -143,8 +143,8 @@ { addr_t vmaddr = LLDB_INVALID_ADDRESS; int addr_size = sizeof (addr_t); - if (target && target->GetProcessSP()) - addr_size = target->GetProcessSP()->GetAddressByteSize (); + if (target) + addr_size = target->GetArchitecture().GetAddressByteSize (); bool show_module = false; switch (style) Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Tue Feb 15 15:59:32 2011 @@ -15,6 +15,8 @@ #include "llvm/Support/ELF.h" #include "llvm/Support/MachO.h" +#include "lldb/Host/Endian.h" +#include "lldb/Host/Host.h" using namespace lldb; using namespace lldb_private; @@ -28,6 +30,8 @@ //---------------------------------------------------------------------- struct ArchDefinition { + ByteOrder byte_order; + uint32_t addr_byte_size; uint32_t cpu; uint32_t sub; const char *name; @@ -52,54 +56,36 @@ //---------------------------------------------------------------------- static ArchDefinition g_mach_arch_defs[] = { - { CPU_ANY, CPU_ANY , "all" }, - { llvm::MachO::CPUTypeARM, CPU_ANY , "arm" }, - { llvm::MachO::CPUTypeARM, 0 , "arm" }, - { llvm::MachO::CPUTypeARM, 5 , "armv4" }, - { llvm::MachO::CPUTypeARM, 6 , "armv6" }, - { llvm::MachO::CPUTypeARM, 7 , "armv5" }, - { llvm::MachO::CPUTypeARM, 8 , "xscale" }, - { llvm::MachO::CPUTypeARM, 9 , "armv7" }, - { llvm::MachO::CPUTypePowerPC, CPU_ANY , "ppc" }, - { llvm::MachO::CPUTypePowerPC, 0 , "ppc" }, - { llvm::MachO::CPUTypePowerPC, 1 , "ppc601" }, - { llvm::MachO::CPUTypePowerPC, 2 , "ppc602" }, - { llvm::MachO::CPUTypePowerPC, 3 , "ppc603" }, - { llvm::MachO::CPUTypePowerPC, 4 , "ppc603e" }, - { llvm::MachO::CPUTypePowerPC, 5 , "ppc603ev" }, - { llvm::MachO::CPUTypePowerPC, 6 , "ppc604" }, - { llvm::MachO::CPUTypePowerPC, 7 , "ppc604e" }, - { llvm::MachO::CPUTypePowerPC, 8 , "ppc620" }, - { llvm::MachO::CPUTypePowerPC, 9 , "ppc750" }, - { llvm::MachO::CPUTypePowerPC, 10 , "ppc7400" }, - { llvm::MachO::CPUTypePowerPC, 11 , "ppc7450" }, - { llvm::MachO::CPUTypePowerPC, 100 , "ppc970" }, - { llvm::MachO::CPUTypePowerPC64, 0 , "ppc64" }, - { llvm::MachO::CPUTypePowerPC64, 100 , "ppc970-64" }, - { llvm::MachO::CPUTypeI386, 3 , "i386" }, - { llvm::MachO::CPUTypeI386, 4 , "i486" }, - { llvm::MachO::CPUTypeI386, 0x84 , "i486sx" }, - { llvm::MachO::CPUTypeI386, CPU_ANY , "i386" }, - { llvm::MachO::CPUTypeX86_64, 3 , "x86_64" }, - { llvm::MachO::CPUTypeX86_64, CPU_ANY , "x86_64" }, - - // TODO: when we get a platform that knows more about the host OS we should - // let it call some accessor funcitons to set the default system arch for - // the default, 32 and 64 bit cases instead of hard coding it in this - // table. - -#if defined (__i386__) || defined(__x86_64__) - { llvm::MachO::CPUTypeX86_64, 3 , LLDB_ARCH_DEFAULT }, - { llvm::MachO::CPUTypeI386, 3 , LLDB_ARCH_DEFAULT_32BIT }, - { llvm::MachO::CPUTypeX86_64, 3 , LLDB_ARCH_DEFAULT_64BIT }, -#elif defined (__arm__) - { llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT }, - { llvm::MachO::CPUTypeARM, 6 , LLDB_ARCH_DEFAULT_32BIT }, -#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) - { llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT }, - { llvm::MachO::CPUTypePowerPC, 10 , LLDB_ARCH_DEFAULT_32BIT }, - { llvm::MachO::CPUTypePowerPC64, 100 , LLDB_ARCH_DEFAULT_64BIT }, -#endif + { eByteOrderInvalid, 0, CPU_ANY, CPU_ANY , "all" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, CPU_ANY , "arm" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 0 , "arm" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 5 , "armv4" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 6 , "armv6" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 7 , "armv5" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 8 , "xscale" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeARM, 9 , "armv7" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, CPU_ANY , "ppc" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 0 , "ppc" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 1 , "ppc601" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 2 , "ppc602" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 3 , "ppc603" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 4 , "ppc603e" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 5 , "ppc603ev" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 6 , "ppc604" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 7 , "ppc604e" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 8 , "ppc620" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 9 , "ppc750" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 10 , "ppc7400" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 11 , "ppc7450" }, + { eByteOrderBig, 4, llvm::MachO::CPUTypePowerPC, 100 , "ppc970" }, + { eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 0 , "ppc64" }, + { eByteOrderBig, 8, llvm::MachO::CPUTypePowerPC64, 100 , "ppc970-64" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 3 , "i386" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 4 , "i486" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, 0x84 , "i486sx" }, + { eByteOrderLittle, 4, llvm::MachO::CPUTypeI386, CPU_ANY , "i386" }, + { eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, 3 , "x86_64" }, + { eByteOrderLittle, 8, llvm::MachO::CPUTypeX86_64, CPU_ANY , "x86_64" }, }; //---------------------------------------------------------------------- @@ -118,33 +104,20 @@ //---------------------------------------------------------------------- static ArchDefinition g_elf_arch_defs[] = { - { llvm::ELF::EM_M32 , 0, "m32" }, // AT&T WE 32100 - { llvm::ELF::EM_SPARC , 0, "sparc" }, // AT&T WE 32100 - { llvm::ELF::EM_386 , 0, "i386" }, // Intel 80386 - { llvm::ELF::EM_68K , 0, "68k" }, // Motorola 68000 - { llvm::ELF::EM_88K , 0, "88k" }, // Motorola 88000 - { llvm::ELF::EM_486 , 0, "i486" }, // Intel 486 (deprecated) - { llvm::ELF::EM_860 , 0, "860" }, // Intel 80860 - { llvm::ELF::EM_MIPS , 0, "rs3000" }, // MIPS RS3000 - { llvm::ELF::EM_PPC , 0, "ppc" }, // PowerPC - { 21 , 0, "ppc64" }, // PowerPC64 - { llvm::ELF::EM_ARM , 0, "arm" }, // ARM - { llvm::ELF::EM_ALPHA , 0, "alpha" }, // DEC Alpha - { llvm::ELF::EM_SPARCV9, 0, "sparc9" }, // SPARC V9 - { llvm::ELF::EM_X86_64 , 0, "x86_64" }, // AMD64 - -#if defined (__i386__) || defined(__x86_64__) - { llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT }, - { llvm::ELF::EM_386 , 0, LLDB_ARCH_DEFAULT_32BIT }, - { llvm::ELF::EM_X86_64 , 0, LLDB_ARCH_DEFAULT_64BIT }, -#elif defined (__arm__) - { llvm::ELF::EM_ARM , 0, LLDB_ARCH_DEFAULT }, - { llvm::ELF::EM_ARM , 0, LLDB_ARCH_DEFAULT_32BIT }, -#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) - { llvm::ELF::EM_PPC , 0, LLDB_ARCH_DEFAULT }, - { llvm::ELF::EM_PPC , 0, LLDB_ARCH_DEFAULT_32BIT }, - { llvm::ELF::EM_PPC64 , 0, LLDB_ARCH_DEFAULT_64BIT }, -#endif + { eByteOrderInvalid, 0, llvm::ELF::EM_M32 , 0, "m32" }, // AT&T WE 32100 + { eByteOrderBig, 4, llvm::ELF::EM_SPARC , 0, "sparc" }, // Sparc + { eByteOrderLittle, 4, llvm::ELF::EM_386 , 0, "i386" }, // Intel 80386 + { eByteOrderBig, 4, llvm::ELF::EM_68K , 0, "68k" }, // Motorola 68000 + { eByteOrderBig, 4, llvm::ELF::EM_88K , 0, "88k" }, // Motorola 88000 + { eByteOrderLittle, 4, llvm::ELF::EM_486 , 0, "i486" }, // Intel 486 (deprecated) + { eByteOrderLittle, 4, llvm::ELF::EM_860 , 0, "860" }, // Intel 80860 + { eByteOrderBig, 4, llvm::ELF::EM_MIPS , 0, "rs3000" }, // MIPS RS3000 + { eByteOrderBig, 4, llvm::ELF::EM_PPC , 0, "ppc" }, // PowerPC + { eByteOrderBig, 8, 21 , 0, "ppc64" }, // PowerPC64 + { eByteOrderLittle, 4, llvm::ELF::EM_ARM , 0, "arm" }, // ARM + { eByteOrderLittle, 4, llvm::ELF::EM_ALPHA , 0, "alpha" }, // DEC Alpha + { eByteOrderLittle, 4, llvm::ELF::EM_SPARCV9, 0, "sparc9" }, // SPARC V9 + { eByteOrderLittle, 8, llvm::ELF::EM_X86_64 , 0, "x86_64" }, // AMD64 }; //---------------------------------------------------------------------- @@ -158,7 +131,10 @@ ArchSpec::ArchSpec() : m_type (eArchTypeMachO), // Use the most complete arch definition which will always be translatable to any other ArchitectureType values m_cpu (LLDB_INVALID_CPUTYPE), - m_sub (0) + m_sub (0), + m_triple (), + m_byte_order (lldb::endian::InlHostByteOrder()), + m_addr_byte_size (0) { } @@ -169,31 +145,38 @@ ArchSpec::ArchSpec (lldb::ArchitectureType arch_type, uint32_t cpu, uint32_t sub) : m_type (arch_type), m_cpu (cpu), - m_sub (sub) + m_sub (sub), + m_triple (), + m_byte_order (lldb::endian::InlHostByteOrder()), + m_addr_byte_size (0) { + if (m_type == eArchTypeMachO) + MachOArchUpdated (); } //---------------------------------------------------------------------- // Constructor that initializes the object with supplied // architecture name. There are also predefined values in // Defines.h: -// liblldb_ARCH_DEFAULT +// LLDB_ARCH_DEFAULT // The arch the current system defaults to when a program is // launched without any extra attributes or settings. // -// liblldb_ARCH_DEFAULT_32BIT +// LLDB_ARCH_DEFAULT_32BIT // The 32 bit arch the current system defaults to (if any) // -// liblldb_ARCH_DEFAULT_32BIT +// LLDB_ARCH_DEFAULT_32BIT // The 64 bit arch the current system defaults to (if any) //---------------------------------------------------------------------- ArchSpec::ArchSpec (const char *arch_name) : m_type (eArchTypeMachO), // Use the most complete arch definition which will always be translatable to any other ArchitectureType values m_cpu (LLDB_INVALID_CPUTYPE), - m_sub (0) + m_sub (0), + m_triple (), + m_byte_order (lldb::endian::InlHostByteOrder()), + m_addr_byte_size (0) { - if (arch_name) - SetArch (arch_name); + SetArch (arch_name); } //---------------------------------------------------------------------- @@ -214,6 +197,9 @@ m_type = rhs.m_type; m_cpu = rhs.m_cpu; m_sub = rhs.m_sub; + m_triple = rhs.m_triple; + m_byte_order = rhs.m_byte_order; + m_addr_byte_size = rhs.m_addr_byte_size; } return *this; } @@ -294,6 +280,9 @@ m_type = eArchTypeInvalid; m_cpu = LLDB_INVALID_CPUTYPE; m_sub = 0; + m_triple = llvm::Triple(); + m_byte_order = lldb::endian::InlHostByteOrder(); + m_addr_byte_size = 0; } @@ -1605,6 +1594,9 @@ uint32_t ArchSpec::GetAddressByteSize() const { + if (m_addr_byte_size > 0) + return m_addr_byte_size; + switch (m_type) { case kNumArchTypes: @@ -1639,7 +1631,6 @@ } break; } - return 0; } @@ -1667,6 +1658,105 @@ } return SetArch (target_triple); } +void +ArchSpec::SetMachOArch (uint32_t cpu, uint32_t sub) +{ + m_type = lldb::eArchTypeMachO; + m_cpu = cpu; + m_sub = sub; + MachOArchUpdated (); +} + +void +ArchSpec::MachOArchUpdated (size_t idx) +{ + // m_type, m_cpu, and m_sub have been updated, fixup everything else + if (idx >= k_num_mach_arch_defs) + { + for (size_t i=0; i= k_num_elf_arch_defs) + { + for (size_t i=0; iprocess) - addr_width = exe_ctx->process->GetAddressByteSize() * 2; + int addr_width = target->GetArchitecture().GetAddressByteSize() * 2; if (addr_width == 0) addr_width = 16; s.Printf("0x%*.*llx", addr_width, addr_width, vaddr); Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Tue Feb 15 15:59:32 2011 @@ -436,16 +436,8 @@ heap_buffer->SetByteSize (bytes_read); data.SetData(data_sp); - if (exe_ctx->process) - { - data.SetByteOrder(exe_ctx->process->GetByteOrder()); - data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize()); - } - else - { - data.SetByteOrder(target->GetArchitecture().GetDefaultEndian()); - data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); - } + data.SetByteOrder(target->GetArchitecture().GetByteOrder()); + data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX); } Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Tue Feb 15 15:59:32 2011 @@ -17,7 +17,7 @@ using namespace lldb_private; EmulateInstruction* -EmulateInstruction::FindPlugin (const ConstString &triple, const char *plugin_name) +EmulateInstruction::FindPlugin (const ArchSpec &arch, const char *plugin_name) { EmulateInstructionCreateInstance create_callback = NULL; if (plugin_name) @@ -25,7 +25,7 @@ create_callback = PluginManager::GetEmulateInstructionCreateCallbackForPluginName (plugin_name); if (create_callback) { - std::auto_ptr instance_ap(create_callback(triple)); + std::auto_ptr instance_ap(create_callback(arch)); if (instance_ap.get()) return instance_ap.release(); } @@ -34,7 +34,7 @@ { for (uint32_t idx = 0; (create_callback = PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) != NULL; ++idx) { - std::auto_ptr instance_ap(create_callback(triple)); + std::auto_ptr instance_ap(create_callback(arch)); if (instance_ap.get()) return instance_ap.release(); } Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Feb 15 15:59:32 2011 @@ -102,11 +102,11 @@ if (m_did_init_ast == false) { ObjectFile * objfile = GetObjectFile(); - ConstString target_triple; - if (objfile && objfile->GetTargetTriple(target_triple)) + ArchSpec object_arch; + if (objfile && objfile->GetArchitecture(object_arch)) { m_did_init_ast = true; - m_ast.SetTargetTriple (target_triple.AsCString()); + m_ast.SetArchitecture (object_arch); } } return m_ast; Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Tue Feb 15 15:59:32 2011 @@ -25,6 +25,7 @@ #include "lldb/Symbol/Variable.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -542,8 +543,8 @@ { address = m_value.ULongLong(LLDB_INVALID_ADDRESS); address_type = eAddressTypeLoad; - data.SetByteOrder(exe_ctx->process->GetByteOrder()); - data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize()); + data.SetByteOrder(exe_ctx->process->GetTarget().GetArchitecture().GetByteOrder()); + data.SetAddressByteSize(exe_ctx->process->GetTarget().GetArchitecture().GetAddressByteSize()); } break; @@ -570,8 +571,8 @@ if (address != LLDB_INVALID_ADDRESS) { address_type = eAddressTypeLoad; - data.SetByteOrder(exe_ctx->process->GetByteOrder()); - data.SetAddressByteSize(exe_ctx->process->GetAddressByteSize()); + data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder()); + data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize()); } else { Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Tue Feb 15 15:59:32 2011 @@ -104,10 +104,10 @@ lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; ExecutionContext exe_ctx (exe_scope); - if (exe_ctx.process) + if (exe_ctx.target) { - m_data.SetByteOrder(exe_ctx.process->GetByteOrder()); - m_data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize()); + m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); } if (expr.IsLocationList()) Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Feb 15 15:59:32 2011 @@ -178,11 +178,9 @@ // Implementation of ClangExpressionParser //===----------------------------------------------------------------------===// -ClangExpressionParser::ClangExpressionParser(const char *target_triple, - Process *process, - ClangExpression &expr) : - m_expr(expr), - m_target_triple (), +ClangExpressionParser::ClangExpressionParser (ExecutionContextScope *exe_scope, + ClangExpression &expr) : + m_expr (expr), m_compiler (), m_code_generator (NULL), m_execution_engine (), @@ -195,12 +193,7 @@ llvm::InitializeAllAsmPrinters(); } } InitializeLLVM; - - if (target_triple && target_triple[0]) - m_target_triple = target_triple; - else - m_target_triple = llvm::sys::getHostTriple(); - + // 1. Create a new compiler instance. m_compiler.reset(new CompilerInstance()); m_compiler->setLLVMContext(new LLVMContext()); @@ -215,6 +208,10 @@ m_compiler->getLangOpts().ObjC1 = true; m_compiler->getLangOpts().ObjC2 = true; + Process *process = NULL; + if (exe_scope) + process = exe_scope->CalculateProcess(); + if (process) { if (process->GetObjCLanguageRuntime()) @@ -239,7 +236,19 @@ m_compiler->getDiagnosticOpts().Warnings.push_back("no-unused-value"); // Set the target triple. - m_compiler->getTargetOpts().Triple = m_target_triple; + Target *target = NULL; + if (exe_scope) + target = exe_scope->CalculateTarget(); + + // TODO: figure out what to really do when we don't have a valid target. + // Sometimes this will be ok to just use the host target triple (when we + // evaluate say "2+3", but other expressions like breakpoint conditions + // and other things that _are_ target specific really shouldn't just be + // using the host triple. This needs to be fixed in a better way. + if (target && target->GetArchitecture().IsValid()) + m_compiler->getTargetOpts().Triple = target->GetArchitecture().GetTriple().str(); + else + m_compiler->getTargetOpts().Triple = llvm::sys::getHostTriple(); // 3. Set up various important bits of infrastructure. m_compiler->createDiagnostics(0, 0); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Feb 15 15:59:32 2011 @@ -17,6 +17,7 @@ #include "clang/CodeGen/ModuleBuilder.h" #include "clang/Frontend/CompilerInstance.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Triple.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Module.h" @@ -36,6 +37,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanCallFunction.h" @@ -48,13 +50,13 @@ //---------------------------------------------------------------------- ClangFunction::ClangFunction ( - const char *target_triple, + ExecutionContextScope *exe_scope, ClangASTContext *ast_context, void *return_qualtype, const Address& functionAddress, const ValueList &arg_value_list ) : - m_target_triple (target_triple), + m_arch (), m_function_ptr (NULL), m_function_addr (functionAddress), m_function_return_qual_type(return_qualtype), @@ -66,16 +68,22 @@ m_compiled (false), m_JITted (false) { + if (exe_scope) + { + Target *target = exe_scope->CalculateTarget(); + if (target) + m_arch = target->GetArchitecture(); + } } ClangFunction::ClangFunction ( - const char *target_triple, + ExecutionContextScope *exe_scope, Function &function, ClangASTContext *ast_context, const ValueList &arg_value_list ) : - m_target_triple (target_triple), + m_arch (), m_function_ptr (&function), m_function_addr (), m_function_return_qual_type (), @@ -87,6 +95,13 @@ m_compiled (false), m_JITted (false) { + if (exe_scope) + { + Target *target = exe_scope->CalculateTarget(); + if (target) + m_arch = target->GetArchitecture(); + } + m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType(); } @@ -212,7 +227,7 @@ // Okay, now compile this expression - m_parser.reset(new ClangExpressionParser(m_target_triple.c_str(), NULL, *this)); + m_parser.reset(new ClangExpressionParser(NULL, *this)); num_errors = m_parser->Parse (errors); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Feb 15 15:59:32 2011 @@ -234,19 +234,6 @@ return false; } - ConstString target_triple; - - target->GetTargetTriple (target_triple); - - if (!target_triple) - target_triple = Host::GetTargetTriple (); - - if (!target_triple) - { - error_stream.PutCString ("error: invalid target triple\n"); - return false; - } - ////////////////////////// // Parse the expression // @@ -257,7 +244,7 @@ m_expr_decl_map->WillParse(exe_ctx); - ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this); + ClangExpressionParser parser(exe_ctx.process, *this); unsigned num_errors = parser.Parse (error_stream); Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Tue Feb 15 15:59:32 2011 @@ -81,20 +81,7 @@ error_stream.PutCString ("error: invalid target\n"); return false; } - - ConstString target_triple; - - target->GetTargetTriple (target_triple); - - if (!target_triple) - target_triple = Host::GetTargetTriple (); - - if (!target_triple) - { - error_stream.PutCString ("error: invalid target triple\n"); - return false; - } - + ////////////////////////// // Parse the expression // @@ -105,7 +92,7 @@ m_expr_decl_map->WillParse(exe_ctx); - ClangExpressionParser parser(target_triple.GetCString(), exe_ctx.process, *this); + ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this); unsigned num_errors = parser.Parse (error_stream); Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Tue Feb 15 15:59:32 2011 @@ -222,38 +222,122 @@ } const ArchSpec & -Host::GetArchitecture () +Host::GetArchitecture (SystemDefaultArchitecture arch_kind) { - static ArchSpec g_host_arch; - if (!g_host_arch.IsValid()) - { + static bool g_supports_32 = false; + static bool g_supports_64 = false; + static ArchSpec g_host_arch_32; + static ArchSpec g_host_arch_64; + #if defined (__APPLE__) + + // Apple is different in that it can support both 32 and 64 bit executables + // in the same operating system running concurrently. Here we detect the + // correct host architectures for both 32 and 64 bit including if 64 bit + // executables are supported on the system. + + if (g_supports_32 == false && g_supports_64 == false) + { + // All apple systems support 32 bit execution. + g_supports_32 = true; uint32_t cputype, cpusubtype; - uint32_t is_64_bit_capable; + uint32_t is_64_bit_capable = false; size_t len = sizeof(cputype); + ArchSpec host_arch; + // These will tell us about the kernel architecture, which even on a 64 + // bit machine can be 32 bit... if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0) { - len = sizeof(cpusubtype); - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - g_host_arch.SetMachOArch (cputype, cpusubtype); - + len = sizeof (cpusubtype); + if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0) + cpusubtype = CPU_TYPE_ANY; + len = sizeof (is_64_bit_capable); if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0) { if (is_64_bit_capable) + g_supports_64 = true; + } + + if (is_64_bit_capable) + { + if (cputype & CPU_ARCH_ABI64) { - if (cputype == CPU_TYPE_I386 && cpusubtype == CPU_SUBTYPE_486) + // We have a 64 bit kernel on a 64 bit system + g_host_arch_32.SetMachOArch (CPU_TYPE_I386, CPU_SUBTYPE_386); + g_host_arch_64.SetMachOArch (cputype, cpusubtype); + } + else + { + // We have a 32 bit kernel on a 64 bit system + g_host_arch_32.SetMachOArch (cputype, cpusubtype); +#if defined (__i386__) || defined (__x86_64__) + if (cpusubtype == CPU_SUBTYPE_486) cpusubtype = CPU_SUBTYPE_I386_ALL; - +#endif cputype |= CPU_ARCH_ABI64; + g_host_arch_64.SetMachOArch (cputype, cpusubtype); } } + else + { + g_host_arch_32.SetMachOArch (cputype, cpusubtype); + g_host_arch_64.Clear(); + } } -#elif defined (__linux__) - g_host_arch.SetElfArch(7u, 144u); + } + +#else // #if defined (__APPLE__) + + if (g_supports_32 == false && g_supports_64 == false) + { +#if defined (__x86_64__) + + g_host_arch_64.SetArch ("x86_64"); + g_supports_32 = false; + g_supports_64 = true; + +#elif defined (__i386__) + + g_host_arch.SetArch ("i386"); + g_supports_32 = true; + g_supports_64 = false; + +#elif defined (__arm__) + + g_host_arch.SetArch ("arm"); + g_supports_32 = true; + g_supports_64 = false; + +#elif defined (__ppc64__) + + g_host_arch.SetArch ("ppc64"); + g_supports_32 = false; + g_supports_64 = true; + +#elif defined (__powerpc__) || defined (__ppc__) + g_host_arch.SetArch ("ppc"); + g_supports_32 = true; + g_supports_64 = false; + +#else + +#error undefined architecture, define your architecture here + #endif } - return g_host_arch; + +#endif // #else for #if defined (__APPLE__) + + if (arch_kind == eSystemDefaultArchitecture32) + return g_host_arch_32; + else if (arch_kind == eSystemDefaultArchitecture64) + return g_host_arch_64; + + if (g_supports_64) + return g_host_arch_64; + + return g_host_arch_32; } const ConstString & Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Feb 15 15:59:32 2011 @@ -41,15 +41,12 @@ // Static Functions //------------------------------------------------------------------ lldb_private::ABI * -ABIMacOSX_i386::CreateInstance (const ConstString &triple) +ABIMacOSX_i386::CreateInstance (const ArchSpec &arch) { - llvm::StringRef tripleStr(triple.GetCString()); - llvm::Triple llvmTriple(tripleStr); - - if (llvmTriple.getArch() != llvm::Triple::x86) - return NULL; - - return new ABIMacOSX_i386; + if (arch.GetTriple().getArch() == llvm::Triple::x86) + return new ABIMacOSX_i386; + + return NULL; } bool Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Tue Feb 15 15:59:32 2011 @@ -63,7 +63,7 @@ Terminate(); static lldb_private::ABI * - CreateInstance (const ConstString &triple); + CreateInstance (const ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Feb 15 15:59:32 2011 @@ -42,15 +42,11 @@ // Static Functions //------------------------------------------------------------------ lldb_private::ABI * -ABISysV_x86_64::CreateInstance (const ConstString &triple) +ABISysV_x86_64::CreateInstance (const ArchSpec &arch) { - llvm::StringRef tripleStr(triple.GetCString()); - llvm::Triple llvmTriple(tripleStr); - - if (llvmTriple.getArch() != llvm::Triple::x86_64) - return NULL; - - return new ABISysV_x86_64; + if (arch.GetTriple().getArch() == llvm::Triple::x86_64) + return new ABISysV_x86_64; + return NULL; } bool @@ -227,7 +223,9 @@ uint8_t arg_data[sizeof(arg_contents)]; Error error; thread.GetProcess().ReadMemory(current_stack_argument, arg_data, sizeof(arg_contents), error); - DataExtractor arg_data_extractor(arg_data, sizeof(arg_contents), thread.GetProcess().GetByteOrder(), thread.GetProcess().GetAddressByteSize()); + DataExtractor arg_data_extractor (arg_data, sizeof(arg_contents), + thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), + thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); uint32_t offset = 0; arg_contents = arg_data_extractor.GetMaxU64(&offset, bit_width / 8); if (!offset) Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Tue Feb 15 15:59:32 2011 @@ -62,7 +62,7 @@ Terminate(); static lldb_private::ABI * - CreateInstance (const ConstString &triple); + CreateInstance (const ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Feb 15 15:59:32 2011 @@ -424,7 +424,7 @@ m_dyld_all_image_infos.Clear(); if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS) { - ByteOrder byte_order = m_process->GetByteOrder(); + ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder(); uint32_t addr_size = 4; if (m_dyld_all_image_infos_addr > UINT32_MAX) addr_size = 8; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 15:59:32 2011 @@ -10,6 +10,7 @@ #include #include "EmulateInstructionARM.h" +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/ConstString.h" #include "Plugins/Process/Utility/ARMDefines.h" @@ -3620,38 +3621,22 @@ } bool -EmulateInstructionARM::SetTargetTriple (const ConstString &triple) +EmulateInstructionARM::SetArchitecture (const ArchSpec &arch) { m_arm_isa = 0; - const char *triple_cstr = triple.GetCString(); - if (triple_cstr) + const char *arch_cstr = arch.AsCString (); + if (arch_cstr) { - const char *dash = ::strchr (triple_cstr, '-'); - if (dash) - { - std::string arch (triple_cstr, dash); - const char *arch_cstr = arch.c_str(); - if (strcasecmp(arch_cstr, "armv4t") == 0) - m_arm_isa = ARMv4T; - else if (strcasecmp(arch_cstr, "armv4") == 0) - m_arm_isa = ARMv4; - else if (strcasecmp(arch_cstr, "armv5tej") == 0) - m_arm_isa = ARMv5TEJ; - else if (strcasecmp(arch_cstr, "armv5te") == 0) - m_arm_isa = ARMv5TE; - else if (strcasecmp(arch_cstr, "armv5t") == 0) - m_arm_isa = ARMv5T; - else if (strcasecmp(arch_cstr, "armv6k") == 0) - m_arm_isa = ARMv6K; - else if (strcasecmp(arch_cstr, "armv6") == 0) - m_arm_isa = ARMv6; - else if (strcasecmp(arch_cstr, "armv6t2") == 0) - m_arm_isa = ARMv6T2; - else if (strcasecmp(arch_cstr, "armv7") == 0) - m_arm_isa = ARMv7; - else if (strcasecmp(arch_cstr, "armv8") == 0) - m_arm_isa = ARMv8; - } + if (0 == ::strcasecmp(arch_cstr, "armv4t")) m_arm_isa = ARMv4T; + else if (0 == ::strcasecmp(arch_cstr, "armv4")) m_arm_isa = ARMv4; + else if (0 == ::strcasecmp(arch_cstr, "armv5tej")) m_arm_isa = ARMv5TEJ; + else if (0 == ::strcasecmp(arch_cstr, "armv5te")) m_arm_isa = ARMv5TE; + else if (0 == ::strcasecmp(arch_cstr, "armv5t")) m_arm_isa = ARMv5T; + else if (0 == ::strcasecmp(arch_cstr, "armv6k")) m_arm_isa = ARMv6K; + else if (0 == ::strcasecmp(arch_cstr, "armv6")) m_arm_isa = ARMv6; + else if (0 == ::strcasecmp(arch_cstr, "armv6t2")) m_arm_isa = ARMv6T2; + else if (0 == ::strcasecmp(arch_cstr, "armv7")) m_arm_isa = ARMv7; + else if (0 == ::strcasecmp(arch_cstr, "armv8")) m_arm_isa = ARMv8; } return m_arm_isa != 0; } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 15:59:32 2011 @@ -131,7 +131,7 @@ virtual bool - SetTargetTriple (const ConstString &triple); + SetArchitecture (const ArchSpec &arch); virtual bool ReadInstruction (); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue Feb 15 15:59:32 2011 @@ -104,7 +104,6 @@ arg_value_list.PushValue(value); // This is the return value: - const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); void *return_qualtype = ast_context->GetCStringType(true); @@ -112,7 +111,12 @@ ret.SetContext(Value::eContextTypeClangType, return_qualtype); // Now we're ready to call the function: - ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); + ClangFunction func (exe_ctx.GetBestExecutionContextScope(), + ast_context, + return_qualtype, + *function_address, + arg_value_list); + StreamString error_stream; lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Tue Feb 15 15:59:32 2011 @@ -819,11 +819,11 @@ // Next make the runner function for our implementation utility function. if (!m_impl_function.get()) { - m_impl_function.reset(new ClangFunction(process->GetTargetTriple().GetCString(), - clang_ast_context, - clang_void_ptr_type, - impl_code_address, - dispatch_values)); + m_impl_function.reset(new ClangFunction (&thread, + clang_ast_context, + clang_void_ptr_type, + impl_code_address, + dispatch_values)); errors.Clear(); unsigned num_errors = m_impl_function->CompileFunction(errors); Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Feb 15 15:59:32 2011 @@ -1043,40 +1043,28 @@ } bool -ObjectFileELF::GetTargetTriple(ConstString &target_triple) +ObjectFileELF::GetArchitecture (ArchSpec &arch) { - static ConstString g_target_triple; - - if (g_target_triple) - { - target_triple = g_target_triple; - return true; - } - - std::string triple; switch (m_header.e_machine) { default: assert(false && "Unexpected machine type."); break; - case EM_SPARC: triple.assign("sparc-"); break; - case EM_386: triple.assign("i386-"); break; - case EM_68K: triple.assign("68k-"); break; - case EM_88K: triple.assign("88k-"); break; - case EM_860: triple.assign("i860-"); break; - case EM_MIPS: triple.assign("mips-"); break; - case EM_PPC: triple.assign("powerpc-"); break; - case EM_PPC64: triple.assign("powerpc64-"); break; - case EM_ARM: triple.assign("arm-"); break; - case EM_X86_64: triple.assign("x86_64-"); break; + case EM_SPARC: arch.GetTriple().setArchName("sparc"); break; + case EM_386: arch.GetTriple().setArchName("i386"); break; + case EM_68K: arch.GetTriple().setArchName("68k"); break; + case EM_88K: arch.GetTriple().setArchName("88k"); break; + case EM_860: arch.GetTriple().setArchName("i860"); break; + case EM_MIPS: arch.GetTriple().setArchName("mips"); break; + case EM_PPC: arch.GetTriple().setArchName("powerpc"); break; + case EM_PPC64: arch.GetTriple().setArchName("powerpc64"); break; + case EM_ARM: arch.GetTriple().setArchName("arm"); break; + case EM_X86_64: arch.GetTriple().setArchName("x86_64"); break; } // TODO: determine if there is a vendor in the ELF? Default to "linux" for now - triple += "linux-"; + arch.GetTriple().setOSName ("linux"); // TODO: determine if there is an OS in the ELF? Default to "gnu" for now - triple += "gnu"; - g_target_triple.SetCString(triple.c_str()); - target_triple = g_target_triple; - + arch.GetTriple().setVendorName("gnu"); return true; } Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Tue Feb 15 15:59:32 2011 @@ -105,7 +105,7 @@ Dump(lldb_private::Stream *s); virtual bool - GetTargetTriple(lldb_private::ConstString &target_triple); + GetArchitecture (lldb_private::ArchSpec &arch); virtual bool GetUUID(lldb_private::UUID* uuid); Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Feb 15 15:59:32 2011 @@ -1436,15 +1436,11 @@ } bool -ObjectFileMachO::GetTargetTriple (ConstString &target_triple) +ObjectFileMachO::GetArchitecture (ArchSpec &arch) { lldb_private::Mutex::Locker locker(m_mutex); - std::string triple(GetModule()->GetArchitecture().AsCString()); - triple += "-apple-darwin"; - target_triple.SetCString(triple.c_str()); - if (target_triple) - return true; - return false; + arch.SetMachOArch(m_header.cputype, m_header.cpusubtype); + return true; } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Tue Feb 15 15:59:32 2011 @@ -83,7 +83,7 @@ Dump (lldb_private::Stream *s); virtual bool - GetTargetTriple (lldb_private::ConstString &target_triple); + GetArchitecture (lldb_private::ArchSpec &arch); virtual bool GetUUID (lldb_private::UUID* uuid); Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Tue Feb 15 15:59:32 2011 @@ -443,39 +443,10 @@ Module * exe_module = GetTarget().GetExecutableModule ().get(); assert (exe_module); - m_arch_spec = exe_module->GetArchitecture(); - assert (m_arch_spec.IsValid()); - - ObjectFile *exe_objfile = exe_module->GetObjectFile(); - assert (exe_objfile); - - m_byte_order = exe_objfile->GetByteOrder(); - assert (m_byte_order != eByteOrderInvalid); // Install a signal handler so we can catch when our child process // dies and set the exit status correctly. m_monitor_thread = Host::StartMonitoringChildProcess (Process::SetProcessExitStatus, NULL, GetID(), false); - - if (m_arch_spec == ArchSpec("arm")) - { - // On ARM we want the actual target triple of the OS to get the - // most capable ARM slice for the process. Since this plug-in is - // only used for doing native debugging this will work. - m_target_triple = Host::GetTargetTriple(); - } - else - { - // We want the arch of the process, and the vendor and OS from the - // host OS. - StreamString triple; - - triple.Printf("%s-%s-%s", - m_arch_spec.AsCString(), - Host::GetVendorString().AsCString("apple"), - Host::GetOSString().AsCString("darwin")); - - m_target_triple.SetCString(triple.GetString().c_str()); - } } } @@ -883,12 +854,6 @@ return error; } -ByteOrder -ProcessMacOSX::GetByteOrder () const -{ - return m_byte_order; -} - //------------------------------------------------------------------ // Process Queries //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h Tue Feb 15 15:59:32 2011 @@ -222,9 +222,6 @@ virtual lldb_private::Error DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc); - virtual lldb::ByteOrder - GetByteOrder () const; - virtual lldb_private::DynamicLoader * GetDynamicLoader (); Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Tue Feb 15 15:59:32 2011 @@ -107,7 +107,9 @@ uint8_t memory_buffer[8]; addr_t dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS; - DataExtractor data(memory_buffer, sizeof(memory_buffer), m_process.GetByteOrder(), m_process.GetAddressByteSize()); + DataExtractor data (memory_buffer, sizeof(memory_buffer), + m_process.GetTarget().GetArchitecture().GetByteOrder(), + m_process.GetTarget().GetArchitecture().GetAddressByteSize()); static ConstString g_dispatch_queue_offsets_symbol_name ("dispatch_queue_offsets"); const Symbol *dispatch_queue_offsets_symbol = NULL; ModuleSP module_sp(m_process.GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib", false))); @@ -477,6 +479,8 @@ case eStateStepping: Resume(); break; + default: + break; } m_context->ThreadWillResume(); } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Feb 15 15:59:32 2011 @@ -13,6 +13,7 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/Triple.h" #include "lldb/Interpreter/Args.h" #include "lldb/Core/ConnectionFileDescriptor.h" #include "lldb/Core/Log.h" Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Feb 15 15:59:32 2011 @@ -638,7 +638,7 @@ BuildDynamicRegisterInfo (false); - m_byte_order = m_gdb_comm.GetByteOrder(); + m_target.GetArchitecture().SetByteOrder (m_gdb_comm.GetByteOrder()); StreamString strm; @@ -656,33 +656,16 @@ // defacto architecture in this case. if (gdb_remote_arch == ArchSpec ("arm") && - vendor != NULL && - strcmp(vendor, "apple") == 0) + vendor && ::strcmp(vendor, "apple") == 0) { GetTarget().SetArchitecture (gdb_remote_arch); target_arch = gdb_remote_arch; } - if (!target_arch.IsValid()) - target_arch = gdb_remote_arch; - - if (target_arch.IsValid()) - { - if (vendor == NULL) - vendor = Host::GetVendorString().AsCString("apple"); - - if (os_type == NULL) - os_type = Host::GetOSString().AsCString("darwin"); - - strm.Printf ("%s-%s-%s", target_arch.AsCString(), vendor, os_type); - - std::transform (strm.GetString().begin(), - strm.GetString().end(), - strm.GetString().begin(), - ::tolower); - - m_target_triple.SetCString(strm.GetString().c_str()); - } + if (vendor) + m_target.GetArchitecture().GetTriple().setVendorName(vendor); + if (os_type) + m_target.GetArchitecture().GetTriple().setOSName(os_type); } } @@ -2557,7 +2540,10 @@ } uint8_t memory_buffer[8]; - DataExtractor data(memory_buffer, sizeof(memory_buffer), GetByteOrder(), GetAddressByteSize()); + DataExtractor data (memory_buffer, + sizeof(memory_buffer), + m_target.GetArchitecture().GetByteOrder(), + m_target.GetArchitecture().GetAddressByteSize()); // Excerpt from src/queue_private.h struct dispatch_queue_offsets_s Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Feb 15 15:59:32 2011 @@ -54,6 +54,7 @@ #include #endif +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/dwarf.h" #include "lldb/Core/Flags.h" #include "lldb/Core/Log.h" @@ -395,6 +396,13 @@ m_target_triple.assign(target_triple); } +void +ClangASTContext::SetArchitecture (const ArchSpec &arch) +{ + Clear(); + m_target_triple.assign(arch.GetTriple().str()); +} + bool ClangASTContext::HasExternalSource () { Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Tue Feb 15 15:59:32 2011 @@ -25,6 +25,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -355,7 +356,8 @@ if (address != LLDB_INVALID_ADDRESS) { DataExtractor data; - data.SetByteOrder (exe_ctx->process->GetByteOrder()); + if (exe_ctx->target) + data.SetByteOrder (exe_ctx->target->GetArchitecture().GetByteOrder()); if (ReadFromMemory (exe_ctx, address, address_type, data)) { DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose); Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Tue Feb 15 15:59:32 2011 @@ -58,12 +58,11 @@ } ArchSpec arch; - ConstString str; - m_object_file.GetTargetTriple (str); - arch.SetArchFromTargetTriple (str.GetCString()); - m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch); - - m_initialized = true; + if (m_object_file.GetArchitecture (arch)) + { + m_assembly_profiler = UnwindAssemblyProfiler::FindPlugin (arch); + m_initialized = true; + } } UnwindTable::~UnwindTable () Modified: lldb/trunk/source/Target/ABI.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/ABI.cpp (original) +++ lldb/trunk/source/Target/ABI.cpp Tue Feb 15 15:59:32 2011 @@ -14,7 +14,7 @@ using namespace lldb_private; ABI* -ABI::FindPlugin (const ConstString &triple) +ABI::FindPlugin (const ArchSpec &arch) { std::auto_ptr abi_ap; ABICreateInstance create_callback; @@ -23,7 +23,7 @@ (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != NULL; ++idx) { - abi_ap.reset (create_callback(triple)); + abi_ap.reset (create_callback(arch)); if (abi_ap.get()) return abi_ap.release(); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Feb 15 15:59:32 2011 @@ -229,9 +229,6 @@ m_breakpoint_site_list (), m_dynamic_checkers_ap (), m_unix_signals (), - m_target_triple (), - m_byte_order (lldb::endian::InlHostByteOrder()), - m_addr_byte_size (0), m_abi_sp (), m_process_input_reader (), m_stdio_communication ("process.stdio"), @@ -857,15 +854,8 @@ const ABI * Process::GetABI() { - ConstString& triple = m_target_triple; - - if (triple.IsEmpty()) - return NULL; - if (m_abi_sp.get() == NULL) - { - m_abi_sp.reset(ABI::FindPlugin(triple)); - } + m_abi_sp.reset(ABI::FindPlugin(m_target.GetArchitecture())); return m_abi_sp.get(); } @@ -1317,7 +1307,10 @@ else { uint8_t tmp[sizeof(uint64_t)]; - DataExtractor data (tmp, integer_byte_size, GetByteOrder(), GetAddressByteSize()); + DataExtractor data (tmp, + integer_byte_size, + m_target.GetArchitecture().GetByteOrder(), + m_target.GetArchitecture().GetAddressByteSize()); if (ReadMemory (vm_addr, tmp, integer_byte_size, error) == integer_byte_size) { uint32_t offset = 0; @@ -1509,7 +1502,6 @@ ) { Error error; - m_target_triple.Clear(); m_abi_sp.reset(); m_process_input_reader.reset(); @@ -1666,7 +1658,6 @@ Process::Attach (lldb::pid_t attach_pid) { - m_target_triple.Clear(); m_abi_sp.reset(); m_process_input_reader.reset(); @@ -1710,7 +1701,6 @@ Error Process::Attach (const char *process_name, bool wait_for_launch) { - m_target_triple.Clear(); m_abi_sp.reset(); m_process_input_reader.reset(); @@ -1756,7 +1746,6 @@ Error Process::ConnectRemote (const char *remote_url) { - m_target_triple.Clear(); m_abi_sp.reset(); m_process_input_reader.reset(); @@ -1975,32 +1964,19 @@ return error; } -UnixSignals & -Process::GetUnixSignals () +lldb::ByteOrder +Process::GetByteOrder () const { - return m_unix_signals; -} - -Target & -Process::GetTarget () -{ - return m_target; -} - -const Target & -Process::GetTarget () const -{ - return m_target; + return m_target.GetArchitecture().GetByteOrder(); } uint32_t -Process::GetAddressByteSize() +Process::GetAddressByteSize () const { - if (m_addr_byte_size == 0) - return m_target.GetArchitecture().GetAddressByteSize(); - return m_addr_byte_size; + return m_target.GetArchitecture().GetAddressByteSize(); } + bool Process::ShouldBroadcastEvent (Event *event_ptr) { @@ -2111,22 +2087,6 @@ return return_value; } -//------------------------------------------------------------------ -// Thread Queries -//------------------------------------------------------------------ - -ThreadList & -Process::GetThreadList () -{ - return m_thread_list; -} - -const ThreadList & -Process::GetThreadList () const -{ - return m_thread_list; -} - bool Process::StartPrivateStateThread () @@ -2517,30 +2477,6 @@ return false; } -Target * -Process::CalculateTarget () -{ - return &m_target; -} - -Process * -Process::CalculateProcess () -{ - return this; -} - -Thread * -Process::CalculateThread () -{ - return NULL; -} - -StackFrame * -Process::CalculateStackFrame () -{ - return NULL; -} - void Process::CalculateExecutionContext (ExecutionContext &exe_ctx) { Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Tue Feb 15 15:59:32 2011 @@ -910,7 +910,7 @@ if (show_frame_index) strm->Printf("frame #%u: ", m_frame_index); - strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget())); + strm->Printf("0x%0*llx ", m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget())); GetSymbolContext(eSymbolContextEverything); const bool show_module = true; const bool show_inline = true; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Feb 15 15:59:32 2011 @@ -45,7 +45,6 @@ m_breakpoint_list (false), m_internal_breakpoint_list (true), m_process_sp(), - m_triple(), m_search_filter_sp(), m_image_search_paths (ImageSearchPathsChanged, this), m_scratch_ast_context_ap (NULL), @@ -447,10 +446,9 @@ } // Now see if we know the target triple, and if so, create our scratch AST context: - ConstString target_triple; - if (GetTargetTriple(target_triple)) + if (m_arch_spec.IsValid()) { - m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString())); + m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch_spec.GetTriple().str().c_str())); } } @@ -458,18 +456,6 @@ } -ModuleList& -Target::GetImages () -{ - return m_images; -} - -ArchSpec -Target::GetArchitecture () const -{ - return m_arch_spec; -} - bool Target::SetArchitecture (const ArchSpec &arch_spec) { @@ -492,7 +478,6 @@ ModuleSP executable_sp = GetExecutableModule (); m_images.Clear(); m_scratch_ast_context_ap.reset(); - m_triple.Clear(); // Need to do something about unsetting breakpoints. if (executable_sp) @@ -524,31 +509,6 @@ } } -bool -Target::GetTargetTriple(ConstString &triple) -{ - triple.Clear(); - - if (m_triple) - { - triple = m_triple; - } - else - { - Module *exe_module = GetExecutableModule().get(); - if (exe_module) - { - ObjectFile *objfile = exe_module->GetObjectFile(); - if (objfile) - { - objfile->GetTargetTriple(m_triple); - triple = m_triple; - } - } - } - return !triple.IsEmpty(); -} - void Target::ModuleAdded (ModuleSP &module_sp) { Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Feb 15 15:59:32 2011 @@ -21,6 +21,7 @@ #include "lldb/Symbol/Function.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepThrough.h" @@ -75,7 +76,8 @@ if (log) { StreamString s; - s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize()); + s.Address (m_thread.GetRegisterContext()->GetPC(), + m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); log->Printf("ThreadPlanStepInRange reached %s.", s.GetData()); } Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Tue Feb 15 15:59:32 2011 @@ -123,10 +123,10 @@ StreamString s; s.PutCString ("Stepped in to: "); addr_t stop_addr = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC(); - s.Address (stop_addr, m_thread.GetProcess().GetAddressByteSize()); + s.Address (stop_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); s.PutCString (" stepping out to: "); addr_t return_addr = return_frame->GetRegisterContext()->GetPC(); - s.Address (return_addr, m_thread.GetProcess().GetAddressByteSize()); + s.Address (return_addr, m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); log->Printf("%s.", s.GetData()); } m_thread.QueueThreadPlanForStepOut(false, NULL, true, m_stop_other_threads, eVoteNo, eVoteNoOpinion, 0); Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Tue Feb 15 15:59:32 2011 @@ -19,6 +19,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepThrough.h" @@ -69,7 +70,8 @@ if (log) { StreamString s; - s.Address (m_thread.GetRegisterContext()->GetPC(), m_thread.GetProcess().GetAddressByteSize()); + s.Address (m_thread.GetRegisterContext()->GetPC(), + m_thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); log->Printf("ThreadPlanStepOverRange reached %s.", s.GetData()); } Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=125602&r1=125601&r2=125602&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Tue Feb 15 15:59:32 2011 @@ -3270,7 +3270,10 @@ strm << "endian:pdp;"; #endif - strm << "ptrsize:" << std::dec << sizeof(void *) << ';'; + if (promoted_to_64) + strm << "ptrsize:8;"; + else + strm << "ptrsize:" << std::dec << sizeof(void *) << ';'; return SendPacket (strm.str()); } From gclayton at apple.com Tue Feb 15 16:00:20 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Feb 2011 22:00:20 -0000 Subject: [Lldb-commits] [lldb] r125603 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110215220020.B511F2A6C12C@llvm.org> Author: gclayton Date: Tue Feb 15 16:00:20 2011 New Revision: 125603 URL: http://llvm.org/viewvc/llvm-project?rev=125603&view=rev Log: Removed my specific binaires from the xcscheme. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=125603&r1=125602&r2=125603&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Feb 15 16:00:20 2011 @@ -88,16 +88,6 @@ ReferencedContainer = "container:lldb.xcodeproj"> - - - - - - + isEnabled = "NO"> + isEnabled = "NO"> From johnny.chen at apple.com Tue Feb 15 16:21:33 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 22:21:33 -0000 Subject: [Lldb-commits] [lldb] r125606 - /lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Message-ID: <20110215222133.8743C2A6C12D@llvm.org> Author: johnny Date: Tue Feb 15 16:21:33 2011 New Revision: 125606 URL: http://llvm.org/viewvc/llvm-project?rev=125606&view=rev Log: Modify the various shift routines to handle cases where the shift amount comes from the bottom byte of a register. Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125606&r1=125605&r2=125606&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Tue Feb 15 16:21:33 2011 @@ -78,14 +78,14 @@ static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0 && amount < 32); - carry_out = Bit32(value, 32 - amount); + assert(amount > 0); + carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0; return value << amount; } static inline uint32_t LSL(const uint32_t value, const uint32_t amount) { - assert(amount >= 0 && amount < 32); + assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -94,14 +94,14 @@ static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0 && amount <= 32); - carry_out = Bit32(value, amount - 1); + assert(amount > 0); + carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0; return value >> amount; } static inline uint32_t LSR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0 && amount <= 32); + assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -111,14 +111,23 @@ static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { assert(amount > 0 && amount <= 32); - carry_out = Bit32(value, amount - 1); - int64_t extended = llvm::SignExtend64<32>(value); - return UnsignedBits(extended, amount + 31, amount); + bool negative = BitIsSet(value, 31); + if (amount <= 32) + { + carry_out = Bit32(value, amount - 1); + int64_t extended = llvm::SignExtend64<32>(value); + return UnsignedBits(extended, amount + 31, amount); + } + else + { + carry_out = (negative ? 1 : 0); + return (negative ? 0xffffffff : 0); + } } static inline uint32_t ASR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0 && amount <= 32); + assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -127,15 +136,16 @@ static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0 && amount < 32); - uint32_t result = Rotr32(value, amount); + assert(amount > 0); + uint32_t amt = amount % 32; + uint32_t result = Rotr32(value, amt); carry_out = Bit32(value, 31); return result; } static inline uint32_t ROR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0 && amount < 32); + assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; From ctice at apple.com Tue Feb 15 16:53:54 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 15 Feb 2011 22:53:54 -0000 Subject: [Lldb-commits] [lldb] r125610 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110215225354.987C32A6C12C@llvm.org> Author: ctice Date: Tue Feb 15 16:53:54 2011 New Revision: 125610 URL: http://llvm.org/viewvc/llvm-project?rev=125610&view=rev Log: Add eContextRegisterLoad instruction emulation context. Add code to emulate STR (Immediate, Thumb) instruction. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125610&r1=125609&r2=125610&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Feb 15 16:53:54 2011 @@ -133,6 +133,8 @@ // arg2 = address of store eContextRegisterStore, + eContextRegisterLoad, + // Used when performing a PC-relative branch where the // arg0 = don't care // arg1 = imm32 (signed offset) Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125610&r1=125609&r2=125610&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 16:53:54 2011 @@ -3396,7 +3396,169 @@ } return true; } + +// STR (store immediate) calcualtes an address from a base register value and an immediate offset, and stores a word +// from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. +bool +EmulateInstructionARM::EmulateSTRThumb (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); NullCheckIfThumbEE(n); + offset_addr = if add then (R[n] + imm32) else (R[n] - imm32); + address = if index then offset_addr else R[n]; + if UnalignedSupport() || address<1:0> == ???00??? then + MemU[address,4] = R[t]; + else // Can only occur before ARMv7 + MemU[address,4] = bits(32) UNKNOWN; + if wback then R[n] = offset_addr; +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + const uint32_t addr_byte_size = GetAddressByteSize(); + + uint32_t t; + uint32_t n; + uint32_t imm32; + bool index; + bool add; + bool wback; + // EncodingSpecificOperations (); NullCheckIfThumbEE(n); + switch (encoding) + { + case eEncodingT1: + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm5:???00???, 32); + t = Bits32 (opcode, 2, 0); + n = Bits32 (opcode, 5, 3); + imm32 = Bits32 (opcode, 10, 6) << 2; + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = false; + wback = false; + break; + + case eEncodingT2: + // t = UInt(Rt); n = 13; imm32 = ZeroExtend(imm8:???00???, 32); + t = Bits32 (opcode, 10, 8); + n = 13; + imm32 = Bits32 (opcode, 7, 0) << 2; + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + break; + + case eEncodingT3: + // if Rn == ???1111??? then UNDEFINED; + if (Bits32 (opcode, 19, 16) == 15) + return false; + + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + imm32 = Bits32 (opcode, 11, 0); + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + + // if t == 15 then UNPREDICTABLE; + if (t == 15) + return false; + break; + + case eEncodingT4: + // if P == ???1??? && U == ???1??? && W == ???0??? then SEE STRT; + // if Rn == ???1101??? && P == ???1??? && U == ???0??? && W == ???1??? && imm8 == ???00000100??? then SEE PUSH; + // if Rn == ???1111??? || (P == ???0??? && W == ???0???) then UNDEFINED; + if ((Bits32 (opcode, 19, 16) == 15) + || (BitIsClear (opcode, 10) && BitIsClear (opcode, 8))) + return false; + + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8, 32); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + imm32 = Bits32 (opcode, 7, 0); + + // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + index = BitIsSet (opcode, 10); + add = BitIsSet (opcode, 9); + wback = BitIsSet (opcode, 8); + // if t == 15 || (wback && n == t) then UNPREDICTABLE; + if ((t == 15) || (wback && (n == t))) + return false; + break; + + default: + return false; + } + + addr_t offset_addr; + addr_t address; + + // offset_addr = if add then (R[n] + imm32) else (R[n] - imm32); + uint32_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + if (add) + offset_addr = base_address + imm32; + else + offset_addr = base_address - imm32; + + // address = if index then offset_addr else R[n]; + if (index) + address = offset_addr; + else + address = base_address; + + EmulateInstruction::Context context; + context.type = eContextRegisterStore; + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + // if UnalignedSupport() || address<1:0> == ???00??? then + if (UnalignedSupport () || (BitIsClear (address, 1) && BitIsClear (address, 0))) + { + // MemU[address,4] = R[t]; + uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + t, 0, &success); + if (!success) + return false; + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + int32_t offset = address - base_address; + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + if (!WriteMemoryUnsigned (context, address, data, addr_byte_size)) + return false; + } + else + { + // MemU[address,4] = bits(32) UNKNOWN; + WriteBits32UnknownToMemory (address); + } + + // if wback then R[n] = offset_addr; + if (wback) + { + context.type = eContextRegisterLoad; + context.SetAddress (offset_addr); + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr)) + return false; + } + } + return true; +} EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) @@ -3607,8 +3769,11 @@ //---------------------------------------------------------------------- { 0xfffff800, 0x0000c000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, { 0xffd00000, 0xe8800000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTM, "stm.w {!} " }, - { 0xffd00000, 0xe9000000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " } - + { 0xffd00000, 0xe9000000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " }, + { 0xfffff800, 0x00006000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTRThumb, "str [{,#}]" }, + { 0xfffff800, 0x00009000, ARMV4T_ABOVE, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateSTRThumb, "str [SP,#]" }, + { 0xfff00000, 0xf8c00000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str.w ,#]" }, + { 0xfff00800, 0xf8400800, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str [,#+/-]" } }; const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125610&r1=125609&r2=125610&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 16:53:54 2011 @@ -335,6 +335,9 @@ bool EmulateSTMIB (ARMEncoding encoding); + bool + EmulateSTRThumb(ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From johnny.chen at apple.com Tue Feb 15 17:22:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Feb 2011 23:22:46 -0000 Subject: [Lldb-commits] [lldb] r125614 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110215232246.E01BD2A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 17:22:46 2011 New Revision: 125614 URL: http://llvm.org/viewvc/llvm-project?rev=125614&view=rev Log: A8.6.14 ASR (register) Add EmulateASRReg() Encodings T1, T2, and A1 to the opcodes tables. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125614&r1=125613&r2=125614&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 17:22:46 2011 @@ -2132,9 +2132,9 @@ if (ConditionPassed()) { - uint32_t Rd; // the destination register - uint32_t Rm; // the first operand register - uint32_t imm5; // encoding for the shift amount + uint32_t Rd; // the destination register + uint32_t Rm; // the first operand register + uint32_t imm5; // encoding for the shift amount uint32_t carry; // the carry bit after the shift operation bool setflags; switch (encoding) { @@ -2203,6 +2203,103 @@ return true; } +// Arithmetic Shift Right (register) shifts a register value right by a variable number of bits, +// shifting in copies of its sign bit, and writes the result to the destination register. +// The variable number of bits is read from the bottom byte of a register. It can optionally update +// the condition flags based on the result. +bool +EmulateInstructionARM::EmulateASRReg (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[m]<7:0>); + (result, carry) = Shift_C(R[m], SRType_ASR, shift_n, APSR.C); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + uint32_t Rd; // the destination register + uint32_t Rn; // the first operand register + uint32_t Rm; // the register whose bottom byte contains the amount to shift by + uint32_t carry; // the carry bit after the shift operation + bool setflags; + switch (encoding) { + case eEncodingT1: + Rd = Bits32(opcode, 2, 0); + Rn = Rd; + Rm = Bits32(opcode, 5, 3); + setflags = !InITBlock(); + break; + case eEncodingT2: + Rd = Bits32(opcode, 11, 8); + Rn = Bits32(opcode, 19, 16); + Rm = Bits32(opcode, 3, 0); + setflags = BitIsSet(opcode, 20); + if (BadReg(Rd) || BadReg(Rn) || BadReg(Rm)) + return false; + break; + case eEncodingA1: + Rd = Bits32(opcode, 15, 12); + Rn = Bits32(opcode, 3, 0); + Rm = Bits32(opcode, 11, 8); + setflags = BitIsSet(opcode, 20); + if (Rd == 15 || Rn == 15 || Rm == 15) + return false; + break; + default: + return false; + } + + // Get the first operand. + uint32_t value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rn, 0, &success); + if (!success) + return false; + // Get the Rm register content. + uint32_t val = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); + if (!success) + return false; + + // Get the shift amount. + uint32_t amt = Bits32(val, 7, 0); + + uint32_t result = Shift_C(value, SRType_ASR, amt, Bit32(m_inst_cpsr, CPSR_C), carry); + + // The context specifies that an immediate is to be moved into Rd. + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextImmediate; + context.SetNoArgs (); + + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + return false; + if (setflags) + { + m_new_inst_cpsr = m_inst_cpsr; + SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); + SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); + SetBit32(m_new_inst_cpsr, CPSR_C, carry); + if (m_new_inst_cpsr != m_inst_cpsr) + { + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) + return false; + } + } + } + return true; +} + // LDM loads multiple registers from consecutive memory locations, using an // address from a base register. Optionally the address just above the highest of those locations // can be written back to the base register. @@ -3625,6 +3722,8 @@ { 0x0fef0000, 0x03e00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateMvnRdImm, "mvn{s} , #"}, // asr (immediate) { 0x0fef0070, 0x01a00040, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s} , , #imm"}, + // asr (immediate) + { 0x0fef00f0, 0x01a00050, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateASRReg, "asr{s} , , "}, //---------------------------------------------------------------------- // Load instructions @@ -3753,6 +3852,9 @@ // asr (immediate) { 0xfffff800, 0x00001000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateASRImm, "asrs|asr , , #imm"}, { 0xffef8030, 0xea4f0020, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s}.w , , #imm"}, + // asr (register) + { 0xffffffc0, 0x00004100, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateASRReg, "asrs|asr , "}, + { 0xffe0f0f0, 0xfa40f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRReg, "asr{s}.w , , "}, //---------------------------------------------------------------------- // Load instructions Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125614&r1=125613&r2=125614&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 17:22:46 2011 @@ -308,6 +308,10 @@ bool EmulateASRImm (ARMEncoding encoding); + // A8.6.15 ASR (register) + bool + EmulateASRReg (ARMEncoding encoding); + bool EmulateLDM (ARMEncoding encoding); From gclayton at apple.com Tue Feb 15 18:00:43 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 16 Feb 2011 00:00:43 -0000 Subject: [Lldb-commits] [lldb] r125617 - in /lldb/trunk/source/Plugins: Disassembler/llvm/DisassemblerLLVM.cpp Disassembler/llvm/DisassemblerLLVM.h Process/gdb-remote/GDBRemoteCommunication.cpp Message-ID: <20110216000044.0B3102A6C12C@llvm.org> Author: gclayton Date: Tue Feb 15 18:00:43 2011 New Revision: 125617 URL: http://llvm.org/viewvc/llvm-project?rev=125617&view=rev Log: Fixed an issue where detection of vCont support wasn't being done correctly. Fixed how the LLDBDisassembler computes and uses a target triple. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=125617&r1=125616&r2=125617&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue Feb 15 18:00:43 2011 @@ -342,39 +342,33 @@ return 0; } -static inline const char * -TripleForArchSpec (const ArchSpec &arch, char *triple, size_t triple_len) -{ - const char *arch_name = arch.AsCString(); - - if (arch_name) - { - snprintf(triple, triple_len, "%s-unknown-unknown", arch_name); - return triple; - } - return NULL; -} - static inline EDAssemblySyntax_t SyntaxForArchSpec (const ArchSpec &arch) { - const char *arch_name = arch.AsCString(); - - if (arch_name != NULL - && ( (0 == ::strncasecmp (arch_name, "i386", 4)) - || (0 == ::strncasecmp (arch_name, "x86_64", 6)))) + switch (arch.GetGenericCPUType()) + { + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: return kEDAssemblySyntaxX86ATT; - + + case ArchSpec::eCPU_arm: + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + case ArchSpec::eCPU_sparc: + default: + break; + } return (EDAssemblySyntax_t)0; // default } Disassembler * DisassemblerLLVM::CreateInstance(const ArchSpec &arch) { - char triple[256]; + std::auto_ptr disasm_ap (new DisassemblerLLVM(arch)); + + if (disasm_ap->IsValid()) + return disasm_ap.release(); - if (TripleForArchSpec (arch, triple, sizeof(triple))) - return new DisassemblerLLVM(arch); return NULL; } @@ -382,11 +376,11 @@ Disassembler (arch), m_disassembler (NULL) { - char triple[256]; - if (TripleForArchSpec (arch, triple, sizeof(triple))) + const std::string &arch_triple = arch.GetTriple().str(); + if (!arch_triple.empty()) { - int err = EDGetDisassembler(&m_disassembler, triple, SyntaxForArchSpec (arch)); - assert (err == 0); + if (EDGetDisassembler(&m_disassembler, arch_triple.c_str(), SyntaxForArchSpec (arch))) + m_disassembler = NULL; } } Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=125617&r1=125616&r2=125617&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Tue Feb 15 18:00:43 2011 @@ -102,6 +102,12 @@ EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); protected: + bool + IsValid() const + { + return m_disassembler != NULL; + } + EDDisassemblerRef m_disassembler; }; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=125617&r1=125616&r2=125617&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Feb 15 18:00:43 2011 @@ -172,6 +172,8 @@ if (m_supports_vCont_c == eLazyBoolCalculate) { StringExtractorGDBRemote response; + m_supports_vCont_any = eLazyBoolNo; + m_supports_vCont_all = eLazyBoolNo; m_supports_vCont_c = eLazyBoolNo; m_supports_vCont_C = eLazyBoolNo; m_supports_vCont_s = eLazyBoolNo; From johnny.chen at apple.com Tue Feb 15 18:06:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 00:06:18 -0000 Subject: [Lldb-commits] [lldb] r125618 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110216000618.3BB112A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 18:06:18 2011 New Revision: 125618 URL: http://llvm.org/viewvc/llvm-project?rev=125618&view=rev Log: Add section headings corresponding to some of the ARM/Thumb emulation methods for better documentation. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125618&r1=125617&r2=125618&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 18:06:18 2011 @@ -219,88 +219,111 @@ static ARMOpcode* GetThumbOpcodeForInstruction (const uint32_t opcode); + // A8.6.123 PUSH bool EmulatePush (ARMEncoding encoding); - bool + // A8.6.122 POP + bool EmulatePop (ARMEncoding encoding); + // A8.6.8 ADD (SP plus immediate) bool EmulateAddRdSPImmediate (ARMEncoding encoding); + // A8.6.97 MOV (register) -- Rd == r7|ip and Rm == sp bool EmulateMovRdSP (ARMEncoding encoding); + // A8.6.97 MOV (register) -- move from r8-r15 to r0-r7 bool EmulateMovLowHigh (ARMEncoding encoding); + // A8.6.59 LDR (literal) bool EmulateLDRRtPCRelative (ARMEncoding encoding); + // A8.6.8 ADD (SP plus immediate) bool EmulateAddSPImmediate (ARMEncoding encoding); + // A8.6.9 ADD (SP plus register) bool EmulateAddSPRm (ARMEncoding encoding); + // A8.6.23 BL, BLX (immediate) bool EmulateBLXImmediate (ARMEncoding encoding); + // A8.6.24 BLX (register) bool EmulateBLXRm (ARMEncoding encoding); + // A8.6.25 BX bool EmulateBXRm (ARMEncoding encoding); + // A8.6.212 SUB (immediate, ARM) -- Rd == r7 and Rm == ip bool EmulateSubR7IPImmediate (ARMEncoding encoding); + // A8.6.215 SUB (SP minus immediate) -- Rd == ip bool EmulateSubIPSPImmediate (ARMEncoding encoding); + // A8.6.215 SUB (SP minus immediate) bool EmulateSubSPImmdiate (ARMEncoding encoding); + // A8.6.194 STR (immediate, ARM) -- Rn == sp bool EmulateSTRRtSP (ARMEncoding encoding); + // A8.6.355 VPUSH bool EmulateVPUSH (ARMEncoding encoding); + // A8.6.354 VPOP bool EmulateVPOP (ARMEncoding encoding); + // A8.6.218 SVC (previously SWI) bool EmulateSVC (ARMEncoding encoding); + // A8.6.50 IT bool EmulateIT (ARMEncoding encoding); + // A8.6.16 bool EmulateB (ARMEncoding encoding); - // CBNZ, CBZ + // A8.6.27 CBNZ, CBZ bool EmulateCB (ARMEncoding encoding); + // A8.6.6 ADD (register) -- Encoding T2 bool EmulateAddRdnRm (ARMEncoding encoding); - // MOV (register) + // A8.6.97 MOV (register) bool EmulateMovRdRm (ARMEncoding encoding); - // MOV (immediate) + // A8.6.96 MOV (immediate) bool EmulateMovRdImm (ARMEncoding encoding); - // MVN (immediate) + // A8.6.106 MVN (immediate) bool EmulateMvnRdImm (ARMEncoding encoding); + // A8.6.35 CMP (immediate) bool EmulateCmpRnImm (ARMEncoding encoding); + // A8.6.36 CMP (register) bool EmulateCmpRnRm (ARMEncoding encoding); From johnny.chen at apple.com Tue Feb 15 18:17:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 00:17:18 -0000 Subject: [Lldb-commits] [lldb] r125620 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110216001718.914172A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 18:17:18 2011 New Revision: 125620 URL: http://llvm.org/viewvc/llvm-project?rev=125620&view=rev Log: Section heading for EmulateB(). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125620&r1=125619&r2=125620&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 18:17:18 2011 @@ -295,7 +295,7 @@ bool EmulateIT (ARMEncoding encoding); - // A8.6.16 + // A8.6.16 B bool EmulateB (ARMEncoding encoding); From ctice at apple.com Tue Feb 15 18:33:43 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 16 Feb 2011 00:33:43 -0000 Subject: [Lldb-commits] [lldb] r125623 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110216003343.DD77E2A6C12C@llvm.org> Author: ctice Date: Tue Feb 15 18:33:43 2011 New Revision: 125623 URL: http://llvm.org/viewvc/llvm-project?rev=125623&view=rev Log: Add documentation tags for LDM/STM instruction families. Add code to emulate STR (register) Arm instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125623&r1=125622&r2=125623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 18:33:43 2011 @@ -3657,6 +3657,199 @@ return true; } +// STR (Store Register) calculates an address from a base register value and an offset register value, stores a +// word from a register to memory. The offset register value can optionally be shifted. +bool +EmulateInstructionARM::EmulateSTRRegister (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); NullCheckIfThumbEE(n); + offset = Shift(R[m], shift_t, shift_n, APSR.C); + offset_addr = if add then (R[n] + offset) else (R[n] - offset); + address = if index then offset_addr else R[n]; + if t == 15 then // Only possible for encoding A1 + data = PCStoreValue(); + else + data = R[t]; + if UnalignedSupport() || address<1:0> == ???00??? || CurrentInstrSet() == InstrSet_ARM then + MemU[address,4] = data; + else // Can only occur before ARMv7 + MemU[address,4] = bits(32) UNKNOWN; + if wback then R[n] = offset_addr; +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed()) + { + const uint32_t addr_byte_size = GetAddressByteSize(); + + uint32_t t; + uint32_t n; + uint32_t m; + ARM_ShifterType shift_t; + uint32_t shift_n; + bool index; + bool add; + bool wback; + + // EncodingSpecificOperations (); NullCheckIfThumbEE(n); + switch (encoding) + { + case eEncodingT1: + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation in ThumbEE"; + // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + t = Bits32 (opcode, 2, 0); + n = Bits32 (opcode, 5, 3); + m = Bits32 (opcode, 8, 6); + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + + // (shift_t, shift_n) = (SRType_LSL, 0); + shift_t = SRType_LSL; + shift_n = 0; + break; + + case eEncodingT2: + // if Rn == ???1111??? then UNDEFINED; + if (Bits32 (opcode, 19, 16) == 15) + return false; + + // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + m = Bits32 (opcode, 3, 0); + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + + // (shift_t, shift_n) = (SRType_LSL, UInt(imm2)); + shift_t = SRType_LSL; + shift_n = Bits32 (opcode, 5, 4); + + // if t == 15 || BadReg(m) then UNPREDICTABLE; + if ((t == 15) || (BadReg (m))) + return false; + break; + + case eEncodingA1: + { + // if P == ???0??? && W == ???1??? then SEE STRT; + // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + m = Bits32 (opcode, 3, 0); + + // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + index = BitIsSet (opcode, 24); + add = BitIsSet (opcode, 23); + wback = (BitIsClear (opcode, 24) || BitIsSet (opcode, 21)); + + // (shift_t, shift_n) = DecodeImmShift(type, imm5); + uint32_t typ = Bits32 (opcode, 6, 5); + uint32_t imm5 = Bits32 (opcode, 11, 7); + shift_n = DecodeImmShift(typ, imm5, shift_t); + + // if m == 15 then UNPREDICTABLE; + if (m == 15) + return false; + + // if wback && (n == 15 || n == t) then UNPREDICTABLE; + if (wback && ((n == 15) || (n == t))) + return false; + + break; + } + default: + return false; + } + + addr_t offset_addr; + addr_t address; + int32_t offset = 0; + + addr_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + uint32_t Rm_data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + m, 0, &success); + if (!success) + return false; + + // offset = Shift(R[m], shift_t, shift_n, APSR.C); + offset = Shift (Rm_data, shift_t, shift_n, Bit32(m_inst_cpsr, CPSR_C)); + + // offset_addr = if add then (R[n] + offset) else (R[n] - offset); + if (add) + offset_addr = base_address + offset; + else + offset_addr = base_address - offset; + + // address = if index then offset_addr else R[n]; + if (index) + address = offset_addr; + else + address = base_address; + + uint32_t data; + // if t == 15 then // Only possible for encoding A1 + if (t == 15) + // data = PCStoreValue(); + data = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + else + // data = R[t]; + data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + t, 0, &success); + + if (!success) + return false; + + EmulateInstruction::Context context; + context.type = eContextRegisterStore; + + // if UnalignedSupport() || address<1:0> == ???00??? || CurrentInstrSet() == InstrSet_ARM then + if (UnalignedSupport () + || (BitIsClear (address, 1) && BitIsClear (address, 0)) + || CurrentInstrSet() == eModeARM) + { + // MemU[address,4] = data; + + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - base_address); + if (!WriteMemoryUnsigned (context, address, data, addr_byte_size)) + return false; + + } + else + // MemU[address,4] = bits(32) UNKNOWN; + WriteBits32UnknownToMemory (address); + + // if wback then R[n] = offset_addr; + if (wback) + { + context.type = eContextRegisterLoad; + context.SetAddress (offset_addr); + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr)) + return false; + } + + } + return true; +} + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) { @@ -3739,7 +3932,8 @@ { 0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTM, "stm {!} " }, { 0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDA, "stmda {!} " }, { 0x0fd00000, 0x09000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMDB, "stmdb {!} " }, - { 0x0fd00000, 0x09800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMIB, "stmib {!} " } + { 0x0fd00000, 0x09800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTMIB, "stmib {!} " }, + { 0x0e500010, 0x06000000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSTRRegister, "str [ +/- {}]{!}" } }; @@ -3875,7 +4069,9 @@ { 0xfffff800, 0x00006000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTRThumb, "str [{,#}]" }, { 0xfffff800, 0x00009000, ARMV4T_ABOVE, eEncodingT2, eSize16, &EmulateInstructionARM::EmulateSTRThumb, "str [SP,#]" }, { 0xfff00000, 0xf8c00000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str.w ,#]" }, - { 0xfff00800, 0xf8400800, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str [,#+/-]" } + { 0xfff00800, 0xf8400800, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str [,#+/-]" }, + { 0xfffffe00, 0x00005000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTRRegister, "str { ]" }, + { 0xfff00fc0, 0xf8400000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTRRegister, "str.w [ {lsl #imm2>}]" } }; const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125623&r1=125622&r2=125623&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 18:33:43 2011 @@ -335,36 +335,49 @@ bool EmulateASRReg (ARMEncoding encoding); + // A8.6.53 LDM/LDMIA/LDMFD bool EmulateLDM (ARMEncoding encoding); + // A8.6.54 LDMDA/LDMFA bool EmulateLDMDA (ARMEncoding encoding); + // A8.6.55 LDMDB/LDMEA bool EmulateLDMDB (ARMEncoding encoding); + // A8.6.56 LDMIB/LDMED bool EmulateLDMIB (ARMEncoding encoding); bool EmulateLDRRtRnImm (ARMEncoding encoding); + // A8.6.188 STM/STMIA/STMEA bool EmulateSTM (ARMEncoding encoding); + // A8.6.189 STMDA/STMED bool EmulateSTMDA (ARMEncoding encoding); + // A8.6.190 STMDB/STMFD bool EmulateSTMDB (ARMEncoding encoding); + // A8.6.191 STMIB/STMFA bool EmulateSTMIB (ARMEncoding encoding); + // A8.6.192 STR (immediate, Thumb) bool EmulateSTRThumb(ARMEncoding encoding); + // A8.6.194 STR (register) + bool + EmulateSTRRegister (ARMEncoding encoding); + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From johnny.chen at apple.com Tue Feb 15 19:27:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 01:27:54 -0000 Subject: [Lldb-commits] [lldb] r125633 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Instruction/ARM/EmulateInstructionARM.h Process/Utility/ARMDefines.h Process/Utility/ARMUtils.h Message-ID: <20110216012754.EBC022A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 19:27:54 2011 New Revision: 125633 URL: http://llvm.org/viewvc/llvm-project?rev=125633&view=rev Log: Add emulation methods for LSL (immediate), LSL (register), LSR (immediate), and LSR (register). Create two helper methods EmulateShiftImm() and EmulateShiftReg() and have ASR, LSL, and LSR delegate to the helper methods which take an extra ARM_ShifterType parameter. The opcodes tables have not been updated yet to reflect these new entries. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125633&r1=125632&r2=125633&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Feb 15 19:27:54 2011 @@ -2125,6 +2125,136 @@ // APSR.V unchanged #endif + return EmulateShiftImm(encoding, SRType_ASR); +} + +// Arithmetic Shift Right (register) shifts a register value right by a variable number of bits, +// shifting in copies of its sign bit, and writes the result to the destination register. +// The variable number of bits is read from the bottom byte of a register. It can optionally update +// the condition flags based on the result. +bool +EmulateInstructionARM::EmulateASRReg (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[m]<7:0>); + (result, carry) = Shift_C(R[m], SRType_ASR, shift_n, APSR.C); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftReg(encoding, SRType_ASR); +} + +// Logical Shift Left (immediate) shifts a register value left by an immediate number of bits, +// shifting in zeros, and writes the result to the destination register. It can optionally +// update the condition flags based on the result. +bool +EmulateInstructionARM::EmulateLSLImm (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + (result, carry) = Shift_C(R[m], SRType_LSL, shift_n, APSR.C); + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftImm(encoding, SRType_LSL); +} + +// Logical Shift Left (register) shifts a register value left by a variable number of bits, +// shifting in zeros, and writes the result to the destination register. The variable number +// of bits is read from the bottom byte of a register. It can optionally update the condition +// flags based on the result. +bool +EmulateInstructionARM::EmulateLSLReg (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[m]<7:0>); + (result, carry) = Shift_C(R[m], SRType_LSL, shift_n, APSR.C); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftReg(encoding, SRType_LSL); +} + +// Logical Shift Right (immediate) shifts a register value right by an immediate number of bits, +// shifting in zeros, and writes the result to the destination register. It can optionally +// update the condition flags based on the result. +bool +EmulateInstructionARM::EmulateLSRImm (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + (result, carry) = Shift_C(R[m], SRType_LSR, shift_n, APSR.C); + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftImm(encoding, SRType_LSR); +} + +// Logical Shift Right (register) shifts a register value right by a variable number of bits, +// shifting in zeros, and writes the result to the destination register. The variable number +// of bits is read from the bottom byte of a register. It can optionally update the condition +// flags based on the result. +bool +EmulateInstructionARM::EmulateLSRReg (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[m]<7:0>); + (result, carry) = Shift_C(R[m], SRType_LSR, shift_n, APSR.C); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftReg(encoding, SRType_LSR); +} + +bool +EmulateInstructionARM::EmulateShiftImm (ARMEncoding encoding, ARM_ShifterType shift_type) +{ + assert(shift_type == SRType_ASR || shift_type == SRType_LSL || shift_type == SRType_LSR); + bool success = false; const uint32_t opcode = OpcodeAsUnsigned (&success); if (!success) @@ -2168,9 +2298,9 @@ return false; // Decode the shift amount. - uint32_t amt = DecodeImmShift(SRType_ASR, imm5); + uint32_t amt = DecodeImmShift(shift_type, imm5); - uint32_t result = Shift_C(value, SRType_ASR, amt, Bit32(m_inst_cpsr, CPSR_C), carry); + uint32_t result = Shift_C(value, shift_type, amt, Bit32(m_inst_cpsr, CPSR_C), carry); // The context specifies that an immediate is to be moved into Rd. EmulateInstruction::Context context; @@ -2203,26 +2333,10 @@ return true; } -// Arithmetic Shift Right (register) shifts a register value right by a variable number of bits, -// shifting in copies of its sign bit, and writes the result to the destination register. -// The variable number of bits is read from the bottom byte of a register. It can optionally update -// the condition flags based on the result. bool -EmulateInstructionARM::EmulateASRReg (ARMEncoding encoding) +EmulateInstructionARM::EmulateShiftReg (ARMEncoding encoding, ARM_ShifterType shift_type) { -#if 0 - // ARM pseudo code... - if ConditionPassed() then - EncodingSpecificOperations(); - shift_n = UInt(R[m]<7:0>); - (result, carry) = Shift_C(R[m], SRType_ASR, shift_n, APSR.C); - R[d] = result; - if setflags then - APSR.N = result<31>; - APSR.Z = IsZeroBit(result); - APSR.C = carry; - // APSR.V unchanged -#endif + assert(shift_type == SRType_ASR || shift_type == SRType_LSL || shift_type == SRType_LSR); bool success = false; const uint32_t opcode = OpcodeAsUnsigned (&success); @@ -2275,7 +2389,7 @@ // Get the shift amount. uint32_t amt = Bits32(val, 7, 0); - uint32_t result = Shift_C(value, SRType_ASR, amt, Bit32(m_inst_cpsr, CPSR_C), carry); + uint32_t result = Shift_C(value, shift_type, amt, Bit32(m_inst_cpsr, CPSR_C), carry); // The context specifies that an immediate is to be moved into Rd. EmulateInstruction::Context context; Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125633&r1=125632&r2=125633&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 19:27:54 2011 @@ -12,6 +12,7 @@ #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/Error.h" +#include "Plugins/Process/Utility/ARMDefines.h" namespace lldb_private { @@ -335,6 +336,30 @@ bool EmulateASRReg (ARMEncoding encoding); + // A8.6.88 LSL (immediate) + bool + EmulateLSLImm (ARMEncoding encoding); + + // A8.6.89 LSL (register) + bool + EmulateLSLReg (ARMEncoding encoding); + + // A8.6.90 LSR (immediate) + bool + EmulateLSRImm (ARMEncoding encoding); + + // A8.6.91 LSR (register) + bool + EmulateLSRReg (ARMEncoding encoding); + + // Helper method for ASR, LSL, and LSR + bool + EmulateShiftImm (ARMEncoding encoding, ARM_ShifterType shift_type); + + // Helper method for ASR, LSL, and LSR + bool + EmulateShiftReg (ARMEncoding encoding, ARM_ShifterType shift_type); + // A8.6.53 LDM/LDMIA/LDMFD bool EmulateLDM (ARMEncoding encoding); Modified: lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h?rev=125633&r1=125632&r2=125633&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h Tue Feb 15 19:27:54 2011 @@ -10,12 +10,20 @@ #ifndef lldb_ARMDefines_h_ #define lldb_ARMDefines_h_ -#include "InstructionUtils.h" - // Common defintions for the ARM/Thumb Instruction Set Architecture. namespace lldb_private { +// ARM shifter types +typedef enum +{ + SRType_LSL, + SRType_LSR, + SRType_ASR, + SRType_ROR, + SRType_RRX +} ARM_ShifterType; + // ARM conditions // Meaning (integer) Meaning (floating-point) Condition flags #define COND_EQ 0x0 // Equal Equal Z == 1 #define COND_NE 0x1 // Not equal Not equal, or unordered Z == 0 Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125633&r1=125632&r2=125633&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Tue Feb 15 19:27:54 2011 @@ -10,6 +10,7 @@ #ifndef lldb_ARMUtils_h_ #define lldb_ARMUtils_h_ +#include "ARMDefines.h" #include "InstructionUtils.h" #include "llvm/Support/MathExtras.h" // for SignExtend64 template function @@ -17,15 +18,6 @@ namespace lldb_private { -typedef enum -{ - SRType_LSL, - SRType_LSR, - SRType_ASR, - SRType_ROR, - SRType_RRX -} ARM_ShifterType; - static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5, ARM_ShifterType &shift_t) { switch (type) { From johnny.chen at apple.com Tue Feb 15 19:31:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 01:31:20 -0000 Subject: [Lldb-commits] [lldb] r125634 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110216013120.912472A6C12C@llvm.org> Author: johnny Date: Tue Feb 15 19:31:20 2011 New Revision: 125634 URL: http://llvm.org/viewvc/llvm-project?rev=125634&view=rev Log: Minor comment change. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125634&r1=125633&r2=125634&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Feb 15 19:31:20 2011 @@ -352,11 +352,11 @@ bool EmulateLSRReg (ARMEncoding encoding); - // Helper method for ASR, LSL, and LSR + // Helper method for ASR, LSL, and LSR (immediate) bool EmulateShiftImm (ARMEncoding encoding, ARM_ShifterType shift_type); - // Helper method for ASR, LSL, and LSR + // Helper method for ASR, LSL, and LSR (register) bool EmulateShiftReg (ARMEncoding encoding, ARM_ShifterType shift_type); From wilsons at start.ca Tue Feb 15 22:05:35 2011 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 15 Feb 2011 23:05:35 -0500 Subject: [Lldb-commits] [PATCH] Use SIZE_MAX instead of SIZE_T_MAX for portability. Message-ID: diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h index 198722c..3bb14ac 100644 --- a/include/lldb/Core/ArchSpec.h +++ b/include/lldb/Core/ArchSpec.h @@ -12,6 +12,8 @@ #if defined(__cplusplus) +#include + #include "lldb/lldb-private.h" #include "llvm/ADT/Triple.h" @@ -348,10 +350,10 @@ protected: private: void - MachOArchUpdated (size_t macho_idx = SIZE_T_MAX); + MachOArchUpdated (size_t macho_idx = SIZE_MAX); void - ELFArchUpdated (size_t idx = SIZE_T_MAX); + ELFArchUpdated (size_t idx = SIZE_MAX); }; From wilsons at start.ca Tue Feb 15 22:10:42 2011 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 15 Feb 2011 23:10:42 -0500 Subject: [Lldb-commits] [PATCH] linux: Set ArchSpec m_type correctly from object file. Message-ID: An ArchSpec's type defaults to MachO. Ensure the type is properly set on ELF systems. diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index a16e486..0739b97 100644 --- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1065,6 +1065,8 @@ ObjectFileELF::GetArchitecture (ArchSpec &arch) arch.GetTriple().setOSName ("linux"); // TODO: determine if there is an OS in the ELF? Default to "gnu" for now arch.GetTriple().setVendorName("gnu"); + + arch.SetElfArch(m_header.e_machine, m_header.e_flags); return true; } From gclayton at apple.com Tue Feb 15 22:46:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 16 Feb 2011 04:46:07 -0000 Subject: [Lldb-commits] [lldb] r125650 - in /lldb/trunk: include/lldb/ include/lldb/Target/ source/Core/ source/Host/common/ source/Plugins/DynamicLoader/Linux-DYLD/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Process/Linux/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Target/ tools/debugserver/source/ Message-ID: <20110216044607.AA12E2A6C12C@llvm.org> Author: gclayton Date: Tue Feb 15 22:46:07 2011 New Revision: 125650 URL: http://llvm.org/viewvc/llvm-project?rev=125650&view=rev Log: The DynamicLoader plug-in instance now lives up in lldb_private::Process where it should live and the lldb_private::Process takes care of managing the auto pointer to the dynamic loader instance. Also, now that the ArchSpec contains the target triple, we are able to correctly set the Target architecture in DidLaunch/DidAttach in the subclasses, and then the lldb_private::Process will find the dynamic loader plug-in by letting the dynamic loader plug-ins inspect the arch/triple in the target. So now the ProcessGDBRemote plug-in is another step closer to be purely process/platform agnostic. I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-private-interfaces.h lldb/trunk/source/Core/DynamicLoader.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Target/Process.cpp lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Feb 15 22:46:07 2011 @@ -1232,6 +1232,12 @@ lldb::StateType GetPrivateState (); + //------------------------------------------------------------------ + // Called internally + //------------------------------------------------------------------ + void + CompleteAttach (); + public: //------------------------------------------------------------------ /// Get the exit status for a process. @@ -1755,9 +1761,12 @@ const ABI * GetABI (); - virtual DynamicLoader * - GetDynamicLoader (); - + DynamicLoader * + GetDynamicLoader () + { + return m_dyld_ap.get(); + } + virtual LanguageRuntime * GetLanguageRuntime (lldb::LanguageType language); @@ -1940,6 +1949,7 @@ Listener &m_listener; BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend ///< to insert in the target. + std::auto_ptr m_dyld_ap; std::auto_ptr m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. UnixSignals m_unix_signals; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-interfaces.h (original) +++ lldb/trunk/include/lldb/lldb-private-interfaces.h Tue Feb 15 22:46:07 2011 @@ -18,7 +18,7 @@ { typedef ABI* (*ABICreateInstance) (const ArchSpec &arch); typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch); - typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process); + typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process, bool force); typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length); typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length); typedef LogChannel* (*LogChannelCreateInstance) (); Modified: lldb/trunk/source/Core/DynamicLoader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DynamicLoader.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Core/DynamicLoader.cpp (original) +++ lldb/trunk/source/Core/DynamicLoader.cpp Tue Feb 15 22:46:07 2011 @@ -23,7 +23,7 @@ create_callback = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name); if (create_callback) { - std::auto_ptr instance_ap(create_callback(process)); + std::auto_ptr instance_ap(create_callback(process, true)); if (instance_ap.get()) return instance_ap.release(); } @@ -32,7 +32,7 @@ { for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx) { - std::auto_ptr instance_ap(create_callback(process)); + std::auto_ptr instance_ap(create_callback(process, false)); if (instance_ap.get()) return instance_ap.release(); } Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Tue Feb 15 22:46:07 2011 @@ -261,20 +261,20 @@ if (is_64_bit_capable) { +#if defined (__i386__) || defined (__x86_64__) + if (cpusubtype == CPU_SUBTYPE_486) + cpusubtype = CPU_SUBTYPE_I386_ALL; +#endif if (cputype & CPU_ARCH_ABI64) { // We have a 64 bit kernel on a 64 bit system - g_host_arch_32.SetMachOArch (CPU_TYPE_I386, CPU_SUBTYPE_386); + g_host_arch_32.SetMachOArch (~(CPU_ARCH_MASK) & cputype, cpusubtype); g_host_arch_64.SetMachOArch (cputype, cpusubtype); } else { // We have a 32 bit kernel on a 64 bit system g_host_arch_32.SetMachOArch (cputype, cpusubtype); -#if defined (__i386__) || defined (__x86_64__) - if (cpusubtype == CPU_SUBTYPE_486) - cpusubtype = CPU_SUBTYPE_I386_ALL; -#endif cputype |= CPU_ARCH_ABI64; g_host_arch_64.SetMachOArch (cputype, cpusubtype); } Modified: lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp Tue Feb 15 22:46:07 2011 @@ -73,9 +73,19 @@ } DynamicLoader * -DynamicLoaderLinuxDYLD::CreateInstance(Process *process) +DynamicLoaderLinuxDYLD::CreateInstance(Process *process, bool force) { - return new DynamicLoaderLinuxDYLD(process); + bool create = force; + if (!create) + { + const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); + if (triple_ref.getOS() == llvm::Triple::Linux) + create = true; + } + + if (create) + return new DynamicLoaderLinuxDYLD (process); + return NULL; } DynamicLoaderLinuxDYLD::DynamicLoaderLinuxDYLD(Process *process) Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Feb 15 22:46:07 2011 @@ -63,9 +63,19 @@ // allows the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader * -DynamicLoaderMacOSXDYLD::CreateInstance (Process* process) +DynamicLoaderMacOSXDYLD::CreateInstance (Process* process, bool force) { - return new DynamicLoaderMacOSXDYLD (process); + bool create = force; + if (!create) + { + const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); + if (triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple) + create = true; + } + + if (create) + return new DynamicLoaderMacOSXDYLD (process); + return NULL; } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Tue Feb 15 22:46:07 2011 @@ -44,7 +44,7 @@ GetPluginDescriptionStatic(); static lldb_private::DynamicLoader * - CreateInstance (lldb_private::Process *process); + CreateInstance (lldb_private::Process *process, bool force); DynamicLoaderMacOSXDYLD (lldb_private::Process *process); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Tue Feb 15 22:46:07 2011 @@ -106,12 +106,6 @@ ProcessLinux::WillLaunch(Module* module) { Error error; - - m_dyld_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.linux-dyld")); - if (m_dyld_ap.get() == NULL) - error.SetErrorString("unable to find the dynamic loader named " - "'dynamic-loader.linux-dyld'"); - return error; } @@ -146,8 +140,6 @@ void ProcessLinux::DidLaunch() { - if (m_dyld_ap.get() != NULL) - m_dyld_ap->DidLaunch(); } Error @@ -405,12 +397,6 @@ return m_byte_order; } -DynamicLoader * -ProcessLinux::GetDynamicLoader() -{ - return m_dyld_ap.get(); -} - //------------------------------------------------------------------------------ // ProcessInterface protocol. Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Tue Feb 15 22:46:07 2011 @@ -138,9 +138,6 @@ virtual lldb::addr_t GetImageInfoAddress(); - virtual lldb_private::DynamicLoader * - GetDynamicLoader(); - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ @@ -186,9 +183,6 @@ lldb_private::Mutex m_message_mutex; std::queue m_message_queue; - /// Dynamic loader plugin associated with this process. - std::auto_ptr m_dyld_ap; - /// Updates the loaded sections provided by the executable. /// /// FIXME: It would probably be better to delegate this task to the Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Tue Feb 15 22:46:07 2011 @@ -234,8 +234,7 @@ m_stdout_data (), m_exception_messages (), m_exception_messages_mutex (Mutex::eMutexTypeRecursive), - m_arch_spec (), - m_dynamic_loader_ap () + m_arch_spec () { } @@ -414,14 +413,7 @@ Error ProcessMacOSX::WillLaunchOrAttach () { - Error error; - // TODO: this is hardcoded for macosx right now. We need this to be more dynamic - m_dynamic_loader_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.macosx-dyld")); - - if (m_dynamic_loader_ap.get() == NULL) - error.SetErrorString("unable to find the dynamic loader named 'dynamic-loader.macosx-dyld'"); - - return error; + return Error(); } @@ -434,11 +426,7 @@ void ProcessMacOSX::DidLaunchOrAttach () { - if (GetID() == LLDB_INVALID_PROCESS_ID) - { - m_dynamic_loader_ap.reset(); - } - else + if (GetID() != LLDB_INVALID_PROCESS_ID) { Module * exe_module = GetTarget().GetExecutableModule ().get(); assert (exe_module); @@ -455,16 +443,12 @@ { ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::DidLaunch()"); DidLaunchOrAttach (); - if (m_dynamic_loader_ap.get()) - m_dynamic_loader_ap->DidLaunch(); } void ProcessMacOSX::DidAttach () { DidLaunchOrAttach (); - if (m_dynamic_loader_ap.get()) - m_dynamic_loader_ap->DidAttach(); } Error @@ -870,12 +854,6 @@ return Task().GetDYLDAllImageInfosAddress(); } -DynamicLoader * -ProcessMacOSX::GetDynamicLoader() -{ - return m_dynamic_loader_ap.get(); -} - //------------------------------------------------------------------ // Process Memory //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h Tue Feb 15 22:46:07 2011 @@ -222,9 +222,6 @@ virtual lldb_private::Error DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc); - virtual lldb_private::DynamicLoader * - GetDynamicLoader (); - static void AddArchCreateCallback(const lldb_private::ArchSpec& arch_spec, ProcessMacOSX::CreateArchCalback callback); @@ -244,7 +241,6 @@ MachException::Message::collection m_exception_messages; // A collection of exception messages caught when listening to the exception port lldb_private::Mutex m_exception_messages_mutex; // Multithreaded protection for m_exception_messages lldb_private::ArchSpec m_arch_spec; - std::auto_ptr m_dynamic_loader_ap; //---------------------------------------------------------------------- // Child process control Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Feb 15 22:46:07 2011 @@ -101,7 +101,6 @@ //---------------------------------------------------------------------- ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) : Process (target, listener), - m_dynamic_loader_ap (), m_flags (0), m_stdio_mutex (Mutex::eMutexTypeRecursive), m_gdb_comm(), @@ -132,8 +131,6 @@ //---------------------------------------------------------------------- ProcessGDBRemote::~ProcessGDBRemote() { - m_dynamic_loader_ap.reset(); - if (IS_VALID_LLDB_HOST_THREAD(m_debugserver_thread)) { Host::ThreadCancel (m_debugserver_thread, NULL); @@ -410,13 +407,7 @@ ProcessGDBRemote::WillLaunchOrAttach () { Error error; - // TODO: this is hardcoded for macosx right now. We need this to be more dynamic - m_dynamic_loader_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.macosx-dyld")); - - if (m_dynamic_loader_ap.get() == NULL) - error.SetErrorString("unable to find the dynamic loader named 'dynamic-loader.macosx-dyld'"); m_stdio_communication.Clear (); - return error; } @@ -628,11 +619,7 @@ LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) log->Printf ("ProcessGDBRemote::DidLaunch()"); - if (GetID() == LLDB_INVALID_PROCESS_ID) - { - m_dynamic_loader_ap.reset(); - } - else + if (GetID() != LLDB_INVALID_PROCESS_ID) { m_dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS; @@ -673,8 +660,6 @@ ProcessGDBRemote::DidLaunch () { DidLaunchOrAttach (); - if (m_dynamic_loader_ap.get()) - m_dynamic_loader_ap->DidLaunch(); } Error @@ -816,8 +801,6 @@ ProcessGDBRemote::DidAttach () { DidLaunchOrAttach (); - if (m_dynamic_loader_ap.get()) - m_dynamic_loader_ap->DidAttach(); } Error @@ -1540,12 +1523,6 @@ return LLDB_INVALID_ADDRESS; } -DynamicLoader * -ProcessGDBRemote::GetDynamicLoader() -{ - return m_dynamic_loader_ap.get(); -} - //------------------------------------------------------------------ // Process Memory //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Tue Feb 15 22:46:07 2011 @@ -219,9 +219,6 @@ virtual lldb_private::Error DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc); - virtual lldb_private::DynamicLoader * - GetDynamicLoader (); - virtual bool StartNoticingNewThreads(); @@ -328,8 +325,6 @@ eBroadcastBitAsyncThreadShouldExit = (1 << 1) }; - - std::auto_ptr m_dynamic_loader_ap; lldb_private::Flags m_flags; // Process specific flags (see eFlags enums) lldb_private::Mutex m_stdio_mutex; // Multithreaded protection for stdio GDBRemoteCommunication m_gdb_comm; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Feb 15 22:46:07 2011 @@ -845,12 +845,6 @@ return error; } -DynamicLoader * -Process::GetDynamicLoader() -{ - return NULL; -} - const ABI * Process::GetABI() { @@ -1503,6 +1497,7 @@ { Error error; m_abi_sp.reset(); + m_dyld_ap.reset(); m_process_input_reader.reset(); Module *exe_module = m_target.GetExecutableModule().get(); @@ -1569,8 +1564,13 @@ if (state == eStateStopped || state == eStateCrashed) { + DidLaunch (); + m_dyld_ap.reset (DynamicLoader::FindPlugin(this, false)); + if (m_dyld_ap.get()) + m_dyld_ap->DidLaunch(); + // This delays passing the stopped event to listeners till DidLaunch gets // a chance to complete... HandlePrivateEvent (event_sp); @@ -1609,25 +1609,7 @@ // lldb_private::Process subclasses must set the process must set // the new process ID. assert (m_process->GetID() != LLDB_INVALID_PROCESS_ID); - m_process->DidAttach (); - // Figure out which one is the executable, and set that in our target: - ModuleList &modules = m_process->GetTarget().GetImages(); - - size_t num_modules = modules.GetSize(); - for (int i = 0; i < num_modules; i++) - { - ModuleSP module_sp = modules.GetModuleAtIndex(i); - if (module_sp->IsExecutable()) - { - ModuleSP exec_module = m_process->GetTarget().GetExecutableModule(); - if (!exec_module || exec_module != module_sp) - { - - m_process->GetTarget().SetExecutableModule (module_sp, false); - } - break; - } - } + m_process->CompleteAttach (); return eEventActionSuccess; } @@ -1671,6 +1653,8 @@ GetTarget().SetArchitecture(attach_spec); } + m_dyld_ap.reset(); + Error error (WillAttachToProcessWithID(attach_pid)); if (error.Success()) { @@ -1716,6 +1700,8 @@ GetTarget().SetArchitecture(attach_spec); } } + + m_dyld_ap.reset(); Error error (WillAttachToProcessWithName(process_name, wait_for_launch)); if (error.Success()) @@ -1743,6 +1729,36 @@ return error; } +void +Process::CompleteAttach () +{ + // Let the process subclass figure out at much as it can about the process + // before we go looking for a dynamic loader plug-in. + DidAttach(); + + // We have complete the attach, now it is time to find the dynamic loader + // plug-in + m_dyld_ap.reset (DynamicLoader::FindPlugin(this, false)); + if (m_dyld_ap.get()) + m_dyld_ap->DidAttach(); + + // Figure out which one is the executable, and set that in our target: + ModuleList &modules = m_target.GetImages(); + + size_t num_modules = modules.GetSize(); + for (int i = 0; i < num_modules; i++) + { + ModuleSP module_sp (modules.GetModuleAtIndex(i)); + if (module_sp->IsExecutable()) + { + ModuleSP target_exe_module_sp (m_target.GetExecutableModule()); + if (target_exe_module_sp != module_sp) + m_target.SetExecutableModule (module_sp, false); + break; + } + } +} + Error Process::ConnectRemote (const char *remote_url) { Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=125650&r1=125649&r2=125650&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Tue Feb 15 22:46:07 2011 @@ -3258,7 +3258,11 @@ char ostype[64]; len = sizeof(ostype); if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0) + { + len = strlen(ostype); + std::transform (ostype, ostype + len, ostype, tolower); strm << "ostype:" << std::dec << ostype << ';'; + } strm << "vendor:apple;"; From wilsons at start.ca Tue Feb 15 23:24:31 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 16 Feb 2011 05:24:31 -0000 Subject: [Lldb-commits] [lldb] r125653 - /lldb/trunk/include/lldb/Core/ArchSpec.h Message-ID: <20110216052431.9D4D52A6C12C@llvm.org> Author: wilsons Date: Tue Feb 15 23:24:31 2011 New Revision: 125653 URL: http://llvm.org/viewvc/llvm-project?rev=125653&view=rev Log: Use SIZE_MAX instead of SIZE_T_MAX for portability. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=125653&r1=125652&r2=125653&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Tue Feb 15 23:24:31 2011 @@ -12,6 +12,8 @@ #if defined(__cplusplus) +#include + #include "lldb/lldb-private.h" #include "llvm/ADT/Triple.h" @@ -348,10 +350,10 @@ private: void - MachOArchUpdated (size_t macho_idx = SIZE_T_MAX); + MachOArchUpdated (size_t macho_idx = SIZE_MAX); void - ELFArchUpdated (size_t idx = SIZE_T_MAX); + ELFArchUpdated (size_t idx = SIZE_MAX); }; From wilsons at start.ca Tue Feb 15 23:25:14 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 16 Feb 2011 05:25:14 -0000 Subject: [Lldb-commits] [lldb] r125654 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Message-ID: <20110216052514.194D92A6C12C@llvm.org> Author: wilsons Date: Tue Feb 15 23:25:13 2011 New Revision: 125654 URL: http://llvm.org/viewvc/llvm-project?rev=125654&view=rev Log: linux: Set ArchSpec m_type correctly from object file. An ArchSpec's type defaults to MachO. Ensure the type is properly set on ELF systems. Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=125654&r1=125653&r2=125654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Feb 15 23:25:13 2011 @@ -1065,6 +1065,8 @@ arch.GetTriple().setOSName ("linux"); // TODO: determine if there is an OS in the ELF? Default to "gnu" for now arch.GetTriple().setVendorName("gnu"); + + arch.SetElfArch(m_header.e_machine, m_header.e_flags); return true; } From wilsons at start.ca Tue Feb 15 23:36:26 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 16 Feb 2011 05:36:26 -0000 Subject: [Lldb-commits] [lldb] r125655 - /lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Message-ID: <20110216053626.ABE282A6C12C@llvm.org> Author: wilsons Date: Tue Feb 15 23:36:26 2011 New Revision: 125655 URL: http://llvm.org/viewvc/llvm-project?rev=125655&view=rev Log: Expose includes for the socket layer on all platforms. This patch reverts a portion of r125199 to allow the tree to build again on linux. The specific mingw issues that revision intended to address can be sorted out at a later time. Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=125655&r1=125654&r2=125655&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Tue Feb 15 23:36:26 2011 @@ -12,14 +12,12 @@ // C Includes #include #include -#ifdef __APPLE__ #include #include #include #include #include #include -#endif #include #include #include From wilsons at start.ca Tue Feb 15 23:38:31 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 16 Feb 2011 05:38:31 -0000 Subject: [Lldb-commits] [lldb] r125656 - /lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h Message-ID: <20110216053831.F085D2A6C12C@llvm.org> Author: wilsons Date: Tue Feb 15 23:38:31 2011 New Revision: 125656 URL: http://llvm.org/viewvc/llvm-project?rev=125656&view=rev Log: Make declaration of DynamicLoaderLinuxDYLD::CreateInstance match its definition. Modified: lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h Modified: lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h?rev=125656&r1=125655&r2=125656&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.h Tue Feb 15 23:38:31 2011 @@ -37,7 +37,7 @@ GetPluginDescriptionStatic(); static lldb_private::DynamicLoader * - CreateInstance(lldb_private::Process *process); + CreateInstance(lldb_private::Process *process, bool force); DynamicLoaderLinuxDYLD(lldb_private::Process *process); From jingham at apple.com Wed Feb 16 11:54:55 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 16 Feb 2011 17:54:55 -0000 Subject: [Lldb-commits] [lldb] r125668 - in /lldb/trunk/source/Target: Process.cpp Target.cpp Message-ID: <20110216175455.9D3FD2A6C12C@llvm.org> Author: jingham Date: Wed Feb 16 11:54:55 2011 New Revision: 125668 URL: http://llvm.org/viewvc/llvm-project?rev=125668&view=rev Log: Destroy the dynamic loader plugin in Process::Finalize. If you wait till the auto_ptr gets deleted in the normal course of things the real process class will have been destroyed already, and it's hard to shut down the dynamic loader without accessing some process pure virtual method. Modified: lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=125668&r1=125667&r2=125668&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Feb 16 11:54:55 2011 @@ -279,6 +279,11 @@ { // Do any cleanup needed prior to being destructed... Subclasses // that override this method should call this superclass method as well. + + // We need to destroy the loader before the derived Process class gets destroyed + // since it is very likely that undoing the loader will require access to the real process. + if (m_dyld_ap.get() != NULL) + m_dyld_ap.reset(); } void Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=125668&r1=125667&r2=125668&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Feb 16 11:54:55 2011 @@ -98,8 +98,8 @@ m_section_load_list.Clear(); if (m_process_sp->IsAlive()) m_process_sp->Destroy(); - else - m_process_sp->Finalize(); + + m_process_sp->Finalize(); // Do any cleanup of the target we need to do between process instances. // NB It is better to do this before destroying the process in case the From johnny.chen at apple.com Wed Feb 16 12:35:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 18:35:47 -0000 Subject: [Lldb-commits] [lldb] r125671 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110216183547.2E21E2A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 12:35:47 2011 New Revision: 125671 URL: http://llvm.org/viewvc/llvm-project?rev=125671&view=rev Log: Add tagging for EmulateLDRRtRnImm(). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125671&r1=125670&r2=125671&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Wed Feb 16 12:35:47 2011 @@ -376,6 +376,7 @@ bool EmulateLDMIB (ARMEncoding encoding); + // A8.6.57 LDR (immediate, Thumb) -- Encoding T1 bool EmulateLDRRtRnImm (ARMEncoding encoding); From clattner at apple.com Wed Feb 16 12:48:00 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 16 Feb 2011 10:48:00 -0800 Subject: [Lldb-commits] [PATCH] Use SIZE_MAX instead of SIZE_T_MAX for portability. In-Reply-To: References: Message-ID: On Feb 15, 2011, at 8:05 PM, Stephen Wilson wrote: > > diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h > index 198722c..3bb14ac 100644 > --- a/include/lldb/Core/ArchSpec.h > +++ b/include/lldb/Core/ArchSpec.h > @@ -12,6 +12,8 @@ > > #if defined(__cplusplus) > > +#include stdint.h isn't portable. Please use llvm/Support/DataTypes.h. Alternatively you can just use something like "~(size_t)0". -Chris > + > #include "lldb/lldb-private.h" > #include "llvm/ADT/Triple.h" > > @@ -348,10 +350,10 @@ protected: > private: > > void > - MachOArchUpdated (size_t macho_idx = SIZE_T_MAX); > + MachOArchUpdated (size_t macho_idx = SIZE_MAX); > > void > - ELFArchUpdated (size_t idx = SIZE_T_MAX); > + ELFArchUpdated (size_t idx = SIZE_MAX); > }; > > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Wed Feb 16 13:22:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 19:22:52 -0000 Subject: [Lldb-commits] [lldb] r125682 - /lldb/trunk/test/threads/main.cpp Message-ID: <20110216192252.A54FF2A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 13:22:52 2011 New Revision: 125682 URL: http://llvm.org/viewvc/llvm-project?rev=125682&view=rev Log: Fix clang++ warning building the executable for testing. Modified: lldb/trunk/test/threads/main.cpp Modified: lldb/trunk/test/threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/main.cpp?rev=125682&r1=125681&r2=125682&view=diff ============================================================================== --- lldb/trunk/test/threads/main.cpp (original) +++ lldb/trunk/test/threads/main.cpp Wed Feb 16 13:22:52 2011 @@ -61,7 +61,7 @@ { // random micro second sleep from zero to 3 seconds int usec = ::rand() % 3000000; - printf ("%s (thread = %u) doing a usleep (%li)...\n", __FUNCTION__, thread_index, usec); + printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec); ::usleep (usec); printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line. } From johnny.chen at apple.com Wed Feb 16 13:27:43 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 19:27:43 -0000 Subject: [Lldb-commits] [lldb] r125683 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110216192743.810492A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 13:27:43 2011 New Revision: 125683 URL: http://llvm.org/viewvc/llvm-project?rev=125683&view=rev Log: Add encoding entries for LSL (immediate and register) and LSR (immediate and register) to ARM and Thumb opcode tables. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125683&r1=125682&r2=125683&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed Feb 16 13:27:43 2011 @@ -4029,8 +4029,16 @@ { 0x0fef0000, 0x03e00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateMvnRdImm, "mvn{s} , #"}, // asr (immediate) { 0x0fef0070, 0x01a00040, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateASRImm, "asr{s} , , #imm"}, - // asr (immediate) + // asr (register) { 0x0fef00f0, 0x01a00050, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateASRReg, "asr{s} , , "}, + // lsl (immediate) + { 0x0fef0070, 0x01a00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSLImm, "lsl{s} , , #imm"}, + // lsl (register) + { 0x0fef00f0, 0x01a00010, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSLReg, "lsl{s} , , "}, + // lsr (immediate) + { 0x0fef0070, 0x01a00020, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSRImm, "lsr{s} , , #imm"}, + // lsr (register) + { 0x0fef00f0, 0x01a00050, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSRReg, "lsr{s} , , "}, //---------------------------------------------------------------------- // Load instructions @@ -4163,6 +4171,18 @@ // asr (register) { 0xffffffc0, 0x00004100, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateASRReg, "asrs|asr , "}, { 0xffe0f0f0, 0xfa40f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateASRReg, "asr{s}.w , , "}, + // lsl (immediate) + { 0xfffff800, 0x00000000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSLImm, "lsls|lsl , , #imm"}, + { 0xffef8030, 0xea4f0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSLImm, "lsl{s}.w , , #imm"}, + // lsl (register) + { 0xffffffc0, 0x00004080, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSLReg, "lsls|lsl , "}, + { 0xffe0f0f0, 0xfa00f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSLReg, "lsl{s}.w , , "}, + // lsr (immediate) + { 0xfffff800, 0x00000800, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSRImm, "lsrs|lsr , , #imm"}, + { 0xffef8030, 0xea4f0010, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSRImm, "lsr{s}.w , , #imm"}, + // lsr (register) + { 0xffffffc0, 0x000040c0, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSRReg, "lsrs|asr , "}, + { 0xffe0f0f0, 0xfa20f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSRReg, "lsr{s}.w , , "}, //---------------------------------------------------------------------- // Load instructions From gclayton at apple.com Wed Feb 16 13:54:14 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 16 Feb 2011 19:54:14 -0000 Subject: [Lldb-commits] [lldb] r125685 - in /lldb/branches/apple/calcite/lldb: include/lldb/ include/lldb/Symbol/ include/lldb/Utility/ source/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Utility/ Message-ID: <20110216195414.B10052A6C12C@llvm.org> Author: gclayton Date: Wed Feb 16 13:54:14 2011 New Revision: 125685 URL: http://llvm.org/viewvc/llvm-project?rev=125685&view=rev Log: Ported over the shared pointers in unwind plans and arch default plans fixes. Modified: lldb/branches/apple/calcite/lldb/include/lldb/Symbol/FuncUnwinders.h lldb/branches/apple/calcite/lldb/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/branches/apple/calcite/lldb/include/lldb/lldb-forward-rtti.h lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.h lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/branches/apple/calcite/lldb/source/Symbol/FuncUnwinders.cpp lldb/branches/apple/calcite/lldb/source/Utility/ArchDefaultUnwindPlan.cpp lldb/branches/apple/calcite/lldb/source/lldb.cpp Modified: lldb/branches/apple/calcite/lldb/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Symbol/FuncUnwinders.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/include/lldb/Symbol/FuncUnwinders.h (original) +++ lldb/branches/apple/calcite/lldb/include/lldb/Symbol/FuncUnwinders.h Wed Feb 16 13:54:14 2011 @@ -43,16 +43,16 @@ // On architectures where the pc points to the next instruction that will execute, this // offset value will have already been decremented by 1 to stay within the bounds of the // correct function body. - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanAtCallSite (int current_offset); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanFastUnwind (lldb_private::Thread& Thread); - UnwindPlan* + lldb::UnwindPlanSP GetUnwindPlanArchitectureDefault (lldb_private::Thread& thread); Address& @@ -74,10 +74,10 @@ AddressRange m_range; Mutex m_mutex; - std::auto_ptr m_unwind_at_call_site_ap; - std::auto_ptr m_unwind_at_non_call_site_ap; - std::auto_ptr m_unwind_fast_ap; - UnwindPlan *m_unwind_arch_default; + lldb::UnwindPlanSP m_unwind_plan_call_site_sp; + lldb::UnwindPlanSP m_unwind_plan_non_call_site_sp; + lldb::UnwindPlanSP m_unwind_plan_fast_sp; + lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; bool m_tried_unwind_at_call_site:1, m_tried_unwind_at_non_call_site:1, Modified: lldb/branches/apple/calcite/lldb/include/lldb/Utility/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Utility/ArchDefaultUnwindPlan.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/include/lldb/Utility/ArchDefaultUnwindPlan.h (original) +++ lldb/branches/apple/calcite/lldb/include/lldb/Utility/ArchDefaultUnwindPlan.h Wed Feb 16 13:54:14 2011 @@ -23,10 +23,10 @@ virtual ~ArchDefaultUnwindPlan(); - virtual lldb_private::UnwindPlan* + virtual lldb::UnwindPlanSP GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) = 0; - static ArchDefaultUnwindPlan* + static lldb::ArchDefaultUnwindPlanSP FindPlugin (const ArchSpec &arch); protected: Modified: lldb/branches/apple/calcite/lldb/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/lldb-forward-rtti.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/include/lldb/lldb-forward-rtti.h (original) +++ lldb/branches/apple/calcite/lldb/include/lldb/lldb-forward-rtti.h Wed Feb 16 13:54:14 2011 @@ -22,6 +22,7 @@ typedef SharedPtr::Type ABISP; typedef SharedPtr::Type AddressResolverSP; + typedef SharedPtr::Type ArchDefaultUnwindPlanSP; typedef SharedPtr::Type BatonSP; typedef SharedPtr::Type BlockSP; typedef SharedPtr::Type BreakpointSP; @@ -67,6 +68,7 @@ typedef SharedPtr::Type TypeSP; typedef SharedPtr::Type FuncUnwindersSP; typedef SharedPtr::Type UserSettingsControllerSP; + typedef SharedPtr::Type UnwindPlanSP; typedef SharedPtr::Type ValueObjectSP; typedef SharedPtr::Type VariableSP; typedef SharedPtr::Type VariableListSP; Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp Wed Feb 16 13:54:14 2011 @@ -8,115 +8,182 @@ //===----------------------------------------------------------------------===// #include "ArchDefaultUnwindPlan-x86.h" -#include "llvm/Support/MachO.h" -#include "lldb/lldb-private.h" -#include "lldb/Utility/ArchDefaultUnwindPlan.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/lldb-enumerations.h" +#include "lldb/Utility/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; -lldb_private::UnwindPlan* -ArchDefaultUnwindPlan_x86::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) -{ - if (m_cpu == llvm::MachO::CPUTypeX86_64) - { - return &m_64bit_default; - } - if (m_cpu == llvm::MachO::CPUTypeI386) - { - return &m_32bit_default; - } - return NULL; -} - lldb_private::ArchDefaultUnwindPlan * -ArchDefaultUnwindPlan_x86::CreateInstance (const lldb_private::ArchSpec &arch) +ArchDefaultUnwindPlan_x86_64::CreateInstance (const lldb_private::ArchSpec &arch) { - uint32_t cpu = arch.GetCPUType (); - if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386) - return NULL; - - return new ArchDefaultUnwindPlan_x86 (cpu); + if (arch.GetGenericCPUType () == ArchSpec::eCPU_x86_64) + return new ArchDefaultUnwindPlan_x86_64 (); + return NULL; } -ArchDefaultUnwindPlan_x86::ArchDefaultUnwindPlan_x86(int cpu) : +ArchDefaultUnwindPlan_x86_64::ArchDefaultUnwindPlan_x86_64() : lldb_private::ArchDefaultUnwindPlan(), - m_cpu(cpu), - m_32bit_default(), - m_64bit_default() + m_unwind_plan_sp (new UnwindPlan) { UnwindPlan::Row row; UnwindPlan::Row::RegisterLocation regloc; - m_32bit_default.SetRegisterKind (eRegisterKindGeneric); + m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 4); + row.SetCFAOffset (2 * 8); row.SetOffset (0); - regloc.SetAtCFAPlusOffset (2 * -4); + regloc.SetAtCFAPlusOffset (2 * -8); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -4); + regloc.SetAtCFAPlusOffset (1 * -8); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); regloc.SetIsCFAPlusOffset (0); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - m_32bit_default.AppendRow (row); - m_32bit_default.SetSourceName ("architectural default"); + m_unwind_plan_sp->AppendRow (row); + m_unwind_plan_sp->SetSourceName ("x86_64 architectural default"); +} + +//------------------------------------------------------------------ +// PluginInterface protocol in UnwindAssemblyParser_x86 +//------------------------------------------------------------------ - row.Clear(); +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginName() +{ + return "ArchDefaultUnwindPlan_x86_64"; +} - m_64bit_default.SetRegisterKind (eRegisterKindGeneric); +const char * +ArchDefaultUnwindPlan_x86_64::GetShortPluginName() +{ + return "lldb.arch-default-unwind-plan.x86-64"; +} + + +uint32_t +ArchDefaultUnwindPlan_x86_64::GetPluginVersion() +{ + return 1; +} + +void +ArchDefaultUnwindPlan_x86_64::GetPluginCommandHelp (const char *command, Stream *strm) +{ +} + +Error +ArchDefaultUnwindPlan_x86_64::ExecutePluginCommand (Args &command, Stream *strm) +{ + Error error; + error.SetErrorString("No plug-in command are currently supported."); + return error; +} + +Log * +ArchDefaultUnwindPlan_x86_64::EnablePluginLogging (Stream *strm, Args &command) +{ + return NULL; +} + +void +ArchDefaultUnwindPlan_x86_64::Initialize() +{ + PluginManager::RegisterPlugin (GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); +} + +void +ArchDefaultUnwindPlan_x86_64::Terminate() +{ + PluginManager::UnregisterPlugin (CreateInstance); +} + + +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginNameStatic() +{ + return "ArchDefaultUnwindPlan_x86_64"; +} + +const char * +ArchDefaultUnwindPlan_x86_64::GetPluginDescriptionStatic() +{ + return "x86_64 architecture default unwind plan assembly plugin."; +} + +UnwindPlanSP +ArchDefaultUnwindPlan_x86_64::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) +{ + return m_unwind_plan_sp; +} + + + +lldb_private::ArchDefaultUnwindPlan * +ArchDefaultUnwindPlan_i386::CreateInstance (const lldb_private::ArchSpec &arch) +{ + if (arch.GetGenericCPUType () == ArchSpec::eCPU_i386) + return new ArchDefaultUnwindPlan_i386 (); + return NULL; +} + +ArchDefaultUnwindPlan_i386::ArchDefaultUnwindPlan_i386() : + lldb_private::ArchDefaultUnwindPlan(), + m_unwind_plan_sp (new UnwindPlan) +{ + UnwindPlan::Row row; + UnwindPlan::Row::RegisterLocation regloc; + + m_unwind_plan_sp->SetRegisterKind (eRegisterKindGeneric); row.SetCFARegister (LLDB_REGNUM_GENERIC_FP); - row.SetCFAOffset (2 * 8); + row.SetCFAOffset (2 * 4); row.SetOffset (0); - regloc.SetAtCFAPlusOffset (2 * -8); + regloc.SetAtCFAPlusOffset (2 * -4); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_FP, regloc); - regloc.SetAtCFAPlusOffset (1 * -8); + regloc.SetAtCFAPlusOffset (1 * -4); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_PC, regloc); regloc.SetIsCFAPlusOffset (0); row.SetRegisterInfo (LLDB_REGNUM_GENERIC_SP, regloc); - m_64bit_default.AppendRow (row); - m_64bit_default.SetSourceName ("architectural default"); + m_unwind_plan_sp->AppendRow (row); + m_unwind_plan_sp->SetSourceName ("i386 architectural default"); } - - - //------------------------------------------------------------------ // PluginInterface protocol in UnwindAssemblyParser_x86 //------------------------------------------------------------------ const char * -ArchDefaultUnwindPlan_x86::GetPluginName() +ArchDefaultUnwindPlan_i386::GetPluginName() { - return "ArchDefaultUnwindPlan_x86"; + return "ArchDefaultUnwindPlan_i386"; } const char * -ArchDefaultUnwindPlan_x86::GetShortPluginName() +ArchDefaultUnwindPlan_i386::GetShortPluginName() { - return "archdefaultunwindplan.x86"; + return "lldb.arch-default-unwind-plan.i386"; } uint32_t -ArchDefaultUnwindPlan_x86::GetPluginVersion() +ArchDefaultUnwindPlan_i386::GetPluginVersion() { return 1; } void -ArchDefaultUnwindPlan_x86::GetPluginCommandHelp (const char *command, Stream *strm) +ArchDefaultUnwindPlan_i386::GetPluginCommandHelp (const char *command, Stream *strm) { } Error -ArchDefaultUnwindPlan_x86::ExecutePluginCommand (Args &command, Stream *strm) +ArchDefaultUnwindPlan_i386::ExecutePluginCommand (Args &command, Stream *strm) { Error error; error.SetErrorString("No plug-in command are currently supported."); @@ -124,13 +191,13 @@ } Log * -ArchDefaultUnwindPlan_x86::EnablePluginLogging (Stream *strm, Args &command) +ArchDefaultUnwindPlan_i386::EnablePluginLogging (Stream *strm, Args &command) { return NULL; } void -ArchDefaultUnwindPlan_x86::Initialize() +ArchDefaultUnwindPlan_i386::Initialize() { PluginManager::RegisterPlugin (GetPluginNameStatic(), GetPluginDescriptionStatic(), @@ -138,20 +205,27 @@ } void -ArchDefaultUnwindPlan_x86::Terminate() +ArchDefaultUnwindPlan_i386::Terminate() { PluginManager::UnregisterPlugin (CreateInstance); } const char * -ArchDefaultUnwindPlan_x86::GetPluginNameStatic() +ArchDefaultUnwindPlan_i386::GetPluginNameStatic() { - return "ArchDefaultUnwindPlan_x86"; + return "ArchDefaultUnwindPlan_i386"; } const char * -ArchDefaultUnwindPlan_x86::GetPluginDescriptionStatic() +ArchDefaultUnwindPlan_i386::GetPluginDescriptionStatic() +{ + return "i386 architecture default unwind plan assembly plugin."; +} + +UnwindPlanSP +ArchDefaultUnwindPlan_i386::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) { - return "i386 and x86_64 architecture default unwind plan assembly plugin."; + return m_unwind_plan_sp; } + Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h Wed Feb 16 13:54:14 2011 @@ -17,13 +17,13 @@ namespace lldb_private { -class ArchDefaultUnwindPlan_x86 : public lldb_private::ArchDefaultUnwindPlan +class ArchDefaultUnwindPlan_x86_64 : public lldb_private::ArchDefaultUnwindPlan { public: - ~ArchDefaultUnwindPlan_x86 () { } + ~ArchDefaultUnwindPlan_x86_64 () { } - virtual lldb_private::UnwindPlan* + virtual lldb::UnwindPlanSP GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); static lldb_private::ArchDefaultUnwindPlan * @@ -63,11 +63,60 @@ EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); private: - ArchDefaultUnwindPlan_x86(int cpu); // Call CreateInstance instead. + ArchDefaultUnwindPlan_x86_64(); // Call CreateInstance instead. - int m_cpu; - lldb_private::UnwindPlan m_32bit_default; - lldb_private::UnwindPlan m_64bit_default; + lldb::UnwindPlanSP m_unwind_plan_sp; +}; + +class ArchDefaultUnwindPlan_i386 : public lldb_private::ArchDefaultUnwindPlan +{ +public: + + ~ArchDefaultUnwindPlan_i386 () { } + + virtual lldb::UnwindPlanSP + GetArchDefaultUnwindPlan (Thread& thread, Address current_pc); + + static lldb_private::ArchDefaultUnwindPlan * + CreateInstance (const lldb_private::ArchSpec &arch); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); + +private: + ArchDefaultUnwindPlan_i386(); // Call CreateInstance instead. + + lldb::UnwindPlanSP m_unwind_plan_sp; }; Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Wed Feb 16 13:54:14 2011 @@ -34,7 +34,7 @@ RegisterContextLLDB::RegisterContextLLDB ( Thread& thread, - const RegisterContextSP &next_frame, + const SharedPtr &next_frame, SymbolContext& sym_ctx, uint32_t frame_number ) : @@ -48,8 +48,8 @@ m_start_pc (), m_current_pc (), m_frame_number (frame_number), - m_full_unwind_plan(NULL), - m_fast_unwind_plan(NULL), + m_full_unwind_plan_sp (), + m_fast_unwind_plan_sp (), m_frame_type (-1), m_current_offset (0), m_current_offset_backed_up_one (0), @@ -68,20 +68,9 @@ } // This same code exists over in the GetFullUnwindPlanForFrame() but it may not have been executed yet - bool behaves_like_zeroth_frame = false; - if (IsFrameZero()) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero() && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eSigtrampFrame) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero() && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eDebuggerFrame) - { - behaves_like_zeroth_frame = true; - } - if (behaves_like_zeroth_frame) + if (IsFrameZero() + || m_next_frame->m_frame_type == eSigtrampFrame + || m_next_frame->m_frame_type == eDebuggerFrame) { m_all_registers_available = true; } @@ -124,6 +113,7 @@ if (addr_range.GetBaseAddress().IsValid()) { m_start_pc = addr_range.GetBaseAddress(); + assert (frame_sp->GetFrameCodeAddress().GetSection() == m_start_pc.GetSection()); m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset(); m_current_offset_backed_up_one = m_current_offset; } @@ -136,16 +126,16 @@ // We've set m_frame_type and m_sym_ctx before these calls. - m_fast_unwind_plan = GetFastUnwindPlanForFrame (); - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - + m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame (); + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + const UnwindPlan::Row *active_row = NULL; int cfa_offset = 0; int row_register_kind; - if (m_full_unwind_plan && m_full_unwind_plan->PlanValidAtAddress (m_current_pc)) + if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_full_unwind_plan->GetRegisterKind (); + active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); } if (active_row == NULL) @@ -189,7 +179,7 @@ m_frame_number, (uint64_t) m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()), (uint64_t) m_cfa, - m_full_unwind_plan->GetSourceName().GetCString()); + m_full_unwind_plan_sp->GetSourceName().GetCString()); } } @@ -205,7 +195,8 @@ m_frame_type = eNotAValidFrame; return; } - if (!((RegisterContextLLDB*)m_next_frame.get())->IsValid()) + + if (!m_next_frame->IsValid()) { m_frame_type = eNotAValidFrame; return; @@ -244,20 +235,20 @@ log->Printf("%*sFrame %u using architectural default unwind method", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); + if (arch_default_sp) { - m_fast_unwind_plan = NULL; - m_full_unwind_plan = arch_default->GetArchDefaultUnwindPlan (m_thread, m_current_pc); + m_fast_unwind_plan_sp.reset(); + m_full_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); m_frame_type = eNormalFrame; m_all_registers_available = false; m_current_offset = -1; m_current_offset_backed_up_one = -1; addr_t cfa_regval; - int row_register_kind = m_full_unwind_plan->GetRegisterKind (); - uint32_t cfa_regnum = m_full_unwind_plan->GetRowForFunctionOffset(0)->GetCFARegister(); - int cfa_offset = m_full_unwind_plan->GetRowForFunctionOffset(0)->GetCFAOffset(); + int row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); + uint32_t cfa_regnum = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFARegister(); + int cfa_offset = m_full_unwind_plan_sp->GetRowForFunctionOffset(0)->GetCFAOffset(); if (!ReadGPRValue (row_register_kind, cfa_regnum, cfa_regval)) { if (log) @@ -315,8 +306,8 @@ // Or if we're in the middle of the stack (and not "above" an asynchronous event like sigtramp), // and our "current" pc is the start of a function... if (m_sym_ctx_valid - && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eSigtrampFrame - && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eDebuggerFrame + && m_next_frame->m_frame_type != eSigtrampFrame + && m_next_frame->m_frame_type != eDebuggerFrame && addr_range.GetBaseAddress().IsValid() && addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection() && addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset()) @@ -374,7 +365,7 @@ } // We've set m_frame_type and m_sym_ctx before this call. - m_fast_unwind_plan = GetFastUnwindPlanForFrame (); + m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame (); const UnwindPlan::Row *active_row = NULL; int cfa_offset = 0; @@ -383,18 +374,18 @@ // Try to get by with just the fast UnwindPlan if possible - the full UnwindPlan may be expensive to get // (e.g. if we have to parse the entire eh_frame section of an ObjectFile for the first time.) - if (m_fast_unwind_plan && m_fast_unwind_plan->PlanValidAtAddress (m_current_pc)) + if (m_fast_unwind_plan_sp && m_fast_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_fast_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_fast_unwind_plan->GetRegisterKind (); + active_row = m_fast_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_fast_unwind_plan_sp->GetRegisterKind (); } else { - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - if (m_full_unwind_plan && m_full_unwind_plan->PlanValidAtAddress (m_current_pc)) + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - row_register_kind = m_full_unwind_plan->GetRegisterKind (); + active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + row_register_kind = m_full_unwind_plan_sp->GetRegisterKind (); } } @@ -460,49 +451,42 @@ // 3. m_current_pc should have the current pc value for this frame // 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown -UnwindPlan * +UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame () { if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) - { - return NULL; - } + return UnwindPlanSP(); if (IsFrameZero ()) - { - return NULL; - } + return UnwindPlanSP(); - FuncUnwindersSP fu; - fu = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); - if (fu.get() == NULL) - { - return NULL; - } + FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx)); + if (!func_unwinders_sp) + return UnwindPlanSP(); // If we're in _sigtramp(), unwinding past this frame requires special knowledge. if (m_frame_type == eSigtrampFrame || m_frame_type == eDebuggerFrame) - { - return NULL; - } + return UnwindPlanSP(); - if (fu->GetUnwindPlanFastUnwind (m_thread) - && fu->GetUnwindPlanFastUnwind (m_thread)->PlanValidAtAddress (m_current_pc)) + UnwindPlanSP unwind_plan_sp (func_unwinders_sp->GetUnwindPlanFastUnwind (m_thread)); + if (unwind_plan_sp) { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - if (log && IsLogVerbose()) + if (unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - const char *has_fast = ""; - if (m_fast_unwind_plan) - has_fast = ", and has a fast UnwindPlan"; - log->Printf("%*sFrame %u frame has a fast UnwindPlan", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + if (log && IsLogVerbose()) + { + const char *has_fast = ""; + if (m_fast_unwind_plan_sp) + has_fast = ", and has a fast UnwindPlan"; + log->Printf("%*sFrame %u frame has a fast UnwindPlan", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + } + m_frame_type = eNormalFrame; + return unwind_plan_sp; } - m_frame_type = eNormalFrame; - return fu->GetUnwindPlanFastUnwind (m_thread); } - - return NULL; + return UnwindPlanSP(); } // On entry to this method, @@ -512,37 +496,25 @@ // 3. m_current_pc should have the current pc value for this frame // 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown -UnwindPlan * +UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame () { + UnwindPlanSP unwind_plan_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); - UnwindPlan *up; - UnwindPlan *arch_default_up = NULL; - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) - { - arch_default_up = arch_default->GetArchDefaultUnwindPlan (m_thread, m_current_pc); - } + UnwindPlanSP arch_default_unwind_plan_sp; + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (arch)); + if (arch_default_sp) + arch_default_unwind_plan_sp = arch_default_sp->GetArchDefaultUnwindPlan (m_thread, m_current_pc); bool behaves_like_zeroth_frame = false; - if (IsFrameZero ()) - { - behaves_like_zeroth_frame = true; - } - if (!IsFrameZero () && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eSigtrampFrame) + if (IsFrameZero () + || m_next_frame->m_frame_type == eSigtrampFrame + || m_next_frame->m_frame_type == eDebuggerFrame) { behaves_like_zeroth_frame = true; - } - if (!IsFrameZero () && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type == eDebuggerFrame) - { - behaves_like_zeroth_frame = true; - } - - // If this frame behaves like a 0th frame (currently executing or interrupted asynchronously), all registers - // can be retrieved. - if (behaves_like_zeroth_frame) - { + // If this frame behaves like a 0th frame (currently executing or + // interrupted asynchronously), all registers can be retrieved. m_all_registers_available = true; } @@ -550,20 +522,20 @@ if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) { m_frame_type = eNormalFrame; - return arch_default_up; + return arch_default_unwind_plan_sp; } - FuncUnwindersSP fu; + FuncUnwindersSP func_unwinders_sp; if (m_sym_ctx_valid) { - fu = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); + func_unwinders_sp = m_current_pc.GetModule()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx); } // No FuncUnwinders available for this pc, try using architectural default unwind. - if (fu.get() == NULL) + if (!func_unwinders_sp) { m_frame_type = eNormalFrame; - return arch_default_up; + return arch_default_unwind_plan_sp; } // If we're in _sigtramp(), unwinding past this frame requires special knowledge. On Mac OS X this knowledge @@ -572,53 +544,54 @@ // how to unwind out of sigtramp. if (m_frame_type == eSigtrampFrame) { - m_fast_unwind_plan = NULL; - up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); - if (up && up->PlanValidAtAddress (m_current_pc)) - { - return up; - } + m_fast_unwind_plan_sp.reset(); + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) + return unwind_plan_sp; } // Typically the NonCallSite UnwindPlan is the unwind created by inspecting the assembly language instructions - up = fu->GetUnwindPlanAtNonCallSite (m_thread); - if (behaves_like_zeroth_frame && up && up->PlanValidAtAddress (m_current_pc)) + if (behaves_like_zeroth_frame) { - if (log && IsLogVerbose()) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { - log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + if (log && IsLogVerbose()) + { + log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + unwind_plan_sp->GetSourceName().GetCString()); + } + return unwind_plan_sp; } - return up; } // Typically this is unwind info from an eh_frame section intended for exception handling; only valid at call sites - up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); - if (up && up->PlanValidAtAddress (m_current_pc)) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { if (log && IsLogVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + unwind_plan_sp->GetSourceName().GetCString()); } - return up; + return unwind_plan_sp; } // We'd prefer to use an UnwindPlan intended for call sites when we're at a call site but if we've // struck out on that, fall back to using the non-call-site assembly inspection UnwindPlan if possible. - up = fu->GetUnwindPlanAtNonCallSite (m_thread); - if (up && up->PlanValidAtAddress (m_current_pc)) + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { if (log && IsLogVerbose()) { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - up->GetSourceName().GetCString()); + unwind_plan_sp->GetSourceName().GetCString()); } - return up; + return unwind_plan_sp; } // If nothing else, use the architectural default UnwindPlan and hope that does the job. @@ -626,9 +599,9 @@ { log->Printf("%*sFrame %u frame uses %s for full UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - arch_default_up->GetSourceName().GetCString()); + arch_default_unwind_plan_sp->GetSourceName().GetCString()); } - return arch_default_up; + return arch_default_unwind_plan_sp; } @@ -812,9 +785,9 @@ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); // Have we already found this register location? - std::map::const_iterator iterator; - if (m_registers.size() > 0) + if (!m_registers.empty()) { + std::map::const_iterator iterator; iterator = m_registers.find (lldb_regnum); if (iterator != m_registers.end()) { @@ -843,10 +816,10 @@ bool have_unwindplan_regloc = false; int unwindplan_registerkind = -1; - if (m_fast_unwind_plan) + if (m_fast_unwind_plan_sp) { - const UnwindPlan::Row *active_row = m_fast_unwind_plan->GetRowForFunctionOffset (m_current_offset); - unwindplan_registerkind = m_fast_unwind_plan->GetRegisterKind (); + const UnwindPlan::Row *active_row = m_fast_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + unwindplan_registerkind = m_fast_unwind_plan_sp->GetRegisterKind (); uint32_t row_regnum; if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum)) { @@ -872,15 +845,14 @@ if (!have_unwindplan_regloc) { - // m_full_unwind_plan being NULL means that we haven't tried to find a full UnwindPlan yet - if (m_full_unwind_plan == NULL) - { - m_full_unwind_plan = GetFullUnwindPlanForFrame (); - } - if (m_full_unwind_plan) + // m_full_unwind_plan_sp being NULL means that we haven't tried to find a full UnwindPlan yet + if (!m_full_unwind_plan_sp) + m_full_unwind_plan_sp = GetFullUnwindPlanForFrame (); + + if (m_full_unwind_plan_sp) { - const UnwindPlan::Row *active_row = m_full_unwind_plan->GetRowForFunctionOffset (m_current_offset); - unwindplan_registerkind = m_full_unwind_plan->GetRegisterKind (); + const UnwindPlan::Row *active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + unwindplan_registerkind = m_full_unwind_plan_sp->GetRegisterKind (); uint32_t row_regnum; if (!m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindLLDB, lldb_regnum, unwindplan_registerkind, row_regnum)) { @@ -905,7 +877,7 @@ { log->Printf("%*sFrame %u supplying caller's saved reg %d's location using %s UnwindPlan", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_regnum, m_full_unwind_plan->GetSourceName().GetCString()); + lldb_regnum, m_full_unwind_plan_sp->GetSourceName().GetCString()); } } } @@ -915,7 +887,7 @@ { // If a volatile register is being requested, we don't want to forward m_next_frame's register contents // up the stack -- the register is not retrievable at this frame. - ArchSpec arch = m_thread.GetProcess().GetTarget().GetArchitecture (); + const ArchSpec &arch = m_thread.GetProcess().GetTarget().GetArchitecture (); ArchVolatileRegs *volatile_regs = ArchVolatileRegs::FindPlugin (arch); if (volatile_regs && volatile_regs->RegisterIsVolatile (m_thread, lldb_regnum)) { @@ -928,11 +900,7 @@ return false; } - if (!IsFrameZero ()) - { - return ((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc); - } - else + if (IsFrameZero ()) { // This is frame 0 - we should return the actual live register context value RegisterLocation new_regloc; @@ -942,6 +910,10 @@ regloc = new_regloc; return true; } + else + { + return m_next_frame->SavedLocationForRegister (lldb_regnum, regloc); + } if (log) { log->Printf("%*sFrame %u could not supply caller's reg %d location", @@ -968,11 +940,7 @@ if (unwindplan_regloc.IsSame()) { - if (!IsFrameZero ()) - { - return ((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc); - } - else + if (IsFrameZero ()) { if (log) { @@ -982,6 +950,10 @@ } return false; } + else + { + return m_next_frame->SavedLocationForRegister (lldb_regnum, regloc); + } } if (unwindplan_regloc.IsCFAPlusOffset()) @@ -1123,7 +1095,7 @@ } RegisterLocation regloc; - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_regnum, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc)) { return false; } @@ -1166,7 +1138,7 @@ RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) return false; return ReadRegisterBytesFromRegisterLocation (lldb_reg, regloc, data); @@ -1200,7 +1172,7 @@ RegisterLocation regloc; // Find out where the NEXT frame saved THIS frame's register contents - if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc)) + if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc)) return false; return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset); Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h Wed Feb 16 13:54:14 2011 @@ -20,8 +20,10 @@ class RegisterContextLLDB : public lldb_private::RegisterContext { public: + typedef lldb::SharedPtr::Type SharedPtr; + RegisterContextLLDB (lldb_private::Thread &thread, - const lldb::RegisterContextSP& next_frame, + const SharedPtr& next_frame, lldb_private::SymbolContext& sym_ctx, uint32_t frame_number); @@ -147,22 +149,23 @@ bool ReadGPRValue (int register_kind, uint32_t regnum, lldb::addr_t &value); - lldb_private::UnwindPlan * + lldb::UnwindPlanSP GetFastUnwindPlanForFrame (); - lldb_private::UnwindPlan * + lldb::UnwindPlanSP GetFullUnwindPlanForFrame (); lldb_private::Thread& m_thread; - lldb::RegisterContextSP m_next_frame; + + SharedPtr m_next_frame; /// // The following tell us how to retrieve the CALLER's register values (ie the "previous" frame, aka the frame above) // i.e. where THIS frame saved them /// - lldb_private::UnwindPlan *m_fast_unwind_plan; // may be NULL - lldb_private::UnwindPlan *m_full_unwind_plan; + lldb::UnwindPlanSP m_fast_unwind_plan_sp; // may be NULL + lldb::UnwindPlanSP m_full_unwind_plan_sp; bool m_all_registers_available; // Can we retrieve all regs or just nonvolatile regs? int m_frame_type; // enum FrameType Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Wed Feb 16 13:54:14 2011 @@ -519,7 +519,6 @@ bool AssemblyParse_x86::get_non_call_site_unwind_plan (UnwindPlan &unwind_plan) { - UnwindPlan up; UnwindPlan::Row row; int non_prologue_insn_count = 0; m_cur_insn = m_func_bounds.GetBaseAddress (); Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp Wed Feb 16 13:54:14 2011 @@ -15,10 +15,12 @@ #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/Function.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" -#include "UnwindLLDB.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Core/Log.h" +#include "UnwindLLDB.h" +#include "RegisterContextLLDB.h" + using namespace lldb; using namespace lldb_private; @@ -65,23 +67,24 @@ { // First, set up the 0th (initial) frame CursorSP first_cursor_sp(new Cursor ()); - RegisterContextSP no_frame; - std::auto_ptr first_register_ctx_ap (new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0)); - if (first_register_ctx_ap.get() == NULL) + first_cursor_sp->reg_ctx_sp.reset (new RegisterContextLLDB (m_thread, + RegisterContextLLDB::SharedPtr(), + first_cursor_sp->sc, + 0)); + if (!first_cursor_sp->reg_ctx_sp) return false; - if (!first_register_ctx_ap->IsValid()) + if (!first_cursor_sp->reg_ctx_sp->IsValid()) return false; - if (!first_register_ctx_ap->GetCFA (first_cursor_sp->cfa)) + if (!first_cursor_sp->reg_ctx_sp->GetCFA (first_cursor_sp->cfa)) return false; - if (!first_register_ctx_ap->ReadPC (first_cursor_sp->start_pc)) + if (!first_cursor_sp->reg_ctx_sp->ReadPC (first_cursor_sp->start_pc)) return false; // Everything checks out, so release the auto pointer value and let the // cursor own it in its shared pointer - first_cursor_sp->reg_ctx.reset(first_register_ctx_ap.release()); m_frames.push_back (first_cursor_sp); return true; } @@ -92,20 +95,22 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); CursorSP cursor_sp(new Cursor ()); + if (!cursor_sp) + return false; // Frame zero is a little different if (m_frames.size() == 0) return false; uint32_t cur_idx = m_frames.size (); - std::auto_ptr register_ctx_ap(new RegisterContextLLDB (m_thread, - m_frames[cur_idx - 1]->reg_ctx, - cursor_sp->sctx, - cur_idx)); - if (register_ctx_ap.get() == NULL) + cursor_sp->reg_ctx_sp.reset(new RegisterContextLLDB (m_thread, + m_frames[cur_idx - 1]->reg_ctx_sp, + cursor_sp->sc, + cur_idx)); + if (!cursor_sp->reg_ctx_sp) return false; - if (!register_ctx_ap->IsValid()) + if (!cursor_sp->reg_ctx_sp->IsValid()) { if (log) { @@ -114,7 +119,7 @@ } return false; } - if (!register_ctx_ap->GetCFA (cursor_sp->cfa)) + if (!cursor_sp->reg_ctx_sp->GetCFA (cursor_sp->cfa)) { if (log) { @@ -132,7 +137,7 @@ } return false; } - if (!register_ctx_ap->ReadPC (cursor_sp->start_pc)) + if (!cursor_sp->reg_ctx_sp->ReadPC (cursor_sp->start_pc)) { if (log) { @@ -150,8 +155,6 @@ return false; } } - RegisterContextSP register_ctx_sp(register_ctx_ap.release()); - cursor_sp->reg_ctx = register_ctx_sp; m_frames.push_back (cursor_sp); return true; } @@ -198,6 +201,6 @@ ; if (idx < m_frames.size ()) - reg_ctx_sp = m_frames[idx]->reg_ctx; + reg_ctx_sp = m_frames[idx]->reg_ctx_sp; return reg_ctx_sp; } Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/Utility/UnwindLLDB.h Wed Feb 16 13:54:14 2011 @@ -10,15 +10,15 @@ #ifndef lldb_UnwindLLDB_h_ #define lldb_UnwindLLDB_h_ -#include "lldb/lldb-private.h" -#include "lldb/lldb-types.h" -#include "lldb/Target/Unwind.h" +#include + +#include "lldb/lldb-include.h" #include "lldb/Symbol/FuncUnwinders.h" #include "lldb/Symbol/UnwindPlan.h" -#include "RegisterContextLLDB.h" #include "lldb/Target/RegisterContext.h" -#include +#include "lldb/Target/Unwind.h" +#include "RegisterContextLLDB.h" namespace lldb_private { @@ -52,10 +52,16 @@ { lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown lldb::addr_t cfa; // The canonical frame address for this stack frame - lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation - lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's + lldb_private::SymbolContext sc; // A symbol context we'll contribute to & provide to the StackFrame creation + RegisterContextLLDB::SharedPtr reg_ctx_sp; // These are all RegisterContextLLDB's - Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } + Cursor () : + start_pc (LLDB_INVALID_ADDRESS), + cfa (LLDB_INVALID_ADDRESS), + sc(), + reg_ctx_sp() + { + } private: DISALLOW_COPY_AND_ASSIGN (Cursor); }; Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Wed Feb 16 13:54:14 2011 @@ -178,11 +178,12 @@ return false; } -void +bool GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - assert (reg_info); + if (reg_info == NULL) + return false; // Invalidate if needed InvalidateIfNeeded(false); @@ -200,6 +201,7 @@ // leave it as it was. m_reg_valid[reg] = false; } + return success; } Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h Wed Feb 16 13:54:14 2011 @@ -228,7 +228,7 @@ protected: friend class ThreadGDBRemote; - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); void Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Feb 16 13:54:14 2011 @@ -919,6 +919,18 @@ case 'T': case 'S': { + if (GetStopID() == 0) + { + // Our first stop, make sure we have a process ID, and also make + // sure we know about our registers + if (GetID() == LLDB_INVALID_PROCESS_ID) + { + lldb::pid_t pid = m_gdb_comm.GetCurrentProcessID (1); + if (pid != LLDB_INVALID_PROCESS_ID) + SetID (pid); + } + BuildDynamicRegisterInfo (true); + } // Stop with signal and thread info const uint8_t signo = stop_packet.GetHexU8(); std::string name; @@ -952,7 +964,14 @@ { // thread in big endian hex tid = Args::StringToUInt32 (value.c_str(), 0, 16); + Mutex::Locker locker (m_thread_list.GetMutex ()); thread_sp = m_thread_list.FindThreadByID(tid, false); + if (!thread_sp) + { + // Create the thread if we need to + thread_sp.reset (new ThreadGDBRemote (*this, tid)); + m_thread_list.AddThread(thread_sp); + } } else if (name.compare("hexname") == 0) { @@ -985,7 +1004,13 @@ StringExtractor reg_value_extractor; // Swap "value" over into "reg_value_extractor" reg_value_extractor.GetStringRef().swap(value); - static_cast (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor); + if (!static_cast (thread_sp.get())->PrivateSetRegisterValue (reg, reg_value_extractor)) + { + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD)); + if (log) + log->Printf ("Setting thread register '%s' (decoded to %u (0x%x)) with value '%s' for stop packet:\n %s\n", + name.c_str(), reg, reg, reg_value_extractor.GetStringRef().c_str(), stop_packet.GetStringRef().c_str()); + } } } } Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Wed Feb 16 13:54:14 2011 @@ -202,12 +202,12 @@ return reg_ctx_sp; } -void +bool ThreadGDBRemote::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) { GDBRemoteRegisterContext *gdb_reg_ctx = static_cast(GetRegisterContext ().get()); assert (gdb_reg_ctx); - gdb_reg_ctx->PrivateSetRegisterValue (reg, response); + return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } bool Modified: lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Wed Feb 16 13:54:14 2011 @@ -105,7 +105,7 @@ virtual bool RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); - void + bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Feb 16 13:54:14 2011 @@ -197,6 +197,14 @@ return g_dwarf_section_name; } +UniqueDWARFASTTypeMap & +SymbolFileDWARF::GetUniqueDWARFASTTypeMap () +{ + if (m_debug_map_symfile) + return m_debug_map_symfile->GetUniqueDWARFASTTypeMap (); + return m_unique_ast_type_map; +} + ClangASTContext & SymbolFileDWARF::GetClangASTContext () { @@ -559,7 +567,7 @@ { FileSpec cu_file_spec; - if (cu_die_name[0] == '/' || cu_comp_dir == NULL && cu_comp_dir[0]) + if (cu_die_name[0] == '/' || cu_comp_dir == NULL || cu_comp_dir[0] == '\0') { // If we have a full path to the compile unit, we don't need to resolve // the file. This can be expensive e.g. when the source files are NFS mounted. @@ -3172,10 +3180,10 @@ UniqueDWARFASTType unique_ast_entry; if (decl.IsValid()) { - if (m_unique_ast_type_map.Find (type_name_const_str, - die, - decl, - unique_ast_entry)) + if (GetUniqueDWARFASTTypeMap().Find (type_name_const_str, + die, + decl, + unique_ast_entry)) { // We have already parsed this type or from another // compile unit. GCC loves to use the "one definition @@ -3273,8 +3281,8 @@ unique_ast_entry.m_type_sp = type_sp; unique_ast_entry.m_die = die; unique_ast_entry.m_declaration = decl; - m_unique_ast_type_map.Insert (type_name_const_str, - unique_ast_entry); + GetUniqueDWARFASTTypeMap().Insert (type_name_const_str, + unique_ast_entry); if (die->HasChildren() == false && is_forward_declaration == false) { Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Feb 16 13:54:14 2011 @@ -321,6 +321,9 @@ clang::NamespaceDecl * ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die); + UniqueDWARFASTTypeMap & + GetUniqueDWARFASTTypeMap (); + SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Wed Feb 16 13:54:14 2011 @@ -15,6 +15,8 @@ #include #include "lldb/Symbol/SymbolFile.h" +#include "UniqueDWARFASTType.h" + class SymbolFileDWARF; class DWARFCompileUnit; class DWARFDebugInfoEntry; @@ -211,6 +213,11 @@ const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + UniqueDWARFASTTypeMap & + GetUniqueDWARFASTTypeMap () + { + return m_unique_ast_type_map; + } //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ @@ -218,6 +225,7 @@ std::vector m_compile_unit_infos; std::vector m_func_indexes; // Sorted by address std::vector m_glob_indexes; + UniqueDWARFASTTypeMap m_unique_ast_type_map; }; #endif // #ifndef liblldb_SymbolFileDWARFDebugMap_h_ Modified: lldb/branches/apple/calcite/lldb/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Symbol/FuncUnwinders.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Symbol/FuncUnwinders.cpp Wed Feb 16 13:54:14 2011 @@ -34,10 +34,10 @@ m_assembly_profiler(assembly_profiler), m_range(range), m_mutex (Mutex::eMutexTypeNormal), - m_unwind_at_call_site_ap (), - m_unwind_at_non_call_site_ap (), - m_unwind_fast_ap (), - m_unwind_arch_default (NULL), + m_unwind_plan_call_site_sp (), + m_unwind_plan_non_call_site_sp (), + m_unwind_plan_fast_sp (), + m_unwind_plan_arch_default_sp (), m_tried_unwind_at_call_site (false), m_tried_unwind_at_non_call_site (false), m_tried_unwind_fast (false), @@ -50,15 +50,15 @@ { } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite (int current_offset) { // Lock the mutex to ensure we can always give out the most appropriate // information. We want to make sure if someone requests a call site unwind // plan, that they get one and don't run into a race condition where one // thread has started to create the unwind plan and has put it into - // m_unwind_at_call_site_ap, and have another thread enter this function - // and return the partially filled in m_unwind_at_call_site_ap pointer. + // m_unwind_plan_call_site_sp, and have another thread enter this function + // and return the partially filled in m_unwind_plan_call_site_sp pointer. // We also want to make sure that we lock out other unwind plans from // being accessed until this one is done creating itself in case someone // had some code like: @@ -66,7 +66,7 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_call_site == false && m_unwind_at_call_site_ap.get() == NULL) + if (m_tried_unwind_at_call_site == false && m_unwind_plan_call_site_sp.get() == NULL) { m_tried_unwind_at_call_site = true; // We have cases (e.g. with _sigtramp on Mac OS X) where the hand-written eh_frame unwind info for a @@ -84,16 +84,16 @@ DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); if (eh_frame) { - m_unwind_at_call_site_ap.reset (new UnwindPlan); - if (!eh_frame->GetUnwindPlan (current_pc, *m_unwind_at_call_site_ap)) - m_unwind_at_call_site_ap.reset(); + m_unwind_plan_call_site_sp.reset (new UnwindPlan); + if (!eh_frame->GetUnwindPlan (current_pc, *m_unwind_plan_call_site_sp)) + m_unwind_plan_call_site_sp.reset(); } } } - return m_unwind_at_call_site_ap.get(); + return m_unwind_plan_call_site_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -109,17 +109,17 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_at_non_call_site == false && m_unwind_at_non_call_site_ap.get() == NULL) + if (m_tried_unwind_at_non_call_site == false && m_unwind_plan_non_call_site_sp.get() == NULL) { m_tried_unwind_at_non_call_site = true; - m_unwind_at_non_call_site_ap.reset (new UnwindPlan); - if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_at_non_call_site_ap)) - m_unwind_at_non_call_site_ap.reset(); + m_unwind_plan_non_call_site_sp.reset (new UnwindPlan); + if (!m_assembly_profiler->GetNonCallSiteUnwindPlanFromAssembly (m_range, thread, *m_unwind_plan_non_call_site_sp)) + m_unwind_plan_non_call_site_sp.reset(); } - return m_unwind_at_non_call_site_ap.get(); + return m_unwind_plan_non_call_site_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanFastUnwind (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -135,17 +135,17 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_fast == false && m_unwind_fast_ap.get() == NULL) + if (m_tried_unwind_fast == false && m_unwind_plan_fast_sp.get() == NULL) { m_tried_unwind_fast = true; - m_unwind_fast_ap.reset (new UnwindPlan); - if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_fast_ap)) - m_unwind_fast_ap.reset(); + m_unwind_plan_fast_sp.reset (new UnwindPlan); + if (!m_assembly_profiler->GetFastUnwindPlan (m_range, thread, *m_unwind_plan_fast_sp)) + m_unwind_plan_fast_sp.reset(); } - return m_unwind_fast_ap.get(); + return m_unwind_plan_fast_sp; } -UnwindPlan* +UnwindPlanSP FuncUnwinders::GetUnwindPlanArchitectureDefault (Thread& thread) { // Lock the mutex to ensure we can always give out the most appropriate @@ -161,21 +161,20 @@ // if (best_unwind_plan == NULL) // best_unwind_plan = GetUnwindPlanAtNonCallSite (...) Mutex::Locker locker (m_mutex); - if (m_tried_unwind_arch_default == false && m_unwind_arch_default == NULL) + if (m_tried_unwind_arch_default == false && m_unwind_plan_arch_default_sp.get() == NULL) { m_tried_unwind_arch_default = true; Address current_pc; Target *target = thread.CalculateTarget(); if (target) { - ArchSpec arch = target->GetArchitecture (); - ArchDefaultUnwindPlan *arch_default = ArchDefaultUnwindPlan::FindPlugin (arch); - if (arch_default) - m_unwind_arch_default = arch_default->GetArchDefaultUnwindPlan (thread, current_pc); + ArchDefaultUnwindPlanSP arch_default_sp (ArchDefaultUnwindPlan::FindPlugin (target->GetArchitecture ())); + if (arch_default_sp) + m_unwind_plan_arch_default_sp = arch_default_sp->GetArchDefaultUnwindPlan (thread, current_pc); } } - return m_unwind_arch_default; + return m_unwind_plan_arch_default_sp; } Address& Modified: lldb/branches/apple/calcite/lldb/source/Utility/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Utility/ArchDefaultUnwindPlan.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/Utility/ArchDefaultUnwindPlan.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/Utility/ArchDefaultUnwindPlan.cpp Wed Feb 16 13:54:14 2011 @@ -7,28 +7,42 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" + +#include + +#include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Host/Mutex.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" using namespace lldb; using namespace lldb_private; -ArchDefaultUnwindPlan* +ArchDefaultUnwindPlanSP ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch) { ArchDefaultUnwindPlanCreateInstance create_callback; + typedef std::map ArchDefaultUnwindPlanMap; + static ArchDefaultUnwindPlanMap g_plugin_map; + static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); + Mutex::Locker locker (g_plugin_map_mutex); + ArchDefaultUnwindPlanMap::iterator pos = g_plugin_map.find (arch); + if (pos != g_plugin_map.end()) + return pos->second; for (uint32_t idx = 0; (create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL; ++idx) { - std::auto_ptr default_unwind_plan_ap (create_callback (arch)); - if (default_unwind_plan_ap.get ()) - return default_unwind_plan_ap.release (); + ArchDefaultUnwindPlanSP default_unwind_plan_sp (create_callback (arch)); + if (default_unwind_plan_sp) + { + g_plugin_map[arch] = default_unwind_plan_sp; + return default_unwind_plan_sp; + } } - return NULL; + return ArchDefaultUnwindPlanSP(); } ArchDefaultUnwindPlan::ArchDefaultUnwindPlan () Modified: lldb/branches/apple/calcite/lldb/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/lldb.cpp?rev=125685&r1=125684&r2=125685&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/source/lldb.cpp (original) +++ lldb/branches/apple/calcite/lldb/source/lldb.cpp Wed Feb 16 13:54:14 2011 @@ -75,7 +75,8 @@ SymbolFileDWARF::Initialize(); SymbolFileSymtab::Initialize(); UnwindAssemblyProfiler_x86::Initialize(); - ArchDefaultUnwindPlan_x86::Initialize(); + ArchDefaultUnwindPlan_i386::Initialize(); + ArchDefaultUnwindPlan_x86_64::Initialize(); ArchVolatileRegs_x86::Initialize(); ScriptInterpreter::Initialize (); @@ -116,9 +117,10 @@ SymbolFileDWARF::Terminate(); SymbolFileSymtab::Terminate(); UnwindAssemblyProfiler_x86::Terminate(); - ArchDefaultUnwindPlan_x86::Terminate(); + ArchDefaultUnwindPlan_x86_64::Terminate(); + ArchDefaultUnwindPlan_i386::Terminate(); ArchVolatileRegs_x86::Terminate(); - ScriptInterpreter::Terminate (); + ScriptInterpreter::Terminate(); #ifdef __APPLE__ DynamicLoaderMacOSXDYLD::Terminate(); From ctice at apple.com Wed Feb 16 14:22:22 2011 From: ctice at apple.com (Caroline Tice) Date: Wed, 16 Feb 2011 20:22:22 -0000 Subject: [Lldb-commits] [lldb] r125686 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110216202222.4A8722A6C12C@llvm.org> Author: ctice Date: Wed Feb 16 14:22:22 2011 New Revision: 125686 URL: http://llvm.org/viewvc/llvm-project?rev=125686&view=rev Log: Add code to emulate STRB (Thumb) instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125686&r1=125685&r2=125686&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed Feb 16 14:22:22 2011 @@ -3963,6 +3963,144 @@ } return true; } + +bool +EmulateInstructionARM::EmulateSTRBThumb (ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); NullCheckIfThumbEE(n); + offset_addr = if add then (R[n] + imm32) else (R[n] - imm32); + address = if index then offset_addr else R[n]; + MemU[address,1] = R[t]<7:0>; + if wback then R[n] = offset_addr; +#endif + + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + if (ConditionPassed ()) + { + uint32_t t; + uint32_t n; + uint32_t imm32; + bool index; + bool add; + bool wback; + // EncodingSpecificOperations(); NullCheckIfThumbEE(n); + switch (encoding) + { + case eEncodingT1: + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm5, 32); + t = Bits32 (opcode, 2, 0); + n = Bits32 (opcode, 5, 3); + imm32 = Bits32 (opcode, 10, 6); + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + break; + + case eEncodingT2: + // if Rn == ???1111??? then UNDEFINED; + if (Bits32 (opcode, 19, 16) == 15) + return false; + + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + imm32 = Bits32 (opcode, 11, 0); + + // index = TRUE; add = TRUE; wback = FALSE; + index = true; + add = true; + wback = false; + + // if BadReg(t) then UNPREDICTABLE; + if (BadReg (t)) + return false; + break; + + case eEncodingT3: + // if P == ???1??? && U == ???1??? && W == ???0??? then SEE STRBT; + // if Rn == ???1111??? || (P == ???0??? && W == ???0???) then UNDEFINED; + if (Bits32 (opcode, 19, 16) == 15) + return false; + + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8, 32); + t = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + imm32 = Bits32 (opcode, 7, 0); + + // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + index = BitIsSet (opcode, 10); + add = BitIsSet (opcode, 9); + wback = BitIsSet (opcode, 8); + + // if BadReg(t) || (wback && n == t) then UNPREDICTABLE + if ((BadReg (t)) || (wback && (n == t))) + return false; + break; + + default: + return false; + } + + addr_t offset_addr; + addr_t address; + addr_t base_address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; + + // offset_addr = if add then (R[n] + imm32) else (R[n] - imm32); + if (add) + offset_addr = base_address + imm32; + else + offset_addr = base_address - imm32; + + // address = if index then offset_addr else R[n]; + if (index) + address = offset_addr; + else + address = base_address; + + // MemU[address,1] = R[t]<7:0>; NOTE: "MemU' means UNALIGNED memory access + Register base_reg; + base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); + + Register data_reg; + data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); + + EmulateInstruction::Context context; + context.type = eContextRegisterStore; + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - base_address); + + uint32_t data = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + t, 0, &success); + if (!success) + return false; + + data = Bits32 (data, 7, 0); + + if (!WriteMemoryUnsigned (context, address, data, 1)) + return false; + + // if wback then R[n] = offset_addr; + if (wback) + { + context.type = eContextRegisterLoad; + context.SetAddress (offset_addr); + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, offset_addr)) + return false; + } + + } + + return true; +} EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) @@ -4205,7 +4343,10 @@ { 0xfff00000, 0xf8c00000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str.w ,#]" }, { 0xfff00800, 0xf8400800, ARMV6T2_ABOVE, eEncodingT4, eSize32, &EmulateInstructionARM::EmulateSTRThumb, "str [,#+/-]" }, { 0xfffffe00, 0x00005000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTRRegister, "str { ]" }, - { 0xfff00fc0, 0xf8400000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTRRegister, "str.w [ {lsl #imm2>}]" } + { 0xfff00fc0, 0xf8400000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTRRegister, "str.w [ {lsl #imm2>}]" }, + { 0xfffff800, 0x00007000, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSTRBThumb, "strb [ #]" }, + { 0xfff00000, 0xf8800000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSTRBThumb, "strb.w [ #]" }, + { 0xfff00800, 0xf8000800, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSTRBThumb, "strb [, #+/-]{!}" } }; const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125686&r1=125685&r2=125686&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Wed Feb 16 14:22:22 2011 @@ -404,6 +404,11 @@ bool EmulateSTRRegister (ARMEncoding encoding); + // A8.6.195 STRB (immediate, Thumb) + bool + EmulateSTRBThumb (ARMEncoding encoding); + + uint32_t m_arm_isa; Mode m_inst_mode; uint32_t m_inst_cpsr; From johnny.chen at apple.com Wed Feb 16 16:14:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Feb 2011 22:14:44 -0000 Subject: [Lldb-commits] [lldb] r125689 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Instruction/ARM/EmulateInstructionARM.h Process/Utility/ARMUtils.h Message-ID: <20110216221444.7F8622A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 16:14:44 2011 New Revision: 125689 URL: http://llvm.org/viewvc/llvm-project?rev=125689&view=rev Log: Add emulation methods for ROR (immediate), ROR (register), and RRX. Turns out that they can be funneled through the helper methods EmulateShiftImm()/ EmulateShiftReg() as well. Modify EmulateShiftImm() to handle SRType_ROR and SRType_RRX. And fix a typo in the impl of utility Shift_C() in ARMUtils.h. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125689&r1=125688&r2=125689&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed Feb 16 16:14:44 2011 @@ -2250,6 +2250,82 @@ return EmulateShiftReg(encoding, SRType_LSR); } +// Rotate Right (immediate) provides the value of the contents of a register rotated by a constant value. +// The bits that are rotated off the right end are inserted into the vacated bit positions on the left. +// It can optionally update the condition flags based on the result. +bool +EmulateInstructionARM::EmulateRORImm (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + (result, carry) = Shift_C(R[m], SRType_ROR, shift_n, APSR.C); + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftImm(encoding, SRType_ROR); +} + +// Rotate Right (register) provides the value of the contents of a register rotated by a variable number of bits. +// The bits that are rotated off the right end are inserted into the vacated bit positions on the left. +// The variable number of bits is read from the bottom byte of a register. It can optionally update the condition +// flags based on the result. +bool +EmulateInstructionARM::EmulateRORReg (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[m]<7:0>); + (result, carry) = Shift_C(R[m], SRType_ROR, shift_n, APSR.C); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftReg(encoding, SRType_ROR); +} + +// Rotate Right with Extend provides the value of the contents of a register shifted right by one place, +// with the carry flag shifted into bit [31]. +// +// RRX can optionally update the condition flags based on the result. +// In that case, bit [0] is shifted into the carry flag. +bool +EmulateInstructionARM::EmulateRRX (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + if ConditionPassed() then + EncodingSpecificOperations(); + (result, carry) = Shift_C(R[m], SRType_RRX, 1, APSR.C); + if d == 15 then // Can only occur for ARM encoding + ALUWritePC(result); // setflags is always FALSE here + else + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + // APSR.V unchanged +#endif + + return EmulateShiftImm(encoding, SRType_RRX); +} + bool EmulateInstructionARM::EmulateShiftImm (ARMEncoding encoding, ARM_ShifterType shift_type) { @@ -2267,14 +2343,30 @@ uint32_t imm5; // encoding for the shift amount uint32_t carry; // the carry bit after the shift operation bool setflags; + + // Special case handling! + // A8.6.139 ROR (immediate) -- Encoding T1 + if (shift_type == SRType_ROR && encoding == eEncodingT1) + { + // Morph the T1 encoding from the ARM Architecture Manual into T2 encoding to + // have the same decoding of bit fields as the other Thumb2 shift operations. + encoding = eEncodingT2; + } + switch (encoding) { case eEncodingT1: + // Due to the above special case handling! + assert(shift_type != SRType_ROR); + Rd = Bits32(opcode, 2, 0); Rm = Bits32(opcode, 5, 3); setflags = !InITBlock(); imm5 = Bits32(opcode, 10, 6); break; case eEncodingT2: + // A8.6.141 RRX + assert(shift_type != SRType_RRX); + Rd = Bits32(opcode, 11, 8); Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); @@ -2292,13 +2384,17 @@ return false; } + // A8.6.139 ROR (immediate) + if (shift_type == SRType_ROR && imm5 == 0) + shift_type = SRType_RRX; + // Get the first operand. uint32_t value = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); if (!success) return false; - // Decode the shift amount. - uint32_t amt = DecodeImmShift(shift_type, imm5); + // Decode the shift amount if not RRX. + uint32_t amt = (shift_type == SRType_RRX ? 1 : DecodeImmShift(shift_type, imm5)); uint32_t result = Shift_C(value, shift_type, amt, Bit32(m_inst_cpsr, CPSR_C), carry); @@ -4177,6 +4273,12 @@ { 0x0fef0070, 0x01a00020, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSRImm, "lsr{s} , , #imm"}, // lsr (register) { 0x0fef00f0, 0x01a00050, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLSRReg, "lsr{s} , , "}, + // rrx is a special case encoding of ror (immediate) + { 0x0fef0ff0, 0x01a00060, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateRRX, "rrx{s} , "}, + // ror (immediate) + { 0x0fef0070, 0x01a00060, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateRORImm, "ror{s} , , #imm"}, + // ror (register) + { 0x0fef00f0, 0x01a00070, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateRORReg, "ror{s} , , "}, //---------------------------------------------------------------------- // Load instructions @@ -4319,8 +4421,15 @@ { 0xfffff800, 0x00000800, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSRImm, "lsrs|lsr , , #imm"}, { 0xffef8030, 0xea4f0010, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSRImm, "lsr{s}.w , , #imm"}, // lsr (register) - { 0xffffffc0, 0x000040c0, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSRReg, "lsrs|asr , "}, + { 0xffffffc0, 0x000040c0, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateLSRReg, "lsrs|lsr , "}, { 0xffe0f0f0, 0xfa20f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLSRReg, "lsr{s}.w , , "}, + // rrx is a special case encoding of ror (immediate) + { 0xffeff0f0, 0xea4f0030, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateRRX, "rrx{s}.w , "}, + // ror (immediate) + { 0xffef8030, 0xea4f0030, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateRORImm, "ror{s}.w , , #imm"}, + // ror (register) + { 0xffffffc0, 0x000041c0, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateRORReg, "rors|ror , "}, + { 0xffe0f0f0, 0xfa60f000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateRORReg, "ror{s}.w , , "}, //---------------------------------------------------------------------- // Load instructions Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125689&r1=125688&r2=125689&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Wed Feb 16 16:14:44 2011 @@ -352,11 +352,23 @@ bool EmulateLSRReg (ARMEncoding encoding); - // Helper method for ASR, LSL, and LSR (immediate) + // A8.6.139 ROR (immediate) + bool + EmulateRORImm (ARMEncoding encoding); + + // A8.6.140 ROR (register) + bool + EmulateRORReg (ARMEncoding encoding); + + // A8.6.141 RRX + bool + EmulateRRX (ARMEncoding encoding); + + // Helper method for ASR, LSL, LSR, ROR (immediate), and RRX bool EmulateShiftImm (ARMEncoding encoding, ARM_ShifterType shift_type); - // Helper method for ASR, LSL, and LSR (register) + // Helper method for ASR, LSL, LSR, and ROR (register) bool EmulateShiftReg (ARMEncoding encoding, ARM_ShifterType shift_type); Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125689&r1=125688&r2=125689&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Wed Feb 16 16:14:44 2011 @@ -180,7 +180,7 @@ result = ROR_C(value, amount, carry_out); break; case SRType_RRX: - result = RRX_C(value, amount, carry_out); + result = RRX_C(value, carry_in, carry_out); break; } return result; From gclayton at apple.com Wed Feb 16 17:00:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 16 Feb 2011 23:00:21 -0000 Subject: [Lldb-commits] [lldb] r125691 - in /lldb/trunk: include/lldb/Core/Value.h include/lldb/Symbol/Function.h include/lldb/Symbol/Type.h source/Commands/CommandObjectImage.cpp source/Core/Value.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangFunction.cpp source/Expression/ClangUserExpression.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp source/Symbol/Function.cpp source/Symbol/Type.cpp Message-ID: <20110216230021.F30E02A6C12C@llvm.org> Author: gclayton Date: Wed Feb 16 17:00:21 2011 New Revision: 125691 URL: http://llvm.org/viewvc/llvm-project?rev=125691&view=rev Log: Clean up a bit of the type getting code where lldb_private:Type now has clang_type_t GetClangFullType(); // Get a completely defined clang type clang_type_t GetClangLayoutType(); // Get a clang type that can be used for type layout clang_type_t GetClangForwardType(); // A type that can be completed if needed, but is more efficient. Modified: lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Symbol/Function.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Wed Feb 16 17:00:21 2011 @@ -74,7 +74,7 @@ Value * GetProxyTarget(); - void * + lldb::clang_type_t GetClangType(); ValueType Modified: lldb/trunk/include/lldb/Symbol/Function.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Function.h (original) +++ lldb/trunk/include/lldb/Symbol/Function.h Wed Feb 16 17:00:21 2011 @@ -546,19 +546,16 @@ const Type* GetType() const; - Type - GetReturnType (); + lldb::clang_type_t + GetReturnClangType (); // The Number of arguments, or -1 for an unprototyped function. int GetArgumentCount (); - const Type + lldb::clang_type_t GetArgumentTypeAtIndex (size_t idx); - const char * - GetArgumentNameAtIndex (size_t idx); - bool IsVariadic (); Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Wed Feb 16 17:00:21 2011 @@ -185,7 +185,7 @@ // Get the clang type, and resolve definitions for any // class/struct/union/enum types completely. lldb::clang_type_t - GetClangType (); + GetClangFullType (); // Get the clang type, and resolve definitions enough so that the type could // have layout performed. This allows ptrs and refs to class/struct/union/enum Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Wed Feb 16 17:00:21 2011 @@ -442,7 +442,7 @@ { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetClangType (); + type_sp->GetClangFullType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); } strm.EOL(); Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Wed Feb 16 17:00:21 2011 @@ -409,7 +409,7 @@ return byte_size; } -void * +clang_type_t Value::GetClangType () { if (m_context_type == eContextTypeValue) @@ -429,12 +429,12 @@ case eContextTypeLLDBType: if (GetType()) - return GetType()->GetClangType(); + return GetType()->GetClangForwardType(); break; case eContextTypeVariable: if (GetVariable()) - return GetVariable()->GetType()->GetClangType(); + return GetVariable()->GetType()->GetClangForwardType(); break; } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Feb 16 17:00:21 2011 @@ -1503,7 +1503,7 @@ { if (type->GetASTContext() == var_sp->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangFullType())) return NULL; } else @@ -1642,7 +1642,7 @@ log->PutCString (strm.GetData()); } - TypeFromUser this_user_type(this_type->GetClangType(), + TypeFromUser this_user_type(this_type->GetClangFullType(), this_type->GetClangAST()); m_struct_vars->m_object_pointer_type = this_user_type; @@ -1689,7 +1689,7 @@ if (!self_type) return; - TypeFromUser self_user_type(self_type->GetClangType(), + TypeFromUser self_user_type(self_type->GetClangFullType(), self_type->GetClangAST()); m_struct_vars->m_object_pointer_type = self_user_type; @@ -1747,7 +1747,7 @@ log->PutCString (strm.GetData()); } - TypeFromUser user_type (type_sp->GetClangType(), + TypeFromUser user_type (type_sp->GetClangFullType(), type_sp->GetClangAST()); AddOneType(context, user_type, false); @@ -1775,7 +1775,7 @@ return NULL; } - void *var_opaque_type = var_type->GetClangType(); + clang_type_t var_opaque_type = var_type->GetClangFullType(); if (!var_opaque_type) { @@ -2031,7 +2031,7 @@ return; } - fun_opaque_type = fun_type->GetClangType(); + fun_opaque_type = fun_type->GetClangFullType(); if (!fun_opaque_type) { Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Feb 16 17:00:21 2011 @@ -103,7 +103,7 @@ } m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress(); - m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType(); + m_function_return_qual_type = m_function_ptr->GetReturnClangType(); } //---------------------------------------------------------------------- @@ -163,12 +163,12 @@ std::string args_list_buffer; // This one stores the argument list called from the structure. for (size_t i = 0; i < num_args; i++) { - const char *type_string; - std::string type_stdstr; + std::string type_name; if (trust_function) { - type_string = m_function_ptr->GetArgumentTypeAtIndex(i).GetName().AsCString(); + lldb::clang_type_t arg_clang_type = m_function_ptr->GetArgumentTypeAtIndex(i); + type_name = ClangASTContext::GetTypeName(arg_clang_type); } else { @@ -176,8 +176,7 @@ void *clang_qual_type = arg_value->GetClangType (); if (clang_qual_type != NULL) { - type_stdstr = ClangASTContext::GetTypeName(clang_qual_type); - type_string = type_stdstr.c_str(); + type_name = ClangASTContext::GetTypeName(clang_qual_type); } else { @@ -186,13 +185,13 @@ } } - m_wrapper_function_text.append (type_string); + m_wrapper_function_text.append (type_name); if (i < num_args - 1) m_wrapper_function_text.append (", "); char arg_buf[32]; args_buffer.append (" "); - args_buffer.append (type_string); + args_buffer.append (type_name); snprintf(arg_buf, 31, "arg_%zd", i); args_buffer.push_back (' '); args_buffer.append (arg_buf); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Feb 16 17:00:21 2011 @@ -84,13 +84,12 @@ lldb::clang_type_t pointer_target_type; - if (ClangASTContext::IsPointerType(this_type->GetClangType(), + if (ClangASTContext::IsPointerType(this_type->GetClangForwardType(), &pointer_target_type)) { TypeFromUser target_ast_type(pointer_target_type, this_type->GetClangAST()); - if (target_ast_type.IsDefined() && - ClangASTContext::IsCXXClassType(target_ast_type.GetOpaqueQualType())) + if (ClangASTContext::IsCXXClassType(target_ast_type.GetOpaqueQualType())) { m_cplusplus = true; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Feb 16 17:00:21 2011 @@ -670,7 +670,7 @@ { Type *class_type = ResolveType (dwarf_cu, parent_die); if (class_type) - class_type->GetClangType(); + class_type->GetClangFullType(); } break; @@ -1312,17 +1312,18 @@ Type *base_class_type = ResolveTypeUID(encoding_uid); assert(base_class_type); + clang_type_t base_class_clang_type = base_class_type->GetClangFullType(); + assert (base_class_clang_type); if (class_language == eLanguageTypeObjC) { - GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_type->GetClangType()); + GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_clang_type); } else { - base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), + base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_clang_type, accessibility, is_virtual, is_base_of_class)); - assert(base_classes.back()); } } } @@ -3723,7 +3724,7 @@ element_orders.push_back (1); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); - clang_type_t array_element_type = element_type->GetClangType(); + clang_type_t array_element_type = element_type->GetClangFullType(); uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; uint64_t num_elements = 0; std::vector::const_reverse_iterator pos; Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Feb 16 17:00:21 2011 @@ -957,8 +957,8 @@ clang_type_t type1, clang_type_t type2) { - return ast->hasSameType(QualType::getFromOpaquePtr(type1), - QualType::getFromOpaquePtr(type2)); + return ast->hasSameType (QualType::getFromOpaquePtr(type1), + QualType::getFromOpaquePtr(type2)); } #pragma mark CVR modifiers Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Wed Feb 16 17:00:21 2011 @@ -399,39 +399,20 @@ return m_type; } -Type -Function::GetReturnType () +clang_type_t +Function::GetReturnClangType () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); - assert (clang_type->isFunctionType()); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); const clang::FunctionType *function_type = dyn_cast (clang_type); - clang::QualType fun_return_qualtype = function_type->getResultType(); - - const ConstString fun_return_name(ClangASTType::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr())); - - SymbolContext sc; - CalculateSymbolContext (&sc); - // Null out everything below the CompUnit 'cause we don't actually know these. - - size_t bit_size = ClangASTType::GetClangTypeBitWidth (GetType()->GetClangASTContext().getASTContext(), - fun_return_qualtype.getAsOpaquePtr()); - Type return_type (0, - GetType()->GetSymbolFile(), - fun_return_name, - bit_size, - sc.comp_unit, - 0, - Type::eEncodingIsSyntheticUID, - Declaration(), - fun_return_qualtype.getAsOpaquePtr(), - Type::eResolveStateFull); - return return_type; + if (function_type) + return function_type->getResultType().getAsOpaquePtr(); + return NULL; } int Function::GetArgumentCount () { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return -1; @@ -443,67 +424,33 @@ return 0; } -const Type +clang_type_t Function::GetArgumentTypeAtIndex (size_t idx) { - clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType())); - assert (clang_type->isFunctionType()); - if (!clang_type->isFunctionProtoType()) - return Type(); - + clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType())); const clang::FunctionProtoType *function_proto_type = dyn_cast(clang_type); - if (function_proto_type != NULL) + if (function_proto_type) { unsigned num_args = function_proto_type->getNumArgs(); if (idx >= num_args) - return Type(); - clang::QualType arg_qualtype = (function_proto_type->arg_type_begin())[idx]; - - const ConstString arg_return_name(ClangASTType::GetClangTypeName(arg_qualtype.getAsOpaquePtr())); - SymbolContext sc; - CalculateSymbolContext (&sc); - // Null out everything below the CompUnit 'cause we don't actually know these. - - size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), arg_qualtype.getAsOpaquePtr()); - Type arg_type (0, - GetType()->GetSymbolFile(), - arg_return_name, - bit_size, - sc.comp_unit, - 0, - Type::eEncodingIsSyntheticUID, - Declaration(), - arg_qualtype.getAsOpaquePtr(), - Type::eResolveStateFull); - return arg_type; + return NULL; + + return (function_proto_type->arg_type_begin())[idx].getAsOpaquePtr(); } - - return Type(); -} - -const char * -Function::GetArgumentNameAtIndex (size_t idx) -{ - const clang::Type *clang_type = static_cast(GetType()->GetClangType())->getTypePtr(); - assert (clang_type->isFunctionType()); - if (!clang_type->isFunctionProtoType()) - return NULL; return NULL; } bool Function::IsVariadic () { - const clang::Type *clang_type = static_cast(GetType()->GetClangType())->getTypePtr(); + const clang::Type *clang_type = static_cast(GetType()->GetClangFullType())->getTypePtr(); assert (clang_type->isFunctionType()); if (!clang_type->isFunctionProtoType()) return false; const clang::FunctionProtoType *function_proto_type = dyn_cast(clang_type); - if (function_proto_type != NULL) - { + if (function_proto_type) return function_proto_type->isVariadic(); - } return false; } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=125691&r1=125690&r2=125691&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Wed Feb 16 17:00:21 2011 @@ -578,7 +578,7 @@ } clang_type_t -Type::GetClangType () +Type::GetClangFullType () { ResolveClangType(eResolveStateFull); return m_clang_type; From wilsons at start.ca Wed Feb 16 18:01:47 2011 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 17 Feb 2011 00:01:47 -0000 Subject: [Lldb-commits] [lldb] r125695 - /lldb/trunk/include/lldb/Core/ArchSpec.h Message-ID: <20110217000147.61DC62A6C12C@llvm.org> Author: wilsons Date: Wed Feb 16 18:01:47 2011 New Revision: 125695 URL: http://llvm.org/viewvc/llvm-project?rev=125695&view=rev Log: Do not use constants from stdint.h that we cannot portably provide on all platforms. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=125695&r1=125694&r2=125695&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Wed Feb 16 18:01:47 2011 @@ -12,8 +12,6 @@ #if defined(__cplusplus) -#include - #include "lldb/lldb-private.h" #include "llvm/ADT/Triple.h" @@ -350,10 +348,10 @@ private: void - MachOArchUpdated (size_t macho_idx = SIZE_MAX); + MachOArchUpdated (size_t macho_idx = ~(size_t)0); void - ELFArchUpdated (size_t idx = SIZE_MAX); + ELFArchUpdated (size_t idx = ~(size_t)0); }; From wilsons at start.ca Wed Feb 16 18:06:16 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 16 Feb 2011 19:06:16 -0500 Subject: [Lldb-commits] [PATCH] Use SIZE_MAX instead of SIZE_T_MAX for portability. In-Reply-To: (Chris Lattner's message of "Wed, 16 Feb 2011 10:48:00 -0800") References: Message-ID: Chris Lattner writes: > On Feb 15, 2011, at 8:05 PM, Stephen Wilson wrote: > >> >> diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h >> index 198722c..3bb14ac 100644 >> --- a/include/lldb/Core/ArchSpec.h >> +++ b/include/lldb/Core/ArchSpec.h >> @@ -12,6 +12,8 @@ >> >> #if defined(__cplusplus) >> >> +#include > > stdint.h isn't portable. Please use llvm/Support/DataTypes.h. Alternatively you can just use something like "~(size_t)0". We do have a bit of work to do if we want to purge non-portable use of stdint.h and similar headers in lldb, but I totally agree we should not make it any worse. Since llvm/Support/DataTypes.h does not portably vend SIZE_MAX I simply replaced our use with ~(size_t)0 for now. Fixed in r125695. Thanks! > > -Chris > >> + >> #include "lldb/lldb-private.h" >> #include "llvm/ADT/Triple.h" >> >> @@ -348,10 +350,10 @@ protected: >> private: >> >> void >> - MachOArchUpdated (size_t macho_idx = SIZE_T_MAX); >> + MachOArchUpdated (size_t macho_idx = SIZE_MAX); >> >> void >> - ELFArchUpdated (size_t idx = SIZE_T_MAX); >> + ELFArchUpdated (size_t idx = SIZE_MAX); >> }; >> >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > -- steve From johnny.chen at apple.com Wed Feb 16 19:35:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Feb 2011 01:35:27 -0000 Subject: [Lldb-commits] [lldb] r125701 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110217013527.B7AC62A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 19:35:27 2011 New Revision: 125701 URL: http://llvm.org/viewvc/llvm-project?rev=125701&view=rev Log: Refactoring. Wrap the following pseudocode from the ARM Architecture Reference Manul: // if d == 15 then // Can only occur for encoding A1 // ALUWritePC(result); // setflags is always FALSE here // else // R[d] = result; // if setflags then // APSR.N = result<31>; // APSR.Z = IsZeroBit(result); // APSR.C = carry; // // APSR.V unchanged into a helper method WriteCoreRegisterWithFlags, and modified the existing methods to take advantage of it. Plus add two emulation methods (declaration only for now) for ORR (immediate) and ORR (register). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125701&r1=125700&r2=125701&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Wed Feb 16 19:35:27 2011 @@ -616,7 +616,7 @@ default: return false; } - uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); + uint32_t result = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); if (!success) return false; @@ -626,28 +626,9 @@ Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + Rm); context.SetRegisterPlusOffset (dwarf_reg, 0); - - if (Rd == 15) - { - if (!ALUWritePC (context, reg_value)) - return false; - } - else - { - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, reg_value)) - return false; - if (setflags) - { - m_new_inst_cpsr = m_inst_cpsr; - SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(reg_value, CPSR_N)); - SetBit32(m_new_inst_cpsr, CPSR_Z, reg_value == 0 ? 1 : 0); - if (m_new_inst_cpsr != m_inst_cpsr) - { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) - return false; - } - } - } + + if (!WriteCoreRegisterWithFlags(context, result, Rd, setflags)) + return false; } return true; } @@ -711,29 +692,9 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - - if (Rd == 15) - { - if (!ALUWritePC (context, result)) - return false; - } - else - { - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) - return false; - if (setflags) - { - m_new_inst_cpsr = m_inst_cpsr; - SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); - SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); - SetBit32(m_new_inst_cpsr, CPSR_C, carry); - if (m_new_inst_cpsr != m_inst_cpsr) - { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) - return false; - } - } - } + + if (!WriteCoreRegisterWithFlags(context, result, Rd, setflags, carry)) + return false; } return true; } @@ -796,29 +757,9 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - - if (Rd == 15) - { - if (!ALUWritePC (context, result)) - return false; - } - else - { - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) - return false; - if (setflags) - { - m_new_inst_cpsr = m_inst_cpsr; - SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); - SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); - SetBit32(m_new_inst_cpsr, CPSR_C, carry); - if (m_new_inst_cpsr != m_inst_cpsr) - { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) - return false; - } - } - } + + if (!WriteCoreRegisterWithFlags(context, result, Rd, setflags, carry)) + return false; } return true; } @@ -1926,13 +1867,13 @@ if (ConditionPassed()) { uint32_t Rd, Rn, Rm; - //bool setflags = false; + bool setflags; switch (encoding) { case eEncodingT2: - // setflags = FALSE Rd = Rn = Bit32(opcode, 7) << 3 | Bits32(opcode, 2, 0); Rm = Bits32(opcode, 6, 3); + setflags = false; if (Rn == 15 && Rm == 15) return false; break; @@ -1957,22 +1898,16 @@ if (!success) return false; + // TODO: Handle the case where Rm needs to be shifted properly. + AddWithCarryResult res = AddWithCarry(val1, val2, 0); result = val1 + val2; EmulateInstruction::Context context; context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - - if (Rd == 15) - { - if (!ALUWritePC (context, result)) - return false; - } - else - { - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) - return false; - } + + if (!WriteCoreRegisterWithFlags(context, res.result, Rd, setflags, res.carry_out, res.overflow)) + return false; } return true; } @@ -2403,28 +2338,8 @@ context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - if (Rd == 15) - { - if (!ALUWritePC (context, result)) - return false; - } - else - { - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) - return false; - if (setflags) - { - m_new_inst_cpsr = m_inst_cpsr; - SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); - SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); - SetBit32(m_new_inst_cpsr, CPSR_C, carry); - if (m_new_inst_cpsr != m_inst_cpsr) - { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) - return false; - } - } - } + if (!WriteCoreRegisterWithFlags(context, result, Rd, setflags, carry)) + return false; } return true; } @@ -2492,20 +2407,8 @@ context.type = EmulateInstruction::eContextImmediate; context.SetNoArgs (); - if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + if (!WriteCoreRegisterWithFlags(context, result, Rd, setflags, carry)) return false; - if (setflags) - { - m_new_inst_cpsr = m_inst_cpsr; - SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); - SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); - SetBit32(m_new_inst_cpsr, CPSR_C, carry); - if (m_new_inst_cpsr != m_inst_cpsr) - { - if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) - return false; - } - } } return true; } @@ -4774,6 +4677,60 @@ return res; } +// Write the result to the ARM core register Rd, and optionally update the +// condition flags based on the result. +// +// This helper method tries to encapsulate the following pseudocode from the +// ARM Architecture Reference Manual: +// +// if d == 15 then // Can only occur for encoding A1 +// ALUWritePC(result); // setflags is always FALSE here +// else +// R[d] = result; +// if setflags then +// APSR.N = result<31>; +// APSR.Z = IsZeroBit(result); +// APSR.C = carry; +// // APSR.V unchanged +// +// In the above case, the API client does not pass in the overflow arg, which +// defaults to ~0u. +bool +EmulateInstructionARM::WriteCoreRegisterWithFlags (Context &context, + const uint32_t result, + const uint32_t Rd, + bool setflags, + const uint32_t carry, + const uint32_t overflow) +{ + if (Rd == 15) + { + if (!ALUWritePC (context, result)) + return false; + } + else + { + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, result)) + return false; + if (setflags) + { + m_new_inst_cpsr = m_inst_cpsr; + SetBit32(m_new_inst_cpsr, CPSR_N, Bit32(result, CPSR_N)); + SetBit32(m_new_inst_cpsr, CPSR_Z, result == 0 ? 1 : 0); + if (carry != ~0u) + SetBit32(m_new_inst_cpsr, CPSR_C, carry); + if (overflow != ~0u) + SetBit32(m_new_inst_cpsr, CPSR_V, overflow); + if (m_new_inst_cpsr != m_inst_cpsr) + { + if (!WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr)) + return false; + } + } + } + return true; +} + bool EmulateInstructionARM::EvaluateInstruction () { Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125701&r1=125700&r2=125701&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Wed Feb 16 19:35:27 2011 @@ -192,6 +192,14 @@ AddWithCarryResult AddWithCarry(uint32_t x, uint32_t y, uint8_t carry_in); + bool + WriteCoreRegisterWithFlags (Context &context, + const uint32_t result, + const uint32_t Rd, + bool setflags, + const uint32_t carry = ~0u, + const uint32_t overflow = ~0u); + protected: // Typedef for the callback function used during the emulation. @@ -372,6 +380,14 @@ bool EmulateShiftReg (ARMEncoding encoding, ARM_ShifterType shift_type); + // A8.6.113 ORR (immediate) + bool + EmulateORRImm (ARMEncoding encoding); + + // A8.6.114 ORR (register) + bool + EmulateORRReg (ARMEncoding encoding); + // A8.6.53 LDM/LDMIA/LDMFD bool EmulateLDM (ARMEncoding encoding); From johnny.chen at apple.com Wed Feb 16 19:49:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Feb 2011 01:49:00 -0000 Subject: [Lldb-commits] [lldb] r125703 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110217014900.B19BD2A6C12C@llvm.org> Author: johnny Date: Wed Feb 16 19:49:00 2011 New Revision: 125703 URL: http://llvm.org/viewvc/llvm-project?rev=125703&view=rev Log: Add comment for the helper method WriteCoreRegisterWithFlags(). Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125703&r1=125702&r2=125703&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Wed Feb 16 19:49:00 2011 @@ -192,6 +192,9 @@ AddWithCarryResult AddWithCarry(uint32_t x, uint32_t y, uint8_t carry_in); + // See A8.6.96 MOV (immediate) Operation. + // Default arguments are specified for carry and overflow parameters, which means + // not to update the respective flags if setflags is true. bool WriteCoreRegisterWithFlags (Context &context, const uint32_t result, From gclayton at apple.com Wed Feb 16 20:05:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Feb 2011 02:05:38 -0000 Subject: [Lldb-commits] [lldb] r125706 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20110217020538.518A42A6C12C@llvm.org> Author: gclayton Date: Wed Feb 16 20:05:38 2011 New Revision: 125706 URL: http://llvm.org/viewvc/llvm-project?rev=125706&view=rev Log: Modified version of Marco Minutoli's host arch patch. Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=125706&r1=125705&r2=125706&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Wed Feb 16 20:05:38 2011 @@ -294,37 +294,31 @@ #if defined (__x86_64__) g_host_arch_64.SetArch ("x86_64"); - g_supports_32 = false; - g_supports_64 = true; #elif defined (__i386__) - g_host_arch.SetArch ("i386"); - g_supports_32 = true; - g_supports_64 = false; + g_host_arch_32.SetArch ("i386"); #elif defined (__arm__) - g_host_arch.SetArch ("arm"); - g_supports_32 = true; - g_supports_64 = false; + g_host_arch_32.SetArch ("arm"); #elif defined (__ppc64__) - g_host_arch.SetArch ("ppc64"); - g_supports_32 = false; - g_supports_64 = true; + g_host_arch_64.SetArch ("ppc64"); #elif defined (__powerpc__) || defined (__ppc__) - g_host_arch.SetArch ("ppc"); - g_supports_32 = true; - g_supports_64 = false; + + g_host_arch_32.SetArch ("ppc"); #else #error undefined architecture, define your architecture here #endif + + g_supports_32 = g_host_arch_32.IsValid(); + g_supports_64 = g_host_arch_64.IsValid(); } #endif // #else for #if defined (__APPLE__) From gclayton at apple.com Wed Feb 16 21:16:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Feb 2011 03:16:52 -0000 Subject: [Lldb-commits] [lldb] r125716 - in /lldb/branches/apple/calcite/lldb: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110217031652.572232A6C12C@llvm.org> Author: gclayton Date: Wed Feb 16 21:16:52 2011 New Revision: 125716 URL: http://llvm.org/viewvc/llvm-project?rev=125716&view=rev Log: Change version to 50 Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist Modified: lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj?rev=125716&r1=125715&r2=125716&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj (original) +++ lldb/branches/apple/calcite/lldb/lldb.xcodeproj/project.pbxproj Wed Feb 16 21:16:52 2011 @@ -2976,9 +2976,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 49; + DYLIB_CURRENT_VERSION = 50; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3033,11 +3033,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 49; + DYLIB_CURRENT_VERSION = 50; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3120,7 +3120,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3156,11 +3156,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 49; + DYLIB_CURRENT_VERSION = 50; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3214,7 +3214,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3253,7 +3253,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 49; + CURRENT_PROJECT_VERSION = 50; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist?rev=125716&r1=125715&r2=125716&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist (original) +++ lldb/branches/apple/calcite/lldb/resources/LLDB-Info.plist Wed Feb 16 21:16:52 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 49 + 50 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Wed Feb 16 21:17:11 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Feb 2011 03:17:11 -0000 Subject: [Lldb-commits] [lldb] r125717 - /lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110217031712.02E632A6C12C@llvm.org> Author: gclayton Date: Wed Feb 16 21:17:11 2011 New Revision: 125717 URL: http://llvm.org/viewvc/llvm-project?rev=125717&view=rev Log: Change version to 134 Modified: lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=125717&r1=125716&r2=125717&view=diff ============================================================================== --- lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/branches/apple/calcite/lldb/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed Feb 16 21:17:11 2011 @@ -460,7 +460,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -478,7 +478,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -498,7 +498,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -556,7 +556,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -597,7 +597,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 133; + CURRENT_PROJECT_VERSION = 134; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Thu Feb 17 11:31:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Feb 2011 17:31:09 -0000 Subject: [Lldb-commits] [lldb] r125753 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Process/Utility/ARMUtils.h Message-ID: <20110217173109.1FDF02A6C12C@llvm.org> Author: johnny Date: Thu Feb 17 11:31:08 2011 New Revision: 125753 URL: http://llvm.org/viewvc/llvm-project?rev=125753&view=rev Log: Move Align(val, alignment) utility function to ARMUtils.h. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125753&r1=125752&r2=125753&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Feb 17 11:31:08 2011 @@ -23,11 +23,6 @@ using namespace lldb; using namespace lldb_private; -static inline uint32_t Align(uint32_t val, uint32_t alignment) -{ - return alignment * (val / alignment); -} - //---------------------------------------------------------------------- // // ITSession implementation Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=125753&r1=125752&r2=125753&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Thu Feb 17 11:31:08 2011 @@ -18,6 +18,11 @@ namespace lldb_private { +static inline uint32_t Align(uint32_t val, uint32_t alignment) +{ + return alignment * (val / alignment); +} + static inline uint32_t DecodeImmShift(const uint32_t type, const uint32_t imm5, ARM_ShifterType &shift_t) { switch (type) { From ctice at apple.com Thu Feb 17 13:20:40 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 17 Feb 2011 19:20:40 -0000 Subject: [Lldb-commits] [lldb] r125766 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110217192040.9B5772A6C12C@llvm.org> Author: ctice Date: Thu Feb 17 13:20:40 2011 New Revision: 125766 URL: http://llvm.org/viewvc/llvm-project?rev=125766&view=rev Log: Add stubs for pseudocode functions "MemA[]" amd "MemU[]", corresponding to aligned and unaligned memory accesses. The new stub functions are MemARead, MemAWrite, MemURead, and MemUWrite. At the moment these stubs just call ReadMemoryUnsigned or WriteMemoryUnsigned, but we can fill them out further later if we decide we need more accurate emulation of the memory system. Replaced all the direct calls to ReadMemoryUnsigned and WriteMemoryUnsigned in EmulateInstructionARM.cpp with calls to the appropriate new stub function. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125766&r1=125765&r2=125766&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Feb 17 13:20:40 2011 @@ -150,7 +150,7 @@ uint32_t random_data = rand (); const uint32_t addr_byte_size = GetAddressByteSize(); - if (!WriteMemoryUnsigned (context, address, random_data, addr_byte_size)) + if (!MemAWrite (context, address, random_data, addr_byte_size)) return false; return true; @@ -279,7 +279,7 @@ uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_reg.num, 0, &success); if (!success) return false; - if (!WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size)) + if (!MemAWrite (context, addr, reg_value, addr_byte_size)) return false; addr += addr_byte_size; } @@ -292,7 +292,7 @@ const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; - if (!WriteMemoryUnsigned (context, addr, pc + 8, addr_byte_size)) + if (!MemAWrite (context, addr, pc + 8, addr_byte_size)) return false; } @@ -406,7 +406,7 @@ { dwarf_reg.num = dwarf_r0 + i; context.SetRegisterPlusOffset (dwarf_reg, addr - sp); - data = ReadMemoryUnsigned(context, addr, 4, 0, &success); + data = MemARead(context, addr, 4, 0, &success); if (!success) return false; if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_reg.num, data)) @@ -419,7 +419,7 @@ { dwarf_reg.num = dwarf_pc; context.SetRegisterPlusOffset (dwarf_reg, addr - sp); - data = ReadMemoryUnsigned(context, addr, 4, 0, &success); + data = MemARead(context, addr, 4, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. @@ -833,7 +833,7 @@ address = base + imm32; else address = base - imm32; - data = ReadMemoryUnsigned(context, address, 4, 0, &success); + data = MemURead(context, address, 4, 0, &success); if (!success) return false; @@ -1417,7 +1417,7 @@ uint32_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_reg.num, 0, &success); if (!success) return false; - if (!WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size)) + if (!MemUWrite (context, addr, reg_value, addr_byte_size)) return false; } else @@ -1427,7 +1427,7 @@ const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); if (!success) return false; - if (!WriteMemoryUnsigned (context, addr, pc + 8, addr_byte_size)) + if (!MemUWrite (context, addr, pc + 8, addr_byte_size)) return false; } @@ -1522,7 +1522,7 @@ uint64_t reg_value = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_reg.num, 0, &success); if (!success) return false; - if (!WriteMemoryUnsigned (context, addr, reg_value, reg_byte_size)) + if (!MemAWrite (context, addr, reg_value, reg_byte_size)) return false; addr += reg_byte_size; } @@ -1614,7 +1614,7 @@ { dwarf_reg.num = start_reg + i; context.SetRegisterPlusOffset (dwarf_reg, addr - sp); - data = ReadMemoryUnsigned(context, addr, reg_byte_size, 0, &success); + data = MemARead(context, addr, reg_byte_size, 0, &success); if (!success) return false; if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_reg.num, data)) @@ -2511,7 +2511,7 @@ context.type = EmulateInstruction::eContextPopRegisterOffStack; // R[i] = MemA [address, 4]; address = address + 4; - uint32_t data = ReadMemoryUnsigned (context, base_address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, base_address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2527,7 +2527,7 @@ //LoadWritePC (MemA [address, 4]); context.type = EmulateInstruction::eContextRegisterPlusOffset; context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, base_address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, base_address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. @@ -2629,7 +2629,7 @@ { // R[i] = MemA[address,4]; address = address + 4; context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + i, data)) @@ -2643,7 +2643,7 @@ if (BitIsSet (registers, 15)) { context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. @@ -2768,7 +2768,7 @@ { // R[i] = MemA[address,4]; address = address + 4; context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2784,7 +2784,7 @@ if (BitIsSet (registers, 15)) { context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. @@ -2885,7 +2885,7 @@ // R[i] = MemA[address,4]; address = address + 4; context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -2901,7 +2901,7 @@ if (BitIsSet (registers, 15)) { context.SetRegisterPlusOffset (dwarf_reg, offset); - uint32_t data = ReadMemoryUnsigned (context, address + offset, addr_byte_size, 0, &success); + uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; // In ARMv5T and above, this is an interworking branch. @@ -3009,7 +3009,7 @@ context.SetNoArgs (); // Read memory from the address. - data = ReadMemoryUnsigned(context, address, 4, 0, &success); + data = MemURead(context, address, 4, 0, &success); if (!success) return false; @@ -3153,7 +3153,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); - if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -3173,7 +3173,7 @@ if (!success) return false; - if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + if (!MemAWrite (context, address + offset, pc + 8, addr_byte_size)) return false; } @@ -3281,7 +3281,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); - if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -3301,7 +3301,7 @@ if (!success) return false; - if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + if (!MemAWrite (context, address + offset, pc + 8, addr_byte_size)) return false; } @@ -3435,7 +3435,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); - if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -3455,7 +3455,7 @@ if (!success) return false; - if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + if (!MemAWrite (context, address + offset, pc + 8, addr_byte_size)) return false; } @@ -3564,7 +3564,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); - if (!WriteMemoryUnsigned (context, address + offset, data, addr_byte_size)) + if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -3584,7 +3584,7 @@ if (!success) return false; - if (!WriteMemoryUnsigned (context, address + offset, pc + 8, addr_byte_size)) + if (!MemAWrite (context, address + offset, pc + 8, addr_byte_size)) return false; } @@ -3744,7 +3744,7 @@ data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); int32_t offset = address - base_address; context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); - if (!WriteMemoryUnsigned (context, address, data, addr_byte_size)) + if (!MemUWrite (context, address, data, addr_byte_size)) return false; } else @@ -3937,7 +3937,7 @@ data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + t); context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, address - base_address); - if (!WriteMemoryUnsigned (context, address, data, addr_byte_size)) + if (!MemUWrite (context, address, data, addr_byte_size)) return false; } @@ -4062,7 +4062,7 @@ else address = base_address; - // MemU[address,1] = R[t]<7:0>; NOTE: "MemU' means UNALIGNED memory access + // MemU[address,1] = R[t]<7:0> Register base_reg; base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); @@ -4079,7 +4079,7 @@ data = Bits32 (data, 7, 0); - if (!WriteMemoryUnsigned (context, address, data, 1)) + if (!MemUWrite (context, address, data, 1)) return false; // if wback then R[n] = offset_addr; @@ -4404,7 +4404,7 @@ if (m_inst_cpsr & MASK_CPSR_T) { m_inst_mode = eModeThumb; - uint32_t thumb_opcode = ReadMemoryUnsigned(read_inst_context, pc, 2, 0, &success); + uint32_t thumb_opcode = MemARead(read_inst_context, pc, 2, 0, &success); if (success) { @@ -4416,7 +4416,7 @@ else { m_inst.opcode_type = eOpcode32; - m_inst.opcode.inst32 = (thumb_opcode << 16) | ReadMemoryUnsigned(read_inst_context, pc + 2, 2, 0, &success); + m_inst.opcode.inst32 = (thumb_opcode << 16) | MemARead(read_inst_context, pc + 2, 2, 0, &success); } } } @@ -4424,7 +4424,7 @@ { m_inst_mode = eModeARM; m_inst.opcode_type = eOpcode32; - m_inst.opcode.inst32 = ReadMemoryUnsigned(read_inst_context, pc, 4, 0, &success); + m_inst.opcode.inst32 = MemARead(read_inst_context, pc, 4, 0, &success); } } } Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=125766&r1=125765&r2=125766&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Thu Feb 17 13:20:40 2011 @@ -203,6 +203,75 @@ const uint32_t carry = ~0u, const uint32_t overflow = ~0u); + inline uint64_t + MemARead (EmulateInstruction::Context &context, + lldb::addr_t address, + uint32_t size, + uint64_t fail_value, + bool *success_ptr) + { + // This is a stub function corresponding to "MemA[]" in the ARM manual pseudocode, for + // aligned reads from memory. Since we are not trying to write a full hardware simulator, and since + // we are running in User mode (rather than Kernel mode) and therefore won't have access to many of the + // system registers we would need in order to fully implement this function, we will just call + // ReadMemoryUnsigned from here. In the future, if we decide we do need to do more faithful emulation of + // the hardware, we can update this function appropriately. + + return ReadMemoryUnsigned (context, address, size, fail_value, success_ptr); + } + + inline bool + MemAWrite (EmulateInstruction::Context &context, + lldb::addr_t address, + uint64_t data_val, + uint32_t size) + + { + // This is a stub function corresponding to "MemA[]" in the ARM manual pseudocode, for + // aligned writes to memory. Since we are not trying to write a full hardware simulator, and since + // we are running in User mode (rather than Kernel mode) and therefore won't have access to many of the + // system registers we would need in order to fully implement this function, we will just call + // WriteMemoryUnsigned from here. In the future, if we decide we do need to do more faithful emulation of + // the hardware, we can update this function appropriately. + + return WriteMemoryUnsigned (context, address, data_val, size); + } + + + inline uint64_t + MemURead (EmulateInstruction::Context &context, + lldb::addr_t address, + uint32_t size, + uint64_t fail_value, + bool *success_ptr) + { + // This is a stub function corresponding to "MemU[]" in the ARM manual pseudocode, for + // unaligned reads from memory. Since we are not trying to write a full hardware simulator, and since + // we are running in User mode (rather than Kernel mode) and therefore won't have access to many of the + // system registers we would need in order to fully implement this function, we will just call + // ReadMemoryUnsigned from here. In the future, if we decide we do need to do more faithful emulation of + // the hardware, we can update this function appropriately. + + return ReadMemoryUnsigned (context, address, size, fail_value, success_ptr); + } + + inline bool + MemUWrite (EmulateInstruction::Context &context, + lldb::addr_t address, + uint64_t data_val, + uint32_t size) + + { + // This is a stub function corresponding to "MemU[]" in the ARM manual pseudocode, for + // unaligned writes to memory. Since we are not trying to write a full hardware simulator, and since + // we are running in User mode (rather than Kernel mode) and therefore won't have access to many of the + // system registers we would need in order to fully implement this function, we will just call + // WriteMemoryUnsigned from here. In the future, if we decide we do need to do more faithful emulation of + // the hardware, we can update this function appropriately. + + return WriteMemoryUnsigned (context, address, data_val, size); + } + protected: // Typedef for the callback function used during the emulation. From johnny.chen at apple.com Thu Feb 17 13:34:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Feb 2011 19:34:27 -0000 Subject: [Lldb-commits] [lldb] r125767 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110217193427.8C7642A6C12C@llvm.org> Author: johnny Date: Thu Feb 17 13:34:27 2011 New Revision: 125767 URL: http://llvm.org/viewvc/llvm-project?rev=125767&view=rev Log: Add EmulateTB() method to emulate "Table Branch Byte" and "Table Branch Halfword" operations for Thumb2. Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=125767&r1=125766&r2=125767&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Thu Feb 17 13:34:27 2011 @@ -153,6 +153,10 @@ // arg1 = immediate data or don't care // arg2 = don't care eContextSupervisorCall, + + // Used when performing a MemU operation to read the PC-relative offset + // from an address. + eContextTableBranchReadMemory, // Used when random bits are written into a register // arg0 = target register kind Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=125767&r1=125766&r2=125767&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Feb 17 13:34:27 2011 @@ -1831,6 +1831,87 @@ return true; } +// Table Branch Byte causes a PC-relative forward branch using a table of single byte offsets. +// A base register provides a pointer to the table, and a second register supplies an index into the table. +// The branch length is twice the value of the byte returned from the table. +// +// Table Branch Halfword causes a PC-relative forward branch using a table of single halfword offsets. +// A base register provides a pointer to the table, and a second register supplies an index into the table. +// The branch length is twice the value of the halfword returned from the table. +// TBB, TBH +bool +EmulateInstructionARM::EmulateTB (ARMEncoding encoding) +{ +#if 0 + // ARM pseudo code... + EncodingSpecificOperations(); NullCheckIfThumbEE(n); + if is_tbh then + halfwords = UInt(MemU[R[n]+LSL(R[m],1), 2]); + else + halfwords = UInt(MemU[R[n]+R[m], 1]); + BranchWritePC(PC + 2*halfwords); +#endif + + bool success = false; + const uint32_t opcode = OpcodeAsUnsigned (&success); + if (!success) + return false; + + uint32_t Rn; // the base register which contains the address of the table of branch lengths + uint32_t Rm; // the index register which contains an integer pointing to a byte/halfword in the table + bool is_tbh; // true if table branch halfword + switch (encoding) { + case eEncodingT1: + Rn = Bits32(opcode, 19, 16); + Rm = Bits32(opcode, 3, 0); + is_tbh = BitIsSet(opcode, 4); + if (Rn == 13 || BadReg(Rm)) + return false; + if (InITBlock() && !LastInITBlock()) + return false; + break; + default: + return false; + } + + // Read the address of the table from the operand register Rn. + // The PC can be used, in which case the table immediately follows this instruction. + uint32_t base = + Rn == 15 ? (ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success) + 4) + : ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rn, 0, &success); + if (!success) + return false; + + // the table index + uint32_t index = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success); + if (!success) + return false; + + // the offsetted table address + addr_t addr = base + (is_tbh ? index*2 : index); + + // PC-relative offset to branch forward + EmulateInstruction::Context context; + context.type = EmulateInstruction::eContextTableBranchReadMemory; + uint32_t offset = MemURead(context, addr, is_tbh ? 2 : 1, 0, &success); + if (!success) + return false; + + const uint32_t pc = ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success); + if (!success) + return false; + + // target address + addr_t target = pc + 4 + offset; + context.type = EmulateInstruction::eContextRelativeBranchImmediate; + context.SetModeAndImmediateSigned (eModeThumb, 4 + offset); + + if (!BranchWritePC(context, target)) + return false; + + return true; +} + // ADD , // where the destination register is also the first operand register // and is the second operand register. @@ -4282,6 +4363,10 @@ { 0xffffff87, 0x00004700, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateBXRm, "bx "}, // compare and branch { 0xfffff500, 0x0000b100, ARMV6T2_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateCB, "cb{n}z , Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Fri Feb 18 20:53:09 2011 @@ -63,9 +63,9 @@ { if (log) log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", m_opaque_ap.get(), - m_opaque_ap->GetOutputStream().GetData()); + m_opaque_ap->GetOutputData()); - return m_opaque_ap->GetOutputStream().GetData(); + return m_opaque_ap->GetOutputData(); } if (log) @@ -83,9 +83,9 @@ { if (log) log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"", m_opaque_ap.get(), - m_opaque_ap->GetErrorStream().GetData()); + m_opaque_ap->GetErrorData()); - return m_opaque_ap->GetErrorStream().GetData(); + return m_opaque_ap->GetErrorData(); } if (log) @@ -98,7 +98,7 @@ SBCommandReturnObject::GetOutputSize () { if (m_opaque_ap.get()) - return m_opaque_ap->GetOutputStream().GetSize(); + return strlen (m_opaque_ap->GetOutputData()); return 0; } @@ -106,7 +106,7 @@ SBCommandReturnObject::GetErrorSize () { if (m_opaque_ap.get()) - return m_opaque_ap->GetErrorStream().GetSize(); + return strlen(m_opaque_ap->GetErrorData()); return 0; } @@ -234,3 +234,17 @@ return true; } + +void +SBCommandReturnObject::SetImmediateOutputFile (FILE *fh) +{ + if (m_opaque_ap.get()) + m_opaque_ap->SetImmediateOutputFile (fh); +} + +void +SBCommandReturnObject::SetImmediateErrorFile (FILE *fh) +{ + if (m_opaque_ap.get()) + m_opaque_ap->SetImmediateErrorFile (fh); +} Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Feb 18 20:53:09 2011 @@ -34,7 +34,7 @@ using namespace lldb_private; static void -AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) +AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) { s->IndentMore(); bp->GetDescription (s, level, true); @@ -370,8 +370,8 @@ m_options.m_check_inlines).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); + Stream &output_stream = result.GetOutputStream(); + result.AppendMessage ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); if (bp->GetNumLocations() == 0) @@ -417,7 +417,7 @@ Breakpoint::Exact).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -450,7 +450,7 @@ bp = target->CreateBreakpoint (&module_spec, regexp).get(); if (bp) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -497,7 +497,7 @@ if (bp && !use_module) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); output_stream.EOL(); @@ -775,7 +775,7 @@ return true; } - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); if (args.GetArgumentCount() == 0) { @@ -1212,7 +1212,7 @@ if (num_cleared > 0) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("%d breakpoints cleared:\n", num_cleared); output_stream << ss.GetData(); output_stream.EOL(); Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Feb 18 20:53:09 2011 @@ -790,15 +790,19 @@ BreakpointOptions::CommandData *data = (BreakpointOptions::CommandData *) baton; StringList &commands = data->user_source; - + if (commands.GetSize() > 0) { - CommandReturnObject result; if (context->exe_ctx.target) { - + CommandReturnObject result; Debugger &debugger = context->exe_ctx.target->GetDebugger(); - + // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously + // if the debugger is set up that way. + + result.SetImmediateOutputFile (debugger.GetOutputFile().GetStream()); + result.SetImmediateErrorFile (debugger.GetErrorFile().GetStream()); + bool stop_on_continue = true; bool echo_commands = false; bool print_results = true; @@ -810,14 +814,6 @@ echo_commands, print_results, result); - // Now dump the commands to the debugger's output: - if (!result.Succeeded()) - { - debugger.GetErrorFile().Printf ("%s", result.GetErrorStream().GetData()); - } - - debugger.GetOutputFile().Printf ("%s", result.GetOutputStream().GetData()); - } } return ret_value; Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Feb 18 20:53:09 2011 @@ -187,7 +187,7 @@ // First time through here, generate the help text for the object and // push it to the return result object as well - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Feb 18 20:53:09 2011 @@ -1483,7 +1483,7 @@ CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Feb 18 20:53:09 2011 @@ -65,7 +65,7 @@ CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); + Stream &output_stream = result.GetOutputStream(); DataExtractor reg_data; ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Feb 18 20:53:09 2011 @@ -131,7 +131,7 @@ if (num_thread_infos_dumped < num_threads) result.GetOutputStream().Printf("%u of %u threads stopped with reasons:\n", num_thread_infos_dumped, num_threads); - result.GetOutputStream().GetString().append(strm.GetString()); + result.AppendMessage (strm.GetString().c_str()); result.SetStatus (eReturnStatusSuccessFinishNoResult); } return num_thread_infos_dumped; @@ -1379,7 +1379,7 @@ CommandReturnObject &result ) { - StreamString &strm = result.GetOutputStream(); + Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) Modified: lldb/trunk/source/Commands/CommandObjectVersion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVersion.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectVersion.cpp Fri Feb 18 20:53:09 2011 @@ -40,8 +40,7 @@ CommandReturnObject &result ) { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("%s\n", lldb_private::GetVersion()); + result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion()); result.SetStatus (eReturnStatusSuccessFinishResult); return true; } Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Fri Feb 18 20:53:09 2011 @@ -22,7 +22,7 @@ static void DumpSettingEntry (CommandInterpreter &interpreter, - StreamString &result_stream, + Stream &result_stream, const uint32_t max_len, const SettingEntry &entry) { @@ -802,7 +802,7 @@ } void -UserSettingsController::GetAllDefaultSettingValues (StreamString &result_stream) +UserSettingsController::GetAllDefaultSettingValues (Stream &result_stream) { std::string parent_prefix; BuildParentPrefix (parent_prefix); @@ -845,7 +845,7 @@ } void -UserSettingsController::GetAllPendingSettingValues (StreamString &result_stream) +UserSettingsController::GetAllPendingSettingValues (Stream &result_stream) { std::map::iterator pos; @@ -913,7 +913,7 @@ void UserSettingsController::GetAllInstanceVariableValues (CommandInterpreter &interpreter, - StreamString &result_stream) + Stream &result_stream) { std::map::iterator pos; std::string parent_prefix; @@ -1092,7 +1092,7 @@ UserSettingsController::FindAllSettingsDescriptions (CommandInterpreter &interpreter, UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err) { // Write out current prefix line. @@ -1156,7 +1156,7 @@ UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_name, - StreamString &result_stream, + Stream &result_stream, Error &err) { Args names = UserSettingsController::BreakNameIntoPieces (search_name); @@ -1310,7 +1310,7 @@ UserSettingsControllerSP root, std::string ¤t_prefix, const char *search_word, - StreamString &result_stream) + Stream &result_stream) { if ((search_word == NULL) || (strlen (search_word) == 0)) return; @@ -1378,7 +1378,7 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, UserSettingsControllerSP root, std::string ¤t_prefix, - StreamString &result_stream, + Stream &result_stream, Error &err) { StreamString description; Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Feb 18 20:53:09 2011 @@ -1518,6 +1518,8 @@ { size_t num_lines = commands.GetSize(); CommandReturnObject tmp_result; + tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ()); + tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ()); // If we are going to continue past a "continue" then we need to run the commands synchronously. // Make sure you reset this value anywhere you return from the function. @@ -1554,7 +1556,7 @@ if (print_results) { if (tmp_result.Succeeded()) - result.AppendMessageWithFormat("%s", tmp_result.GetOutputStream().GetData()); + result.AppendMessageWithFormat("%s", tmp_result.GetOutputData()); } if (!success || !tmp_result.Succeeded()) @@ -1572,7 +1574,7 @@ result.AppendMessageWithFormat ("Command #%d '%s' failed with error: %s.\n", idx + 1, cmd, - tmp_result.GetErrorStream().GetData()); + tmp_result.GetErrorData()); } } Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Fri Feb 18 20:53:09 2011 @@ -19,6 +19,8 @@ using namespace lldb_private; CommandReturnObject::CommandReturnObject () : + m_error_stream_string_sp (), + m_output_stream_string_sp (), m_output_stream (), m_error_stream (), m_status (eReturnStatusStarted), @@ -30,18 +32,6 @@ { } -StreamString & -CommandReturnObject::GetOutputStream () -{ - return m_output_stream; -} - -StreamString & -CommandReturnObject::GetErrorStream () -{ - return m_error_stream; -} - void CommandReturnObject::AppendErrorWithFormat (const char *format, ...) { @@ -51,10 +41,9 @@ sstrm.PrintfVarArg(format, args); va_end (args); - m_error_stream.Printf("error: %s", sstrm.GetData()); + GetErrorStream().Printf("error: %s", sstrm.GetData()); } - void CommandReturnObject::AppendMessageWithFormat (const char *format, ...) { @@ -64,7 +53,7 @@ sstrm.PrintfVarArg(format, args); va_end (args); - m_output_stream.Printf("%s", sstrm.GetData()); + GetOutputStream().Printf("%s", sstrm.GetData()); } void @@ -76,7 +65,7 @@ sstrm.PrintfVarArg(format, args); va_end (args); - m_error_stream.Printf("warning: %s", sstrm.GetData()); + GetErrorStream().Printf("warning: %s", sstrm.GetData()); } void @@ -84,7 +73,7 @@ { if (len < 0) len = ::strlen (in_string); - m_output_stream.Printf("%*.*s\n", len, len, in_string); + GetOutputStream().Printf("%*.*s\n", len, len, in_string); } void @@ -92,7 +81,7 @@ { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf("warning: %*.*s\n", len, len, in_string); + GetErrorStream().Printf("warning: %*.*s\n", len, len, in_string); } // Similar to AppendWarning, but do not prepend 'warning: ' to message, and @@ -103,7 +92,7 @@ { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf("%*.*s", len, len, in_string); + GetErrorStream().Printf("%*.*s", len, len, in_string); } void @@ -114,7 +103,7 @@ if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf ("error: %*.*s\n", len, len, in_string); + GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string); } // Similar to AppendError, but do not prepend 'Error: ' to message, and @@ -125,7 +114,7 @@ { if (len < 0) len = ::strlen (in_string); - m_error_stream.Printf ("%*.*s", len, len, in_string); + GetErrorStream().Printf ("%*.*s", len, len, in_string); } void @@ -156,8 +145,10 @@ void CommandReturnObject::Clear() { - m_output_stream.Clear(); - m_error_stream.Clear(); + if (m_output_stream_string_sp) + static_cast(m_output_stream_string_sp.get())->Clear(); + if (m_error_stream_string_sp) + static_cast(m_error_stream_string_sp.get())->Clear(); m_status = eReturnStatusStarted; } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Feb 18 20:53:09 2011 @@ -433,6 +433,26 @@ return return_value; } +//SymbolContext +//SymbolContext::CreateSymbolContextFromDescription (lldb::TargetSP &target_sp, +// const char *module, +// const char *comp_unit, +// const char *function, +// const char *block_spec +// const char *line_number, +// const char *symbol) +//{ +// SymbolContext sc; +// sc.target = target_sp; +// +// if (module != NULL && module[0] != '0') +// { +// +// } +// +// return sc; +//} + //---------------------------------------------------------------------- // // SymbolContextList Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Fri Feb 18 20:53:09 2011 @@ -84,7 +84,7 @@ self.expect("br s -f main.cpp -l 32", startstr = "Breakpoint created: 3: file ='main.cpp', line = 32, locations = 1") - self.runCmd("br co a -p 1 -o 'print frame'") + self.runCmd("br co a -s python 1 -o 'print frame'") self.expect("br co l 1", substrs = [ "Breakpoint 1:", "Breakpoint commands:", Modified: lldb/trunk/test/alias_tests/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/TestAliases.py?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/test/alias_tests/TestAliases.py (original) +++ lldb/trunk/test/alias_tests/TestAliases.py Fri Feb 18 20:53:09 2011 @@ -72,8 +72,8 @@ "2: name = 'sum', locations = 1", "3: file ='main.cpp', line = 32, locations = 1" ]) - self.runCmd ("bpa -p 1 -o 'print frame; print bp_loc'") - self.runCmd ("bpa -c 2 -o 'frame variable b'") + self.runCmd ("bpa -s python 1 -o 'print frame; print bp_loc'") + self.runCmd ("bpa -s command 2 -o 'frame variable b'") self.expect ("bpi -f", substrs = [ "Current breakpoints:", "1: name = 'foo', locations = 1", Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Feb 18 20:53:09 2011 @@ -51,8 +51,8 @@ self.line) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -c -o 'frame variable -t -s' 1") - self.runCmd("breakpoint command add -p -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") + self.runCmd("breakpoint command add -s command -o 'frame variable -t -s' 1") + self.runCmd("breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); print >> here, \"lldb\"; here.close()' 2") # Check that the breakpoint commands are correctly set. @@ -145,7 +145,7 @@ self.line) # Now add callbacks for the breakpoints just created. - self.runCmd("breakpoint command add -p -o 'here = open(\"output-2.txt\", \"w\"); print >> here, frame; print >> here, bp_loc; here.close()' 1") + self.runCmd("breakpoint command add -s python -o 'here = open(\"output-2.txt\", \"w\"); print >> here, frame; print >> here, bp_loc; here.close()' 1") # Remove 'output-2.txt' if it already exists. Modified: lldb/trunk/test/conditional_break/.lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/.lldb?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/.lldb (original) +++ lldb/trunk/test/conditional_break/.lldb Fri Feb 18 20:53:09 2011 @@ -3,5 +3,5 @@ script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) script import conditional_break -breakpoint command add -p 1 -o "conditional_break.stop_if_called_from_a()" +breakpoint command add -s python 1 -o "conditional_break.stop_if_called_from_a()" Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=126015&r1=126014&r2=126015&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Fri Feb 18 20:53:09 2011 @@ -30,6 +30,7 @@ #include "lldb/API/SBHostOS.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBProcess.h" @@ -894,11 +895,12 @@ if (command_string == NULL) command_string = ""; SBCommandReturnObject result; - if (m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) - { - m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); - m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); - } + result.SetImmediateOutputFile (m_debugger.GetOutputFileHandle()); + result.SetImmediateErrorFile (m_debugger.GetErrorFileHandle()); + + // We've set the result to dump immediately. + m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true); + // We are done getting and running our command, we can now clear the // m_waiting_for_command so we can get another one. m_waiting_for_command = false; From gclayton at apple.com Sat Feb 19 20:15:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 20 Feb 2011 02:15:07 -0000 Subject: [Lldb-commits] [lldb] r126067 - in /lldb/trunk: include/lldb/API/SBCommandInterpreter.h include/lldb/Core/StreamTee.h include/lldb/Interpreter/CommandObject.h include/lldb/Interpreter/CommandReturnObject.h source/API/SBCommandInterpreter.cpp source/Interpreter/CommandInterpreter.cpp source/Interpreter/CommandObject.cpp source/Interpreter/CommandReturnObject.cpp tools/driver/Driver.cpp Message-ID: <20110220021508.116B12A6C12C@llvm.org> Author: gclayton Date: Sat Feb 19 20:15:07 2011 New Revision: 126067 URL: http://llvm.org/viewvc/llvm-project?rev=126067&view=rev Log: Don't limit StreamTee to just two streams. It now can contain N streams by making the stream a vector of stream shared pointers that is protected by a mutex. Streams can be get/set by index which allows indexes to be defined as stream indentifiers. If a stream is set at index 3 and there are now streams in the collection, then empty stream objects are inserted to ensure that stream at index 3 has a valid stream. There is also an append method that allows a stream to be pushed onto the stack. This will allow our streams to be very flexible in where the output goes. Modified the CommandReturnObject to use the new StreamTee functionality. This class now defines two StreamTee indexes: 0 for the stream string stream, and 1 for the immediate stream. This is used both on the output and error streams. Added the ability to get argument types as strings or as descriptions. This is exported through the SBCommandInterpreter API to allow external access. Modified the Driver class to use the newly exported argument names from SBCommandInterpreter::GetArgumentTypeAsCString(). Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/Core/StreamTee.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandReturnObject.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Sat Feb 19 20:15:07 2011 @@ -33,6 +33,12 @@ ~SBCommandInterpreter (); + static const char * + GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); + + static const char * + GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); + bool IsValid() const; Modified: lldb/trunk/include/lldb/Core/StreamTee.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamTee.h?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/StreamTee.h (original) +++ lldb/trunk/include/lldb/Core/StreamTee.h Sat Feb 19 20:15:07 2011 @@ -11,6 +11,7 @@ #define liblldb_StreamTee_h_ #include "lldb/Core/Stream.h" +#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -18,20 +19,42 @@ { public: StreamTee () : - Stream() + Stream (), + m_streams_mutex (Mutex::eMutexTypeRecursive), + m_streams () { } - StreamTee (lldb::StreamSP &stream_1_sp, lldb::StreamSP &stream_2_sp): - m_stream_1_sp (stream_1_sp), - m_stream_2_sp (stream_2_sp) + StreamTee (lldb::StreamSP &stream_sp): + Stream (), + m_streams_mutex (Mutex::eMutexTypeRecursive), + m_streams () { + // No need to lock mutex during construction + if (stream_sp) + m_streams.push_back (stream_sp); } + - StreamTee (lldb::StreamSP &stream_1_sp): - m_stream_1_sp (stream_1_sp), - m_stream_2_sp () + StreamTee (lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : + Stream (), + m_streams_mutex (Mutex::eMutexTypeRecursive), + m_streams () + { + // No need to lock mutex during construction + if (stream_sp) + m_streams.push_back (stream_sp); + if (stream_2_sp) + m_streams.push_back (stream_2_sp); + } + + StreamTee (const StreamTee &rhs) : + Stream (rhs), + m_streams_mutex (Mutex::eMutexTypeRecursive), + m_streams() // Don't copy until we lock down "rhs" { + Mutex::Locker locker (rhs.m_streams_mutex); + m_streams = rhs.m_streams; } virtual @@ -39,58 +62,109 @@ { } + StreamTee & + operator = (const StreamTee &rhs) + { + if (this != &rhs) { + Stream::operator=(rhs); + Mutex::Locker lhs_locker (m_streams_mutex); + Mutex::Locker rhs_locker (rhs.m_streams_mutex); + m_streams = rhs.m_streams; + } + return *this; + } + virtual void Flush () { - if (m_stream_1_sp) - m_stream_1_sp->Flush (); - - if (m_stream_2_sp) - m_stream_2_sp->Flush (); + Mutex::Locker locker (m_streams_mutex); + collection::iterator pos, end; + for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) + { + // Allow for our collection to contain NULL streams. This allows + // the StreamTee to be used with hard coded indexes for clients + // that might want N total streams with only a few that are set + // to valid values. + Stream *strm = pos->get(); + if (strm) + strm->Flush (); + } } virtual int Write (const void *s, size_t length) { - int ret_1; - int ret_2; - if (m_stream_1_sp) - ret_1 = m_stream_1_sp->Write (s, length); - - if (m_stream_2_sp) - ret_2 = m_stream_2_sp->Write (s, length); - - return ret_1 < ret_2 ? ret_1 : ret_2; + Mutex::Locker locker (m_streams_mutex); + if (m_streams.empty()) + return 0; + + int min_bytes_written = INT_MAX; + collection::iterator pos, end; + for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) + { + // Allow for our collection to contain NULL streams. This allows + // the StreamTee to be used with hard coded indexes for clients + // that might want N total streams with only a few that are set + // to valid values. + Stream *strm = pos->get(); + if (strm) + { + int bytes_written = strm->Write (s, length); + if (min_bytes_written > bytes_written) + min_bytes_written = bytes_written; + } + } + return min_bytes_written; + } + + size_t + AppendStream (const lldb::StreamSP &stream_sp) + { + size_t new_idx = m_streams.size(); + Mutex::Locker locker (m_streams_mutex); + m_streams.push_back (stream_sp); + return new_idx; + } + + size_t + GetNumStreams () const + { + size_t result = 0; + { + Mutex::Locker locker (m_streams_mutex); + result = m_streams.size(); + } + return result; + } + + lldb::StreamSP + GetStreamAtIndex (uint32_t idx) + { + lldb::StreamSP stream_sp; + Mutex::Locker locker (m_streams_mutex); + if (idx < m_streams.size()) + stream_sp = m_streams[idx]; + return stream_sp; } void - SetStream1 (lldb::StreamSP &stream_1_sp) + SetStreamAtIndex (uint32_t idx, const lldb::StreamSP& stream_sp) { - m_stream_1_sp = stream_1_sp; + Mutex::Locker locker (m_streams_mutex); + // Resize our stream vector as necessary to fit as many streams + // as needed. This also allows this class to be used with hard + // coded indexes that can be used contain many streams, not all + // of which are valid. + if (idx >= m_streams.size()) + m_streams.resize(idx + 1); + m_streams[idx] = stream_sp; } - void - SetStream2 (lldb::StreamSP &stream_2_sp) - { - m_stream_2_sp = stream_2_sp; - } - - lldb::StreamSP & - GetStream1 () - { - return m_stream_1_sp; - } - - lldb::StreamSP & - GetStream2 () - { - return m_stream_2_sp; - } - -protected: - lldb::StreamSP m_stream_1_sp; - lldb::StreamSP m_stream_2_sp; +protected: + typedef std::vector collection; + mutable Mutex m_streams_mutex; + collection m_streams; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Sat Feb 19 20:15:07 2011 @@ -59,6 +59,13 @@ virtual ~CommandObject (); + + static const char * + GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); + + static const char * + GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); + CommandInterpreter & GetCommandInterpreter () { Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Sat Feb 19 20:15:07 2011 @@ -34,17 +34,18 @@ const char * GetOutputData () { - if (m_output_stream_string_sp) - return static_cast(m_output_stream_string_sp.get())->GetData(); - else - return ""; + lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex)); + if (stream_sp) + return static_cast(stream_sp.get())->GetData(); + return ""; } const char * GetErrorData () { - if (m_error_stream_string_sp) - return static_cast(m_error_stream_string_sp.get())->GetData(); + lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex)); + if (stream_sp) + return static_cast(stream_sp.get())->GetData(); else return ""; } @@ -52,63 +53,66 @@ Stream & GetOutputStream () { - if (!m_output_stream_string_sp) + // Make sure we at least have our normal string stream output stream + lldb::StreamSP stream_sp (m_out_stream.GetStreamAtIndex (eStreamStringIndex)); + if (!stream_sp) { - StreamString *new_stream = new StreamString(); - m_output_stream_string_sp.reset (new_stream); - m_output_stream.SetStream1 (m_output_stream_string_sp); + stream_sp.reset (new StreamString()); + m_out_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp); } - return m_output_stream; + return m_out_stream; } Stream & GetErrorStream () { - if (!m_error_stream_string_sp) + // Make sure we at least have our normal string stream output stream + lldb::StreamSP stream_sp (m_err_stream.GetStreamAtIndex (eStreamStringIndex)); + if (!stream_sp) { - StreamString *new_stream = new StreamString(); - m_error_stream_string_sp.reset (new_stream); - m_error_stream.SetStream1 (m_error_stream_string_sp); + stream_sp.reset (new StreamString()); + m_err_stream.SetStreamAtIndex (eStreamStringIndex, stream_sp); } - return m_error_stream; + return m_err_stream; } void - SetImmediateOutputFile (FILE *fh) + SetImmediateOutputFile (FILE *fh, bool transfer_fh_ownership = false) { - lldb::StreamSP new_stream_sp (new StreamFile (fh, false)); - m_output_stream.SetStream2 (new_stream_sp); + lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership)); + m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp); } void - SetImmediateErrorFile (FILE *fh) + SetImmediateErrorFile (FILE *fh, bool transfer_fh_ownership = false) { - lldb::StreamSP new_stream_sp (new StreamFile (fh, false)); - SetImmediateOutputStream (new_stream_sp); + lldb::StreamSP stream_sp (new StreamFile (fh, transfer_fh_ownership)); + m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp); } void - SetImmediateOutputStream (lldb::StreamSP &new_stream_sp) + SetImmediateOutputStream (const lldb::StreamSP &stream_sp) { - m_output_stream.SetStream2 (new_stream_sp); + m_out_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp); } void - SetImmediateErrorStream (lldb::StreamSP &new_stream_sp) + SetImmediateErrorStream (const lldb::StreamSP &stream_sp) { - m_error_stream.SetStream2 (new_stream_sp); + // Ensure we always have our normal output stream + m_err_stream.SetStreamAtIndex (eImmediateStreamIndex, stream_sp); } - lldb::StreamSP & + lldb::StreamSP GetImmediateOutputStream () { - return m_output_stream.GetStream2 (); + return m_out_stream.GetStreamAtIndex (eImmediateStreamIndex); } - lldb::StreamSP & + lldb::StreamSP GetImmediateErrorStream () { - return m_error_stream.GetStream2 (); + return m_err_stream.GetStreamAtIndex (eImmediateStreamIndex); } void @@ -155,10 +159,14 @@ void SetDidChangeProcessState (bool b); private: - lldb::StreamSP m_output_stream_string_sp; - lldb::StreamSP m_error_stream_string_sp; - StreamTee m_output_stream; - StreamTee m_error_stream; + enum + { + eStreamStringIndex = 0, + eImmediateStreamIndex = 1 + }; + + StreamTee m_out_stream; + StreamTee m_err_stream; lldb::ReturnStatus m_status; bool m_did_change_process_state; Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Sat Feb 19 20:15:07 2011 @@ -292,3 +292,17 @@ return broadcaster; } +const char * +SBCommandInterpreter::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) +{ + return CommandObject::GetArgumentTypeAsCString (arg_type); +} + +const char * +SBCommandInterpreter::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) +{ + return CommandObject::GetArgumentDescriptionAsCString (arg_type); +} + + + Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Sat Feb 19 20:15:07 2011 @@ -92,27 +92,27 @@ LoadCommandDictionary (); // Set up some initial aliases. - result.Clear(); HandleCommand ("command alias q quit", false, result); - result.Clear(); HandleCommand ("command alias run process launch --", false, result); - result.Clear(); HandleCommand ("command alias r process launch --", false, result); - result.Clear(); HandleCommand ("command alias c process continue", false, result); - result.Clear(); HandleCommand ("command alias continue process continue", false, result); - result.Clear(); HandleCommand ("command alias expr expression", false, result); - result.Clear(); HandleCommand ("command alias exit quit", false, result); - result.Clear(); HandleCommand ("command alias b regexp-break", false, result); - result.Clear(); HandleCommand ("command alias bt thread backtrace", false, result); - result.Clear(); HandleCommand ("command alias si thread step-inst", false, result); - result.Clear(); HandleCommand ("command alias step thread step-in", false, result); - result.Clear(); HandleCommand ("command alias s thread step-in", false, result); - result.Clear(); HandleCommand ("command alias next thread step-over", false, result); - result.Clear(); HandleCommand ("command alias n thread step-over", false, result); - result.Clear(); HandleCommand ("command alias finish thread step-out", false, result); - result.Clear(); HandleCommand ("command alias x memory read", false, result); - result.Clear(); HandleCommand ("command alias l source list", false, result); - result.Clear(); HandleCommand ("command alias list source list", false, result); - result.Clear(); HandleCommand ("command alias p frame variable", false, result); - result.Clear(); HandleCommand ("command alias print frame variable", false, result); - result.Clear(); HandleCommand ("command alias po expression -o --", false, result); + HandleCommand ("command alias q quit", false, result); + HandleCommand ("command alias run process launch --", false, result); + HandleCommand ("command alias r process launch --", false, result); + HandleCommand ("command alias c process continue", false, result); + HandleCommand ("command alias continue process continue", false, result); + HandleCommand ("command alias expr expression", false, result); + HandleCommand ("command alias exit quit", false, result); + HandleCommand ("command alias b regexp-break", false, result); + HandleCommand ("command alias bt thread backtrace", false, result); + HandleCommand ("command alias si thread step-inst", false, result); + HandleCommand ("command alias step thread step-in", false, result); + HandleCommand ("command alias s thread step-in", false, result); + HandleCommand ("command alias next thread step-over", false, result); + HandleCommand ("command alias n thread step-over", false, result); + HandleCommand ("command alias finish thread step-out", false, result); + HandleCommand ("command alias x memory read", false, result); + HandleCommand ("command alias l source list", false, result); + HandleCommand ("command alias list source list", false, result); + HandleCommand ("command alias p frame variable", false, result); + HandleCommand ("command alias print frame variable", false, result); + HandleCommand ("command alias po expression -o --", false, result); } const char * @@ -1517,9 +1517,6 @@ CommandReturnObject &result) { size_t num_lines = commands.GetSize(); - CommandReturnObject tmp_result; - tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ()); - tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ()); // If we are going to continue past a "continue" then we need to run the commands synchronously. // Make sure you reset this value anywhere you return from the function. @@ -1543,7 +1540,6 @@ if (cmd[0] == '\0') continue; - tmp_result.Clear(); if (echo_commands) { result.AppendMessageWithFormat ("%s %s\n", @@ -1551,6 +1547,9 @@ cmd); } + CommandReturnObject tmp_result; + tmp_result.SetImmediateOutputStream (result.GetImmediateOutputStream ()); + tmp_result.SetImmediateErrorStream (result.GetImmediateErrorStream ()); bool success = HandleCommand(cmd, false, tmp_result, NULL); if (print_results) Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Sat Feb 19 20:15:07 2011 @@ -600,6 +600,23 @@ return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. This can be done through several mechanisms. The easiest way is to just enter a space-separated list of breakpoint ids. To specify all the breakpoint locations under a major breakpoint, you can use the major breakpoint number followed by '.*', eg. '5.*' means all the locations under breakpoint 5. You can also indicate a range of breakpoints by using - . The start-bp-id and end-bp-id for a range can be any valid breakpoint ids. It is not legal, however, to specify a range using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7 is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; } +const char * +CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) +{ + if (arg_type >=0 && arg_type < eArgTypeLastArg) + return g_arguments_data[arg_type].arg_name; + return NULL; + +} + +const char * +CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) +{ + if (arg_type >=0 && arg_type < eArgTypeLastArg) + return g_arguments_data[arg_type].help_text; + return NULL; +} + CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = { @@ -667,6 +684,8 @@ const CommandObject::ArgumentTableEntry* CommandObject::GetArgumentTable () { + // If this assertion fires, then the table above is out of date with the CommandArgumentType enumeration + assert ((sizeof (CommandObject::g_arguments_data) / sizeof (CommandObject::ArgumentTableEntry)) == eArgTypeLastArg); return CommandObject::g_arguments_data; } Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Sat Feb 19 20:15:07 2011 @@ -19,10 +19,8 @@ using namespace lldb_private; CommandReturnObject::CommandReturnObject () : - m_error_stream_string_sp (), - m_output_stream_string_sp (), - m_output_stream (), - m_error_stream (), + m_out_stream (), + m_err_stream (), m_status (eReturnStatusStarted), m_did_change_process_state (false) { @@ -145,11 +143,15 @@ void CommandReturnObject::Clear() { - if (m_output_stream_string_sp) - static_cast(m_output_stream_string_sp.get())->Clear(); - if (m_error_stream_string_sp) - static_cast(m_error_stream_string_sp.get())->Clear(); + lldb::StreamSP stream_sp; + stream_sp = m_out_stream.GetStreamAtIndex (eStreamStringIndex); + if (stream_sp) + static_cast(stream_sp.get())->Clear(); + stream_sp = m_err_stream.GetStreamAtIndex (eStreamStringIndex); + if (stream_sp) + static_cast(stream_sp.get())->Clear(); m_status = eReturnStatusStarted; + m_did_change_process_state = false; } bool Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=126067&r1=126066&r2=126067&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Sat Feb 19 20:15:07 2011 @@ -181,35 +181,6 @@ } } -void -GetArgumentName (const CommandArgumentType arg_type, std::string &arg_name) -{ - //Fudge this function here, since we can't call the "real" version in lldb_private::CommandObject... - - switch (arg_type) - { - // Make cases for all the arg_types used in Driver.cpp - - case eArgTypeNone: - arg_name = ""; - break; - - case eArgTypeArchitecture: - arg_name = "architecture"; - break; - - case eArgTypeScriptLang: - arg_name = "script-language"; - break; - - case eArgTypeFilename: - arg_name = "filename"; - break; - } - return; -} - - void ShowUsage (FILE *out, lldb::OptionDefinition *option_table, Driver::OptionData data) { @@ -265,23 +236,22 @@ if (option_table[i].usage_mask & opt_set_mask) { CommandArgumentType arg_type = option_table[i].argument_type; - std::string arg_name; - GetArgumentName (arg_type, arg_name); + const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type); if (option_table[i].required) { if (option_table[i].option_has_arg == required_argument) - fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name.c_str()); + fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name); else if (option_table[i].option_has_arg == optional_argument) - fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name.c_str()); + fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name); else fprintf (out, " -%c", option_table[i].short_option); } else { if (option_table[i].option_has_arg == required_argument) - fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name.c_str()); + fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name); else if (option_table[i].option_has_arg == optional_argument) - fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name.c_str()); + fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name); else fprintf (out, " [-%c]", option_table[i].short_option); } @@ -311,17 +281,16 @@ if (pos == options_seen.end()) { CommandArgumentType arg_type = option_table[i].argument_type; - std::string arg_name; - GetArgumentName (arg_type, arg_name); + const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type); options_seen.insert (option_table[i].short_option); fprintf (out, "%*s-%c ", indent_level, "", option_table[i].short_option); if (arg_type != eArgTypeNone) - fprintf (out, "<%s>", arg_name.c_str()); + fprintf (out, "<%s>", arg_name); fprintf (out, "\n"); fprintf (out, "%*s--%s ", indent_level, "", option_table[i].long_option); if (arg_type != eArgTypeNone) - fprintf (out, "<%s>", arg_name.c_str()); + fprintf (out, "<%s>", arg_name); fprintf (out, "\n"); indent_level += 5; OutputFormattedUsageText (out, indent_level, option_table[i].usage_text, screen_width);