[Lldb-commits] [lldb] r181727 - Fixed expression evaluation with convenience registers.

Ashok Thirumurthi ashok.thirumurthi at intel.com
Mon May 13 12:56:47 PDT 2013


Author: athirumu
Date: Mon May 13 14:56:46 2013
New Revision: 181727

URL: http://llvm.org/viewvc/llvm-project?rev=181727&view=rev
Log:
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.

Modified:
    lldb/trunk/include/lldb/Core/RegisterValue.h
    lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp
    lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.h
    lldb/trunk/test/functionalities/register/TestRegisters.py

Modified: lldb/trunk/include/lldb/Core/RegisterValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=181727&r1=181726&r2=181727&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegisterValue.h (original)
+++ lldb/trunk/include/lldb/Core/RegisterValue.h Mon May 13 14:56:46 2013
@@ -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;

Modified: lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp?rev=181727&r1=181726&r2=181727&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.cpp Mon May 13 14:56:46 2013
@@ -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::IsRegisterSetAva
 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(con
     }
     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) {

Modified: lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.h?rev=181727&r1=181726&r2=181727&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/RegisterContext_x86_64.h Mon May 13 14:56:46 2013
@@ -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,

Modified: lldb/trunk/test/functionalities/register/TestRegisters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/register/TestRegisters.py?rev=181727&r1=181726&r2=181727&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/register/TestRegisters.py (original)
+++ lldb/trunk/test/functionalities/register/TestRegisters.py Mon May 13 14:56:46 2013
@@ -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'])
 





More information about the lldb-commits mailing list