Skip to content

Commit ed3003b

Browse files
committed
[lldb] Fix TestDiagnoseDereferenceFunctionReturn on linux
The test was failing because it was looking up the immediate value from the call instruction as a load address, whereas in fact it was a file address. This worked on darwin because (with ASLR disabled) the two addresses are generally the same. On linux, this depends on the build mode, but with the default (PIE) build type, the two are never the same. The test also fails on a mac with ASLR enabled. This path fixes the code to look up the value as a file address.
1 parent 9d19105 commit ed3003b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lldb/source/Target/StackFrame.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,13 +1670,14 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
16701670
break;
16711671
case Instruction::Operand::Type::Immediate: {
16721672
SymbolContext sc;
1673-
Address load_address;
1674-
if (!frame.CalculateTarget()->ResolveLoadAddress(
1675-
operands[0].m_immediate, load_address)) {
1673+
if (!pc.GetModule())
1674+
break;
1675+
Address address(operands[0].m_immediate,
1676+
pc.GetModule()->GetSectionList());
1677+
if (!address.IsValid())
16761678
break;
1677-
}
16781679
frame.CalculateTarget()->GetImages().ResolveSymbolContextForAddress(
1679-
load_address, eSymbolContextFunction, sc);
1680+
address, eSymbolContextFunction, sc);
16801681
if (!sc.function) {
16811682
break;
16821683
}

lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class TestDiagnoseDereferenceFunctionReturn(TestBase):
13-
@expectedFailureAll(oslist=no_match(lldbplatformutil.getDarwinOSTriples()))
13+
@expectedFailureAll(oslist=["windows"])
1414
@skipIf(
1515
archs=no_match(["x86_64"])
1616
) # <rdar://problem/33842388> frame diagnose doesn't work for armv7 or arm64

0 commit comments

Comments
 (0)