From ctice at apple.com Mon Mar 28 11:10:45 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 28 Mar 2011 16:10:45 -0000 Subject: [Lldb-commits] [lldb] r128409 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110328161045.80FFE2A6C12C@llvm.org> Author: ctice Date: Mon Mar 28 11:10:45 2011 New Revision: 128409 URL: http://llvm.org/viewvc/llvm-project?rev=128409&view=rev Log: Fix single quote characters throughout the ARM emulation stuff. Fix bugs in various ARM istruction emulation functions: EmulateVPUSH - Fix context. - Fix bug calculating register numbers. EmulateVPOP - Fix context. - Fix bug calculating register numbers. EmulateShiftIMM - Fix bug in assert statement. EmulateLDMDA - Fix context. EmulateLDMDB - Fix context. EmulateLDMIB - Fix context. EmulateSTM - Fix bug calculating lowest_set_bit. EmulateSTMDA - Fix context. - Fix bug calculating lowest_set_bit. EmulateSTMDB - Fix context. - Fix bug calculating lowest_set_bit. EmulateSTMIB - FIx context EmulateLDRSBImmed - Fix test to match correction in corrected manual 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=128409&r1=128408&r2=128409&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon Mar 28 11:10:45 2011 @@ -202,7 +202,7 @@ for (i = 0 to 14) { - if (registers == ???1???) + if (registers == '1') { if i == 13 && i != LowestSetBit(registers) // Only possible for encoding A1 MemA[address,4] = bits(32) UNKNOWN; @@ -212,7 +212,7 @@ } } - if (registers<15> == ???1???) // Only possible for encoding A1 or A2 + if (registers<15> == '1') // Only possible for encoding A1 or A2 MemA[address,4] = PCStoreValue(); SP = SP - 4*BitCount(registers); @@ -326,15 +326,15 @@ EncodingSpecificOperations(); NullCheckIfThumbEE(13); address = SP; for i = 0 to 14 - if registers == ???1??? then + if registers == '1' then R[i} = if UnalignedAllowed then MemU[address,4] else MemA[address,4]; address = address + 4; - if registers<15> == ???1??? then + if registers<15> == '1' then if UnalignedAllowed then LoadWritePC(MemU[address,4]); else LoadWritePC(MemA[address,4]); - if registers<13> == ???0??? then SP = SP + 4*BitCount(registers); - if registers<13> == ???1??? then SP = bits(32) UNKNOWN; + if registers<13> == '0' then SP = SP + 4*BitCount(registers); + if registers<13> == '1' then SP = bits(32) UNKNOWN; } #endif @@ -383,7 +383,7 @@ // which amounts to popping one reg from the full descending stacks. // if BitCount(register_list) < 2 then SEE LDM / LDMIA / LDMFD; - // if registers<13> == ???1??? && ArchVersion() >= 7 then UNPREDICTABLE; + // if registers<13> == '1' && ArchVersion() >= 7 then UNPREDICTABLE; if (BitIsSet(opcode, 13) && ArchVersion() >= ARMv7) return false; break; @@ -454,7 +454,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - (result, carry, overflow) = AddWithCarry(SP, imm32, ???0???); + (result, carry, overflow) = AddWithCarry(SP, imm32, '0'); if d == 15 then ALUWritePC(result); // setflags is always FALSE here else @@ -772,7 +772,7 @@ break; case eEncodingA1: - // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == '1'); d = Bits32 (opcode, 19, 16); n = Bits32 (opcode, 3, 0); m = Bits32 (opcode, 11, 8); @@ -994,8 +994,8 @@ address = if add then (base + imm32) else (base - imm32); data = MemU[address,4]; if t == 15 then - if address<1:0> == ???00??? then LoadWritePC(data); else UNPREDICTABLE; - elsif UnalignedSupport() || address<1:0> = ???00??? then + if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; + elsif UnalignedSupport() || address<1:0> = '00' then R[t] = data; else // Can only apply before ARMv7 if CurrentInstrSet() == InstrSet_ARM then @@ -1086,7 +1086,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - (result, carry, overflow) = AddWithCarry(SP, imm32, ???0???); + (result, carry, overflow) = AddWithCarry(SP, imm32, '0'); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -1112,7 +1112,7 @@ switch (encoding) { case eEncodingT1: - // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:???00???, 32); + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:'00', 32); d = Bits32 (opcode, 10, 8); setflags = false; imm32 = (Bits32 (opcode, 7, 0) << 2); @@ -1120,7 +1120,7 @@ break; case eEncodingT2: - // d = 13; setflags = FALSE; imm32 = ZeroExtend(imm7:???00???, 32); + // d = 13; setflags = FALSE; imm32 = ZeroExtend(imm7:'00', 32); d = 13; setflags = false; imm32 = ThumbImm7Scaled(opcode); // imm32 = ZeroExtend(imm7:'00', 32) @@ -1162,7 +1162,7 @@ { EncodingSpecificOperations(); shifted = Shift(R[m], shift_t, shift_n, APSR.C); - (result, carry, overflow) = AddWithCarry(SP, shifted, ???0???); + (result, carry, overflow) = AddWithCarry(SP, shifted, '0'); if d == 15 then ALUWritePC(result); // setflags is always FALSE here else @@ -1320,7 +1320,7 @@ LR = next_instr_addr; else next_instr_addr = PC - 2; - LR = next_instr_addr<31:1> : ???1???; + LR = next_instr_addr<31:1> : '1'; BXWritePC(target); } #endif @@ -1427,7 +1427,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - if JMCR.JE == ???0??? || CurrentInstrSet() == InstrSet_ThumbEE then + if JMCR.JE == '0' || CurrentInstrSet() == InstrSet_ThumbEE then BXWritePC(R[m]); else if JazelleAcceptsExecution() then @@ -1482,7 +1482,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), ???1???); + (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), '1'); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -1534,7 +1534,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), ???1???); + (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), '1'); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -1588,7 +1588,7 @@ if (ConditionPassed()) { EncodingSpecificOperations(); - (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), ???1???); + (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), '1'); if d == 15 then // Can only occur for ARM encoding ALUWritePC(result); // setflags is always FALSE here else @@ -1834,10 +1834,12 @@ context.type = EmulateInstruction::eContextPushRegisterOnStack; Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, 0); - for (i=d; i; @@ -2259,9 +2263,9 @@ break; case eEncodingT3: - // if Rd == ???1111??? && S == ???1??? then SEE CMN (immediate); - // if Rn == ???1101??? then SEE ADD (SP plus immediate); - // d = UInt(Rd); n = UInt(Rn); setflags = (S == ???1???); imm32 = ThumbExpandImm(i:imm3:imm8); + // if Rd == '1111' && S == '1' then SEE CMN (immediate); + // if Rn == '1101' then SEE ADD (SP plus immediate); + // d = UInt(Rd); n = UInt(Rn); setflags = (S == '1'); imm32 = ThumbExpandImm(i:imm3:imm8); d = Bits32 (opcode, 11, 8); n = Bits32 (opcode, 19, 16); setflags = BitIsSet (opcode, 20); @@ -2275,8 +2279,8 @@ case eEncodingT4: { - // if Rn == ???1111??? then SEE ADR; - // if Rn == ???1101??? then SEE ADD (SP plus immediate); + // if Rn == '1111' then SEE ADR; + // if Rn == '1101' then SEE ADD (SP plus immediate); // d = UInt(Rd); n = UInt(Rn); setflags = FALSE; imm32 = ZeroExtend(i:imm3:imm8, 32); d = Bits32 (opcode, 11, 8); n = Bits32 (opcode, 19, 16); @@ -2300,7 +2304,7 @@ if (!success) return false; - //(result, carry, overflow) = AddWithCarry(R[n], imm32, ???0???); + //(result, carry, overflow) = AddWithCarry(R[n], imm32, '0'); AddWithCarryResult res = AddWithCarry (Rn, imm32, 0); Register reg_n; @@ -2937,7 +2941,11 @@ bool EmulateInstructionARM::EmulateShiftImm (const uint32_t opcode, const ARMEncoding encoding, ARM_ShifterType shift_type) { - assert(shift_type == SRType_ASR || shift_type == SRType_LSL || shift_type == SRType_LSR); + assert(shift_type == SRType_ASR + || shift_type == SRType_LSL + || shift_type == SRType_LSR + || shift_type == SRType_ROR + || shift_type == SRType_RRX); bool success = false; @@ -3115,7 +3123,7 @@ switch (encoding) { case eEncodingT1: - // n = UInt(Rn); registers = ???00000000???:register_list; wback = (registers == ???0???); + // 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. @@ -3125,24 +3133,24 @@ 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???); + // 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 || (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 registers<15> == '1' && InITBlock() && !LastInITBlock() then UNPREDICTABLE; if (BitIsSet (registers, 15) && InITBlock() && !LastInITBlock()) return false; - // if wback && registers == ???1??? then UNPREDICTABLE; + // if wback && registers == '1' then UNPREDICTABLE; if (wback && BitIsSet (registers, n)) return false; @@ -3222,9 +3230,9 @@ return true; } -// LDMDA loads multiple registers from consecutive memory locations using an address from a base registers. -// The consecutive memorty locations end at this address and the address just below the lowest of those locations -// can optionally be written back tot he base registers. +// LDMDA loads multiple registers from 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::EmulateLDMDA (const uint32_t opcode, const ARMEncoding encoding) { @@ -3235,14 +3243,14 @@ address = R[n] - 4*BitCount(registers) + 4; for i = 0 to 14 - if registers == ???1??? then + if registers == '1' then R[i] = MemA[address,4]; address = address + 4; - if registers<15> == ???1??? then + if registers<15> == '1' then LoadWritePC(MemA[address,4]); - if wback && registers == ???0??? then R[n] = R[n] - 4*BitCount(registers); - if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; + if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); + if wback && registers == '1' then R[n] = bits(32) UNKNOWN; #endif bool success = false; @@ -3258,7 +3266,7 @@ switch (encoding) { case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -3275,12 +3283,12 @@ // address = R[n] - 4*BitCount(registers) + 4; int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadCoreReg (n, &success); if (!success) return false; - address = address - (addr_byte_size * BitCount (registers)) + addr_byte_size; + addr_t address = Rn - (addr_byte_size * BitCount (registers)) + addr_byte_size; EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; @@ -3291,11 +3299,11 @@ // for i = 0 to 14 for (int i = 0; i < 14; ++i) { - // if registers == ???1??? then + // if registers == '1' then if (BitIsSet (registers, i)) { // R[i] = MemA[address,4]; address = address + 4; - context.SetRegisterPlusOffset (dwarf_reg, offset); + context.SetRegisterPlusOffset (dwarf_reg, Rn - (address + offset)); uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -3305,7 +3313,7 @@ } } - // if registers<15> == ???1??? then + // if registers<15> == '1' then // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { @@ -3318,22 +3326,21 @@ return false; } - // if wback && registers == ???0??? then R[n] = R[n] - 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); if (wback && BitIsClear (registers, n)) { - addr_t addr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr = addr + offset; + addr_t addr = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; } - // if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; + // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; if (wback && BitIsSet (registers, n)) return WriteBits32Unknown (n); } @@ -3353,13 +3360,13 @@ address = R[n] - 4*BitCount(registers); for i = 0 to 14 - if registers == ???1??? then + if registers == '1' then R[i] = MemA[address,4]; address = address + 4; - if registers<15> == ???1??? then + if registers<15> == '1' then LoadWritePC(MemA[address,4]); - if wback && registers == ???0??? then R[n] = R[n] - 4*BitCount(registers); - if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 + if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); + if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 #endif bool success = false; @@ -3373,30 +3380,30 @@ switch (encoding) { case eEncodingT1: - // n = UInt(Rn); registers = P:M:???0???:register_list; wback = (W == ???1???); + // 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; + // 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 registers<15> == '1' && InITBlock() && !LastInITBlock() then UNPREDICTABLE; if (BitIsSet (registers, 15) && InITBlock() && !LastInITBlock()) return false; - // if wback && registers == ???1??? then UNPREDICTABLE; + // if wback && registers == '1' then UNPREDICTABLE; if (wback && BitIsSet (registers, n)) return false; break; case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -3414,24 +3421,24 @@ // address = R[n] - 4*BitCount(registers); int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; - address = address - (addr_byte_size * BitCount (registers)); + addr_t address = Rn - (addr_byte_size * BitCount (registers)); EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; Register dwarf_reg; dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - context.SetRegisterPlusOffset (dwarf_reg, offset); + context.SetRegisterPlusOffset (dwarf_reg, Rn - address); for (int i = 0; i < 14; ++i) { if (BitIsSet (registers, i)) { // R[i] = MemA[address,4]; address = address + 4; - context.SetRegisterPlusOffset (dwarf_reg, offset); + context.SetRegisterPlusOffset (dwarf_reg, Rn - (address + offset)); uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -3443,7 +3450,7 @@ } } - // if registers<15> == ???1??? then + // if registers<15> == '1' then // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { @@ -3456,22 +3463,21 @@ return false; } - // if wback && registers == ???0??? then R[n] = R[n] - 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); if (wback && BitIsClear (registers, n)) { - addr_t addr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr = addr + offset; + addr_t addr = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; } - // if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 + // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 if (wback && BitIsSet (registers, n)) return WriteBits32Unknown (n); } @@ -3490,13 +3496,13 @@ address = R[n] + 4; for i = 0 to 14 - if registers == ???1??? then + if registers == '1' then R[i] = MemA[address,4]; address = address + 4; - if registers<15> == ???1??? then + if registers<15> == '1' then LoadWritePC(MemA[address,4]); - if wback && registers == ???0??? then R[n] = R[n] + 4*BitCount(registers); - if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; + if wback && registers == '0' then R[n] = R[n] + 4*BitCount(registers); + if wback && registers == '1' then R[n] = bits(32) UNKNOWN; #endif bool success = false; @@ -3510,7 +3516,7 @@ switch (encoding) { case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -3526,12 +3532,12 @@ // address = R[n] + 4; int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; - address = address + addr_byte_size; + addr_t address = Rn + addr_byte_size; EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterPlusOffset; @@ -3545,7 +3551,7 @@ { // R[i] = MemA[address,4]; address = address + 4; - context.SetRegisterPlusOffset (dwarf_reg, offset); + context.SetRegisterPlusOffset (dwarf_reg, offset + addr_byte_size); uint32_t data = MemARead (context, address + offset, addr_byte_size, 0, &success); if (!success) return false; @@ -3557,7 +3563,7 @@ } } - // if registers<15> == ???1??? then + // if registers<15> == '1' then // LoadWritePC(MemA[address,4]); if (BitIsSet (registers, 15)) { @@ -3570,22 +3576,21 @@ return false; } - // if wback && registers == ???0??? then R[n] = R[n] + 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] + 4*BitCount(registers); if (wback && BitIsClear (registers, n)) { - addr_t addr = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr = addr + offset; + addr_t addr = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, addr)) return false; } - // if wback && registers == ???1??? then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 + // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // Only possible for encoding A1 if (wback && BitIsSet (registers, n)) return WriteBits32Unknown (n); } @@ -3639,7 +3644,7 @@ break; case eEncodingT2: - // t = UInt(Rt); n = 13; imm32 = ZeroExtend(imm8:???00???, 32); + // t = UInt(Rt); n = 13; imm32 = ZeroExtend(imm8:'00', 32); Rt = Bits32 (opcode, 10, 8); Rn = 13; imm32 = Bits32 (opcode, 7, 0) << 2; @@ -3652,7 +3657,7 @@ break; case eEncodingT3: - // if Rn == ???1111??? then SEE LDR (literal); + // if Rn == '1111' then SEE LDR (literal); // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); Rt = Bits32 (opcode, 15, 12); Rn = Bits32 (opcode, 19, 16); @@ -3670,10 +3675,10 @@ break; case eEncodingT4: - // if Rn == ???1111??? then SEE LDR (literal); - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE LDRT; - // if Rn == ???1101??? && P == ???0??? && U == ???1??? && W == ???1??? && imm8 == ???00000100??? then SEE POP; - // if P == ???0??? && W == ???0??? then UNDEFINED; + // if Rn == '1111' then SEE LDR (literal); + // if P == '1' && U == '1' && W == '0' then SEE LDRT; + // if Rn == '1101' && P == '0' && U == '1' && W == '1' && imm8 == '00000100' then SEE POP; + // if P == '0' && W == '0' then UNDEFINED; if (BitIsClear (opcode, 10) && BitIsClear (opcode, 8)) return false; @@ -3682,7 +3687,7 @@ Rn = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -3761,14 +3766,14 @@ address = R[n]; for i = 0 to 14 - if registers == ???1??? then + if registers == '1' then if i == n && wback && i != LowestSetBit(registers) then MemA[address,4] = bits(32) UNKNOWN; // Only possible for encodings T1 and A1 else MemA[address,4] = R[i]; address = address + 4; - if registers<15> == ???1??? then // Only possible for encoding A1 + 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 @@ -3786,7 +3791,7 @@ switch (encoding) { case eEncodingT1: - // n = UInt(Rn); registers = ???00000000???:register_list; wback = TRUE; + // 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. @@ -3799,7 +3804,7 @@ break; case eEncodingT2: - // n = UInt(Rn); registers = ???0???:M:???0???:register_list; wback = (W == ???1???); + // 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. @@ -3809,14 +3814,14 @@ if ((n == 15) || (BitCount (registers) < 2)) return false; - // if wback && registers == ???1??? then UNPREDICTABLE; + // if wback && registers == '1' then UNPREDICTABLE; if (wback && BitIsSet (registers, n)) return false; break; case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -3843,10 +3848,10 @@ base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); // for i = 0 to 14 + int lowest_set_bit = 14; for (int i = 0; i < 14; ++i) { - int lowest_set_bit = 14; - // if registers == ???1??? then + // if registers == '1' then if (BitIsSet (registers, i)) { if (i < lowest_set_bit) @@ -3874,7 +3879,7 @@ } } - // if registers<15> == ???1??? then // Only possible for encoding A1 + // if registers<15> == '1' then // Only possible for encoding A1 // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { @@ -3915,14 +3920,14 @@ address = R[n] - 4*BitCount(registers) + 4; for i = 0 to 14 - if registers == ???1??? then + 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 + if registers<15> == '1' then MemA[address,4] = PCStoreValue(); if wback then R[n] = R[n] - 4*BitCount(registers); @@ -3941,7 +3946,7 @@ switch (encoding) { case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -3956,11 +3961,11 @@ // address = R[n] - 4*BitCount(registers) + 4; int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadCoreReg (n, &success); if (!success) return false; - address = address - (addr_byte_size * BitCount (registers)) + 4; + addr_t address = Rn - (addr_byte_size * BitCount (registers)) + 4; EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; @@ -3968,10 +3973,10 @@ base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); // for i = 0 to 14 + int lowest_bit_set = 14; for (int i = 0; i < 14; ++i) { - int lowest_bit_set = 14; - // if registers == ???1??? then + // if registers == '1' then if (BitIsSet (registers, i)) { if (i < lowest_bit_set) @@ -3989,7 +3994,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); - context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, Rn - (address + offset)); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -3999,7 +4004,7 @@ } } - // if registers<15> == ???1??? then + // if registers<15> == '1' then // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { @@ -4020,7 +4025,7 @@ offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr_t data = address + offset; + addr_t data = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) return false; } @@ -4040,14 +4045,14 @@ address = R[n] - 4*BitCount(registers); for i = 0 to 14 - if registers == ???1??? then + 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 + if registers<15> == '1' then // Only possible for encoding A1 MemA[address,4] = PCStoreValue(); if wback then R[n] = R[n] - 4*BitCount(registers); @@ -4067,12 +4072,12 @@ switch (encoding) { case eEncodingT1: - // if W == ???1??? && Rn == ???1101??? then SEE PUSH; + // 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 = 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. @@ -4080,18 +4085,18 @@ // if n == 15 || BitCount(registers) < 2 then UNPREDICTABLE; if ((n == 15) || BitCount (registers) < 2) return false; - // if wback && registers == ???1??? then UNPREDICTABLE; + // 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 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 = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -4107,11 +4112,11 @@ // address = R[n] - 4*BitCount(registers); int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; - address = address - (addr_byte_size * BitCount (registers)); + addr_t address = Rn - (addr_byte_size * BitCount (registers)); EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; @@ -4119,10 +4124,10 @@ base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); // for i = 0 to 14 + uint32_t lowest_set_bit = 14; for (int i = 0; i < 14; ++i) { - uint32_t lowest_set_bit = 14; - // if registers == ???1??? then + // if registers == '1' then if (BitIsSet (registers, i)) { if (i < lowest_set_bit) @@ -4140,7 +4145,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); - context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, Rn - (address + offset)); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -4150,7 +4155,7 @@ } } - // if registers<15> == ???1??? then // Only possible for encoding A1 + // if registers<15> == '1' then // Only possible for encoding A1 // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { @@ -4171,7 +4176,7 @@ offset = (addr_byte_size * BitCount (registers)) * -1; context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr_t data = address + offset; + addr_t data = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) return false; } @@ -4191,14 +4196,14 @@ address = R[n] + 4; for i = 0 to 14 - if registers == ???1??? then + 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 + if registers<15> == '1' then MemA[address,4] = PCStoreValue(); if wback then R[n] = R[n] + 4*BitCount(registers); @@ -4217,7 +4222,7 @@ switch (encoding) { case eEncodingA1: - // n = UInt(Rn); registers = register_list; wback = (W == ???1???); + // n = UInt(Rn); registers = register_list; wback = (W == '1'); n = Bits32 (opcode, 19, 16); registers = Bits32 (opcode, 15, 0); wback = BitIsSet (opcode, 21); @@ -4232,11 +4237,11 @@ // address = R[n] + 4; int32_t offset = 0; - addr_t address = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + addr_t Rn = ReadCoreReg (n, &success); if (!success) return false; - address = address + addr_byte_size; + addr_t address = Rn + addr_byte_size; EmulateInstruction::Context context; context.type = EmulateInstruction::eContextRegisterStore; @@ -4247,7 +4252,7 @@ // for i = 0 to 14 for (int i = 0; i < 14; ++i) { - // if registers == ???1??? then + // if registers == '1' then if (BitIsSet (registers, i)) { if (i < lowest_set_bit) @@ -4266,7 +4271,7 @@ Register data_reg; data_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + i); - context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset); + context.SetRegisterToRegisterPlusOffset (data_reg, base_reg, offset + addr_byte_size); if (!MemAWrite (context, address + offset, data, addr_byte_size)) return false; } @@ -4276,7 +4281,7 @@ } } - // if registers<15> == ???1??? then + // if registers<15> == '1' then // MemA[address,4] = PCStoreValue(); if (BitIsSet (registers, 15)) { @@ -4297,7 +4302,7 @@ offset = addr_byte_size * BitCount (registers); context.type = EmulateInstruction::eContextAdjustBaseRegister; context.SetImmediateSigned (offset); - addr_t data = address + offset; + addr_t data = Rn + offset; if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + n, data)) return false; } @@ -4315,7 +4320,7 @@ 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 + if UnalignedSupport() || address<1:0> == '00' then MemU[address,4] = R[t]; else // Can only occur before ARMv7 MemU[address,4] = bits(32) UNKNOWN; @@ -4338,7 +4343,7 @@ switch (encoding) { case eEncodingT1: - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm5:???00???, 32); + // 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; @@ -4350,7 +4355,7 @@ break; case eEncodingT2: - // t = UInt(Rt); n = 13; imm32 = ZeroExtend(imm8:???00???, 32); + // t = UInt(Rt); n = 13; imm32 = ZeroExtend(imm8:'00', 32); t = Bits32 (opcode, 10, 8); n = 13; imm32 = Bits32 (opcode, 7, 0) << 2; @@ -4362,7 +4367,7 @@ break; case eEncodingT3: - // if Rn == ???1111??? then UNDEFINED; + // if Rn == '1111' then UNDEFINED; if (Bits32 (opcode, 19, 16) == 15) return false; @@ -4382,9 +4387,9 @@ 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 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; @@ -4394,7 +4399,7 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -4432,7 +4437,7 @@ Register base_reg; base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); - // if UnalignedSupport() || address<1:0> == ???00??? then + // if UnalignedSupport() || address<1:0> == '00' then if (UnalignedSupport () || (BitIsClear (address, 1) && BitIsClear (address, 0))) { // MemU[address,4] = R[t]; @@ -4480,7 +4485,7 @@ data = PCStoreValue(); else data = R[t]; - if UnalignedSupport() || address<1:0> == ???00??? || CurrentInstrSet() == InstrSet_ARM then + 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; @@ -4523,7 +4528,7 @@ break; case eEncodingT2: - // if Rn == ???1111??? then UNDEFINED; + // if Rn == '1111' then UNDEFINED; if (Bits32 (opcode, 19, 16) == 15) return false; @@ -4548,13 +4553,13 @@ case eEncodingA1: { - // if P == ???0??? && W == ???1??? then SEE STRT; + // 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 = (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)); @@ -4620,7 +4625,7 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; - // if UnalignedSupport() || address<1:0> == ???00??? || CurrentInstrSet() == InstrSet_ARM then + // if UnalignedSupport() || address<1:0> == '00' || CurrentInstrSet() == InstrSet_ARM then if (UnalignedSupport () || (BitIsClear (address, 1) && BitIsClear (address, 0)) || CurrentInstrSet() == eModeARM) @@ -4694,7 +4699,7 @@ break; case eEncodingT2: - // if Rn == ???1111??? then UNDEFINED; + // if Rn == '1111' then UNDEFINED; if (Bits32 (opcode, 19, 16) == 15) return false; @@ -4714,8 +4719,8 @@ break; case eEncodingT3: - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE STRBT; - // if Rn == ???1111??? || (P == ???0??? && W == ???0???) then UNDEFINED; + // 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; @@ -4724,7 +4729,7 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -4801,7 +4806,7 @@ 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 UnalignedSupport() || address<0> == ???0??? then + if UnalignedSupport() || address<0> == '0' then MemU[address,2] = R[t]<15:0>; else // Can only occur before ARMv7 MemU[address,2] = bits(16) UNKNOWN; @@ -4843,7 +4848,7 @@ break; case eEncodingT2: - // if Rn == ???1111??? then UNDEFINED; + // if Rn == '1111' then UNDEFINED; // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -4867,13 +4872,13 @@ break; case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE STRHT; + // if P == '0' && W == '1' then SEE STRHT; // 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 = (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)); @@ -4928,7 +4933,7 @@ Register offset_reg; offset_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); - // if UnalignedSupport() || address<0> == ???0??? then + // if UnalignedSupport() || address<0> == '0' then if (UnalignedSupport() || BitIsClear (address, 0)) { // MemU[address,2] = R[t]<15:0>; @@ -5393,7 +5398,7 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ARMExpandImm(imm12, APSR.C) - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) return false; @@ -5475,7 +5480,7 @@ Rm = Bits32(opcode, 3, 0); setflags = BitIsSet(opcode, 20); shift_n = DecodeImmShiftARM(opcode, shift_t); - // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rd == '1111' && S == '1' then SEE SUBS PC, LR and related instructions; // TODO: Emulate SUBS PC, LR and related instructions. if (Rd == 15 && setflags) return false; @@ -5520,8 +5525,8 @@ data = MemU[address,4]; if wback then R[n] = offset_addr; if t == 15 then - if address<1:0> == ???00??? then LoadWritePC(data); else UNPREDICTABLE; - elsif UnalignedSupport() || address<1:0> = ???00??? then + if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; + elsif UnalignedSupport() || address<1:0> = '00' then R[t] = data; else // Can only apply before ARMv7 R[t] = ROR(data, 8*UInt(address<1:0>)); @@ -5543,18 +5548,18 @@ switch (encoding) { case eEncodingA1: - // if Rn == ???1111??? then SEE LDR (literal); - // if P == ???0??? && W == ???1??? then SEE LDRT; - // if Rn == ???1101??? && P == ???0??? && U == ???1??? && W == ???0??? && imm12 == ???000000000100??? then SEE POP; + // if Rn == '1111' then SEE LDR (literal); + // if P == '0' && W == '1' then SEE LDRT; + // if Rn == '1101' && P == '0' && U == '1' && W == '0' && imm12 == '000000000100' then SEE POP; // 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 = (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)); + // 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)); // if wback && n == t then UNPREDICTABLE; if (wback && (n == t)) @@ -5609,7 +5614,7 @@ // if t == 15 then if (t == 15) { - // if address<1:0> == ???00??? then LoadWritePC(data); else UNPREDICTABLE; + // if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; if (BitIsClear (address, 1) && BitIsClear (address, 0)) { // LoadWritePC (data); @@ -5620,7 +5625,7 @@ else return false; } - // elsif UnalignedSupport() || address<1:0> = ???00??? then + // elsif UnalignedSupport() || address<1:0> = '00' then else if (UnalignedSupport() || (BitIsClear (address, 1) && BitIsClear (address, 0))) { // R[t] = data; @@ -5658,8 +5663,8 @@ data = MemU[address,4]; if wback then R[n] = offset_addr; if t == 15 then - if address<1:0> == ???00??? then LoadWritePC(data); else UNPREDICTABLE; - elsif UnalignedSupport() || address<1:0> = ???00??? then + if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; + elsif UnalignedSupport() || address<1:0> = '00' then R[t] = data; else // Can only apply before ARMv7 if CurrentInstrSet() == InstrSet_ARM then @@ -5704,7 +5709,7 @@ break; case eEncodingT2: - // if Rn == ???1111??? then SEE LDR (literal); + // if Rn == '1111' then SEE LDR (literal); // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -5731,13 +5736,13 @@ case eEncodingA1: { - // if P == ???0??? && W == ???1??? then SEE LDRT; + // if P == '0' && W == '1' then SEE LDRT; // 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 = (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)); @@ -5812,7 +5817,7 @@ // if t == 15 then if (t == 15) { - // if address<1:0> == ???00??? then LoadWritePC(data); else UNPREDICTABLE; + // if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; if (BitIsClear (address, 1) && BitIsClear (address, 0)) { context.type = eContextRegisterLoad; @@ -5822,7 +5827,7 @@ else return false; } - // elsif UnalignedSupport() || address<1:0> = ???00??? then + // elsif UnalignedSupport() || address<1:0> = '00' then else if (UnalignedSupport () || (BitIsClear (address, 1) && BitIsClear (address, 0))) { // R[t] = data; @@ -5894,8 +5899,8 @@ break; case eEncodingT2: - // if Rt == ???1111??? then SEE PLD; - // if Rn == ???1111??? then SEE LDRB (literal); + // if Rt == '1111' then SEE PLD; + // if Rn == '1111' then SEE LDRB (literal); // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -5913,10 +5918,10 @@ break; case eEncodingT3: - // if Rt == ???1111??? && P == ???1??? && U == ???0??? && W == ???0??? then SEE PLD; - // if Rn == ???1111??? then SEE LDRB (literal); - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE LDRBT; - // if P == ???0??? && W == ???0??? then UNDEFINED; + // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE PLD; + // if Rn == '1111' then SEE LDRB (literal); + // if P == '1' && U == '1' && W == '0' then SEE LDRBT; + // if P == '0' && W == '0' then UNDEFINED; if (BitIsClear (opcode, 10) && BitIsClear (opcode, 8)) return false; @@ -5925,7 +5930,7 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -6011,8 +6016,8 @@ switch (encoding) { case eEncodingT1: - // if Rt == ???1111??? then SEE PLD; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ???1???); + // if Rt == '1111' then SEE PLD; + // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = Bits32 (opcode, 11, 0); add = BitIsSet (opcode, 23); @@ -6024,7 +6029,7 @@ break; case eEncodingA1: - // t == UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ???1???); + // t == UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = Bits32 (opcode, 11, 0); add = BitIsSet (opcode, 23); @@ -6116,8 +6121,8 @@ break; case eEncodingT2: - // if Rt == ???1111??? then SEE PLD; - // if Rn == ???1111??? then SEE LDRB (literal); + // if Rt == '1111' then SEE PLD; + // if Rn == '1111' then SEE LDRB (literal); // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6139,13 +6144,13 @@ case eEncodingA1: { - // if P == ???0??? && W == ???1??? then SEE LDRBT; + // if P == '0' && W == '1' then SEE LDRBT; // 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 = (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)); @@ -6235,7 +6240,7 @@ address = if index then offset_addr else R[n]; data = MemU[address,2]; if wback then R[n] = offset_addr; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = ZeroExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -6257,7 +6262,7 @@ switch (encoding) { case eEncodingT1: - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm5:???0???, 32); + // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm5:'0', 32); t = Bits32 (opcode, 2, 0); n = Bits32 (opcode, 5, 3); imm32 = Bits32 (opcode, 10, 6) << 1; @@ -6270,8 +6275,8 @@ break; case eEncodingT2: - // if Rt == ???1111??? then SEE "Unallocated memory hints"; - // if Rn == ???1111??? then SEE LDRH (literal); + // if Rt == '1111' then SEE "Unallocated memory hints"; + // if Rn == '1111' then SEE LDRH (literal); // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6288,10 +6293,10 @@ break; case eEncodingT3: - // if Rn == ???1111??? then SEE LDRH (literal); - // if Rt == ???1111??? && P == ???1??? && U == ???0??? && W == ???0??? then SEE "Unallocated memory hints"; - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE LDRHT; - // if P == ???0??? && W == ???0??? then UNDEFINED; + // if Rn == '1111' then SEE LDRH (literal); + // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE "Unallocated memory hints"; + // if P == '1' && U == '1' && W == '0' then SEE LDRHT; + // if P == '0' && W == '0' then UNDEFINED; if (BitIsClear (opcode, 10) && BitIsClear (opcode, 8)) return false; @@ -6300,7 +6305,7 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -6354,7 +6359,7 @@ return false; } - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport () || BitIsClear (address, 0)) { // R[t] = ZeroExtend(data, 32); @@ -6383,7 +6388,7 @@ base = Align(PC,4); address = if add then (base + imm32) else (base - imm32); data = MemU[address,2]; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = ZeroExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -6401,8 +6406,8 @@ switch (encoding) { case eEncodingT1: - // if Rt == ???1111??? then SEE "Unallocated memory hints"; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ???1???); + // if Rt == '1111' then SEE "Unallocated memory hints"; + // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = Bits32 (opcode, 11, 0); add = BitIsSet (opcode, 23); @@ -6418,7 +6423,7 @@ uint32_t imm4H = Bits32 (opcode, 11, 8); uint32_t imm4L = Bits32 (opcode, 3, 0); - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == ???1???); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = (imm4H << 4) | imm4L; add = BitIsSet (opcode, 23); @@ -6460,7 +6465,7 @@ return false; - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport () || BitIsClear (address, 0)) { // R[t] = ZeroExtend(data, 32); @@ -6493,7 +6498,7 @@ address = if index then offset_addr else R[n]; data = MemU[address,2]; if wback then R[n] = offset_addr; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = ZeroExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -6534,8 +6539,8 @@ break; case eEncodingT2: - // if Rn == ???1111??? then SEE LDRH (literal); - // if Rt == ???1111??? then SEE "Unallocated memory hints"; + // if Rn == '1111' then SEE LDRH (literal); + // if Rt == '1111' then SEE "Unallocated memory hints"; // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6556,13 +6561,13 @@ break; case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE LDRHT; + // if P == '0' && W == '1' then SEE LDRHT; // 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 = (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)); @@ -6634,7 +6639,7 @@ return false; } - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport() || BitIsClear (address, 0)) { // R[t] = ZeroExtend(data, 32); @@ -6682,8 +6687,8 @@ switch (encoding) { case eEncodingT1: - // if Rt == ???1111??? then SEE PLI; - // if Rn == ???1111??? then SEE LDRSB (literal); + // if Rt == '1111' then SEE PLI; + // if Rn == '1111' then SEE LDRSB (literal); // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6701,10 +6706,10 @@ break; case eEncodingT2: - // if Rt == ???1111??? && P == ???1??? && U == ???0??? && W == ???0??? then SEE PLI; - // if Rn == ???1111??? then SEE LDRSB (literal); - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE LDRSBT; - // if P == ???0??? && W == ???0??? then UNDEFINED; + // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE PLI; + // if Rn == '1111' then SEE LDRSB (literal); + // if P == '1' && U == '1' && W == '0' then SEE LDRSBT; + // if P == '0' && W == '0' then UNDEFINED; if (BitIsClear (opcode, 10) && BitIsClear (opcode, 8)) return false; @@ -6713,21 +6718,23 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // 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))) + if (((t == 13) || ((t == 15) + && (BitIsClear (opcode, 10) || BitIsSet (opcode, 9) || BitIsSet (opcode, 8)))) + || (wback && (n == t))) return false; break; case eEncodingA1: { - // if Rn == ???1111??? then SEE LDRSB (literal); - // if P == ???0??? && W == ???1??? then SEE LDRSBT; + // if Rn == '1111' then SEE LDRSB (literal); + // if P == '0' && W == '1' then SEE LDRSBT; // t == UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6736,7 +6743,7 @@ uint32_t imm4L = Bits32 (opcode, 3, 0); imm32 = (imm4H << 4) | imm4L; - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // 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)); @@ -6752,7 +6759,7 @@ return false; } - uint64_t Rn = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + uint64_t Rn = ReadCoreReg (n, &success); if (!success) return false; @@ -6825,8 +6832,8 @@ switch (encoding) { case eEncodingT1: - // if Rt == ???1111??? then SEE PLI; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ???1???); + // if Rt == '1111' then SEE PLI; + // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = Bits32 (opcode, 11, 0); add = BitIsSet (opcode, 23); @@ -6839,7 +6846,7 @@ case eEncodingA1: { - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == ???1???); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); uint32_t imm4H = Bits32 (opcode, 11, 8); uint32_t imm4L = Bits32 (opcode, 3, 0); @@ -6939,8 +6946,8 @@ break; case eEncodingT2: - // if Rt == ???1111??? then SEE PLI; - // if Rn == ???1111??? then SEE LDRSB (literal); + // if Rt == '1111' then SEE PLI; + // if Rn == '1111' then SEE LDRSB (literal); // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -6961,13 +6968,13 @@ break; case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE LDRSBT; + // if P == '0' && W == '1' then SEE LDRSBT; // 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 = (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); @@ -7058,7 +7065,7 @@ address = if index then offset_addr else R[n]; data = MemU[address,2]; if wback then R[n] = offset_addr; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = SignExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -7079,8 +7086,8 @@ switch (encoding) { case eEncodingT1: - // if Rn == ???1111??? then SEE LDRSH (literal); - // if Rt == ???1111??? then SEE "Unallocated memory hints"; + // if Rn == '1111' then SEE LDRSH (literal); + // if Rt == '1111' then SEE "Unallocated memory hints"; // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -7098,10 +7105,10 @@ break; case eEncodingT2: - // if Rn == ???1111??? then SEE LDRSH (literal); - // if Rt == ???1111??? && P == ???1??? && U == ???0??? && W == ???0??? then SEE "Unallocated memory hints"; - // if P == ???1??? && U == ???1??? && W == ???0??? then SEE LDRSHT; - // if P == ???0??? && W == ???0??? then UNDEFINED; + // if Rn == '1111' then SEE LDRSH (literal); + // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE "Unallocated memory hints"; + // if P == '1' && U == '1' && W == '0' then SEE LDRSHT; + // if P == '0' && W == '0' then UNDEFINED; if (BitIsClear (opcode, 10) && BitIsClear (opcode, 8)) return false; @@ -7110,7 +7117,7 @@ n = Bits32 (opcode, 19, 16); imm32 = Bits32 (opcode, 7, 0); - // index = (P == ???1???); add = (U == ???1???); wback = (W == ???1???); + // index = (P == '1'); add = (U == '1'); wback = (W == '1'); index = BitIsSet (opcode, 10); add = BitIsSet (opcode, 9); wback = BitIsSet (opcode, 8); @@ -7123,8 +7130,8 @@ case eEncodingA1: { - // if Rn == ???1111??? then SEE LDRSH (literal); - // if P == ???0??? && W == ???1??? then SEE LDRSHT; + // if Rn == '1111' then SEE LDRSH (literal); + // if P == '0' && W == '1' then SEE LDRSHT; // t == UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -7132,7 +7139,7 @@ uint32_t imm4L = Bits32 (opcode, 3, 0); imm32 = (imm4H << 4) | imm4L; - // index = (P == ???1???); add = (U == ???1???); wback = (P == ???0???) || (W == ???1???); + // 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); @@ -7187,7 +7194,7 @@ return false; } - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport() || BitIsClear (address, 0)) { // R[t] = SignExtend(data, 32); @@ -7217,7 +7224,7 @@ base = Align(PC,4); address = if add then (base + imm32) else (base - imm32); data = MemU[address,2]; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = SignExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -7235,8 +7242,8 @@ switch (encoding) { case eEncodingT1: - // if Rt == ???1111??? then SEE "Unallocated memory hints"; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ???1???); + // if Rt == '1111' then SEE "Unallocated memory hints"; + // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); imm32 = Bits32 (opcode, 11, 0); add = BitIsSet (opcode, 23); @@ -7249,7 +7256,7 @@ case eEncodingA1: { - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == ???1???); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); t = Bits32 (opcode, 15, 12); uint32_t imm4H = Bits32 (opcode, 11, 8); uint32_t imm4L = Bits32 (opcode, 3, 0); @@ -7292,7 +7299,7 @@ if (!success) return false; - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport() || BitIsClear (address, 0)) { // R[t] = SignExtend(data, 32); @@ -7323,7 +7330,7 @@ address = if index then offset_addr else R[n]; data = MemU[address,2]; if wback then R[n] = offset_addr; - if UnalignedSupport() || address<0> = ???0??? then + if UnalignedSupport() || address<0> = '0' then R[t] = SignExtend(data, 32); else // Can only apply before ARMv7 R[t] = bits(32) UNKNOWN; @@ -7364,8 +7371,8 @@ break; case eEncodingT2: - // if Rn == ???1111??? then SEE LDRSH (literal); - // if Rt == ???1111??? then SEE "Unallocated memory hints"; + // if Rn == '1111' then SEE LDRSH (literal); + // if Rt == '1111' then SEE "Unallocated memory hints"; // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32 (opcode, 15, 12); n = Bits32 (opcode, 19, 16); @@ -7387,13 +7394,13 @@ break; case eEncodingA1: - // if P == ???0??? && W == ???1??? then SEE LDRSHT; + // if P == '0' && W == '1' then SEE LDRSHT; // 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 = (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); @@ -7466,7 +7473,7 @@ return false; } - // if UnalignedSupport() || address<0> = ???0??? then + // if UnalignedSupport() || address<0> = '0' then if (UnalignedSupport() || BitIsClear (address, 0)) { // R[t] = SignExtend(data, 32); @@ -7518,7 +7525,7 @@ break; case eEncodingT2: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 11, 8); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 5, 4) << 3; @@ -7530,7 +7537,7 @@ break; case eEncodingA1: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 11, 10) << 3; @@ -7600,7 +7607,7 @@ break; case eEncodingT2: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 11, 8); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 5, 4) << 3; @@ -7612,7 +7619,7 @@ break; case eEncodingA1: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 11, 10) << 3; @@ -7682,7 +7689,7 @@ break; case eEncodingT2: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 11, 8); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 5, 4) << 3; @@ -7694,7 +7701,7 @@ break; case eEncodingA1: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 11, 10) << 3; @@ -7761,7 +7768,7 @@ break; case eEncodingT2: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 11, 8); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 5, 4) << 3; @@ -7773,7 +7780,7 @@ break; case eEncodingA1: - // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:???000???); + // d = UInt(Rd); m = UInt(Rm); rotation = UInt(rotate:'000'); d = Bits32 (opcode, 15, 12); m = Bits32 (opcode, 3, 0); rotation = Bits32 (opcode, 11, 10) << 3; @@ -7822,7 +7829,7 @@ else address = if increment then R[n] else R[n]-8; if wordhigher then address = address+4; - CPSRWriteByInstr(MemA[address+4,4], ???1111???, TRUE); + CPSRWriteByInstr(MemA[address+4,4], '1111', TRUE); BranchWritePC(MemA[address,4]); if wback then R[n] = if increment then R[n]+8 else R[n]-8; #endif @@ -7840,7 +7847,7 @@ switch (encoding) { case eEncodingT1: - // n = UInt(Rn); wback = (W == ???1???); increment = FALSE; wordhigher = FALSE; + // n = UInt(Rn); wback = (W == '1'); increment = FALSE; wordhigher = FALSE; n = Bits32 (opcode, 19, 16); wback = BitIsSet (opcode, 21); increment = false; @@ -7857,7 +7864,7 @@ break; case eEncodingT2: - // n = UInt(Rn); wback = (W == ???1???); increment = TRUE; wordhigher = FALSE; + // n = UInt(Rn); wback = (W == '1'); increment = TRUE; wordhigher = FALSE; n = Bits32 (opcode, 19, 16); wback = BitIsSet (opcode, 21); increment = true; @@ -7877,7 +7884,7 @@ // n = UInt(Rn); n = Bits32 (opcode, 19, 16); - // wback = (W == ???1???); inc = (U == ???1???); wordhigher = (P == U); + // wback = (W == '1'); inc = (U == '1'); wordhigher = (P == U); wback = BitIsSet (opcode, 21); increment = BitIsSet (opcode, 23); wordhigher = (Bit32 (opcode, 24) == Bit32 (opcode, 23)); @@ -7913,7 +7920,7 @@ if (wordhigher) address = address + 4; - // CPSRWriteByInstr(MemA[address+4,4], ???1111???, TRUE); + // CPSRWriteByInstr(MemA[address+4,4], '1111', TRUE); Register base_reg; base_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + n); @@ -8158,7 +8165,7 @@ Rn = Bits32(opcode, 19, 16); setflags = BitIsSet(opcode, 20); imm32 = ThumbExpandImm_C(opcode, APSR_C, carry); // (imm32, carry) = ThumbExpandImm(i:imm3:imm8, APSR.C) - // if Rn == ???1111??? then SEE MOV (immediate); + // if Rn == '1111' then SEE MOV (immediate); if (Rn == 15) return EmulateMOVRdImm (opcode, eEncodingT2); if (BadReg(Rd) || Rn == 13) @@ -8757,7 +8764,7 @@ if (Rd == 15 && setflags) return EmulateCMPImm (opcode, eEncodingT2); - // if Rn == ???1101??? then SEE SUB (SP minus immediate); + // if Rn == '1101' then SEE SUB (SP minus immediate); if (Rn == 13) return EmulateSUBSPImm (opcode, eEncodingT2); @@ -8836,11 +8843,11 @@ setflags = BitIsSet(opcode, 20); imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12) - // if Rn == ???1111??? && S == ???0??? then SEE ADR; + // if Rn == '1111' && S == '0' then SEE ADR; if (Rn == 15 && !setflags) return EmulateADR (opcode, eEncodingA2); - // if Rn == ???1101??? then SEE SUB (SP minus immediate); + // if Rn == '1101' then SEE SUB (SP minus immediate); if (Rn == 13) return EmulateSUBSPImm (opcode, eEncodingA1); From johnny.chen at apple.com Mon Mar 28 17:40:32 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 28 Mar 2011 22:40:32 -0000 Subject: [Lldb-commits] [lldb] r128428 - in /lldb/trunk/utils/test: README-lldb-disasm lldb-disasm.py Message-ID: <20110328224032.EDF2F2A6C12C@llvm.org> Author: johnny Date: Mon Mar 28 17:40:32 2011 New Revision: 128428 URL: http://llvm.org/viewvc/llvm-project?rev=128428&view=rev Log: Add an initial version of lldb-disasm.py script whose purpose is to iterate through all the symbols for an executable image and to issue the lldb 'disassemble' command on each symbol. The initial version just dumps the symbol table. Added: lldb/trunk/utils/test/README-lldb-disasm lldb/trunk/utils/test/lldb-disasm.py (with props) Added: lldb/trunk/utils/test/README-lldb-disasm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/README-lldb-disasm?rev=128428&view=auto ============================================================================== --- lldb/trunk/utils/test/README-lldb-disasm (added) +++ lldb/trunk/utils/test/README-lldb-disasm Mon Mar 28 17:40:32 2011 @@ -0,0 +1,94 @@ +This README describes a sample invocation of lldb-disasm.py whose purpose is to test +the lldb 'disassemble' command. + +This is for the initial checkin of lldb-disasm.py which only reads an executable image and +dumps the symbol table from the imgae and its dependent libraries. The output was cut off +since it is too large. + +da0603a-dhcp191:9131529 johnny$ /Volumes/data/lldb/svn/trunk/utils/test/lldb-disasm.py -C 'platform create remote-ios' -e /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib +lldb commands: ['platform create remote-ios'] +lldb options: None +executable: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib +sys.path: ['/Volumes/data/lldb/svn/trunk/utils/test', '/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/AppleInternal/Library/Python/2.6/site-packages', '/System/Library/Frame works/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode', '/Volumes/data/lldb/svn/trunk/utils/test/../../test/pexpect-2.4', '/Volumes/data/lldb/svn/trunk/test'] +/Volumes/data/lldb/svn/trunk/test/lldbutil.py:80: SyntaxWarning: import * only allowed at module level + def int_to_bytearray(val, bytesize): +/Volumes/data/lldb/svn/trunk/test/lldbutil.py:105: SyntaxWarning: import * only allowed at module level + def bytearray_to_int(bytes, bytesize): +run command: platform create remote-ios +output: Platform: remote-ios +Not connected to a remote platform. +SDKROOT: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3 (8F190)" + +run command: file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib +output: Current executable set to '/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib' (armv7). + +run command: image dump symtab +output: Dumping symbol table for 18 modules. +Symtab, file = /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib, num_symbols = 851: + Debug symbol + |Synthetic symbol + ||Externally Visible + ||| +Index UserID DSX Type File Address/Value Load Address Size Flags Name +------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ---------------------------------- +[ 0] 0 Code 0x0000000000001420 0x0000000000000000 0x000e0008 libSystem_initializer +[ 1] 1 Code 0x00000000000014c4 0x0000000000000000 0x001e0008 __keymgr_initializer +[ 2] 2 Code 0x00000000000014fc 0x0000000000000000 0x000e0008 dwarf2_unwind_dyld_add_image_hook +[ 3] 3 Code 0x0000000000001564 0x0000000000000000 0x000e0008 get_or_create_key_element +[ 4] 4 Code 0x0000000000001684 0x0000000000000000 0x000e0008 unlock_node +[ 5] 5 Code 0x0000000000001930 0x0000000000000000 0x000e0000 RsqrtTable +[ 6] 6 Code 0x0000000000001c30 0x0000000000000000 0x000e0000 acosf_crossover +[ 7] 7 Code 0x0000000000001c34 0x0000000000000000 0x000e0000 acosf_mid_poly +[ 8] 8 Code 0x0000000000001c48 0x0000000000000000 0x000e0000 Pi2_Q30 +[ 9] 9 Code 0x0000000000001c4c 0x0000000000000000 0x000e0000 Pi_Q30 +[ 10] 10 Code 0x0000000000001c78 0x0000000000000000 0x000e0000 acosf_approx +[ 11] 11 Code 0x0000000000001cec 0x0000000000000000 0x000e0000 acosf_pos_tail_poly +[ 12] 12 Code 0x0000000000001d00 0x0000000000000000 0x000e0000 acosf_tail +[ 13] 13 Code 0x0000000000001dfc 0x0000000000000000 0x000e0000 acosf_normalize +[ 14] 14 Code 0x0000000000001e10 0x0000000000000000 0x000e0000 acosf_round +[ 15] 15 Code 0x0000000000001e28 0x0000000000000000 0x000e0000 acosf_encode +[ 16] 16 Code 0x0000000000001e30 0x0000000000000000 0x000e0000 acosf_done +[ 17] 17 Code 0x0000000000001e38 0x0000000000000000 0x000e0000 acosf_special +[ 18] 18 Code 0x0000000000001e68 0x0000000000000000 0x000e0000 acosf_small +[ 19] 19 Code 0x0000000000001e9c 0x0000000000000000 0x000e0000 acosf_very_small +[ 20] 20 Code 0x0000000000001eb8 0x0000000000000000 0x000e0000 Pif +[ 21] 21 Code 0x000000000000220c 0x0000000000000000 0x000e0000 RsqrtTable +[ 22] 22 Code 0x000000000000250c 0x0000000000000000 0x000e0000 asinf_crossover +[ 23] 23 Code 0x0000000000002510 0x0000000000000000 0x000e0000 asinf_mid_poly +[ 24] 24 Code 0x0000000000002524 0x0000000000000000 0x000e0000 Pi2_Q30 +[ 25] 25 Code 0x0000000000002550 0x0000000000000000 0x000e0000 asinf_approx +[ 26] 26 Code 0x00000000000025e4 0x0000000000000000 0x000e0000 asinf_tail_poly +[ 27] 27 Code 0x0000000000002600 0x0000000000000000 0x000e0000 asinf_tail +[ 28] 28 Code 0x00000000000026e0 0x0000000000000000 0x000e0000 asinf_normalize +[ 29] 29 Code 0x00000000000026f4 0x0000000000000000 0x000e0000 asinf_round +[ 30] 30 Code 0x000000000000270c 0x0000000000000000 0x000e0000 asinf_encode +[ 31] 31 Code 0x0000000000002718 0x0000000000000000 0x000e0000 asinf_done +[ 32] 32 Code 0x0000000000002720 0x0000000000000000 0x000e0000 asinf_special +[ 33] 33 Code 0x0000000000002754 0x0000000000000000 0x000e0000 asinf_small +[ 34] 34 Code 0x0000000000002784 0x0000000000000000 0x000e0000 Pi2f +[ 35] 35 Code 0x0000000000005774 0x0000000000000000 0x000e0008 rem_pio2 +[ 36] 36 Code 0x00000000000076c4 0x0000000000000000 0x000e0008 __kernel_rem_pio2 +[ 37] 37 Code 0x0000000000008c90 0x0000000000000000 0x000e0008 __kernel_tan +[ 38] 38 Code 0x0000000000008ef0 0x0000000000000000 0x000e0008 lgammaApprox +[ 39] 39 Code 0x000000000000b3d4 0x0000000000000000 0x000e0000 powf_not_special +[ 40] 40 Code 0x000000000000b3dc 0x0000000000000000 0x000e0000 powf_ylgx +[ 41] 41 Code 0x000000000000b438 0x0000000000000000 0x000e0000 powf_done +[ 42] 42 Code 0x000000000000b43c 0x0000000000000000 0x000e0000 powf_special_y +[ 43] 43 Code 0x000000000000b4a8 0x0000000000000000 0x000e0000 powf_special_x +[ 44] 44 Code 0x000000000000b4cc 0x0000000000000000 0x000e0000 powf_mzero_minf +[ 45] 45 Code 0x000000000000b54c 0x0000000000000000 0x000e0000 powf_y_odd +[ 46] 46 Code 0x000000000000b57c 0x0000000000000000 0x000e0000 powf_y_nonint +[ 47] 47 Code 0x000000000000b588 0x0000000000000000 0x000e0000 powf_y_even +[ 48] 48 Code 0x000000000000b7a8 0x0000000000000000 0x000e0000 powf_log2_reduction +[ 49] 49 Code 0x000000000000b7a8 0x0000000000000000 0x000e0000 powf_log2 +[ 50] 50 Code 0x000000000000b814 0x0000000000000000 0x000e0000 powf_log2_approx +[ 51] 51 Code 0x000000000000b88c 0x0000000000000000 0x000e0000 powf_log2_synthesis +[ 52] 52 Code 0x000000000000b960 0x0000000000000000 0x000e0000 powf_log2_exactPowerOfTwo +[ 53] 53 Code 0x000000000000b980 0x0000000000000000 0x000e0000 powf_log2_near1 +[ 54] 54 Code 0x000000000000b9ec 0x0000000000000000 0x000e0000 powf_log2_synthesis_near1 +[ 55] 55 Code 0x000000000000ba04 0x0000000000000000 0x000e0000 Q32_minimax +[ 56] 56 Code 0x000000000000ba10 0x0000000000000000 0x000e0000 iexp2_lut +[ 57] 57 Code 0x000000000000ba94 0x0000000000000000 0x000e0000 powf_exp2 +[ 58] 58 Code 0x000000000000bb18 0x0000000000000000 0x000e0000 powf_exp2_exact_int +[ 59] 59 Code 0x000000000000bb24 0x0000000000000000 0x000e0000 powf_exp2_big +[ 60] 60 Code 0x000000000000bb74 0x0000000000000000 0x000e0000 powf_exp2_overflow Added: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=128428&view=auto ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (added) +++ lldb/trunk/utils/test/lldb-disasm.py Mon Mar 28 17:40:32 2011 @@ -0,0 +1,151 @@ +#!/usr/bin/env python + +""" +Run lldb to disassemble all the available functions for an executable image. + +""" + +import os +import sys +from optparse import OptionParser + +def setupSysPath(): + """ + Add LLDB.framework/Resources/Python to the search paths for modules. + """ + # Get the directory containing the current script. + scriptPath = sys.path[0] + if not scriptPath.endswith(os.path.join('utils', 'test')): + print "This script expects to reside in lldb's utils/test directory." + sys.exit(-1) + + # This is our base name component. + base = os.path.abspath(os.path.join(scriptPath, os.pardir, os.pardir)) + + # This is for the goodies in the test directory under base. + sys.path.append(os.path.join(base,'test')) + + # These are for xcode build directories. + 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')): + 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 + ',', + print relPath + ', or ' + baiPath + sys.exit(-1) + + # This is to locate the lldb.py module. Insert it right after sys.path[0]. + sys.path[1:1] = [lldbPath] + print "sys.path:", sys.path + + +def run_command(ci, cmd, res): + print "run command:", cmd + ci.HandleCommand(cmd, res) + if res.Succeeded(): + print "output:", res.GetOutput() + else: + print "run command failed!" + print "error:", res.GetError() + +def do_lldb_disassembly(lldb_commands, lldb_options, exe): + import lldb, lldbutil, atexit + + # Create the debugger instance now. + dbg = lldb.SBDebugger.Create() + if not dbg.IsValid(): + raise Exception('Invalid debugger instance') + + # Register an exit callback. + atexit.register(lambda: lldb.SBDebugger.Terminate()) + + # We want our debugger to be synchronous. + dbg.SetAsync(False) + + # Get the command interpreter from the debugger. + ci = dbg.GetCommandInterpreter() + if not ci: + raise Exception('Could not get the command interpreter') + + # And the associated result object. + res = lldb.SBCommandReturnObject() + + # See if there any extra command(s) to execute before we issue the file command. + for cmd in lldb_commands: + run_command(ci, cmd, res) + + # Now issue the file command. + run_command(ci, 'file %s' % exe, res) + + # Send the 'image dump symtab' command. + run_command(ci, 'image dump symtab', res) + +def main(): + # This is to set up the Python path to include the pexpect-2.4 dir. + # Remember to update this when/if things change. + scriptPath = sys.path[0] + sys.path.append(os.path.join(scriptPath, os.pardir, os.pardir, 'test', 'pexpect-2.4')) + + parser = OptionParser(usage="""\ +Run lldb to disassemble all the available functions for an executable image. + +Usage: %prog [options] +""") + parser.add_option('-C', '--lldb-command', + type='string', action='append', metavar='COMMAND', + default=[], dest='lldb_commands', + help='Command(s) lldb executes after starting up (can be empty)') + parser.add_option('-O', '--lldb-options', + type='string', action='store', + dest='lldb_options', + help="""The options passed to 'lldb' command if specified.""") + parser.add_option('-e', '--executable', + type='string', action='store', + dest='executable', + help="""The executable to do disassembly on.""") + + opts, args = parser.parse_args() + + lldb_commands = opts.lldb_commands + lldb_options = opts.lldb_options + + if not opts.executable: + parser.print_help() + sys.exit(1) + executable = opts.executable + + # We have parsed the options. + print "lldb commands:", lldb_commands + print "lldb options:", lldb_options + print "executable:", executable + + setupSysPath() + do_lldb_disassembly(lldb_commands, lldb_options, executable) + +if __name__ == '__main__': + main() Propchange: lldb/trunk/utils/test/lldb-disasm.py ------------------------------------------------------------------------------ svn:executable = * From johnny.chen at apple.com Mon Mar 28 17:48:25 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 28 Mar 2011 22:48:25 -0000 Subject: [Lldb-commits] [lldb] r128429 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110328224825.D3D062A6C12C@llvm.org> Author: johnny Date: Mon Mar 28 17:48:25 2011 New Revision: 128429 URL: http://llvm.org/viewvc/llvm-project?rev=128429&view=rev Log: Doc string change. Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=128429&r1=128428&r2=128429&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Mon Mar 28 17:48:25 2011 @@ -11,7 +11,7 @@ def setupSysPath(): """ - Add LLDB.framework/Resources/Python to the search paths for modules. + Add LLDB.framework/Resources/Python and the test dir to the sys.path. """ # Get the directory containing the current script. scriptPath = sys.path[0] From johnny.chen at apple.com Mon Mar 28 20:07:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 29 Mar 2011 01:07:00 -0000 Subject: [Lldb-commits] [lldb] r128442 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110329010700.F06D92A6C12C@llvm.org> Author: johnny Date: Mon Mar 28 20:07:00 2011 New Revision: 128442 URL: http://llvm.org/viewvc/llvm-project?rev=128442&view=rev Log: Add the ability to invoke lldb's disassemble command on the symbols digested from the 'image dump symtab' command. The number of symbols to disassemble can be specified by the '-n Num' option, or unlimited if not specified. Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=128442&r1=128441&r2=128442&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Mon Mar 28 20:07:00 2011 @@ -64,17 +64,20 @@ print "sys.path:", sys.path -def run_command(ci, cmd, res): - print "run command:", cmd +def run_command(ci, cmd, res, echoInput=True, echoOutput=True): + if echoInput: + print "run command:", cmd ci.HandleCommand(cmd, res) if res.Succeeded(): - print "output:", res.GetOutput() + if echoOutput: + print "run_command output:", res.GetOutput() else: - print "run command failed!" - print "error:", res.GetError() + if echoOutput: + print "run command failed!" + print "run_command error:", res.GetError() -def do_lldb_disassembly(lldb_commands, lldb_options, exe): - import lldb, lldbutil, atexit +def do_lldb_disassembly(lldb_commands, exe, disassemble_options, num_symbols): + import lldb, lldbutil, atexit, re # Create the debugger instance now. dbg = lldb.SBDebugger.Create() @@ -103,7 +106,50 @@ run_command(ci, 'file %s' % exe, res) # Send the 'image dump symtab' command. - run_command(ci, 'image dump symtab', res) + run_command(ci, 'image dump symtab', res, echoOutput=False) + + if not res.Succeeded(): + print "Symbol table dump failed!" + sys.exit(-2) + + # Do disassembly on the symbols. + # The following line from the 'image dump symtab' gives us a hint as to the + # starting char position of the symbol name. + # Index UserID DSX Type File Address/Value Load Address Size Flags Name + # ------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ---------------------------------- + # [ 0] 0 Code 0x0000000000000820 0x0000000000000000 0x000e0008 sandbox_init_internal + symtab_dump = res.GetOutput() + symbol_pos = -1 + code_type_pos = -1 + code_type_end = -1 + + # Heuristics: the first 50 lines should give us the answer for symbol_pos and code_type_pos. + for line in symtab_dump.splitlines()[:50]: + print "line:", line + if re.match("^Index.*Name$", line): + symbol_pos = line.rfind('Name') + #print "symbol_pos:", symbol_pos + code_type_pos = line.find('Type') + code_type_end = code_type_pos + 4 + #print "code_type_pos:", code_type_pos + break + + # Disassembly time. + limited = True if num_symbols != -1 else False + if limited: + count = 0 + for line in symtab_dump.splitlines(): + if line[code_type_pos:code_type_end] == 'Code': + symbol = line[symbol_pos:] + #print "symbol:", symbol + cmd = "disassemble %s '%s'" % (disassemble_options, symbol) + run_command(ci, cmd, res) + if limited: + count = count + 1 + print "number of symbols disassembled:", count + if count >= num_symbols: + break + def main(): # This is to set up the Python path to include the pexpect-2.4 dir. @@ -120,32 +166,43 @@ type='string', action='append', metavar='COMMAND', default=[], dest='lldb_commands', help='Command(s) lldb executes after starting up (can be empty)') - parser.add_option('-O', '--lldb-options', - type='string', action='store', - dest='lldb_options', - help="""The options passed to 'lldb' command if specified.""") parser.add_option('-e', '--executable', type='string', action='store', dest='executable', - help="""The executable to do disassembly on.""") + help="""Mandatory: the executable to do disassembly on.""") + parser.add_option('-o', '--options', + type='string', action='store', + dest='disassemble_options', + help="""Mandatory: the options passed to lldb's 'disassemble' command.""") + parser.add_option('-n', '--num-symbols', + type='int', action='store', + dest='num_symbols', + help="""The number of symbols to disassemble, if specified.""") opts, args = parser.parse_args() lldb_commands = opts.lldb_commands - lldb_options = opts.lldb_options - if not opts.executable: + if not opts.executable or not opts.disassemble_options: parser.print_help() sys.exit(1) + executable = opts.executable + disassemble_options = opts.disassemble_options + + if opts.num_symbols: + num_symbols = opts.num_symbols + else: + num_symbols = -1 # We have parsed the options. print "lldb commands:", lldb_commands - print "lldb options:", lldb_options print "executable:", executable + print "disassemble options:", disassemble_options + print "num of symbols to disassemble:", num_symbols setupSysPath() - do_lldb_disassembly(lldb_commands, lldb_options, executable) + do_lldb_disassembly(lldb_commands, executable, disassemble_options, num_symbols) if __name__ == '__main__': main() From ctice at apple.com Tue Mar 29 14:53:44 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 29 Mar 2011 19:53:44 -0000 Subject: [Lldb-commits] [lldb] r128479 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110329195344.7E2052A6C12C@llvm.org> Author: ctice Date: Tue Mar 29 14:53:44 2011 New Revision: 128479 URL: http://llvm.org/viewvc/llvm-project?rev=128479&view=rev Log: Add missing encodings for EmulateMOVRdImm (MOV register) function. 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=128479&r1=128478&r2=128479&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Mar 29 14:53:44 2011 @@ -681,21 +681,66 @@ uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. bool setflags; switch (encoding) { - case eEncodingT1: - Rd = Bits32(opcode, 10, 8); - setflags = !InITBlock(); - imm32 = Bits32(opcode, 7, 0); // imm32 = ZeroExtend(imm8, 32) - carry = APSR_C; - break; - case eEncodingT2: - Rd = Bits32(opcode, 11, 8); - setflags = BitIsSet(opcode, 20); - imm32 = ThumbExpandImm_C(opcode, APSR_C, carry); - if (BadReg(Rd)) + case eEncodingT1: + Rd = Bits32(opcode, 10, 8); + setflags = !InITBlock(); + imm32 = Bits32(opcode, 7, 0); // imm32 = ZeroExtend(imm8, 32) + carry = APSR_C; + + break; + + case eEncodingT2: + Rd = Bits32(opcode, 11, 8); + setflags = BitIsSet(opcode, 20); + imm32 = ThumbExpandImm_C(opcode, APSR_C, carry); + if (BadReg(Rd)) + return false; + + break; + + case eEncodingT3: + { + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm4:i:imm3:imm8, 32); + Rd = Bits32 (opcode, 11, 8); + setflags = false; + uint32_t imm4 = Bits32 (opcode, 19, 16); + uint32_t imm3 = Bits32 (opcode, 14, 12); + uint32_t i = Bit32 (opcode, 26); + uint32_t imm8 = Bits32 (opcode, 7, 0); + imm32 = (imm4 << 12) | (i << 11) | (imm3 << 8) | imm8; + + // if BadReg(d) then UNPREDICTABLE; + if (BadReg (Rd)) + return false; + } + break; + + case eEncodingA1: + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // d = UInt(Rd); setflags = (S == ???1???); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C); + Rd = Bits32 (opcode, 15, 12); + setflags = BitIsSet (opcode, 20); + imm32 = ARMExpandImm_C (opcode, APSR_C, carry); + + break; + + case eEncodingA2: + { + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm4:imm12, 32); + Rd = Bits32 (opcode, 15, 12); + setflags = false; + uint32_t imm4 = Bits32 (opcode, 19, 16); + uint32_t imm12 = Bits32 (opcode, 11, 0); + imm32 = (imm4 << 12) | imm12; + + // if d == 15 then UNPREDICTABLE; + if (Rd == 15) + return false; + } + break; + + default: return false; - break; - default: - return false; } uint32_t result = imm32; @@ -9242,7 +9287,9 @@ // tst (register) { 0x0ff0f010, 0x01100000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateTSTReg, "tst , {,}"}, - + // mov (immediate) + { 0x0fef0000, 0x03a00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateMOVRdImm, "mov{s} , #"}, + { 0x0ff00000, 0x03000000, ARMV6T2_ABOVE, eEncodingA2, eSize32, &EmulateInstructionARM::EmulateMOVRdImm, "movw , #" }, // mov (register) { 0x0fef0ff0, 0x01a00000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateMOVRdRm, "mov{s} , "}, // mvn (immediate) @@ -9490,6 +9537,7 @@ // move immediate { 0xfffff800, 0x00002000, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateMOVRdImm, "movs|mov , #imm8"}, { 0xfbef8000, 0xf04f0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateMOVRdImm, "mov{s}.w , #"}, + { 0xfbf08000, 0xf2400000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateMOVRdImm, "movw ,#"}, // mvn (immediate) { 0xfbef8000, 0xf06f0000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateMVNImm, "mvn{s} , #"}, // mvn (register) From ctice at apple.com Tue Mar 29 16:24:06 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 29 Mar 2011 21:24:06 -0000 Subject: [Lldb-commits] [lldb] r128491 - in /lldb/trunk: include/lldb/Core/EmulateInstruction.h source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h Message-ID: <20110329212406.829AE2A6C12C@llvm.org> Author: ctice Date: Tue Mar 29 16:24:06 2011 New Revision: 128491 URL: http://llvm.org/viewvc/llvm-project?rev=128491&view=rev Log: Add subtraction context. Add code to emulate SUB (SP minus register) ARM instruction. Add stubs for other ARM emulation functions that need to be written. 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=128491&r1=128490&r2=128491&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original) +++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Mar 29 16:24:06 2011 @@ -139,6 +139,8 @@ eContextMultiplication, eContextAddition, + + eContextSubtraction, eContextReturnFromException }; 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=128491&r1=128490&r2=128491&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Mar 29 16:24:06 2011 @@ -9171,6 +9171,689 @@ } return true; } + +// A8.6.216 SUB (SP minus register) +bool +EmulateInstructionARM::EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 + if ConditionPassed() then + EncodingSpecificOperations(); + shifted = Shift(R[m], shift_t, shift_n, APSR.C); + (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ???1???); + 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 = overflow; +#endif + + bool success = false; + + if (ConditionPassed(opcode)) + { + uint32_t d; + uint32_t m; + bool setflags; + ARM_ShifterType shift_t; + uint32_t shift_n; + + switch (encoding) + { + case eEncodingT1: + // d = UInt(Rd); m = UInt(Rm); setflags = (S == ???1???); + d = Bits32 (opcode, 11, 8); + m = Bits32 (opcode, 3, 0); + setflags = BitIsSet (opcode, 20); + + // (shift_t, shift_n) = DecodeImmShift(type, imm3:imm2); + shift_n = DecodeImmShiftThumb (opcode, shift_t); + + // if d == 13 && (shift_t != SRType_LSL || shift_n > 3) then UNPREDICTABLE; + if ((d == 13) && ((shift_t != SRType_LSL) || (shift_n > 3))) + return false; + + // if d == 15 || BadReg(m) then UNPREDICTABLE; + if ((d == 15) || BadReg (m)) + return false; + break; + + case eEncodingA1: + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // d = UInt(Rd); m = UInt(Rm); setflags = (S == ???1???); + d = Bits32 (opcode, 15, 12); + m = Bits32 (opcode, 3, 0); + setflags = BitIsSet (opcode, 20); + + // (shift_t, shift_n) = DecodeImmShift(type, imm5); + shift_n = DecodeImmShiftARM (opcode, shift_t); + break; + + default: + return false; + } + + // shifted = Shift(R[m], shift_t, shift_n, APSR.C); + uint32_t Rm = ReadCoreReg (m, &success); + if (!success) + return false; + + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); + + // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ???1???); + uint32_t sp_val = ReadCoreReg (SP_REG, &success); + if (!success) + return false; + + AddWithCarryResult res = AddWithCarry (sp_val, ~shifted, 1); + + EmulateInstruction::Context context; + context.type = eContextSubtraction; + Register sp_reg; + sp_reg.SetRegister (eRegisterKindDWARF, dwarf_sp); + Register dwarf_reg; + dwarf_reg.SetRegister (eRegisterKindDWARF, dwarf_r0 + m); + context.SetRegisterRegisterOperands (sp_reg, dwarf_reg); + + uint32_t regnum = dwarf_r0 + d; + + if (!WriteCoreRegOptionalFlags(context, res.result, regnum, setflags, res.carry_out, res.overflow)) + return false; + } + return true; +} + + +// A8.6.7 ADD (register-shifted register) +bool +EmulateInstructionARM::EmulateAddRegShift (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.213 SUB (register) +bool +EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.202 STREX +bool +EmulateInstructionARM::EmulateSTREX (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.197 STRB (immediate, ARM) +bool +EmulateInstructionARM::EmulateSTRBImmARM (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.194 STR (immediate, ARM) +bool +EmulateInstructionARM::EmulateSTRImmARM (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.74 LDRH (immediate, ARM) +bool +EmulateInstructionARM::EmulateLDRHImmediateARM (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.69 LDREX +bool +EmulateInstructionARM::EmulateLDREX (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.62 LDRB (immediate, ARM) +bool +EmulateInstructionARM::EmulateLDRBImmediateARM (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + +// A8.6.59 LDR (literal) +bool +EmulateInstructionARM::EmulateLDRLiteral (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + + +// A8.6.65 LDRBT +bool +EmulateInstructionARM::EmulateLDRBT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.66 LDRD (immediate) +bool +EmulateInstructionARM::EmulateLDRDImmediate (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.67 LDRD (literal) +bool +EmulateInstructionARM::EmulateLDRDLiteral (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.68 LDRD (register) +bool +EmulateInstructionARM::EmulateLDRDRegister (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.70 LDREXB +bool +EmulateInstructionARM::EmulateLDREXB (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.71 LDREXD +bool +EmulateInstructionARM::EmulateLDREXD (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.72 LDREXH +bool +EmulateInstructionARM::EmulateLDREXH (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + + +// A8.6.77 LDRHT +bool +EmulateInstructionARM::EmulateLDRHT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.81 LDRSBT +bool +EmulateInstructionARM::EmulateLDRSBT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.85 LDRSHT +bool +EmulateInstructionARM::EmulateLDRSHT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.86 LDRT +bool +EmulateInstructionARM::EmulateLDRT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + + +// A8.6.198 STRB (register) +bool +EmulateInstructionARM::EmulateSTRBReg (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.199 STRBT +bool +EmulateInstructionARM::EmulateSTRBT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.200 STRD (immediate) +bool +EmulateInstructionARM::EmulateSTRDImm (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.201 STRD (register) +bool +EmulateInstructionARM::EmulateSTRDReg (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.203 STREXB +bool +EmulateInstructionARM::EmulateSTREXB (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.204 STREXD +bool +EmulateInstructionARM::EmulateSTREXD (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.205 STREXH +bool +EmulateInstructionARM::EmulateSTREXH (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.206 STRH (immediate, Thumb) +bool +EmulateInstructionARM::EmulateSTRHImmThumb (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.207 STRH (immediate, ARM) +bool +EmulateInstructionARM::EmulateSTRHImmARM (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + + +// A8.6.209 STRHT +bool +EmulateInstructionARM::EmulateSTRHT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + //bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + +// A8.6.210 STRT +bool +EmulateInstructionARM::EmulateSTRT (const uint32_t opcode, const ARMEncoding encoding) +{ +#if 0 +#endif + + // bool success = false; + + if (ConditionPassed(opcode)) + { + switch (encoding) + { + } + } + return true; +} + + + EmulateInstructionARM::ARMOpcode* EmulateInstructionARM::GetARMOpcodeForInstruction (const uint32_t opcode) @@ -9196,6 +9879,7 @@ // adjust the stack pointer { 0x0ffff000, 0x024dd000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub sp, sp, #"}, + { 0x0fef0010, 0x004d0000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBSPReg, "sub{s} , sp, {,}" }, // push one register // if Rn == '1101' && imm12 == '000000000100' then SEE PUSH; @@ -9407,6 +10091,7 @@ { 0xffffff80, 0x0000b080, ARMvAll, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSUBSPImm, "sub sp, sp, #imm"}, { 0xfbef8f00, 0xf1ad0d00, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub.w sp, sp, #"}, { 0xfbff8f00, 0xf2ad0d00, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "subw sp, sp, #imm12"}, + { 0xffef8000, 0xebad0000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateSUBSPReg, "sub{s} , sp, {,}" }, // vector push consecutive extension register(s) { 0xffbf0f00, 0xed2d0b00, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateVPUSH, "vpush.64 "}, 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=128491&r1=128490&r2=128491&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Mar 29 16:24:06 2011 @@ -371,6 +371,10 @@ // A8.6.215 SUB (SP minus immediate) bool EmulateSUBSPImm (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.216 SUB (SP minus register) + bool + EmulateSUBSPReg (const uint32_t opcode, const ARMEncoding encoding); // A8.6.194 STR (immediate, ARM) -- Rn == sp bool @@ -415,6 +419,10 @@ // A8.6.6 ADD (register) bool EmulateADDReg (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.7 ADD (register-shifted register) + bool + EmulateAddRegShift (const uint32_t opcode, const ARMEncoding encoding); // A8.6.97 MOV (register) bool @@ -476,6 +484,8 @@ bool EmulateShiftReg (const uint32_t opcode, const ARMEncoding encoding, ARM_ShifterType shift_type); + // LOAD FUNCTIONS + // A8.6.53 LDM/LDMIA/LDMFD bool EmulateLDM (const uint32_t opcode, const ARMEncoding encoding); @@ -496,37 +506,212 @@ bool EmulateLDRRtRnImm (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.188 STM/STMIA/STMEA + // A8.6.58 LDR (immediate, ARM) - Encoding A1 + bool + EmulateLDRImmediateARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.59 LDR (literal) + bool + EmulateLDRLiteral (const uint32_t, const ARMEncoding encoding); + + // A8.6.60 LDR (register) - Encoding T1, T2, A1 + bool + EmulateLDRRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.61 LDRB (immediate, Thumb) - Encoding T1, T2, T3 + bool + EmulateLDRBImmediate (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.62 LDRB (immediate, ARM) + bool + EmulateLDRBImmediateARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.63 LDRB (literal) - Encoding T1, A1 + bool + EmulateLDRBLiteral (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.64 LDRB (register) - Encoding T1, T2, A1 + bool + EmulateLDRBRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.65 LDRBT + bool + EmulateLDRBT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.66 LDRD (immediate) + bool + EmulateLDRDImmediate (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.67 + bool + EmulateLDRDLiteral (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.68 LDRD (register) + bool + EmulateLDRDRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.69 LDREX + bool + EmulateLDREX (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.70 LDREXB + bool + EmulateLDREXB (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.71 LDREXD + bool + EmulateLDREXD (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.72 LDREXH + bool + EmulateLDREXH (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.73 LDRH (immediate, Thumb) - Encoding T1, T2, T3 + bool + EmulateLDRHImmediate (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.74 LDRS (immediate, ARM) + bool + EmulateLDRHImmediateARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.75 LDRH (literal) - Encoding T1, A1 + bool + EmulateLDRHLiteral (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.76 LDRH (register) - Encoding T1, T2, A1 + bool + EmulateLDRHRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.77 LDRHT + bool + EmulateLDRHT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.78 LDRSB (immediate) - Encoding T1, T2, A1 + bool + EmulateLDRSBImmediate (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.79 LDRSB (literal) - Encoding T1, A1 + bool + EmulateLDRSBLiteral (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.80 LDRSB (register) - Encoding T1, T2, A1 + bool + EmulateLDRSBRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.81 LDRSBT + bool + EmulateLDRSBT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.82 LDRSH (immediate) - Encoding T1, T2, A1 + bool + EmulateLDRSHImmediate (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.83 LDRSH (literal) - Encoding T1, A1 + bool + EmulateLDRSHLiteral (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.84 LDRSH (register) - Encoding T1, T2, A1 + bool + EmulateLDRSHRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.85 LDRSHT + bool + EmulateLDRSHT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.86 + bool + EmulateLDRT (const uint32_t opcode, const ARMEncoding encoding); + + + // STORE FUNCTIONS + + // A8.6.189 STM/STMIA/STMEA bool EmulateSTM (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.189 STMDA/STMED + // A8.6.190 STMDA/STMED bool EmulateSTMDA (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.190 STMDB/STMFD + // A8.6.191 STMDB/STMFD bool EmulateSTMDB (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.191 STMIB/STMFA + // A8.6.192 STMIB/STMFA bool EmulateSTMIB (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.192 STR (immediate, Thumb) + // A8.6.193 STR (immediate, Thumb) bool EmulateSTRThumb(const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.194 STR (immediate, ARM) + bool + EmulateSTRImmARM (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.194 STR (register) + // A8.6.195 STR (register) bool EmulateSTRRegister (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.195 STRB (immediate, Thumb) + // A8.6.196 STRB (immediate, Thumb) bool EmulateSTRBThumb (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.207 STRH (register) + + // A8.6.197 STRB (immediate, ARM) + bool + EmulateSTRBImmARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.198 STRB (register) + bool + EmulateSTRBReg (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.199 STRBT + bool + EmulateSTRBT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.200 STRD (immediate) + bool + EmulateSTRDImm (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.201 STRD (register) + bool + EmulateSTRDReg (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.202 STREX + bool + EmulateSTREX (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.203 STREXB + bool + EmulateSTREXB (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.204 STREXD + bool + EmulateSTREXD (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.205 STREXH + bool + EmulateSTREXH (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.206 STRH (immediate, Thumb) + bool + EmulateSTRHImmThumb (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.207 STRH (immediate, ARM) + bool + EmulateSTRHImmARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.208 STRH (register) bool EmulateSTRHRegister (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.209 STRHT + bool + EmulateSTRHT (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.210 STRT + bool + EmulateSTRT (const uint32_t opcode, const ARMEncoding encoding); // A8.6.1 ADC (immediate) bool @@ -576,62 +761,6 @@ bool EmulateEORReg (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.58 LDR (immediate, ARM) - Encoding A1 - bool - EmulateLDRImmediateARM (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.60 LDR (register) - Encoding T1, T2, A1 - bool - EmulateLDRRegister (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.61 LDRB (immediate, Thumb) - Encoding T1, T2 - bool - EmulateLDRBImmediate (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.63 LDRB (literal) - Encoding T1 - bool - EmulateLDRBLiteral (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.64 LDRB (register) - Encoding T1 - bool - EmulateLDRBRegister (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.73 LDRH (immediate, Thumb) - Encoding T1, T2 - bool - EmulateLDRHImmediate (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.75 LDRH (literal) - Encoding T1 - bool - EmulateLDRHLiteral (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.76 LDRH (register) - Encoding T1, T2 - bool - EmulateLDRHRegister (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.78 LDRSB (immediate) - Encoding T1 - bool - EmulateLDRSBImmediate (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.79 LDRSB (literal) - Encoding T1 - bool - EmulateLDRSBLiteral (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.80 LDRSB (register) - Encoding T1, T2 - bool - EmulateLDRSBRegister (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.82 LDRSH (immediate) - Encoding T1 - bool - EmulateLDRSHImmediate (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.83 LDRSH (literal) - Encoding T1 - bool - EmulateLDRSHLiteral (const uint32_t opcode, const ARMEncoding encoding); - - // A8.6.84 LDRSH (register) - Encoding T1, T2 - bool - EmulateLDRSHRegister (const uint32_t opcode, const ARMEncoding encoding); - // A8.6.105 MUL bool EmulateMUL (const uint32_t opcode, const ARMEncoding encoding); @@ -695,6 +824,14 @@ // A8.6.212 SUB (immediate, ARM) bool EmulateSUBImmARM (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.213 SUB (register) + bool + EmulateSUBReg (const uint32_t opcode, const ARMEncoding encoding); + + // A8.6.214 SUB (register-shifted register) + bool + EmulateSUBRegShift (const uint32_t opcode, const ARMEncoding encoding); // A8.6.222 SXTB - Encoding T1 bool From jingham at apple.com Tue Mar 29 16:45:47 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 29 Mar 2011 21:45:47 -0000 Subject: [Lldb-commits] [lldb] r128493 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110329214547.378902A6C12C@llvm.org> Author: jingham Date: Tue Mar 29 16:45:47 2011 New Revision: 128493 URL: http://llvm.org/viewvc/llvm-project?rev=128493&view=rev Log: Can't just call "rand" to get a random port, 'cause then you'll get the same sequence in two lldb's. This makes running lldb on lldb not work very well. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 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=128493&r1=128492&r2=128493&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Mar 29 16:45:47 2011 @@ -54,9 +54,16 @@ using namespace lldb; using namespace lldb_private; +static bool rand_initialized = false; + static inline uint16_t get_random_port () { + if (!rand_initialized) + { + rand_initialized = true; + sranddev(); + } return (rand() % (UINT16_MAX - 1000u)) + 1000u; } From ctice at apple.com Tue Mar 29 18:03:16 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 29 Mar 2011 23:03:16 -0000 Subject: [Lldb-commits] [lldb] r128500 - in /lldb/trunk/source/Plugins/Instruction/ARM: EmulateInstructionARM.cpp EmulateInstructionARM.h Message-ID: <20110329230316.EDF372A6C12C@llvm.org> Author: ctice Date: Tue Mar 29 18:03:16 2011 New Revision: 128500 URL: http://llvm.org/viewvc/llvm-project?rev=128500&view=rev Log: Fill in code in EmulateADDRegShift, to emulate the ADD (register-shifted 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=128500&r1=128499&r2=128500&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Mar 29 18:03:16 2011 @@ -9270,18 +9270,96 @@ // A8.6.7 ADD (register-shifted register) bool -EmulateInstructionARM::EmulateAddRegShift (const uint32_t opcode, const ARMEncoding encoding) +EmulateInstructionARM::EmulateADDRegShift (const uint32_t opcode, const ARMEncoding encoding) { #if 0 + if ConditionPassed() then + EncodingSpecificOperations(); + shift_n = UInt(R[s]<7:0>); + shifted = Shift(R[m], shift_t, shift_n, APSR.C); + (result, carry, overflow) = AddWithCarry(R[n], shifted, ???0???); + R[d] = result; + if setflags then + APSR.N = result<31>; + APSR.Z = IsZeroBit(result); + APSR.C = carry; + APSR.V = overflow; #endif - //bool success = false; + bool success = false; if (ConditionPassed(opcode)) { + uint32_t d; + uint32_t n; + uint32_t m; + uint32_t s; + bool setflags; + ARM_ShifterType shift_t; + switch (encoding) { - } + case eEncodingA1: + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); s = UInt(Rs); + d = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + m = Bits32 (opcode, 3, 0); + s = Bits32 (opcode, 11, 8); + + // setflags = (S == ???1???); shift_t = DecodeRegShift(type); + setflags = BitIsSet (opcode, 20); + shift_t = DecodeRegShift (Bits32 (opcode, 6, 5)); + + // if d == 15 || n == 15 || m == 15 || s == 15 then UNPREDICTABLE; + if ((d == 15) || (m == 15) || (m == 15) || (s == 15)) + return false; + break; + + default: + return false; + } + + // shift_n = UInt(R[s]<7:0>); + uint32_t Rs = ReadCoreReg (s, &success); + if (!success) + return false; + + uint32_t shift_n = Bits32 (Rs, 7, 0); + + // shifted = Shift(R[m], shift_t, shift_n, APSR.C); + uint32_t Rm = ReadCoreReg (m, &success); + if (!success) + return false; + + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); + + // (result, carry, overflow) = AddWithCarry(R[n], shifted, ???0???); + uint32_t Rn = ReadCoreReg (n, &success); + if (!success) + return false; + + AddWithCarryResult res = AddWithCarry (Rn, shifted, 0); + + // R[d] = result; + EmulateInstruction::Context context; + context.type = eContextAddition; + Register reg_n; + reg_n.SetRegister (eRegisterKindDWARF, n); + Register reg_m; + reg_m.SetRegister (eRegisterKindDWARF, m); + + context.SetRegisterRegisterOperands (reg_n, reg_m); + + if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + d, res.result)) + return false; + + // if setflags then + // APSR.N = result<31>; + // APSR.Z = IsZeroBit(result); + // APSR.C = carry; + // APSR.V = overflow; + if (setflags) + return WriteFlags (context, res.result, res.carry_out, res.overflow); } return true; } @@ -9927,6 +10005,8 @@ { 0x0fe00000, 0x02800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateADDImmARM, "add{s} , , #const"}, // add (register) { 0x0fe00010, 0x00800000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateADDReg, "add{s} , , {,}"}, + // add (register-shifted register) + { 0x0fe00090, 0x00800010, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateADDRegShift, "add{s} , m, , "}, // adr { 0x0fff0000, 0x028f0000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateADR, "add , PC, #"}, { 0x0fff0000, 0x024f0000, ARMvAll, eEncodingA2, eSize32, &EmulateInstructionARM::EmulateADR, "sub , PC, #"}, 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=128500&r1=128499&r2=128500&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Tue Mar 29 18:03:16 2011 @@ -422,7 +422,7 @@ // A8.6.7 ADD (register-shifted register) bool - EmulateAddRegShift (const uint32_t opcode, const ARMEncoding encoding); + EmulateADDRegShift (const uint32_t opcode, const ARMEncoding encoding); // A8.6.97 MOV (register) bool From wilsons at start.ca Tue Mar 29 18:20:06 2011 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 29 Mar 2011 19:20:06 -0400 Subject: [Lldb-commits] [lldb] r128493 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp In-Reply-To: <20110329214547.378902A6C12C@llvm.org> References: <20110329214547.378902A6C12C@llvm.org> Message-ID: <20110329232005.GA20927@fibrous.localdomain> Hi Jim. On Tue, Mar 29, 2011 at 09:45:47PM -0000, Jim Ingham wrote: > get_random_port () > { > + if (!rand_initialized) > + { > + rand_initialized = true; > + sranddev(); > + } > return (rand() % (UINT16_MAX - 1000u)) + 1000u; > } > Would something like the following address the issue (applied atop your patch)? IIRC sranddev() is mostly a BSD'ism, whereas the following should be OK in any standard C environment. diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index b434853..987f246 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -13,6 +13,7 @@ #include #include #include +#include // C++ Includes #include @@ -61,8 +62,10 @@ get_random_port () { if (!rand_initialized) { + time_t seed = time(NULL); + rand_initialized = true; - sranddev(); + srand(seed); } return (rand() % (UINT16_MAX - 1000u)) + 1000u; } From jingham at apple.com Tue Mar 29 18:22:29 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 29 Mar 2011 23:22:29 -0000 Subject: [Lldb-commits] [lldb] r128505 - /lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Message-ID: <20110329232229.3C6232A6C12C@llvm.org> Author: jingham Date: Tue Mar 29 18:22:29 2011 New Revision: 128505 URL: http://llvm.org/viewvc/llvm-project?rev=128505&view=rev Log: Can't count on the particular number of modules loaded into a basic C executable. Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=128505&r1=128504&r2=128505&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Tue Mar 29 18:22:29 2011 @@ -131,13 +131,13 @@ patterns = ["Line table for .*main.cpp in `a.out"]) self.expect("i d se", - startstr = "Dumping sections for 5 modules.") + patterns = ["Dumping sections for [0-9]+ modules."]) self.expect("i d symf", - startstr = "Dumping debug symbols for 5 modules.") + patterns = ["Dumping debug symbols for [0-9]+ modules."]) self.expect("i d symt", - startstr = "Dumping symbol table for 5 modules.") + patterns = ["Dumping symbol table for [0-9]+ modules."]) self.expect("i li", substrs = [ 'a.out', From jingham at apple.com Tue Mar 29 18:34:15 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 29 Mar 2011 16:34:15 -0700 Subject: [Lldb-commits] [lldb] r128493 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp In-Reply-To: <20110329232005.GA20927@fibrous.localdomain> References: <20110329214547.378902A6C12C@llvm.org> <20110329232005.GA20927@fibrous.localdomain> Message-ID: <5497A5FC-D41E-4E68-B94B-C66120E2C349@apple.com> I looked at what claimed to be Linux man pages online, and they claimed to have sranddev, but seeding from time would also be fine, if you want to apply that feel free. Cryptographic grade random numbers aren't required here, but two lldb's running at the same time shouldn't be trying to use the same port, which is what happens when you try to run lldb on lldb... BTW, at some point we'll fix this more properly by having lldb open the port, and telling the debugserver it launches to connect back to that. That way we can avoid these collisions. But for now anything like this will work. Thanks, Jim On Mar 29, 2011, at 4:20 PM, Stephen Wilson wrote: > Hi Jim. > > On Tue, Mar 29, 2011 at 09:45:47PM -0000, Jim Ingham wrote: >> get_random_port () >> { >> + if (!rand_initialized) >> + { >> + rand_initialized = true; >> + sranddev(); >> + } >> return (rand() % (UINT16_MAX - 1000u)) + 1000u; >> } >> > > Would something like the following address the issue (applied atop your patch)? > IIRC sranddev() is mostly a BSD'ism, whereas the following should be OK > in any standard C environment. > > > > diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp > index b434853..987f246 100644 > --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp > +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > // C++ Includes > #include > @@ -61,8 +62,10 @@ get_random_port () > { > if (!rand_initialized) > { > + time_t seed = time(NULL); > + > rand_initialized = true; > - sranddev(); > + srand(seed); > } > return (rand() % (UINT16_MAX - 1000u)) + 1000u; > } > > From ctice at apple.com Tue Mar 29 18:44:21 2011 From: ctice at apple.com (Caroline Tice) Date: Tue, 29 Mar 2011 23:44:21 -0000 Subject: [Lldb-commits] [lldb] r128508 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110329234421.225102A6C12C@llvm.org> Author: ctice Date: Tue Mar 29 18:44:20 2011 New Revision: 128508 URL: http://llvm.org/viewvc/llvm-project?rev=128508&view=rev Log: Fill in code in EmulateSUBReg to emulate the SUB (register) ARM instruction. 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=128508&r1=128507&r2=128508&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue Mar 29 18:44:20 2011 @@ -9369,19 +9369,123 @@ EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding encoding) { #if 0 + if ConditionPassed() then + EncodingSpecificOperations(); + shifted = Shift(R[m], shift_t, shift_n, APSR.C); + (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ???1???); + 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 = overflow; #endif - //bool success = false; + bool success = false; if (ConditionPassed(opcode)) { + uint32_t d; + uint32_t n; + uint32_t m; + bool setflags; + ARM_ShifterType shift_t; + uint32_t shift_n; + switch (encoding) { - } + case eEncodingT1: + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = !InITBlock(); + d = Bits32 (opcode, 2, 0); + n = Bits32 (opcode, 5, 3); + m = Bits32 (opcode, 8, 6); + setflags = !InITBlock(); + + // (shift_t, shift_n) = (SRType_LSL, 0); + shift_t = SRType_LSL; + shift_n = 0; + + break; + + case eEncodingT2: + // if Rd == ???1111??? && S == ???1??? then SEE CMP (register); + // if Rn == ???1101??? then SEE SUB (SP minus register); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); + d = Bits32 (opcode, 11, 8); + n = Bits32 (opcode, 19, 16); + m = Bits32 (opcode, 3, 0); + setflags = BitIsSet (opcode, 20); + + // (shift_t, shift_n) = DecodeImmShift(type, imm3:imm2); + shift_n = DecodeImmShiftThumb (opcode, shift_t); + + // if d == 13 || (d == 15 && S == '0') || n == 15 || BadReg(m) then UNPREDICTABLE; + if ((d == 13) || ((d == 15) && BitIsClear (opcode, 20)) || (n == 15) || BadReg (m)) + return false; + + break; + + case eEncodingA1: + // if Rd == ???1111??? && S == ???1??? then SEE SUBS PC, LR and related instructions; + // if Rn == ???1101??? then SEE SUB (SP minus register); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ???1???); + d = Bits32 (opcode, 15, 12); + n = Bits32 (opcode, 19, 16); + m = Bits32 (opcode, 3, 0); + setflags = BitIsSet (opcode, 20); + + // (shift_t, shift_n) = DecodeImmShift(type, imm5); + shift_n = DecodeImmShiftARM (opcode, shift_t); + + break; + + default: + return false; + } + + // shifted = Shift(R[m], shift_t, shift_n, APSR.C); + uint32_t Rm = ReadCoreReg (m, &success); + if (!success) + return false; + + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); + + // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ???1???); + uint32_t Rn = ReadCoreReg (n, &success); + if (!success) + return false; + + AddWithCarryResult res = AddWithCarry (Rn, ~shifted, 1); + + // 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 = overflow; + + EmulateInstruction::Context context; + context.type = eContextSubtraction; + Register reg_n; + reg_n.SetRegister (eRegisterKindDWARF, n); + Register reg_m; + reg_m.SetRegister (eRegisterKindDWARF, m); + context.SetRegisterRegisterOperands (reg_n, reg_m); + + uint32_t dest_reg_num = dwarf_r0 + d; + + if (!WriteCoreRegOptionalFlags (context, res.result, dest_reg_num, setflags, res.carry_out, res.overflow)) + return false; } return true; } - + // A8.6.202 STREX bool EmulateInstructionARM::EmulateSTREX (const uint32_t opcode, const ARMEncoding encoding) @@ -10042,6 +10146,8 @@ { 0x0fe00000, 0x02400000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBImmARM, "sub{s} , , #"}, // sub (sp minus immediate) { 0x0fef0000, 0x024d0000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub{s} , sp, #"}, + // sub (register) + { 0x0fe00010, 0x00400000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBReg, "sub{s} , , {,}"}, // teq (immediate) { 0x0ff0f000, 0x03300000, ARMvAll, eEncodingA1, eSize32, &EmulateInstructionARM::EmulateTEQImm, "teq , #const"}, // teq (register) @@ -10282,6 +10388,9 @@ // sub (sp minus immediate) { 0xfbef8000, 0xf1ad0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub{s}.w , sp, #"}, { 0xfbff8000, 0xf2ad0000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "subw , sp, #imm12"}, + // sub (register) + { 0xfffffe00, 0x00001a00, ARMV4T_ABOVE, eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSUBReg, "subs|sub , , "}, + { 0xffe08000, 0xeba00000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSUBReg, "sub{s}.w , , {,}"}, // teq (immediate) { 0xfbf08f00, 0xf0900f00, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateTEQImm, "teq , #"}, // teq (register) From wilsons at start.ca Tue Mar 29 19:12:40 2011 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 30 Mar 2011 00:12:40 -0000 Subject: [Lldb-commits] [lldb] r128514 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110330001240.7427A2A6C12C@llvm.org> Author: wilsons Date: Tue Mar 29 19:12:40 2011 New Revision: 128514 URL: http://llvm.org/viewvc/llvm-project?rev=128514&view=rev Log: Unfortunately, sranddev() is not available on all platforms so seed using the current time instead. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 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=128514&r1=128513&r2=128514&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Mar 29 19:12:40 2011 @@ -13,6 +13,7 @@ #include #include #include +#include // C++ Includes #include @@ -61,8 +62,10 @@ { if (!rand_initialized) { + time_t seed = time(NULL); + rand_initialized = true; - sranddev(); + srand(seed); } return (rand() % (UINT16_MAX - 1000u)) + 1000u; } From wilsons at start.ca Tue Mar 29 19:26:21 2011 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 29 Mar 2011 20:26:21 -0400 Subject: [Lldb-commits] [PATCH] give subclasses access to UnixSignals::m_signals In-Reply-To: <20110328003824.GA30603@fibrous.localdomain> References: <20110328003824.GA30603@fibrous.localdomain> Message-ID: <20110330002621.GA21373@fibrous.localdomain> Any chance I could get a quick thumbs up on the following patch? I know this is a rater trivial change and I should probably just go ahead and commit it. My main concern was if there are any short-term plans to move the default darwin-specific implementation elsewhere -- thus potentially making this change redundant. On Sun, Mar 27, 2011 at 08:38:24PM -0400, Stephen Wilson wrote: > > Allow subclasses of UnixSignals to access m_signals by marking the > member protected instead of private. This enables a subclass to provide > a default signal set as appropriate on construction. > > > > diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h > index 3e13438..f47a90b 100644 > --- a/include/lldb/Target/UnixSignals.h > +++ b/include/lldb/Target/UnixSignals.h > @@ -133,10 +133,6 @@ protected: > void > Reset (); > > -private: > - //------------------------------------------------------------------ > - // For UnixSignals only > - //------------------------------------------------------------------ > typedef std::map collection; > > collection m_signals; > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -- steve From gclayton at apple.com Tue Mar 29 20:02:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 30 Mar 2011 01:02:38 -0000 Subject: [Lldb-commits] [lldb] r128518 - in /lldb/trunk/www: lldb-gdb.html sidebar.incl style.css tutorial.html Message-ID: <20110330010238.365AD2A6C12C@llvm.org> Author: gclayton Date: Tue Mar 29 20:02:37 2011 New Revision: 128518 URL: http://llvm.org/viewvc/llvm-project?rev=128518&view=rev Log: Updated the web site with a getting started with LLDB and also some resources to help GDB users figure out the equivalent commands in LLDB. Added: lldb/trunk/www/lldb-gdb.html (with props) lldb/trunk/www/tutorial.html (with props) Modified: lldb/trunk/www/sidebar.incl lldb/trunk/www/style.css Added: lldb/trunk/www/lldb-gdb.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=128518&view=auto ============================================================================== --- lldb/trunk/www/lldb-gdb.html (added) +++ lldb/trunk/www/lldb-gdb.html Tue Mar 29 20:02:37 2011 @@ -0,0 +1,448 @@ + + + + + +LLDB Goals + + + +
+ The LLDB Debugger +
+ +
+
+ +
+
+

