[Lldb-commits] [lldb] r118486 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp RegisterContextLLDB.h

Jason Molenda jmolenda at apple.com
Mon Nov 8 20:31:16 PST 2010


Author: jmolenda
Date: Mon Nov  8 22:31:16 2010
New Revision: 118486

URL: http://llvm.org/viewvc/llvm-project?rev=118486&view=rev
Log:
Implement RegisterContext::WriteRegisterBytes in RegisterContextLLDB.
I only did a tiny bit of testing; in the one case I tried changing the
contents of a radar in the middle of a stack and it was still current in
the live register context so it filtered down to frame 0 and was handed
over to the live register set RegisterContext.  I need to test a case
where a register is saved on the stack in memory before I check this
one off.


Modified:
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=118486&r1=118485&r2=118486&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Nov  8 22:31:16 2010
@@ -677,6 +677,54 @@
 }
 
 bool
+RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data, uint32_t data_offset)
+{
+    if (!IsValid())
+        return false;
+
+    if (regloc.type == eRegisterInRegister)
+    {
+        if (IsFrameZero ())
+        {
+            return m_base_reg_ctx->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
+        }
+        else
+        {
+            return m_next_frame->WriteRegisterBytes (regloc.location.register_number, data, data_offset);
+        }
+    }
+    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_base_reg_ctx->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;
+}
+
+
+bool
 RegisterContextLLDB::IsValid () const
 {
     return m_frame_type != eNotAValidFrame;
@@ -907,7 +955,8 @@
                     lldb_regnum);
     }
 
-    assert ("UnwindPlan::Row types atDWARFExpression and isDWARFExpression are unsupported.");
+    
+    // assert ("UnwindPlan::Row types atDWARFExpression and isDWARFExpression are unsupported.");
     return false;
 }
 
@@ -1013,23 +1062,50 @@
 }
 
 bool
-RegisterContextLLDB::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
+RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data, uint32_t data_offset)
 {
-    assert ("not yet implemented");  // FIXME
-    return false;
+    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
+    if (!IsValid())
+        return false;
+
+    if (log && IsLogVerbose ())
+    {
+        log->Printf("%*sFrame %d looking for register saved location for reg %d",
+                    m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
+                    lldb_reg);
+    }
+
+    // If this is the 0th frame, hand this over to the live register context
+    if (IsFrameZero ())
+    {
+        if (log)
+        {
+            log->Printf("%*sFrame %d passing along to the live register context for reg %d",
+                        m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number,
+                        lldb_reg);
+        }
+        return m_base_reg_ctx->WriteRegisterBytes (lldb_reg, data, data_offset);
+    }
+
+    RegisterLocation regloc;
+    // Find out where the NEXT frame saved THIS frame's register contents
+    if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc))
+        return false;
+
+    return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset);
 }
 
+// Don't need to implement this one
 bool
-RegisterContextLLDB::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
+RegisterContextLLDB::ReadAllRegisterValues (lldb::DataBufferSP &data_sp)
 {
-    assert ("not yet implemented");  // FIXME
     return false;
 }
 
+// Don't need to implement this one
 bool
 RegisterContextLLDB::WriteAllRegisterValues (const lldb::DataBufferSP& data_sp)
 {
-    assert ("not yet implemented");  // FIXME
     return false;
 }
 

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=118486&r1=118485&r2=118486&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon Nov  8 22:31:16 2010
@@ -139,7 +139,7 @@
     ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data);
 
     bool
-    WriteRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::Scalar value);
+    WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data, uint32_t data_offset);
 
     // Get the contents of a general purpose (address-size) register for this frame 
     // (usually retrieved from the m_next_frame)





More information about the lldb-commits mailing list