summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2012-01-06 00:35:38 +0000
committerJohnny Chen <johnny.chen@apple.com>2012-01-06 00:35:38 +0000
commitb49440fa92c1cbdea3736acdb0882275c1ab0748 (patch)
tree22007b6093b709b6d1472b35a086bd728db4c75a
parent17eaf4089da5462edf57f281da539310fd35dd8e (diff)
downloadbcm5719-llvm-b49440fa92c1cbdea3736acdb0882275c1ab0748.tar.gz
bcm5719-llvm-b49440fa92c1cbdea3736acdb0882275c1ab0748.zip
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. llvm-svn: 147637
-rw-r--r--lldb/include/lldb/Expression/ClangExpressionVariable.h9
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp7
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp2
-rw-r--r--lldb/source/Expression/ClangExpressionVariable.cpp12
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp3
-rw-r--r--lldb/test/expression_command/issue_11588/Test11588.py24
6 files changed, 49 insertions, 8 deletions
diff --git a/lldb/include/lldb/Expression/ClangExpressionVariable.h b/lldb/include/lldb/Expression/ClangExpressionVariable.h
index 1a0e540a269..00897265130 100644
--- a/lldb/include/lldb/Expression/ClangExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ClangExpressionVariable.h
@@ -206,6 +206,15 @@ public:
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;
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index e115054549a..128db9c5753 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -406,13 +406,6 @@ ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP
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)
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 912822399dc..7c3e6589621 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -500,6 +500,8 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
if (execution_policy != eExecutionPolicyAlways && ir_for_target.interpretSuccess())
{
+ if (const_result)
+ const_result->TransferAddress();
evaluated_statically = true;
err.Clear();
return err;
diff --git a/lldb/source/Expression/ClangExpressionVariable.cpp b/lldb/source/Expression/ClangExpressionVariable.cpp
index 9a264eba062..ec08a0c0af3 100644
--- a/lldb/source/Expression/ClangExpressionVariable.cpp
+++ b/lldb/source/Expression/ClangExpressionVariable.cpp
@@ -133,3 +133,15 @@ ClangExpressionVariable::ValueUpdated ()
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());
+}
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index c2164c80037..7719f081518 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -525,6 +525,9 @@ ClangUserExpression::FinalizeJITExecution (Stream &error_stream,
return false;
}
+ if (result)
+ result->TransferAddress();
+
return true;
}
diff --git a/lldb/test/expression_command/issue_11588/Test11588.py b/lldb/test/expression_command/issue_11588/Test11588.py
index ba0c1c622db..ab47281db07 100644
--- a/lldb/test/expression_command/issue_11588/Test11588.py
+++ b/lldb/test/expression_command/issue_11588/Test11588.py
@@ -42,11 +42,33 @@ class Issue11581TestCase(TestBase):
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()
OpenPOWER on IntegriCloud