[Lldb-commits] [lldb] r204764 - Made the Materializer not write back variables
Sean Callanan
scallanan at apple.com
Tue Mar 25 15:30:20 PDT 2014
Author: spyffe
Date: Tue Mar 25 17:30:19 2014
New Revision: 204764
URL: http://llvm.org/viewvc/llvm-project?rev=204764&view=rev
Log:
Made the Materializer not write back variables
if they didn't change, just like it does for
registers. This makes life easier for kernel
debugging and any other situation where values
are read-only.
<rdar://problem/16367795>
Modified:
lldb/trunk/source/Expression/Materializer.cpp
Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=204764&r1=204763&r2=204764&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Tue Mar 25 17:30:19 2014
@@ -535,6 +535,8 @@ public:
m_temporary_allocation = map.Malloc(data.GetByteSize(), byte_align, lldb::ePermissionsReadable | lldb::ePermissionsWritable, IRMemoryMap::eAllocationPolicyMirror, alloc_error);
m_temporary_allocation_size = data.GetByteSize();
+ m_original_data.reset(new DataBufferHeap(data.GetDataStart(), data.GetByteSize()));
+
if (!alloc_error.Success())
{
err.SetErrorStringWithFormat("couldn't allocate a temporary region for %s: %s", m_variable_sp->GetName().AsCString(), alloc_error.AsCString());
@@ -607,14 +609,28 @@ public:
return;
}
- Error set_error;
+ bool actually_write = true;
- valobj_sp->SetData(data, set_error);
+ if (m_original_data)
+ {
+ if ((data.GetByteSize() == m_original_data->GetByteSize()) &&
+ memcmp(m_original_data->GetBytes(), data.GetDataStart(), data.GetByteSize()))
+ {
+ actually_write = false;
+ }
+ }
- if (!set_error.Success())
+ Error set_error;
+
+ if (actually_write)
{
- err.SetErrorStringWithFormat("couldn't write the new contents of %s back into the variable", m_variable_sp->GetName().AsCString());
- return;
+ valobj_sp->SetData(data, set_error);
+
+ if (!set_error.Success())
+ {
+ err.SetErrorStringWithFormat("couldn't write the new contents of %s back into the variable", m_variable_sp->GetName().AsCString());
+ return;
+ }
}
Error free_error;
@@ -627,6 +643,7 @@ public:
return;
}
+ m_original_data.reset();
m_temporary_allocation = LLDB_INVALID_ADDRESS;
m_temporary_allocation_size = 0;
}
@@ -722,6 +739,7 @@ private:
bool m_is_reference;
lldb::addr_t m_temporary_allocation;
size_t m_temporary_allocation_size;
+ lldb::DataBufferSP m_original_data;
};
uint32_t
More information about the lldb-commits
mailing list