[Lldb-commits] [lldb] r147637 - in /lldb/trunk: include/lldb/Expression/ClangExpressionVariable.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangExpressionParser.cpp source/Expression/ClangExpressionVariable.cpp source/Expression/ClangUserExpression.cpp test/expression_command/issue_11588/Test11588.py
Johnny Chen
johnny.chen at apple.com
Thu Jan 5 16:35:38 PST 2012
Author: johnny
Date: Thu Jan 5 18:35:38 2012
New Revision: 147637
URL: http://llvm.org/viewvc/llvm-project?rev=147637&view=rev
Log:
http://llvm.org/bugs/show_bug.cgi?id=11618
lldb::SBValue::AddressOf does not work on dereferenced registers in synthetic children provider
Patch submitted by Enrico Granata.
Modified:
lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
lldb/trunk/source/Expression/ClangExpressionParser.cpp
lldb/trunk/source/Expression/ClangExpressionVariable.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/test/expression_command/issue_11588/Test11588.py
Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Thu Jan 5 18:35:38 2012
@@ -206,6 +206,15 @@
void
ValueUpdated ();
+
+ // this function is used to copy the address-of m_live_sp into m_frozen_sp
+ // this is necessary because the results of certain cast and pointer-arithmetic
+ // operations (such as those described in bugzilla issues 11588 and 11618) generate
+ // frozen objcts that do not have a valid address-of, which can be troublesome when
+ // using synthetic children providers. transferring the address-of the live object
+ // solves these issues and provides the expected user-level behavior
+ void
+ TransferAddress (bool force = false);
typedef lldb::SharedPtr<ValueObjectConstResult>::Type ValueObjectConstResultSP;
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Jan 5 18:35:38 2012
@@ -406,13 +406,6 @@
address,
address_type,
pvar_sp->GetByteSize());
-
- // if the frozen object does not yet have a valid live address we replicate the live_sp address
- // to it. this solves the issue where synthetic children providers are unable to access
- // the address-of result for objects obtained by casting the result of pointer arithmetic
- // performed by the expression parser, as in: print *((ClassType*)(value-1))
- if (pvar_sp->m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS)
- pvar_sp->m_frozen_sp->SetLiveAddress(address);
}
if (pvar_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry)
Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Jan 5 18:35:38 2012
@@ -500,6 +500,8 @@
if (execution_policy != eExecutionPolicyAlways && ir_for_target.interpretSuccess())
{
+ if (const_result)
+ const_result->TransferAddress();
evaluated_statically = true;
err.Clear();
return err;
Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Thu Jan 5 18:35:38 2012
@@ -133,3 +133,15 @@
m_frozen_sp->ValueUpdated ();
}
+void
+ClangExpressionVariable::TransferAddress (bool force)
+{
+ if (m_live_sp.get() == NULL)
+ return;
+
+ if (m_frozen_sp.get() == NULL)
+ return;
+
+ if (force || (m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS))
+ m_frozen_sp->SetLiveAddress(m_live_sp->GetLiveAddress());
+}
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Jan 5 18:35:38 2012
@@ -525,6 +525,9 @@
return false;
}
+ if (result)
+ result->TransferAddress();
+
return true;
}
Modified: lldb/trunk/test/expression_command/issue_11588/Test11588.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/Test11588.py?rev=147637&r1=147636&r2=147637&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/issue_11588/Test11588.py (original)
+++ lldb/trunk/test/expression_command/issue_11588/Test11588.py Thu Jan 5 18:35:38 2012
@@ -42,11 +42,33 @@
self.expect("print *((StgClosure*)(r14-1))",
substrs = ["(StgClosure) $",
- "(StgClosure *) &$0 = 0x",
+ "(StgClosure *) &$","0x",
"(long) addr = ",
"(long) load_address = "])
+ target = lldb.debugger.GetSelectedTarget()
+ process = target.GetProcess()
+# register r14 does not exist on 32-bit architectures, it is an x86_64 extension
+# let's skip this part of the test if we are in 32-bit mode
+ if process.GetAddressByteSize() == 8:
+ frame = process.GetSelectedThread().GetSelectedFrame()
+ pointer = frame.FindVariable("r14")
+ addr = pointer.GetValueAsUnsigned(0)
+ self.assertTrue(addr != 0, "could not read pointer to StgClosure")
+ addr = addr - 1
+ self.runCmd("register write r14 %d" % addr)
+ self.expect("register read r14",
+ substrs = ["0x",hex(addr)[2:]])
+ self.expect("print *(StgClosure*)$r14",
+ substrs = ["(StgClosure) $",
+ "(StgClosure *) &$","0x",
+ "(long) addr = ",
+ "(long) load_address = ",
+ hex(addr)[2:],
+ str(addr)])
+
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
More information about the lldb-commits
mailing list