LLDB to GDB Command Map

+
+ +

Below is a table of LLDB commands with the GDB counterparts. + The built in GDB compatability aliases in GDB are also + listed.

+
+ + +

Execution Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
Launch a process no arguments.
+ (lldb) process launch
+ (lldb) run
+ (lldb) r +
+ (gdb) run
+ (gdb) r +
Launch a process with arguments <args>.
+ (lldb) process launch -- <args>
+ (lldb) run -- <args>
+ (lldb) r <args> +
+ (gdb) run <args>
+ (gdb) r <args> +
Launch a process with arguments in new terminal window (Mac OS X only).
+ (lldb) process launch --tty -- <args>
+ (lldb) process launch -t -- <args>
+
+
Launch a process with arguments in existing terminal /dev/ttys006 (Mac OS X only).
+ (lldb) process launch --tty=/dev/ttys006 -- <args>
+ (lldb) process launch -t/dev/ttys006 -- <args>
+
+
Attach to a process with process ID 123.
+ (lldb) process attach --pid 123
+ (lldb) attach -p 123 +
+ (gdb) attach 123 +
Attach to a process named "a.out".
+ (lldb) process attach --name a.out
+ (lldb) process attach -n a.out +
+ (gdb) attach a.out +
Wait for a process named "a.out" to launch and attach.
+ (lldb) process attach --name a.out --waitfor
+ (lldb) process attach -n a.out -w +
+ (gdb) attach -waitfor a.out +
Do a source level single step in the currently selected thread.
+ (lldb) thread step-in
+ (lldb) step
+ (lldb) s +
+ (gdb) step
+ (gdb) s +
Do a source level single step over in the currently selected thread.
+ (lldb) thread step-over
+ (lldb) next
+ (lldb) n
+
+ (gdb) next
+ (gdb) n +
Do an instruction level single step in the currently selected thread.
+ (lldb) thread step-inst
+ (lldb) si
+
+ (gdb) stepi
+ (gdb) si +
Do an instruction level single step over in the currently selected thread.
+ (lldb) thread step-inst-over
+
+ (gdb) nexti
+ (gdb) ni +
Step out of the currently selected frame.
+ (lldb) thread step-out
+ (lldb) finish
+
+ (gdb) finish
+
+

