While implementing unwind information using UnwindAssemblyInstEmulation I ran
into some cleanup I have been wanting to do when reading/writing registers.
Previously all RegisterContext subclasses would need to implement:
virtual bool
ReadRegisterBytes (uint32_t reg, DataExtractor &data);
virtual bool
WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset = 0);
There is now a new class specifically designed to hold register values:
lldb_private::RegisterValue
The new register context calls that subclasses must implement are:
virtual bool
ReadRegister (const RegisterInfo *reg_info, RegisterValue ®_value) = 0;
virtual bool
WriteRegister (const RegisterInfo *reg_info, const RegisterValue ®_value) = 0;
The RegisterValue class must be big enough to handle any register value. The
class contains an enumeration for the value type, and then a union for the
data value. Any integer/float values are stored directly in an appropriate
host integer/float. Anything bigger is stored in a byte buffer that has a length
and byte order. The RegisterValue class also knows how to copy register value
bytes into in a buffer with a specified byte order which can be used to write
the register value down into memory, and this does the right thing when not
all bytes from the register values are needed (getting a uint8 from a uint32
register value..).
All RegiterContext and other sources have been switched over to using the new
regiter value class.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131096 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index fb331f2..91f1f1c 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -501,9 +501,7 @@
data = MemARead(context, addr, 4, 0, &success);
if (!success)
return false;
- RegisterInfo reg_info;
- GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + i, reg_info);
- if (!WriteRegisterUnsigned(context, reg_info, data))
+ if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + i, data))
return false;
addr += addr_byte_size;
}
@@ -802,12 +800,12 @@
break;
case eEncodingA1:
- // d = UInt(Rd); setflags = (S == ‘1’); (imm32, carry) = ARMExpandImm_C(imm12, APSR.C);
+ // 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);
- // 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;
if ((Rd == 15) && setflags)
return EmulateSUBSPcLrEtc (opcode, encoding);
@@ -1981,7 +1979,7 @@
GetRegisterInfo (eRegisterKindDWARF, start_reg + d + i, dwarf_reg);
context.SetRegisterToRegisterPlusOffset ( dwarf_reg, sp_reg, addr - sp);
// uint64_t to accommodate 64-bit registers.
- uint64_t reg_value = ReadRegisterUnsigned(dwarf_reg, 0, &success);
+ uint64_t reg_value = ReadRegisterUnsigned (&dwarf_reg, 0, &success);
if (!success)
return false;
if (!MemAWrite (context, addr, reg_value, reg_byte_size))
@@ -2077,7 +2075,7 @@
data = MemARead(context, addr, reg_byte_size, 0, &success);
if (!success)
return false;
- if (!WriteRegisterUnsigned(context, dwarf_reg, data))
+ if (!WriteRegisterUnsigned(context, &dwarf_reg, data))
return false;
addr += reg_byte_size;
}
@@ -4232,7 +4230,7 @@
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
@@ -9275,7 +9273,7 @@
if ConditionPassed() then
EncodingSpecificOperations();
shifted = Shift(R[m], shift_t, shift_n, APSR.C);
- (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ‘1’);
+ (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
@@ -9300,7 +9298,7 @@
switch (encoding)
{
case eEncodingT1:
- // d = UInt(Rd); m = UInt(Rm); setflags = (S == ‘1’);
+ // d = UInt(Rd); m = UInt(Rm); setflags = (S == Ô1Õ);
d = Bits32 (opcode, 11, 8);
m = Bits32 (opcode, 3, 0);
setflags = BitIsSet (opcode, 20);
@@ -9318,12 +9316,12 @@
break;
case eEncodingA1:
- // d = UInt(Rd); m = UInt(Rm); setflags = (S == ‘1’);
+ // d = UInt(Rd); m = UInt(Rm); setflags = (S == Ô1Õ);
d = Bits32 (opcode, 15, 12);
m = Bits32 (opcode, 3, 0);
setflags = BitIsSet (opcode, 20);
- // 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;
if (d == 15 && setflags)
EmulateSUBSPcLrEtc (opcode, encoding);
@@ -9342,7 +9340,7 @@
uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C);
- // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ‘1’);
+ // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), Ô1Õ);
uint32_t sp_val = ReadCoreReg (SP_REG, &success);
if (!success)
return false;
@@ -9373,7 +9371,7 @@
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’);
+ (result, carry, overflow) = AddWithCarry(R[n], shifted, Ô0Õ);
R[d] = result;
if setflags then
APSR.N = result<31>;
@@ -9402,7 +9400,7 @@
m = Bits32 (opcode, 3, 0);
s = Bits32 (opcode, 11, 8);
- // setflags = (S == ‘1’); shift_t = DecodeRegShift(type);
+ // setflags = (S == Ô1Õ); shift_t = DecodeRegShift(type);
setflags = BitIsSet (opcode, 20);
shift_t = DecodeRegShift (Bits32 (opcode, 6, 5));
@@ -9429,7 +9427,7 @@
uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C);
- // (result, carry, overflow) = AddWithCarry(R[n], shifted, ‘0’);
+ // (result, carry, overflow) = AddWithCarry(R[n], shifted, Ô0Õ);
uint32_t Rn = ReadCoreReg (n, &success);
if (!success)
return false;
@@ -9468,7 +9466,7 @@
if ConditionPassed() then
EncodingSpecificOperations();
shifted = Shift(R[m], shift_t, shift_n, APSR.C);
- (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ‘1’);
+ (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
@@ -9507,9 +9505,9 @@
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’);
+ // 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);
@@ -9525,14 +9523,14 @@
break;
case eEncodingA1:
- // if Rn == ‘1101’ then SEE SUB (SP minus register);
- // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ‘1’);
+ // 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);
- // 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;
if ((d == 15) && setflags)
EmulateSUBSPcLrEtc (opcode, encoding);
@@ -9552,7 +9550,7 @@
uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C);
- // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ‘1’);
+ // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), Ô1Õ);
uint32_t Rn = ReadCoreReg (n, &success);
if (!success)
return false;
@@ -9613,7 +9611,7 @@
switch (encoding)
{
case eEncodingT1:
- // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:’00’, 32);
+ // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
d = Bits32 (opcode, 11, 8);
t = Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
@@ -9719,13 +9717,13 @@
switch (encoding)
{
case eEncodingA1:
- // if P == ‘0’ && W == ‘1’ then SEE STRBT;
+ // if P == Ô0Õ && W == Ô1Õ then SEE STRBT;
// 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 = (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);
@@ -9817,14 +9815,14 @@
switch (encoding)
{
case eEncodingA1:
- // if P == ‘0’ && W == ‘1’ then SEE STRT;
- // if Rn == ‘1101’ && P == ‘1’ && U == ‘0’ && W == ‘1’ && imm12 == ‘000000000100’ then SEE PUSH;
+ // if P == Ô0Õ && W == Ô1Õ then SEE STRT;
+ // if Rn == Ô1101Õ && P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && imm12 == Ô000000000100Õ then SEE PUSH;
// 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 = (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);
@@ -9929,15 +9927,15 @@
switch (encoding)
{
case eEncodingT1:
- //if P == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- //if Rn == ‘1111’ then SEE LDRD (literal);
- //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:’00’, 32);
+ //if P == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ //if Rn == Ô1111Õ then SEE LDRD (literal);
+ //t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
t = Bits32 (opcode, 15, 12);
t2 = Bits32 (opcode, 11, 8);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- //index = (P == ‘1’); add = (U == ‘1’); wback = (W == ‘1’);
+ //index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (W == Ô1Õ);
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
@@ -9953,8 +9951,8 @@
break;
case eEncodingA1:
- //if Rn == ‘1111’ then SEE LDRD (literal);
- //if Rt<0> == ‘1’ then UNPREDICTABLE;
+ //if Rn == Ô1111Õ then SEE LDRD (literal);
+ //if Rt<0> == Ô1Õ then UNPREDICTABLE;
//t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -9963,12 +9961,12 @@
n = Bits32 (opcode, 19, 16);
imm32 = (Bits32 (opcode, 11, 8) << 4) | 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);
- //if P == ‘0’ && W == ‘1’ then UNPREDICTABLE;
+ //if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10074,7 +10072,7 @@
switch (encoding)
{
case eEncodingA1:
- // if Rt<0> == ‘1’ then UNPREDICTABLE;
+ // if Rt<0> == Ô1Õ then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10083,12 +10081,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);
- // if P == ‘0’ && W == ‘1’ then UNPREDICTABLE;
+ // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10201,14 +10199,14 @@
switch (encoding)
{
case eEncodingT1:
- // if P == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:’00’, 32);
+ // if P == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
t = Bits32 (opcode, 15, 12);
t2 = Bits32 (opcode, 11, 8);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // index = (P == ‘1’); add = (U == ‘1’); wback = (W == ‘1’);
+ // index = (P == Ô1Õ); add = (U == Ô1Õ); wback = (W == Ô1Õ);
index = BitIsSet (opcode, 24);
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
@@ -10224,7 +10222,7 @@
break;
case eEncodingA1:
- // if Rt<0> == ‘1’ then UNPREDICTABLE;
+ // if Rt<0> == Ô1Õ then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10234,12 +10232,12 @@
n = Bits32 (opcode, 19, 16);
imm32 = (Bits32 (opcode, 11, 8) << 4) | 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);
- // if P == ‘0’ && W == ‘1’ then UNPREDICTABLE;
+ // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10349,7 +10347,7 @@
switch (encoding)
{
case eEncodingA1:
- // if Rt<0> == ‘1’ then UNPREDICTABLE;
+ // if Rt<0> == Ô1Õ then UNPREDICTABLE;
// t = UInt(Rt); t2 = t+1; n = UInt(Rn); m = UInt(Rm);
t = Bits32 (opcode, 15, 12);
if (BitIsSet (t, 0))
@@ -10359,12 +10357,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);
- // if P == ‘0’ && W == ‘1’ then UNPREDICTABLE;
+ // if P == Ô0Õ && W == Ô1Õ then UNPREDICTABLE;
if (BitIsClear (opcode, 24) && BitIsSet (opcode, 21))
return false;
@@ -10490,25 +10488,25 @@
{
case eEncodingT1:
case eEncodingA1:
- // if P == ‘0’ && U == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- // if P == ‘0’ && U == ‘1’ && W == ‘1’ && Rn == ‘1101’ then SEE VPOP;
- // if P == ‘1’ && W == ‘0’ then SEE VLDR;
- // if P == U && W == ‘1’ then UNDEFINED;
+ // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ // if P == Ô0Õ && U == Ô1Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPOP;
+ // if P == Ô1Õ && W == Ô0Õ then SEE VLDR;
+ // if P == U && W == Ô1Õ then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = FALSE; add = (U == ‘1’); wback = (W == ‘1’);
+ // single_regs = FALSE; add = (U == Ô1Õ); wback = (W == Ô1Õ);
single_regs = false;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
- // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:’00’, 32);
+ // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see “FLDMX”.
+ // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ÒFLDMXÓ.
regs = Bits32 (opcode, 7, 0) / 2;
// if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE;
@@ -10523,22 +10521,22 @@
case eEncodingT2:
case eEncodingA2:
- // if P == ‘0’ && U == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- // if P == ‘0’ && U == ‘1’ && W == ‘1’ && Rn == ‘1101’ then SEE VPOP;
- // if P == ‘1’ && W == ‘0’ then SEE VLDR;
- // if P == U && W == ‘1’ then UNDEFINED;
+ // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ // if P == Ô0Õ && U == Ô1Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPOP;
+ // if P == Ô1Õ && W == Ô0Õ then SEE VLDR;
+ // if P == U && W == Ô1Õ then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = TRUE; add = (U == ‘1’); wback = (W == ‘1’); d = UInt(Vd:D); n = UInt(Rn);
+ // single_regs = TRUE; add = (U == Ô1Õ); wback = (W == Ô1Õ); d = UInt(Vd:D); n = UInt(Rn);
single_regs = true;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22);
n = Bits32 (opcode, 19, 16);
- // imm32 = ZeroExtend(imm8:’00’, 32); regs = UInt(imm8);
+ // imm32 = ZeroExtend(imm8:Õ00Õ, 32); regs = UInt(imm8);
imm32 = Bits32 (opcode, 7, 0) << 2;
regs = Bits32 (opcode, 7, 0);
@@ -10682,25 +10680,25 @@
{
case eEncodingT1:
case eEncodingA1:
- // if P == ‘0’ && U == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- // if P == ‘1’ && U == ‘0’ && W == ‘1’ && Rn == ‘1101’ then SEE VPUSH;
- // if P == ‘1’ && W == ‘0’ then SEE VSTR;
- // if P == U && W == ‘1’ then UNDEFINED;
+ // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ // if P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPUSH;
+ // if P == Ô1Õ && W == Ô0Õ then SEE VSTR;
+ // if P == U && W == Ô1Õ then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = FALSE; add = (U == ‘1’); wback = (W == ‘1’);
+ // single_regs = FALSE; add = (U == Ô1Õ); wback = (W == Ô1Õ);
single_regs = false;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
- // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:’00’, 32);
+ // d = UInt(D:Vd); n = UInt(Rn); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
d = (Bit32 (opcode, 22) << 4) | Bits32 (opcode, 15, 12);
n = Bits32 (opcode, 19, 16);
imm32 = Bits32 (opcode, 7, 0) << 2;
- // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see “FSTMX”.
+ // regs = UInt(imm8) DIV 2; // If UInt(imm8) is odd, see ÒFSTMXÓ.
regs = Bits32 (opcode, 7, 0) / 2;
// if n == 15 && (wback || CurrentInstrSet() != InstrSet_ARM) then UNPREDICTABLE;
@@ -10715,22 +10713,22 @@
case eEncodingT2:
case eEncodingA2:
- // if P == ‘0’ && U == ‘0’ && W == ‘0’ then SEE “Related encodings”;
- // if P == ‘1’ && U == ‘0’ && W == ‘1’ && Rn == ‘1101’ then SEE VPUSH;
- // if P == ‘1’ && W == ‘0’ then SEE VSTR;
- // if P == U && W == ‘1’ then UNDEFINED;
+ // if P == Ô0Õ && U == Ô0Õ && W == Ô0Õ then SEE ÒRelated encodingsÓ;
+ // if P == Ô1Õ && U == Ô0Õ && W == Ô1Õ && Rn == Ô1101Õ then SEE VPUSH;
+ // if P == Ô1Õ && W == Ô0Õ then SEE VSTR;
+ // if P == U && W == Ô1Õ then UNDEFINED;
if ((Bit32 (opcode, 24) == Bit32 (opcode, 23)) && BitIsSet (opcode, 21))
return false;
// // Remaining combinations are PUW = 010 (IA without !), 011 (IA with !), 101 (DB with !)
- // single_regs = TRUE; add = (U == ‘1’); wback = (W == ‘1’); d = UInt(Vd:D); n = UInt(Rn);
+ // single_regs = TRUE; add = (U == Ô1Õ); wback = (W == Ô1Õ); d = UInt(Vd:D); n = UInt(Rn);
single_regs = true;
add = BitIsSet (opcode, 23);
wback = BitIsSet (opcode, 21);
d = (Bits32 (opcode, 15, 12) << 1) | Bit32 (opcode, 22);
n = Bits32 (opcode, 19, 16);
- // imm32 = ZeroExtend(imm8:’00’, 32); regs = UInt(imm8);
+ // imm32 = ZeroExtend(imm8:Õ00Õ, 32); regs = UInt(imm8);
imm32 = Bits32 (opcode, 7, 0) << 2;
regs = Bits32 (opcode, 7, 0);
@@ -10875,7 +10873,7 @@
{
case eEncodingT1:
case eEncodingA1:
- // single_reg = FALSE; add = (U == ‘1’); imm32 = ZeroExtend(imm8:’00’, 32);
+ // single_reg = FALSE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
single_reg = false;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -10888,7 +10886,7 @@
case eEncodingT2:
case eEncodingA2:
- // single_reg = TRUE; add = (U == ‘1’); imm32 = ZeroExtend(imm8:’00’, 32);
+ // single_reg = TRUE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
single_reg = true;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11004,7 +11002,7 @@
{
case eEncodingT1:
case eEncodingA1:
- // single_reg = FALSE; add = (U == ‘1’); imm32 = ZeroExtend(imm8:’00’, 32);
+ // single_reg = FALSE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
single_reg = false;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11021,7 +11019,7 @@
case eEncodingT2:
case eEncodingA2:
- // single_reg = TRUE; add = (U == ‘1’); imm32 = ZeroExtend(imm8:’00’, 32);
+ // single_reg = TRUE; add = (U == Ô1Õ); imm32 = ZeroExtend(imm8:Õ00Õ, 32);
single_reg = true;
add = BitIsSet (opcode, 23);
imm32 = Bits32 (opcode, 7, 0) << 2;
@@ -11143,16 +11141,16 @@
case eEncodingA1:
{
// case type of
- // when ‘0111’
- // regs = 1; if align<1> == ‘1’ then UNDEFINED;
- // when ‘1010’
- // regs = 2; if align == ‘11’ then UNDEFINED;
- // when ‘0110’
- // regs = 3; if align<1> == ‘1’ then UNDEFINED;
- // when ‘0010’
+ // when Ô0111Õ
+ // regs = 1; if align<1> == Ô1Õ then UNDEFINED;
+ // when Ô1010Õ
+ // regs = 2; if align == Ô11Õ then UNDEFINED;
+ // when Ô0110Õ
+ // regs = 3; if align<1> == Ô1Õ then UNDEFINED;
+ // when Ô0010Õ
// regs = 4;
// otherwise
- // SEE “Related encodings”;
+ // SEE ÒRelated encodingsÓ;
uint32_t type = Bits32 (opcode, 11, 8);
uint32_t align = Bits32 (opcode, 5, 4);
if (type == 7) // '0111'
@@ -11181,7 +11179,7 @@
else
return false;
- // alignment = if align == ‘00’ then 1 else 4 << UInt(align);
+ // alignment = if align == Ô00Õ then 1 else 4 << UInt(align);
if (align == 0)
alignment = 1;
else
@@ -11306,13 +11304,13 @@
{
uint32_t size = Bits32 (opcode, 11, 10);
uint32_t index_align = Bits32 (opcode, 7, 4);
- // if size == ‘11’ then SEE VLD1 (single element to all lanes);
+ // if size == Ô11Õ then SEE VLD1 (single element to all lanes);
if (size == 3)
return EmulateVLD1SingleAll (opcode, encoding);
// case size of
if (size == 0) // when '00'
{
- // if index_align<0> != ‘0’ then UNDEFINED;
+ // if index_align<0> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 0))
return false;
@@ -11322,9 +11320,9 @@
index = Bits32 (index_align, 3, 1);
alignment = 1;
}
- else if (size == 1) // when ‘01’
+ else if (size == 1) // when Ô01Õ
{
- // if index_align<1> != ‘0’ then UNDEFINED;
+ // if index_align<1> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 1))
return false;
@@ -11333,19 +11331,19 @@
esize = 16;
index = Bits32 (index_align, 3, 2);
- // alignment = if index_align<0> == ‘0’ then 1 else 2;
+ // alignment = if index_align<0> == Ô0Õ then 1 else 2;
if (BitIsClear (index_align, 0))
alignment = 1;
else
alignment = 2;
}
- else if (size == 2) // when ‘10’
+ else if (size == 2) // when Ô10Õ
{
- // if index_align<2> != ‘0’ then UNDEFINED;
+ // if index_align<2> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 2))
return false;
- // if index_align<1:0> != ‘00’ && index_align<1:0> != ‘11’ then UNDEFINED;
+ // if index_align<1:0> != Ô00Õ && index_align<1:0> != Ô11Õ then UNDEFINED;
if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3))
return false;
@@ -11354,7 +11352,7 @@
esize = 32;
index = Bit32 (index_align, 3);
- // alignment = if index_align<1:0> == ‘00’ then 1 else 4;
+ // alignment = if index_align<1:0> == Ô00Õ then 1 else 4;
if (Bits32 (index_align, 1, 0) == 0)
alignment = 1;
else
@@ -11484,35 +11482,35 @@
uint32_t align = Bits32 (opcode, 5, 4);
// case type of
- if (type == 7) // when ‘0111’
+ if (type == 7) // when Ô0111Õ
{
- // regs = 1; if align<1> == ‘1’ then UNDEFINED;
+ // regs = 1; if align<1> == Ô1Õ then UNDEFINED;
regs = 1;
if (BitIsSet (align, 1))
return false;
}
- else if (type == 10) // when ‘1010’
+ else if (type == 10) // when Ô1010Õ
{
- // regs = 2; if align == ‘11’ then UNDEFINED;
+ // regs = 2; if align == Ô11Õ then UNDEFINED;
regs = 2;
if (align == 3)
return false;
}
- else if (type == 6) // when ‘0110’
+ else if (type == 6) // when Ô0110Õ
{
- // regs = 3; if align<1> == ‘1’ then UNDEFINED;
+ // regs = 3; if align<1> == Ô1Õ then UNDEFINED;
regs = 3;
if (BitIsSet (align, 1))
return false;
}
- else if (type == 2) // when ‘0010’
+ else if (type == 2) // when Ô0010Õ
// regs = 4;
regs = 4;
else // otherwise
- // SEE “Related encodings”;
+ // SEE ÒRelated encodingsÓ;
return false;
- // alignment = if align == ‘00’ then 1 else 4 << UInt(align);
+ // alignment = if align == Ô00Õ then 1 else 4 << UInt(align);
if (align == 0)
alignment = 0;
else
@@ -11642,14 +11640,14 @@
uint32_t size = Bits32 (opcode, 11, 10);
uint32_t index_align = Bits32 (opcode, 7, 4);
- // if size == ‘11’ then UNDEFINED;
+ // if size == Ô11Õ then UNDEFINED;
if (size == 3)
return false;
// case size of
- if (size == 0) // when ‘00’
+ if (size == 0) // when Ô00Õ
{
- // if index_align<0> != ‘0’ then UNDEFINED;
+ // if index_align<0> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 0))
return false;
// ebytes = 1; esize = 8; index = UInt(index_align<3:1>); alignment = 1;
@@ -11658,9 +11656,9 @@
index = Bits32 (index_align, 3, 1);
alignment = 1;
}
- else if (size == 1) // when ‘01’
+ else if (size == 1) // when Ô01Õ
{
- // if index_align<1> != ‘0’ then UNDEFINED;
+ // if index_align<1> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 1))
return false;
@@ -11669,19 +11667,19 @@
esize = 16;
index = Bits32 (index_align, 3, 2);
- // alignment = if index_align<0> == ‘0’ then 1 else 2;
+ // alignment = if index_align<0> == Ô0Õ then 1 else 2;
if (BitIsClear (index_align, 0))
alignment = 1;
else
alignment = 2;
}
- else if (size == 2) // when ‘10’
+ else if (size == 2) // when Ô10Õ
{
- // if index_align<2> != ‘0’ then UNDEFINED;
+ // if index_align<2> != Ô0Õ then UNDEFINED;
if (BitIsClear (index_align, 2))
return false;
- // if index_align<1:0> != ‘00’ && index_align<1:0> != ‘11’ then UNDEFINED;
+ // if index_align<1:0> != Ô00Õ && index_align<1:0> != Ô11Õ then UNDEFINED;
if ((Bits32 (index_align, 1, 0) != 0) && (Bits32 (index_align, 1, 0) != 3))
return false;
@@ -11690,7 +11688,7 @@
esize = 32;
index = Bit32 (index_align, 3);
- // alignment = if index_align<1:0> == ‘00’ then 1 else 4;
+ // alignment = if index_align<1:0> == Ô00Õ then 1 else 4;
if (Bits32 (index_align, 1, 0) == 0)
alignment = 1;
else
@@ -11799,12 +11797,12 @@
case eEncodingT1:
case eEncodingA1:
{
- //if size == ‘11’ || (size == ‘00’ && a == ‘1’) then UNDEFINED;
+ //if size == Ô11Õ || (size == Ô00Õ && a == Ô1Õ) then UNDEFINED;
uint32_t size = Bits32 (opcode, 7, 6);
if ((size == 3) || ((size == 0) && BitIsSet (opcode, 4)))
return false;
- //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == ‘0’ then 1 else 2;
+ //ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == Ô0Õ then 1 else 2;
ebytes = 1 << size;
elements = 8 / ebytes;
if (BitIsClear (opcode, 5))
@@ -11812,7 +11810,7 @@
else
regs = 2;
- //alignment = if a == ‘0’ then 1 else ebytes;
+ //alignment = if a == Ô0Õ then 1 else ebytes;
if (BitIsClear (opcode, 4))
alignment = 1;
else
@@ -11909,19 +11907,19 @@
UNPREDICTABLE;
operand2 = if register_form then Shift(R[m], shift_t, shift_n, APSR.C) else imm32;
case opcode of
- when ‘0000’ result = R[n] AND operand2; // AND
- when ‘0001’ result = R[n] EOR operand2; // EOR
- when ‘0010’ (result, -, -) = AddWithCarry(R[n], NOT(operand2), ‘1’); // SUB
- when ‘0011’ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ‘1’); // RSB
- when ‘0100’ (result, -, -) = AddWithCarry(R[n], operand2, ‘0’); // ADD
- when ‘0101’ (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
- when ‘0110’ (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
- when ‘0111’ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
- when ‘1100’ result = R[n] OR operand2; // ORR
- when ‘1101’ result = operand2; // MOV
- when ‘1110’ result = R[n] AND NOT(operand2); // BIC
- when ‘1111’ result = NOT(operand2); // MVN
- CPSRWriteByInstr(SPSR[], ‘1111’, TRUE);
+ when Ô0000Õ result = R[n] AND operand2; // AND
+ when Ô0001Õ result = R[n] EOR operand2; // EOR
+ when Ô0010Õ (result, -, -) = AddWithCarry(R[n], NOT(operand2), Ô1Õ); // SUB
+ when Ô0011Õ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, Ô1Õ); // RSB
+ when Ô0100Õ (result, -, -) = AddWithCarry(R[n], operand2, Ô0Õ); // ADD
+ when Ô0101Õ (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
+ when Ô0110Õ (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
+ when Ô0111Õ (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
+ when Ô1100Õ result = R[n] OR operand2; // ORR
+ when Ô1101Õ result = operand2; // MOV
+ when Ô1110Õ result = R[n] AND NOT(operand2); // BIC
+ when Ô1111Õ result = NOT(operand2); // MVN
+ CPSRWriteByInstr(SPSR[], Ô1111Õ, TRUE);
BranchWritePC(result);
#endif
@@ -11941,7 +11939,7 @@
{
case eEncodingT1:
// if CurrentInstrSet() == InstrSet_ThumbEE then UNPREDICTABLE
- // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = ‘0010’; // = SUB
+ // n = 14; imm32 = ZeroExtend(imm8, 32); register_form = FALSE; opcode = Ô0010Õ; // = SUB
n = 14;
imm32 = Bits32 (opcode, 7, 0);
register_form = false;
@@ -12002,62 +12000,62 @@
// case opcode of
switch (code)
{
- case 0: // when ‘0000’
+ case 0: // when Ô0000Õ
// result = R[n] AND operand2; // AND
result.result = Rn & operand2;
break;
- case 1: // when ‘0001’
+ case 1: // when Ô0001Õ
// result = R[n] EOR operand2; // EOR
result.result = Rn ^ operand2;
break;
- case 2: // when ‘0010’
- // (result, -, -) = AddWithCarry(R[n], NOT(operand2), ‘1’); // SUB
+ case 2: // when Ô0010Õ
+ // (result, -, -) = AddWithCarry(R[n], NOT(operand2), Ô1Õ); // SUB
result = AddWithCarry (Rn, ~(operand2), 1);
break;
- case 3: // when ‘0011’
- // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, ‘1’); // RSB
+ case 3: // when Ô0011Õ
+ // (result, -, -) = AddWithCarry(NOT(R[n]), operand2, Ô1Õ); // RSB
result = AddWithCarry (~(Rn), operand2, 1);
break;
- case 4: // when ‘0100’
- // (result, -, -) = AddWithCarry(R[n], operand2, ‘0’); // ADD
+ case 4: // when Ô0100Õ
+ // (result, -, -) = AddWithCarry(R[n], operand2, Ô0Õ); // ADD
result = AddWithCarry (Rn, operand2, 0);
break;
- case 5: // when ‘0101’
+ case 5: // when Ô0101Õ
// (result, -, -) = AddWithCarry(R[n], operand2, APSR.c); // ADC
result = AddWithCarry (Rn, operand2, APSR_C);
break;
- case 6: // when ‘0110’
+ case 6: // when Ô0110Õ
// (result, -, -) = AddWithCarry(R[n], NOT(operand2), APSR.C); // SBC
result = AddWithCarry (Rn, ~(operand2), APSR_C);
break;
- case 7: // when ‘0111’
+ case 7: // when Ô0111Õ
// (result, -, -) = AddWithCarry(NOT(R[n]), operand2, APSR.C); // RSC
result = AddWithCarry (~(Rn), operand2, APSR_C);
break;
- case 10: // when ‘1100’
+ case 10: // when Ô1100Õ
// result = R[n] OR operand2; // ORR
result.result = Rn | operand2;
break;
- case 11: // when ‘1101’
+ case 11: // when Ô1101Õ
// result = operand2; // MOV
result.result = operand2;
break;
- case 12: // when ‘1110’
+ case 12: // when Ô1110Õ
// result = R[n] AND NOT(operand2); // BIC
result.result = Rn & ~(operand2);
break;
- case 15: // when ‘1111’
+ case 15: // when Ô1111Õ
// result = NOT(operand2); // MVN
result.result = ~(operand2);
break;
@@ -12065,7 +12063,7 @@
default:
return false;
}
- // CPSRWriteByInstr(SPSR[], ‘1111’, TRUE);
+ // CPSRWriteByInstr(SPSR[], Ô1111Õ, TRUE);
// For now, in emulation mode, we don't have access to the SPSR, so we will use the CPSR instead, and hope for
// the best.
@@ -13249,9 +13247,9 @@
if (m_opcode_cpsr == 0 || m_ignore_conditions == false)
{
m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindDWARF,
- dwarf_cpsr,
- 0,
- &success);
+ dwarf_cpsr,
+ 0,
+ &success);
}
// Only return false if we are unable to read the CPSR if we care about conditions
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index 1db2f45..1d042f9 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -9,6 +9,7 @@
#include "EmulationStateARM.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/RegisterContext.h"
@@ -33,33 +34,18 @@
bool
EmulationStateARM::LoadPseudoRegistersFromFrame (StackFrame &frame)
{
- RegisterContext *reg_context = frame.GetRegisterContext().get();
- Scalar value;
- uint64_t reg_value64;
- uint32_t reg_value32;
-
+ RegisterContext *reg_ctx = frame.GetRegisterContext().get();
bool success = true;
+ uint32_t reg_num;
for (int i = dwarf_r0; i < dwarf_r0 + 17; ++i)
{
- uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i);
- if (reg_context->ReadRegisterValue (internal_reg_num, value))
+ reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i);
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num);
+ RegisterValue reg_value;
+ if (reg_ctx->ReadRegister (reg_info, reg_value))
{
- reg_value32 = (uint32_t) value.GetRawBits64 (0);
- m_gpr[i - dwarf_r0] = reg_value32;
- }
- else
- success = false;
- }
-
- for (int i = dwarf_s0; i < dwarf_s0 + 32; ++i)
- {
- uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i);
- if (reg_context->ReadRegisterValue (internal_reg_num, value))
- {
- uint32_t idx = i - dwarf_s0;
- reg_value32 = (uint32_t) value.GetRawBits64 (0);
- m_vfp_regs.sd_regs[idx / 2].s_reg[idx % 2] = reg_value32;
+ m_gpr[i - dwarf_r0] = reg_value.GetAsUInt32();
}
else
success = false;
@@ -67,15 +53,17 @@
for (int i = dwarf_d0; i < dwarf_d0 + 32; ++i)
{
- uint32_t internal_reg_num = reg_context->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i);
- if (reg_context->ReadRegisterValue (internal_reg_num, value))
+ reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindDWARF, i);
+ RegisterValue reg_value;
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num);
+
+ if (reg_ctx->ReadRegister (reg_info, reg_value))
{
uint32_t idx = i - dwarf_d0;
- reg_value64 = value.GetRawBits64 (0);
if (i < 16)
- m_vfp_regs.sd_regs[idx].d_reg = reg_value64;
+ m_vfp_regs.sd_regs[idx].d_reg = reg_value.GetAsUInt64();
else
- m_vfp_regs.d_regs[idx - 16] = reg_value64;
+ m_vfp_regs.d_regs[idx - 16] = reg_value.GetAsUInt64();
}
else
success = false;
@@ -254,18 +242,20 @@
bool
EmulationStateARM::ReadPseudoRegister (EmulateInstruction *instruction,
void *baton,
- const RegisterInfo ®_info,
- uint64_t ®_value)
+ const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value)
{
- if (!baton)
+ if (!baton || !reg_info)
return false;
bool success = true;
EmulationStateARM *pseudo_state = (EmulationStateARM *) baton;
+ const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF];
+ assert (dwarf_reg_num != LLDB_INVALID_REGNUM);
+ uint64_t reg_uval = pseudo_state->ReadPseudoRegisterValue (dwarf_reg_num, success);
- assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM);
- reg_value = pseudo_state->ReadPseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], success);
-
+ if (success)
+ success = reg_value.SetUInt(reg_uval, reg_info->byte_size);
return success;
}
@@ -274,15 +264,16 @@
EmulationStateARM::WritePseudoRegister (EmulateInstruction *instruction,
void *baton,
const EmulateInstruction::Context &context,
- const RegisterInfo ®_info,
- uint64_t reg_value)
+ const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value)
{
- if (!baton)
+ if (!baton || !reg_info)
return false;
- assert (reg_info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM);
EmulationStateARM *pseudo_state = (EmulationStateARM *) baton;
- return pseudo_state->StorePseudoRegisterValue (reg_info.kinds[eRegisterKindDWARF], reg_value);
+ const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF];
+ assert (dwarf_reg_num != LLDB_INVALID_REGNUM);
+ return pseudo_state->StorePseudoRegisterValue (dwarf_reg_num, reg_value.GetAsUInt64());
}
bool
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.h b/source/Plugins/Instruction/ARM/EmulationStateARM.h
index b4cc28b..472c5d6 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.h
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.h
@@ -70,15 +70,15 @@
static bool
ReadPseudoRegister (lldb_private::EmulateInstruction *instruction,
void *baton,
- const lldb_private::RegisterInfo ®_info,
- uint64_t ®_value);
+ const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value);
static bool
WritePseudoRegister (lldb_private::EmulateInstruction *instruction,
void *baton,
const lldb_private::EmulateInstruction::Context &context,
- const lldb_private::RegisterInfo ®_info,
- uint64_t reg_value);
+ const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value);
private:
uint32_t m_gpr[17];
struct sd_regs
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
index 35805b5..4f3fe1a 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp
@@ -17,6 +17,7 @@
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Endian.h"
@@ -627,8 +628,9 @@
bool
-RegisterContextMach_arm::ReadRegisterValue (uint32_t reg, Scalar &value)
+RegisterContextMach_arm::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = RegisterContextMach_arm::GetSetForNativeRegNum (reg);
if (set == -1)
@@ -656,7 +658,7 @@
case gpr_lr:
case gpr_pc:
case gpr_cpsr:
- value = gpr.r[reg - gpr_r0];
+ value.SetUInt32 (gpr.r[reg - gpr_r0]);
break;
case fpu_s0:
@@ -691,24 +693,25 @@
case fpu_s29:
case fpu_s30:
case fpu_s31:
- value = fpu.floats.s[reg];
+ value.SetUInt32 (fpu.floats.s[reg], RegisterValue::eTypeFloat);
break;
case fpu_fpscr:
- value = fpu.fpscr;
+ value.SetUInt32 (fpu.fpscr);
break;
case exc_exception:
- value = exc.exception;
+ value.SetUInt32 (exc.exception);
break;
case exc_fsr:
- value = exc.fsr;
+ value.SetUInt32 (exc.fsr);
break;
case exc_far:
- value = exc.far;
+ value.SetUInt32 (exc.far);
break;
default:
+ value.SetValueToInvalid();
return false;
}
@@ -717,8 +720,10 @@
bool
-RegisterContextMach_arm::WriteRegisterValue (uint32_t reg, const Scalar &value)
+RegisterContextMach_arm::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = GetSetForNativeRegNum (reg);
if (set == -1)
@@ -746,7 +751,7 @@
case gpr_lr:
case gpr_pc:
case gpr_cpsr:
- gpr.r[reg - gpr_r0] = value.UInt(0);
+ gpr.r[reg - gpr_r0] = value.GetAsUInt32();
break;
case fpu_s0:
@@ -781,21 +786,21 @@
case fpu_s29:
case fpu_s30:
case fpu_s31:
- fpu.floats.s[reg] = value.UInt(0);
+ fpu.floats.s[reg] = value.GetAsUInt32();
break;
case fpu_fpscr:
- fpu.fpscr = value.UInt(0);
+ fpu.fpscr = value.GetAsUInt32();
break;
case exc_exception:
- exc.exception = value.UInt(0);
+ exc.exception = value.GetAsUInt32();
break;
case exc_fsr:
- exc.fsr = value.UInt(0);
+ exc.fsr = value.GetAsUInt32();
break;
case exc_far:
- exc.far = value.UInt(0);
+ exc.far = value.GetAsUInt32();
break;
default:
@@ -806,195 +811,6 @@
}
bool
-RegisterContextMach_arm::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
-{
- int set = RegisterContextMach_arm::GetSetForNativeRegNum (reg);
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL)
- return false;
-
- switch (reg)
- {
- case gpr_r0:
- case gpr_r1:
- case gpr_r2:
- case gpr_r3:
- case gpr_r4:
- case gpr_r5:
- case gpr_r6:
- case gpr_r7:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_sp:
- case gpr_lr:
- case gpr_pc:
- case gpr_cpsr:
- data.SetData(&gpr.r[reg - gpr_r0], reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_s0:
- case fpu_s1:
- case fpu_s2:
- case fpu_s3:
- case fpu_s4:
- case fpu_s5:
- case fpu_s6:
- case fpu_s7:
- case fpu_s8:
- case fpu_s9:
- case fpu_s10:
- case fpu_s11:
- case fpu_s12:
- case fpu_s13:
- case fpu_s14:
- case fpu_s15:
- case fpu_s16:
- case fpu_s17:
- case fpu_s18:
- case fpu_s19:
- case fpu_s20:
- case fpu_s21:
- case fpu_s22:
- case fpu_s23:
- case fpu_s24:
- case fpu_s25:
- case fpu_s26:
- case fpu_s27:
- case fpu_s28:
- case fpu_s29:
- case fpu_s30:
- case fpu_s31:
- data.SetData(&fpu.floats.s[reg - fpu_s0], reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fpscr:
- data.SetData(&fpu.fpscr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_exception:
- data.SetData(&exc.exception, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_fsr:
- data.SetData(&exc.fsr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_far:
- data.SetData(&exc.far, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-bool
-RegisterContextMach_arm::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
-{
- int set = GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size))
- return false;
-
- uint32_t offset = data_offset;
- switch (reg)
- {
- case gpr_r0:
- case gpr_r1:
- case gpr_r2:
- case gpr_r3:
- case gpr_r4:
- case gpr_r5:
- case gpr_r6:
- case gpr_r7:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_sp:
- case gpr_lr:
- case gpr_pc:
- case gpr_cpsr:
- gpr.r[reg - gpr_r0] = data.GetU32 (&offset);
- break;
-
- case fpu_s0:
- case fpu_s1:
- case fpu_s2:
- case fpu_s3:
- case fpu_s4:
- case fpu_s5:
- case fpu_s6:
- case fpu_s7:
- case fpu_s8:
- case fpu_s9:
- case fpu_s10:
- case fpu_s11:
- case fpu_s12:
- case fpu_s13:
- case fpu_s14:
- case fpu_s15:
- case fpu_s16:
- case fpu_s17:
- case fpu_s18:
- case fpu_s19:
- case fpu_s20:
- case fpu_s21:
- case fpu_s22:
- case fpu_s23:
- case fpu_s24:
- case fpu_s25:
- case fpu_s26:
- case fpu_s27:
- case fpu_s28:
- case fpu_s29:
- case fpu_s30:
- case fpu_s31:
- fpu.floats.s[reg - fpu_s0] = data.GetU32 (&offset);
- break;
-
- case fpu_fpscr:
- fpu.fpscr = data.GetU32 (&offset);
- break;
-
- case exc_exception:
- fpu.fpscr = data.GetU32 (&offset);
- break;
-
- case exc_fsr:
- exc.fsr = data.GetU32 (&offset);
- break;
-
- case exc_far:
- exc.far = data.GetU32 (&offset);
- break;
-
- default:
- return false;
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
-}
-
-bool
RegisterContextMach_arm::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
{
data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h
index ef4b7af..23fd08e 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.h
@@ -75,21 +75,17 @@
GetRegisterSet (uint32_t set);
virtual bool
- ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value);
-
+ ReadRegister (const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value);
+
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
-
+ WriteRegister (const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value);
+
virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value);
-
- virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp
index 6bf4dec..be1a10f 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.cpp
@@ -15,6 +15,7 @@
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Endian.h"
@@ -553,8 +554,10 @@
}
bool
-RegisterContextMach_i386::ReadRegisterValue (uint32_t reg, Scalar &value)
+RegisterContextMach_i386::ReadRegister (const RegisterInfo *reg_info,
+ RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = RegisterContextMach_i386::GetSetForNativeRegNum (reg);
if (set == -1)
@@ -671,8 +674,10 @@
bool
-RegisterContextMach_i386::WriteRegisterValue (uint32_t reg, const Scalar &value)
+RegisterContextMach_i386::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = GetSetForNativeRegNum (reg);
if (set == -1)
@@ -699,47 +704,47 @@
case gpr_es:
case gpr_fs:
case gpr_gs:
- (&gpr.eax)[reg - gpr_eax] = value.UInt(0);
+ (&gpr.eax)[reg - gpr_eax] = value.GetAsUInt32();
break;
case fpu_fcw:
- fpu.fcw = value.UInt(0);
+ fpu.fcw = value.GetAsUInt16();
break;
case fpu_fsw:
- fpu.fsw = value.UInt(0);
+ fpu.fsw = value.GetAsUInt16();
break;
case fpu_ftw:
- fpu.ftw = value.UInt(0);
+ fpu.ftw = value.GetAsUInt8();
break;
case fpu_fop:
- fpu.fop = value.UInt(0);
+ fpu.fop = value.GetAsUInt16();
break;
case fpu_ip:
- fpu.ip = value.UInt(0);
+ fpu.ip = value.GetAsUInt32();
break;
case fpu_cs:
- fpu.cs = value.UInt(0);
+ fpu.cs = value.GetAsUInt16();
break;
case fpu_dp:
- fpu.dp = value.UInt(0);
+ fpu.dp = value.GetAsUInt32();
break;
case fpu_ds:
- fpu.ds = value.UInt(0);
+ fpu.ds = value.GetAsUInt16();
break;
case fpu_mxcsr:
- fpu.mxcsr = value.UInt(0);
+ fpu.mxcsr = value.GetAsUInt32();
break;
case fpu_mxcsrmask:
- fpu.mxcsrmask = value.UInt(0);
+ fpu.mxcsrmask = value.GetAsUInt32();
break;
case fpu_stmm0:
@@ -752,7 +757,7 @@
case fpu_stmm7:
// These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
// must be used for these registers
- //::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, reg_value.value.vector.uint8, 10);
+ ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
return false;
case fpu_xmm0:
@@ -765,254 +770,19 @@
case fpu_xmm7:
// These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
// must be used for these registers
- //::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, reg_value.value.vector.uint8, 16);
+ ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
return false;
case exc_trapno:
- exc.trapno = value.UInt(0);
+ exc.trapno = value.GetAsUInt32();
break;
case exc_err:
- exc.err = value.UInt(0);
+ exc.err = value.GetAsUInt32();
break;
case exc_faultvaddr:
- exc.faultvaddr = value.UInt(0);
- break;
-
- default:
- return false;
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
-}
-
-bool
-RegisterContextMach_i386::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
-{
- int set = RegisterContextMach_i386::GetSetForNativeRegNum (reg);
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL)
- return false;
-
- switch (reg)
- {
- case gpr_eax:
- case gpr_ebx:
- case gpr_ecx:
- case gpr_edx:
- case gpr_edi:
- case gpr_esi:
- case gpr_ebp:
- case gpr_esp:
- case gpr_ss:
- case gpr_eflags:
- case gpr_eip:
- case gpr_cs:
- case gpr_ds:
- case gpr_es:
- case gpr_fs:
- case gpr_gs:
- data.SetData(&gpr.eax + reg - gpr_eax, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fcw:
- data.SetData(&fpu.fcw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fsw:
- data.SetData(&fpu.fsw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ftw:
- data.SetData(&fpu.ftw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fop:
- data.SetData(&fpu.fop, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ip:
- data.SetData(&fpu.ip, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_cs:
- data.SetData(&fpu.cs, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_dp:
- data.SetData(&fpu.dp, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ds:
- data.SetData(&fpu.ds, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_mxcsr:
- data.SetData(&fpu.mxcsr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_mxcsrmask:
- data.SetData(&fpu.mxcsrmask, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- data.SetData(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- data.SetData(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_trapno:
- data.SetData(&exc.trapno, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_err:
- data.SetData(&exc.err, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_faultvaddr:
- data.SetData(&exc.faultvaddr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-bool
-RegisterContextMach_i386::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
-{
- int set = GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size))
- return false;
-
- uint32_t offset = data_offset;
- switch (reg)
- {
- case gpr_eax:
- case gpr_ebx:
- case gpr_ecx:
- case gpr_edx:
- case gpr_edi:
- case gpr_esi:
- case gpr_ebp:
- case gpr_esp:
- case gpr_ss:
- case gpr_eflags:
- case gpr_eip:
- case gpr_cs:
- case gpr_ds:
- case gpr_es:
- case gpr_fs:
- case gpr_gs:
- (&gpr.eax)[reg - gpr_eax] = data.GetU32 (&offset);
- break;
-
- case fpu_fcw:
- fpu.fcw = data.GetU16(&offset);
- break;
-
- case fpu_fsw:
- fpu.fsw = data.GetU16(&offset);
- break;
-
- case fpu_ftw:
- fpu.ftw = data.GetU8(&offset);
- break;
-
- case fpu_fop:
- fpu.fop = data.GetU16(&offset);
- break;
-
- case fpu_ip:
- fpu.ip = data.GetU32(&offset);
- break;
-
- case fpu_cs:
- fpu.cs = data.GetU16(&offset);
- break;
-
- case fpu_dp:
- fpu.dp = data.GetU32(&offset);
- break;
-
- case fpu_ds:
- fpu.ds = data.GetU16(&offset);
- break;
-
- case fpu_mxcsr:
- fpu.mxcsr = data.GetU32(&offset);
- break;
-
- case fpu_mxcsrmask:
- fpu.mxcsrmask = data.GetU32(&offset);
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
- return false;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
- return false;
-
- case exc_trapno:
- exc.trapno = data.GetU32 (&offset);
- break;
-
- case exc_err:
- exc.err = data.GetU32 (&offset);
- break;
-
- case exc_faultvaddr:
- exc.faultvaddr = data.GetU32 (&offset);
+ exc.faultvaddr = value.GetAsUInt32();
break;
default:
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h
index 969fa9a..c066107 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_i386.h
@@ -43,21 +43,15 @@
GetRegisterSet (uint32_t set);
virtual bool
- ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value);
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
-
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value);
-
- virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp
index 098a168..7cdcbbb 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.cpp
@@ -15,6 +15,7 @@
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Endian.h"
@@ -600,10 +601,11 @@
bool
-RegisterContextMach_x86_64::ReadRegisterValue (uint32_t reg, Scalar &value)
+RegisterContextMach_x86_64::ReadRegister (const RegisterInfo *reg_info,
+ RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
-
if (set == -1)
return false;
@@ -684,11 +686,8 @@
case fpu_stmm5:
case fpu_stmm6:
case fpu_stmm7:
- // These values don't fit into scalar types,
- // RegisterContext::ReadRegisterBytes() must be used for these
- // registers
- //::memcpy (reg_value.value.vector.uint8, fpu.stmm[reg - fpu_stmm0].bytes, 10);
- return false;
+ value.SetBytes(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ break;
case fpu_xmm0:
case fpu_xmm1:
@@ -706,10 +705,8 @@
case fpu_xmm13:
case fpu_xmm14:
case fpu_xmm15:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- //::memcpy (reg_value.value.vector.uint8, fpu.xmm[reg - fpu_xmm0].bytes, 16);
- return false;
+ value.SetBytes(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ break;
case exc_trapno:
value = exc.trapno;
@@ -731,8 +728,10 @@
bool
-RegisterContextMach_x86_64::WriteRegisterValue (uint32_t reg, const Scalar &value)
+RegisterContextMach_x86_64::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
if (set == -1)
@@ -764,47 +763,47 @@
case gpr_cs:
case gpr_fs:
case gpr_gs:
- (&gpr.rax)[reg - gpr_rax] = value.ULongLong(0);
+ (&gpr.rax)[reg - gpr_rax] = value.GetAsUInt64();
break;
case fpu_fcw:
- fpu.fcw = value.UInt(0);
+ fpu.fcw = value.GetAsUInt16();
break;
case fpu_fsw:
- fpu.fsw = value.UInt(0);
+ fpu.fsw = value.GetAsUInt16();
break;
case fpu_ftw:
- fpu.ftw = value.UInt(0);
+ fpu.ftw = value.GetAsUInt8();
break;
case fpu_fop:
- fpu.fop = value.UInt(0);
+ fpu.fop = value.GetAsUInt16();
break;
case fpu_ip:
- fpu.ip = value.UInt(0);
+ fpu.ip = value.GetAsUInt32();
break;
case fpu_cs:
- fpu.cs = value.UInt(0);
+ fpu.cs = value.GetAsUInt16();
break;
case fpu_dp:
- fpu.dp = value.UInt(0);
+ fpu.dp = value.GetAsUInt32();
break;
case fpu_ds:
- fpu.ds = value.UInt(0);
+ fpu.ds = value.GetAsUInt16();
break;
case fpu_mxcsr:
- fpu.mxcsr = value.UInt(0);
+ fpu.mxcsr = value.GetAsUInt32();
break;
case fpu_mxcsrmask:
- fpu.mxcsrmask = value.UInt(0);
+ fpu.mxcsrmask = value.GetAsUInt32();
break;
case fpu_stmm0:
@@ -815,139 +814,7 @@
case fpu_stmm5:
case fpu_stmm6:
case fpu_stmm7:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- //::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, reg_value.value.vector.uint8, 10);
- return false;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- //::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, reg_value.value.vector.uint8, 16);
- return false;
-
- case exc_trapno:
- exc.trapno = value.UInt(0);
- break;
-
- case exc_err:
- exc.err = value.UInt(0);
- break;
-
- case exc_faultvaddr:
- exc.faultvaddr = value.UInt(0);
- break;
-
- default:
- return false;
- }
- return WriteRegisterSet(set) == KERN_SUCCESS;
-}
-
-bool
-RegisterContextMach_x86_64::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
-{
- int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL)
- return false;
-
- switch (reg)
- {
- case gpr_rax:
- case gpr_rbx:
- case gpr_rcx:
- case gpr_rdx:
- case gpr_rdi:
- case gpr_rsi:
- case gpr_rbp:
- case gpr_rsp:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_r13:
- case gpr_r14:
- case gpr_r15:
- case gpr_rip:
- case gpr_rflags:
- case gpr_cs:
- case gpr_fs:
- case gpr_gs:
- data.SetData(&gpr.rax + reg - gpr_rax, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fcw:
- data.SetData(&fpu.fcw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fsw:
- data.SetData(&fpu.fsw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ftw:
- data.SetData(&fpu.ftw, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_fop:
- data.SetData(&fpu.fop, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ip:
- data.SetData(&fpu.ip, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_cs:
- data.SetData(&fpu.cs, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_dp:
- data.SetData(&fpu.dp, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_ds:
- data.SetData(&fpu.ds, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_mxcsr:
- data.SetData(&fpu.mxcsr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_mxcsrmask:
- data.SetData(&fpu.mxcsrmask, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- data.SetData(fpu.stmm[reg - fpu_stmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
+ ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize());
break;
case fpu_xmm0:
@@ -966,152 +833,19 @@
case fpu_xmm13:
case fpu_xmm14:
case fpu_xmm15:
- data.SetData(fpu.xmm[reg - fpu_xmm0].bytes, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_trapno:
- data.SetData(&exc.trapno, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_err:
- data.SetData(&exc.err, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- case exc_faultvaddr:
- data.SetData(&exc.faultvaddr, reg_info->byte_size, lldb::endian::InlHostByteOrder());
- break;
-
- default:
- return false;
- }
- return true;
-}
-
-bool
-RegisterContextMach_x86_64::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
-{
- int set = RegisterContextMach_x86_64::GetSetForNativeRegNum (reg);
-
- if (set == -1)
- return false;
-
- if (ReadRegisterSet(set, false) != KERN_SUCCESS)
- return false;
-
-
- const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size))
- return false;
-
- uint32_t offset = data_offset;
- switch (reg)
- {
- case gpr_rax:
- case gpr_rbx:
- case gpr_rcx:
- case gpr_rdx:
- case gpr_rdi:
- case gpr_rsi:
- case gpr_rbp:
- case gpr_rsp:
- case gpr_r8:
- case gpr_r9:
- case gpr_r10:
- case gpr_r11:
- case gpr_r12:
- case gpr_r13:
- case gpr_r14:
- case gpr_r15:
- case gpr_rip:
- case gpr_rflags:
- case gpr_cs:
- case gpr_fs:
- case gpr_gs:
- (&gpr.rax)[reg - gpr_rax] = data.GetU32 (&offset);
- break;
-
- case fpu_fcw:
- fpu.fcw = data.GetU16(&offset);
- break;
-
- case fpu_fsw:
- fpu.fsw = data.GetU16(&offset);
- break;
-
- case fpu_ftw:
- fpu.ftw = data.GetU8(&offset);
- break;
-
- case fpu_fop:
- fpu.fop = data.GetU16(&offset);
- break;
-
- case fpu_ip:
- fpu.ip = data.GetU32(&offset);
- break;
-
- case fpu_cs:
- fpu.cs = data.GetU16(&offset);
- break;
-
- case fpu_dp:
- fpu.dp = data.GetU32(&offset);
- break;
-
- case fpu_ds:
- fpu.ds = data.GetU16(&offset);
- break;
-
- case fpu_mxcsr:
- fpu.mxcsr = data.GetU32(&offset);
- break;
-
- case fpu_mxcsrmask:
- fpu.mxcsrmask = data.GetU32(&offset);
- break;
-
- case fpu_stmm0:
- case fpu_stmm1:
- case fpu_stmm2:
- case fpu_stmm3:
- case fpu_stmm4:
- case fpu_stmm5:
- case fpu_stmm6:
- case fpu_stmm7:
- ::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
- return false;
-
- case fpu_xmm0:
- case fpu_xmm1:
- case fpu_xmm2:
- case fpu_xmm3:
- case fpu_xmm4:
- case fpu_xmm5:
- case fpu_xmm6:
- case fpu_xmm7:
- case fpu_xmm8:
- case fpu_xmm9:
- case fpu_xmm10:
- case fpu_xmm11:
- case fpu_xmm12:
- case fpu_xmm13:
- case fpu_xmm14:
- case fpu_xmm15:
- // These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
- // must be used for these registers
- ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
+ ::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize());
return false;
case exc_trapno:
- exc.trapno = data.GetU32 (&offset);
+ exc.trapno = value.GetAsUInt32();
break;
case exc_err:
- exc.err = data.GetU32 (&offset);
+ exc.err = value.GetAsUInt32();
break;
case exc_faultvaddr:
- exc.faultvaddr = data.GetU32 (&offset);
+ exc.faultvaddr = value.GetAsUInt64();
break;
default:
diff --git a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h
index 5b0bdc7..e821722 100644
--- a/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h
+++ b/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_x86_64.h
@@ -42,21 +42,15 @@
GetRegisterSet (uint32_t set);
virtual bool
- ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value);
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
-
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value);
-
- virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
diff --git a/source/Plugins/Process/Utility/ARMUtils.h b/source/Plugins/Process/Utility/ARMUtils.h
index 71ee03a..e950f2b 100644
--- a/source/Plugins/Process/Utility/ARMUtils.h
+++ b/source/Plugins/Process/Utility/ARMUtils.h
@@ -1,4 +1,4 @@
-//===-- lldb_ARMUtils.h -----------------------------------------*- C++ -*-===//
+//===-- ARMUtils.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
diff --git a/source/Plugins/Process/Utility/InstructionUtils.h b/source/Plugins/Process/Utility/InstructionUtils.h
index c03b63e..4bb644e 100644
--- a/source/Plugins/Process/Utility/InstructionUtils.h
+++ b/source/Plugins/Process/Utility/InstructionUtils.h
@@ -1,4 +1,4 @@
-//===-- lldb_InstructionUtils.h ---------------------------------*- C++ -*-===//
+//===-- InstructionUtils.h --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -36,7 +36,13 @@
static inline uint32_t
Bit32 (const uint32_t bits, const uint32_t bit)
{
- return Bits32(bits, bit, bit);
+ return (bits >> bit) & 1u;
+}
+
+static inline uint64_t
+Bit64 (const uint64_t bits, const uint32_t bit)
+{
+ return (bits >> bit) & 1ull;
}
// Set the bit field(s) from the most significant bit (msbit) to the
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 1b63ad7..ef882fa 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/Function.h"
@@ -658,132 +659,99 @@
}
bool
-RegisterContextLLDB::ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data)
+RegisterContextLLDB::ReadRegisterValueFromRegisterLocation (RegisterLocation regloc,
+ const RegisterInfo *reg_info,
+ RegisterValue &value)
{
if (!IsValid())
return false;
+ bool success = false;
- if (regloc.type == eRegisterInRegister)
+ switch (regloc.type)
{
- data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
- data.SetByteOrder (m_thread.GetProcess().GetByteOrder());
- if (IsFrameZero ())
+ case eRegisterInRegister:
{
- return m_thread.GetRegisterContext()->ReadRegisterBytes (regloc.location.register_number, data);
+ const RegisterInfo *other_reg_info = GetRegisterInfoAtIndex(regloc.location.register_number);
+ if (IsFrameZero ())
+ {
+ success = m_thread.GetRegisterContext()->ReadRegister (other_reg_info, value);
+ }
+ else
+ {
+ success = m_next_frame->ReadRegister (other_reg_info, value);
+ }
}
- else
- {
- return m_next_frame->ReadRegisterBytes (regloc.location.register_number, data);
- }
- }
- if (regloc.type == eRegisterNotSaved)
- {
- return false;
- }
- if (regloc.type == eRegisterSavedAtHostMemoryLocation)
- {
+ break;
+ case eRegisterValueInferred:
+ success = value.SetUInt (regloc.location.inferred_value, reg_info->byte_size);
+ break;
+
+ case eRegisterNotSaved:
+ break;
+ case eRegisterSavedAtHostMemoryLocation:
assert ("FIXME debugger inferior function call unwind");
- }
- if (regloc.type != eRegisterSavedAtMemoryLocation)
- {
- assert ("Unknown RegisterLocation type.");
- }
-
- const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum);
- DataBufferSP data_sp (new DataBufferHeap (reg_info->byte_size, 0));
- data.SetData (data_sp, 0, reg_info->byte_size);
- data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
-
- if (regloc.type == eRegisterValueInferred)
- {
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
- switch (reg_info->byte_size)
+ break;
+ case eRegisterSavedAtMemoryLocation:
{
- case 1:
- {
- uint8_t val = regloc.location.register_value;
- memcpy (data_sp->GetBytes(), &val, sizeof (val));
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
- return true;
- }
- case 2:
- {
- uint16_t val = regloc.location.register_value;
- memcpy (data_sp->GetBytes(), &val, sizeof (val));
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
- return true;
- }
- case 4:
- {
- uint32_t val = regloc.location.register_value;
- memcpy (data_sp->GetBytes(), &val, sizeof (val));
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
- return true;
- }
- case 8:
- {
- uint64_t val = regloc.location.register_value;
- memcpy (data_sp->GetBytes(), &val, sizeof (val));
- data.SetByteOrder (lldb::endian::InlHostByteOrder());
- return true;
- }
+ Error error (ReadRegisterValueFromMemory(reg_info,
+ regloc.location.target_memory_location,
+ reg_info->byte_size,
+ value));
+ success = error.Success();
}
- return false;
+ break;
+ default:
+ assert ("Unknown RegisterLocation type.");
+ break;
}
-
- assert (regloc.type == eRegisterSavedAtMemoryLocation);
- Error error;
- data.SetByteOrder (m_thread.GetProcess().GetByteOrder());
- if (!m_thread.GetProcess().ReadMemory (regloc.location.target_memory_location, data_sp->GetBytes(), reg_info->byte_size, error))
- return false;
- return true;
+ return success;
}
bool
-RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data, uint32_t data_offset)
+RegisterContextLLDB::WriteRegisterValueToRegisterLocation (RegisterLocation regloc,
+ const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
if (!IsValid())
return false;
- if (regloc.type == eRegisterInRegister)
+ bool success = false;
+
+ switch (regloc.type)
{
- if (IsFrameZero ())
- {
- return m_thread.GetRegisterContext()->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
- }
- else
- {
- return m_next_frame->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
- }
+ case eRegisterInRegister:
+ {
+ const RegisterInfo *other_reg_info = GetRegisterInfoAtIndex(regloc.location.register_number);
+ if (IsFrameZero ())
+ {
+ success = m_thread.GetRegisterContext()->WriteRegister (other_reg_info, value);
+ }
+ else
+ {
+ success = m_next_frame->WriteRegister (other_reg_info, value);
+ }
+ }
+ break;
+ case eRegisterValueInferred:
+ case eRegisterNotSaved:
+ break;
+ case eRegisterSavedAtHostMemoryLocation:
+ assert ("FIXME debugger inferior function call unwind");
+ break;
+ case eRegisterSavedAtMemoryLocation:
+ {
+ Error error (WriteRegisterValueToMemory (reg_info,
+ regloc.location.target_memory_location,
+ reg_info->byte_size,
+ value));
+ success = error.Success();
+ }
+ break;
+ default:
+ assert ("Unknown RegisterLocation type.");
+ break;
}
- if (regloc.type == eRegisterNotSaved)
- {
- return false;
- }
- if (regloc.type == eRegisterValueInferred)
- {
- return false;
- }
- if (regloc.type == eRegisterSavedAtHostMemoryLocation)
- {
- assert ("FIXME debugger inferior function call unwind");
- }
- if (regloc.type != eRegisterSavedAtMemoryLocation)
- {
- assert ("Unknown RegisterLocation type.");
- }
-
- Error error;
- const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (regnum);
- if (reg_info->byte_size == 0)
- return false;
- uint8_t *buf = (uint8_t*) alloca (reg_info->byte_size);
- if (data.ExtractBytes (data_offset, reg_info->byte_size, m_thread.GetProcess().GetByteOrder(), buf) != reg_info->byte_size)
- return false;
- if (m_thread.GetProcess().WriteMemory (regloc.location.target_memory_location, buf, reg_info->byte_size, error) != reg_info->byte_size)
- return false;
-
- return true;
+ return success;
}
@@ -818,10 +786,10 @@
if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, eRegisterKindLLDB, sp_regnum)
&& sp_regnum == lldb_regnum)
{
- // make sure we won't lose precision copying an addr_t (m_cfa) into a uint64_t (.register_value)
+ // make sure we won't lose precision copying an addr_t (m_cfa) into a uint64_t (.inferred_value)
assert (sizeof (addr_t) <= sizeof (uint64_t));
regloc.type = eRegisterValueInferred;
- regloc.location.register_value = m_cfa;
+ regloc.location.inferred_value = m_cfa;
m_registers[lldb_regnum] = regloc;
return true;
}
@@ -976,7 +944,7 @@
{
int offset = unwindplan_regloc.GetOffset();
regloc.type = eRegisterValueInferred;
- regloc.location.register_value = m_cfa + offset;
+ regloc.location.inferred_value = m_cfa + offset;
m_registers[lldb_regnum] = regloc;
return true;
}
@@ -1027,7 +995,7 @@
if (unwindplan_regloc.IsDWARFExpression())
{
regloc.type = eRegisterValueInferred;
- regloc.location.register_value = val;
+ regloc.location.inferred_value = val;
m_registers[lldb_regnum] = regloc;
return true;
}
@@ -1090,18 +1058,14 @@
return false;
}
- uint32_t offset = 0;
- DataExtractor data;
- data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
- data.SetByteOrder (m_thread.GetProcess().GetByteOrder());
-
+ const RegisterInfo *reg_info = GetRegisterInfoAtIndex(lldb_regnum);
+ RegisterValue reg_value;
// if this is frame 0 (currently executing frame), get the requested reg contents from the actual thread registers
if (IsFrameZero ())
{
- if (m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_regnum, data))
+ if (m_thread.GetRegisterContext()->ReadRegister (reg_info, reg_value))
{
- data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
- value = data.GetAddress (&offset);
+ value = reg_value.GetAsUInt64();
return true;
}
return false;
@@ -1112,29 +1076,29 @@
{
return false;
}
- if (!ReadRegisterBytesFromRegisterLocation (lldb_regnum, regloc, data))
+ if (ReadRegisterValueFromRegisterLocation (regloc, reg_info, reg_value))
{
- return false;
+ value = reg_value.GetAsUInt64();
+ return true;
}
- data.SetAddressByteSize (m_thread.GetProcess().GetAddressByteSize());
- value = data.GetAddress (&offset);
- return true;
+ return false;
}
// Find the value of a register in THIS frame
bool
-RegisterContextLLDB::ReadRegisterBytes (uint32_t lldb_reg, DataExtractor& data)
+RegisterContextLLDB::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
{
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
if (!IsValid())
return false;
+ const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB];
if (log && IsLogVerbose ())
{
log->Printf("%*sFrame %u looking for register saved location for reg %d",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
- lldb_reg);
+ lldb_regnum);
}
// If this is the 0th frame, hand this over to the live register context
@@ -1144,31 +1108,32 @@
{
log->Printf("%*sFrame %u passing along to the live register context for reg %d",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
- lldb_reg);
+ lldb_regnum);
}
- return m_thread.GetRegisterContext()->ReadRegisterBytes (lldb_reg, data);
+ return m_thread.GetRegisterContext()->ReadRegister (reg_info, value);
}
RegisterLocation regloc;
// Find out where the NEXT frame saved THIS frame's register contents
- if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc))
+ if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc))
return false;
- return ReadRegisterBytesFromRegisterLocation (lldb_reg, regloc, data);
+ return ReadRegisterValueFromRegisterLocation (regloc, reg_info, value);
}
bool
-RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data, uint32_t data_offset)
+RegisterContextLLDB::WriteRegister (const RegisterInfo *reg_info, const RegisterValue &value)
{
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
if (!IsValid())
return false;
+ const uint32_t lldb_regnum = reg_info->kinds[eRegisterKindLLDB];
if (log && IsLogVerbose ())
{
log->Printf("%*sFrame %u looking for register saved location for reg %d",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
- lldb_reg);
+ lldb_regnum);
}
// If this is the 0th frame, hand this over to the live register context
@@ -1178,17 +1143,17 @@
{
log->Printf("%*sFrame %u passing along to the live register context for reg %d",
m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
- lldb_reg);
+ lldb_regnum);
}
- return m_thread.GetRegisterContext()->WriteRegisterBytes (lldb_reg, data, data_offset);
+ return m_thread.GetRegisterContext()->WriteRegister (reg_info, value);
}
RegisterLocation regloc;
// Find out where the NEXT frame saved THIS frame's register contents
- if (!m_next_frame->SavedLocationForRegister (lldb_reg, regloc))
+ if (!m_next_frame->SavedLocationForRegister (lldb_regnum, regloc))
return false;
- return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset);
+ return WriteRegisterValueToRegisterLocation (regloc, reg_info, value);
}
// Don't need to implement this one
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h
index ac2c560..b255636 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -50,15 +50,15 @@
GetRegisterSet (uint32_t reg_set);
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
virtual bool
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
+ virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset = 0);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
@@ -92,7 +92,7 @@
eRegisterSavedAtMemoryLocation, // register is saved at a specific word of target mem (target_memory_location)
eRegisterInRegister, // register is available in a (possible other) register (register_number)
eRegisterSavedAtHostMemoryLocation, // register is saved at a word in lldb's address space
- eRegisterValueInferred // register val was computed (and is in register_value)
+ eRegisterValueInferred // register val was computed (and is in inferred_value)
};
struct RegisterLocation
@@ -103,7 +103,7 @@
lldb::addr_t target_memory_location;
uint32_t register_number; // in eRegisterKindLLDB register numbering system
void* host_memory_location;
- uint64_t register_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset
+ uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset
} location;
};
@@ -138,10 +138,14 @@
SavedLocationForRegister (uint32_t lldb_regnum, RegisterLocation ®loc);
bool
- ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data);
+ ReadRegisterValueFromRegisterLocation (RegisterLocation regloc,
+ const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value);
bool
- WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data, uint32_t data_offset);
+ WriteRegisterValueToRegisterLocation (RegisterLocation regloc,
+ const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value);
// Get the contents of a general purpose (address-size) register for this frame
// (usually retrieved from the m_next_frame)
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
index 0263d77..e00913e 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
#include "lldb/Target/Thread.h"
@@ -80,17 +81,14 @@
bool
-RegisterContextMacOSXFrameBackchain::ReadRegisterValue (uint32_t reg, Scalar &value)
+RegisterContextMacOSXFrameBackchain::ReadRegister (const RegisterInfo *reg_info,
+ RegisterValue &value)
{
if (!m_cursor_is_valid)
return false;
uint64_t reg_value = LLDB_INVALID_ADDRESS;
- const RegisterInfo *reg_info = m_thread.GetRegisterContext()->GetRegisterInfoAtIndex (reg);
- if (reg_info == NULL)
- return false;
-
switch (reg_info->kinds[eRegisterKindGeneric])
{
case LLDB_REGNUM_GENERIC_PC:
@@ -116,34 +114,9 @@
break;
case eEncodingUint:
- switch (reg_info->byte_size)
- {
- case 1:
- case 2:
- case 4:
- value = (uint32_t)reg_value;
- return true;
-
- case 8:
- value = (uint64_t)reg_value;
- return true;
- }
- break;
-
case eEncodingSint:
- switch (reg_info->byte_size)
- {
- case 1:
- case 2:
- case 4:
- value = (int32_t)reg_value;
- return true;
-
- case 8:
- value = (int64_t)reg_value;
- return true;
- }
- break;
+ value.SetUInt(reg_value, reg_info->byte_size);
+ return true;
case eEncodingIEEE754:
switch (reg_info->byte_size)
@@ -151,12 +124,12 @@
case sizeof (float):
if (sizeof (float) == sizeof(uint32_t))
{
- value = (uint32_t)reg_value;
+ value.SetUInt32(reg_value, RegisterValue::eTypeFloat);
return true;
}
else if (sizeof (float) == sizeof(uint64_t))
{
- value = (uint64_t)reg_value;
+ value.SetUInt64(reg_value, RegisterValue::eTypeFloat);
return true;
}
break;
@@ -164,12 +137,12 @@
case sizeof (double):
if (sizeof (double) == sizeof(uint32_t))
{
- value = (uint32_t)reg_value;
+ value.SetUInt32(reg_value, RegisterValue::eTypeDouble);
return true;
}
else if (sizeof (double) == sizeof(uint64_t))
{
- value = (uint64_t)reg_value;
+ value.SetUInt64(reg_value, RegisterValue::eTypeDouble);
return true;
}
break;
@@ -177,12 +150,12 @@
case sizeof (long double):
if (sizeof (long double) == sizeof(uint32_t))
{
- value = (uint32_t)reg_value;
+ value.SetUInt32(reg_value, RegisterValue::eTypeLongDouble);
return true;
}
else if (sizeof (long double) == sizeof(uint64_t))
{
- value = (uint64_t)reg_value;
+ value.SetUInt64(reg_value, RegisterValue::eTypeLongDouble);
return true;
}
break;
@@ -192,45 +165,15 @@
return false;
}
-
bool
-RegisterContextMacOSXFrameBackchain::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
-{
- Scalar reg_value;
-
- if (ReadRegisterValue (reg, reg_value))
- {
- if (reg_value.GetData(data))
- {
- // "reg_value" is local and now "data" points to the data within
- // "reg_value", so we must make a copy that will live within "data"
- DataBufferSP data_sp (new DataBufferHeap (data.GetDataStart(), data.GetByteSize()));
- data.SetData (data_sp, 0, data.GetByteSize());
- return true;
- }
- }
- return false;
-}
-
-
-bool
-RegisterContextMacOSXFrameBackchain::WriteRegisterValue (uint32_t reg, const Scalar &value)
+RegisterContextMacOSXFrameBackchain::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
// Not supported yet. We could easily add support for this by remembering
// the address of each entry (it would need to be part of the cursor)
return false;
}
-
-bool
-RegisterContextMacOSXFrameBackchain::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
-{
- // Not supported yet. We could easily add support for this by remembering
- // the address of each entry (it would need to be part of the cursor)
- return false;
-}
-
-
bool
RegisterContextMacOSXFrameBackchain::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
{
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
index bc7c2a0..cc6cb5d 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
@@ -51,21 +51,15 @@
GetRegisterSet (uint32_t reg_set);
virtual bool
- ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value);
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
-
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value);
-
- virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 841efa2..bf1a00c 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -14,6 +14,7 @@
// Other libraries and framework includes
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/StreamString.h"
// Project includes
@@ -115,65 +116,14 @@
bool
-GDBRemoteRegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value)
+GDBRemoteRegisterContext::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value)
{
// Read the register
- if (ReadRegisterBytes (reg, m_reg_data))
+ if (ReadRegisterBytes (reg_info, value, m_reg_data))
{
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
- uint32_t offset = reg_info->byte_offset;
- switch (reg_info->encoding)
- {
- case eEncodingUint:
- switch (reg_info->byte_size)
- {
- case 1:
- case 2:
- case 4:
- value = m_reg_data.GetMaxU32 (&offset, reg_info->byte_size);
- return true;
-
- case 8:
- value = m_reg_data.GetMaxU64 (&offset, reg_info->byte_size);
- return true;
- }
- break;
-
- case eEncodingSint:
- switch (reg_info->byte_size)
- {
- case 1:
- case 2:
- case 4:
- value = (int32_t)m_reg_data.GetMaxU32 (&offset, reg_info->byte_size);
- return true;
-
- case 8:
- value = m_reg_data.GetMaxS64 (&offset, reg_info->byte_size);
- return true;
- }
- break;
-
- case eEncodingIEEE754:
- switch (reg_info->byte_size)
- {
- case sizeof (float):
- value = m_reg_data.GetFloat (&offset);
- return true;
-
- case sizeof (double):
- value = m_reg_data.GetDouble (&offset);
- return true;
-
- case sizeof (long double):
- value = m_reg_data.GetLongDouble (&offset);
- return true;
- }
- break;
-
- default:
- break;
- }
+ const bool partial_data_ok = false;
+ Error error (value.SetValueFromData(reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok));
+ return error.Success();
}
return false;
}
@@ -206,14 +156,14 @@
bool
-GDBRemoteRegisterContext::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
+GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data)
{
GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
InvalidateIfNeeded(false);
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
- assert (reg_info);
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+
if (!m_reg_valid[reg])
{
Mutex::Locker locker;
@@ -243,6 +193,7 @@
else
{
// Get each register individually
+
if (thread_suffix_supported)
packet_len = ::snprintf (packet, sizeof(packet), "p%x;thread:%4.4x;", reg, m_thread.GetID());
else
@@ -274,21 +225,18 @@
bool
-GDBRemoteRegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value)
+GDBRemoteRegisterContext::WriteRegister (const RegisterInfo *reg_info,
+ const RegisterValue &value)
{
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
- if (reg_info)
- {
- DataExtractor data;
- if (value.GetData (data, reg_info->byte_size))
- return WriteRegisterBytes (reg, data, 0);
- }
+ DataExtractor data;
+ if (value.GetData (data))
+ return WriteRegisterBytes (reg_info, value, data, 0);
return false;
}
bool
-GDBRemoteRegisterContext::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
+GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, const RegisterValue &value, DataExtractor &data, uint32_t data_offset)
{
GDBRemoteCommunicationClient &gdb_comm (GetGDBProcess().GetGDBRemote());
// FIXME: This check isn't right because IsRunning checks the Public state, but this
@@ -297,34 +245,21 @@
// if (gdb_comm.IsRunning())
// return false;
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
+ const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- if (reg_info)
+ // Grab a pointer to where we are going to put this register
+ uint8_t *dst = const_cast<uint8_t*>(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
+
+ if (dst == NULL)
+ return false;
+
+
+ if (data.CopyByteOrderedData (data_offset, // src offset
+ reg_info->byte_size, // src length
+ dst, // dst
+ reg_info->byte_size, // dst length
+ m_reg_data.GetByteOrder())) // dst byte order
{
- // Grab a pointer to where we are going to put this register
- uint8_t *dst = const_cast<uint8_t*>(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
-
- if (dst == NULL)
- return false;
-
- // Grab a pointer to where we are going to grab the new value from
- const uint8_t *src = data.PeekData(0, reg_info->byte_size);
-
- if (src == NULL)
- return false;
-
- if (data.GetByteOrder() == m_reg_data.GetByteOrder())
- {
- // No swapping, just copy the bytes
- ::memcpy (dst, src, reg_info->byte_size);
- }
- else
- {
- // Swap the bytes
- for (uint32_t i=0; i<reg_info->byte_size; ++i)
- dst[i] = src[reg_info->byte_size - 1 - i];
- }
-
Mutex::Locker locker;
if (gdb_comm.GetSequenceMutex (locker))
{
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index 3848ffc..3152847 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -208,21 +208,15 @@
GetRegisterSet (uint32_t reg_set);
virtual bool
- ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value);
+ ReadRegister (const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value);
virtual bool
- ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data);
-
+ WriteRegister (const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value);
+
virtual bool
ReadAllRegisterValues (lldb::DataBufferSP &data_sp);
virtual bool
- WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value);
-
- virtual bool
- WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset);
-
- virtual bool
WriteAllRegisterValues (const lldb::DataBufferSP &data_sp);
virtual uint32_t
@@ -232,6 +226,17 @@
friend class ThreadGDBRemote;
bool
+ ReadRegisterBytes (const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value,
+ lldb_private::DataExtractor &data);
+
+ bool
+ WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value,
+ lldb_private::DataExtractor &data,
+ uint32_t data_offset);
+
+ bool
PrivateSetRegisterValue (uint32_t reg, StringExtractor &response);
void
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 787778a..0ce503c 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -103,7 +103,8 @@
// We use the address byte size to be safe for any future addresss sizes
RegisterInfo sp_reg_info;
m_inst_emulator_ap->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp_reg_info);
- SetRegisterValue(sp_reg_info, (1ull << ((addr_byte_size * 8) - 1)));
+ m_initial_sp = (1ull << ((addr_byte_size * 8) - 1));
+ SetRegisterValue(sp_reg_info, m_initial_sp);
const InstructionList &inst_list = disasm_sp->GetInstructionList ();
const size_t num_instructions = inst_list.GetSize();
@@ -155,7 +156,7 @@
UnwindAssembly *
UnwindAssemblyInstEmulation::CreateInstance (const ArchSpec &arch)
{
- std::auto_ptr<lldb_private::EmulateInstruction> inst_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypePrologueEpilogue, NULL));
+ std::auto_ptr<EmulateInstruction> inst_emulator_ap (EmulateInstruction::FindPlugin (arch, eInstructionTypePrologueEpilogue, NULL));
// Make sure that all prologue instructions are handled
if (inst_emulator_ap.get())
return new UnwindAssemblyInstEmulation (arch, inst_emulator_ap.release());
@@ -215,28 +216,34 @@
uint64_t
-UnwindAssemblyInstEmulation::MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info)
+UnwindAssemblyInstEmulation::MakeRegisterKindValuePair (const RegisterInfo ®_info)
{
uint32_t reg_kind, reg_num;
- if (EmulateInstruction::GetBestRegisterKindAndNumber (reg_info, reg_kind, reg_num))
+ if (EmulateInstruction::GetBestRegisterKindAndNumber (®_info, reg_kind, reg_num))
return (uint64_t)reg_kind << 24 | reg_num;
return 0ull;
}
void
-UnwindAssemblyInstEmulation::SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value)
+UnwindAssemblyInstEmulation::SetRegisterValue (const RegisterInfo ®_info, const RegisterValue ®_value)
{
m_register_values[MakeRegisterKindValuePair (reg_info)] = reg_value;
}
-uint64_t
-UnwindAssemblyInstEmulation::GetRegisterValue (const lldb_private::RegisterInfo ®_info)
+bool
+UnwindAssemblyInstEmulation::GetRegisterValue (const RegisterInfo ®_info, RegisterValue ®_value)
{
const uint64_t reg_id = MakeRegisterKindValuePair (reg_info);
RegisterValueMap::const_iterator pos = m_register_values.find(reg_id);
if (pos != m_register_values.end())
- return pos->second;
- return MakeRegisterKindValuePair (reg_info);
+ {
+ reg_value = pos->second;
+ return true; // We had a real value that comes from an opcode that wrote
+ // to it...
+ }
+ // We are making up a value that is recognizable...
+ reg_value.SetUInt(reg_id, reg_info.byte_size);
+ return false;
}
@@ -280,6 +287,7 @@
switch (context.type)
{
+ default:
case EmulateInstruction::eContextInvalid:
case EmulateInstruction::eContextReadOpcode:
case EmulateInstruction::eContextImmediate:
@@ -299,6 +307,7 @@
case EmulateInstruction::eContextReturnFromException:
case EmulateInstruction::eContextPopRegisterOffStack:
case EmulateInstruction::eContextAdjustStackPointer:
+ assert (!"unhandled case, add code to handle this!");
break;
case EmulateInstruction::eContextPushRegisterOnStack:
@@ -308,8 +317,8 @@
{
UnwindPlan::Row::RegisterLocation regloc;
const uint32_t dwarf_reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindDWARF];
- const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset;
- regloc.SetIsCFAPlusOffset (reg_cfa_offset);
+ //const addr_t reg_cfa_offset = inst_emulator->m_curr_row.GetCFAOffset() + context.info.RegisterToRegisterPlusOffset.offset;
+ regloc.SetAtCFAPlusOffset (addr - inst_emulator->m_initial_sp);
inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc);
}
break;
@@ -320,8 +329,6 @@
}
break;
- break;
-
}
return dst_len;
@@ -330,14 +337,19 @@
bool
UnwindAssemblyInstEmulation::ReadRegister (EmulateInstruction *instruction,
void *baton,
- const RegisterInfo ®_info,
- uint64_t ®_value)
+ const RegisterInfo *reg_info,
+ RegisterValue ®_value)
{
- UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton;
- reg_value = inst_emulator->GetRegisterValue (reg_info);
+ if (baton && reg_info)
+ {
+ UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton;
+ bool synthetic = inst_emulator->GetRegisterValue (*reg_info, reg_value);
- printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => value = 0x%16.16llx\n", reg_info.name, reg_value);
-
+ StreamFile strm (stdout, false);
+ strm.Printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => synthetic_value = %i, value = ", reg_info->name, synthetic);
+ reg_value.Dump(&strm, reg_info, false, eFormatDefault);
+ strm.EOL();
+ }
return true;
}
@@ -345,20 +357,24 @@
UnwindAssemblyInstEmulation::WriteRegister (EmulateInstruction *instruction,
void *baton,
const EmulateInstruction::Context &context,
- const RegisterInfo ®_info,
- uint64_t reg_value)
+ const RegisterInfo *reg_info,
+ const RegisterValue ®_value)
{
+ if (!baton || !reg_info)
+ return false;
+
UnwindAssemblyInstEmulation *inst_emulator = (UnwindAssemblyInstEmulation *)baton;
-
- printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = 0x%16.16llx, context =",
- reg_info.name,
- reg_value);
+ StreamFile strm (stdout, false);
+ strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name);
+ reg_value.Dump(&strm, reg_info, false, eFormatDefault);
+ strm.PutCString (", context = ");
context.Dump(stdout, instruction);
- inst_emulator->SetRegisterValue (reg_info, reg_value);
+ inst_emulator->SetRegisterValue (*reg_info, reg_value);
switch (context.type)
{
+ default:
case EmulateInstruction::eContextInvalid:
case EmulateInstruction::eContextReadOpcode:
case EmulateInstruction::eContextImmediate:
@@ -377,6 +393,7 @@
case EmulateInstruction::eContextAdvancePC:
case EmulateInstruction::eContextReturnFromException:
case EmulateInstruction::eContextPushRegisterOnStack:
+ assert (!"unhandled case, add code to handle this!");
break;
case EmulateInstruction::eContextPopRegisterOffStack:
@@ -385,7 +402,7 @@
{
case EmulateInstruction::eInfoTypeRegisterPlusOffset:
{
- const uint32_t dwarf_reg_num = reg_info.kinds[eRegisterKindDWARF];
+ const uint32_t dwarf_reg_num = reg_info->kinds[eRegisterKindDWARF];
UnwindPlan::Row::RegisterLocation regloc;
regloc.SetSame();
inst_emulator->m_curr_row.SetRegisterInfo (dwarf_reg_num, regloc);
@@ -400,16 +417,7 @@
break;
case EmulateInstruction::eContextAdjustStackPointer:
- switch (context.info_type)
- {
- case EmulateInstruction::eInfoTypeImmediateSigned:
- inst_emulator->m_curr_row.SetCFAOffset (inst_emulator->m_curr_row.GetCFAOffset() + context.info.signed_immediate);
- break;
-
- default:
- assert (!"unhandled case, add code to handle this!");
- break;
- }
+ inst_emulator->m_curr_row.SetCFAOffset (reg_value.GetAsUInt64() - inst_emulator->m_initial_sp);
break;
}
return true;
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index 220864d..96c1381 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -12,6 +12,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/EmulateInstruction.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/UnwindAssembly.h"
@@ -89,15 +90,15 @@
static bool
ReadRegister (lldb_private::EmulateInstruction *instruction,
void *baton,
- const lldb_private::RegisterInfo ®_info,
- uint64_t ®_value);
+ const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue ®_value);
static bool
WriteRegister (lldb_private::EmulateInstruction *instruction,
void *baton,
const lldb_private::EmulateInstruction::Context &context,
- const lldb_private::RegisterInfo ®_info,
- uint64_t reg_value);
+ const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue ®_value);
// Call CreateInstance to get an instance of this class
@@ -120,17 +121,20 @@
MakeRegisterKindValuePair (const lldb_private::RegisterInfo ®_info);
void
- SetRegisterValue (const lldb_private::RegisterInfo ®_info, uint64_t reg_value);
+ SetRegisterValue (const lldb_private::RegisterInfo ®_info,
+ const lldb_private::RegisterValue ®_value);
- uint64_t
- GetRegisterValue (const lldb_private::RegisterInfo ®_info);
+ bool
+ GetRegisterValue (const lldb_private::RegisterInfo ®_info,
+ lldb_private::RegisterValue ®_value);
std::auto_ptr<lldb_private::EmulateInstruction> m_inst_emulator_ap;
lldb_private::AddressRange* m_range_ptr;
lldb_private::Thread* m_thread_ptr;
lldb_private::UnwindPlan* m_unwind_plan_ptr;
lldb_private::UnwindPlan::Row m_curr_row;
- typedef std::map<uint64_t, uint64_t> RegisterValueMap;
+ uint64_t m_initial_sp;
+ typedef std::map<uint64_t, lldb_private::RegisterValue> RegisterValueMap;
RegisterValueMap m_register_values;
};