Fixed expression evaluation with convenience registers.

- Also improved test coverage for passing tests to include expr/x
and a sanity check for $eax as the lower half of $rax.

llvm-svn: 181727
This commit is contained in:
Ashok Thirumurthi 2013-05-13 19:56:46 +00:00
parent 993fbf704a
commit 1999b6d68c
4 changed files with 25 additions and 6 deletions

View File

@ -382,7 +382,7 @@ namespace lldb_private {
RegisterValue::Type m_type;
union
{
uint8_t uint8;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;

View File

@ -547,6 +547,8 @@ RegisterContext_x86_64::GetRegisterCount()
const RegisterInfo *
RegisterContext_x86_64::GetRegisterInfo()
{
// Commonly, this method is overridden and g_register_infos is copied and specialized.
// So, use GetRegisterInfo() rather than g_register_infos in this scope.
return g_register_infos;
}
@ -680,6 +682,9 @@ RegisterContext_x86_64::IsRegisterSetAvailable(size_t set_index)
bool
RegisterContext_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
{
if (!reg_info)
return false;
const uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
if (IsFPR(reg, m_fpr_type)) {
@ -688,8 +693,14 @@ RegisterContext_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue
}
else {
ProcessMonitor &monitor = GetMonitor();
return monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg),
GetRegisterName(reg), GetRegisterSize(reg), value);
bool success = monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg),
GetRegisterName(reg), GetRegisterSize(reg), value);
// If an i386 register should be parsed from an x86_64 register...
if (success && reg >= k_first_i386 && reg <= k_last_i386)
if (value.GetByteSize() > reg_info->byte_size)
value.SetType(reg_info); // ...use the type specified by reg_info rather than the uint64_t default
return success;
}
if (reg_info->encoding == eEncodingVector) {

View File

@ -43,7 +43,8 @@ enum
gpr_ss,
gpr_ds,
gpr_es,
gpr_eax,
k_first_i386,
gpr_eax = k_first_i386,
gpr_ebx,
gpr_ecx,
gpr_edx,
@ -52,8 +53,9 @@ enum
gpr_ebp,
gpr_esp,
gpr_eip,
gpr_eflags,
k_last_gpr = gpr_eflags, // eRegisterKindLLDB == 33
gpr_eflags, // eRegisterKindLLDB == 33
k_last_i386 = gpr_eflags,
k_last_gpr = gpr_eflags,
k_first_fpr,
fpu_fcw = k_first_fpr,

View File

@ -186,6 +186,12 @@ class RegisterCommandsTestCase(TestBase):
"""Test expression evaluation with commands related to registers."""
self.common_setup()
self.expect("expr/x $eax",
substrs = ['unsigned int', ' = 0x'])
self.expect("expr -- ($rax & 0xffffffff) == $eax",
substrs = ['true'])
self.expect("expr $xmm0",
substrs = ['vector_type'])