+

+ + +

Breakpoint Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
Set a breakpoint at all functions named main.
+ (lldb) breakpoint set --name main
+ (lldb) breakpoint set -n main
+ (lldb) b main +
+ (lldb) break main +
Set a breakpoint in file test.c at line 12.
+ (lldb) breakpoint set --file test.c --line 12
+ (lldb) breakpoint set -f test.c -l 12
+ (lldb) b test.c:12 +
+ (lldb) break test.c:12 +
Set a breakpoint at all C++ methods whose basename is main.
+ (lldb) breakpoint set --method main
+ (lldb) breakpoint set -M main
+
+ (lldb) break main
+ (Hope that there are no C funtions named main). +
Set a breakpoint at all Objective C methods whose selector is count.
+ (lldb) breakpoint set --selector count
+ (lldb) breakpoint set -S count
+
+ (lldb) break count
+ (Hope that there are no C or C++ funtions named count). +
+

+

+ + +

Examining Thread State

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +\ + + + + + + + + + + + + + + + + + +
LLDBGDB
Show the arguments and local variables for the current frame.
+ (lldb) frame variable
+
+ (gdb) info args
+ and
+ (gdb) info locals
+
Show the stack backtrace for the current thread.
+ (lldb) thread backtrace
+ (lldb) bt
+
+ (gdb) bt
+
Show the stack backtraces for all threads.
+ (lldb) thread backtrace all
+ (lldb) bt all +
+ (gdb) thread apply all bt +
Show all thread registers.
+ (lldb) register read + + (gdb) info all-registers +
Show the values for the thread registers name "rax", "rsp" and "rbp".
+ (lldb) register read rax rsp rbp + + (gdb) info all-registers rax rsp rbp +
Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.
+ (lldb) memory read --size 4 --format x --count 4 0xbffff3c0
+ (lldb) x --size 4 --format x --count 4 0xbffff3c0 +
+ (gdb) x/4xw 0xbffff3c0 +
Disassemble the current function for the current frame.
+ (lldb) disassemble --frame
+ (lldb) disassemble -f +
+ (gdb) disassemble +
Disassemble any functions named main.
+ (lldb) disassemble --name main
+ (lldb) disassemble -n main +
+ (gdb) disassemble main +
Disassemble an address range.
+ (lldb) disassemble --start-address 0x00001eb8 --end-address 0x00001ec3
+
+ (gdb) disassemble 0x00001eb8 0x00001ec3 +
Show mixed source and disassembly for the current function for the current frame.
+ (lldb) disassemble --frame --mixed
+ (lldb) disassemble -f -m +
+ n/a +
Disassemble the current function for the current frame and show the opcode bytes.
+ (lldb) disassemble --frame --bytes
+ (lldb) disassemble -f -b +
+ n/a +
Disassemble the current source line for the current frame.
+ (lldb) disassemble --line
+ (lldb) disassemble -l +
+ n/a +
+

+

+ + +

Executable and Shared Library Query Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
List the main executable and all dependent shared libraries.
+ (lldb) image list
+
+ (gdb) info shared
+
Lookup information for a raw address in the executable or any shared libraries.
+ (lldb) image lookup --address 0x1ec4
+ (lldb) image lookup -a 0x1ec4
+
+ (gdb) info symbol 0x1ec4
+
Dump all sections from the main executable and any shared libraries.
+ (lldb) image dump sections
+
+ (gdb) maintenance info sections
+
+

+

+ + +

+ + +

+
+
+
+ + Propchange: lldb/trunk/www/lldb-gdb.html ------------------------------------------------------------------------------ svn:executable = * Modified: lldb/trunk/www/sidebar.incl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/sidebar.incl?rev=128518&r1=128517&r2=128518&view=diff ============================================================================== --- lldb/trunk/www/sidebar.incl (original) +++ lldb/trunk/www/sidebar.incl Tue Mar 29 20:02:37 2011 @@ -7,6 +7,8 @@
  • Goals
  • Features
  • Status
  • +
  • Tutorial
  • +
  • LLDB and GDB