Skip to content

Commit 6c17380

Browse files
authored
[lldb] Fix TestDiagnoseDereferenceFunctionReturn on linux (#128512)
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 3872503 commit 6c17380

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
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 & 4 deletions
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
@@ -19,9 +19,6 @@ def test_diagnose_dereference_function_return(self):
1919
TestBase.setUp(self)
2020
self.build()
2121
exe = self.getBuildArtifact("a.out")
22-
# FIXME: This default changed in lldbtest.py and this test
23-
# seems to rely on having it turned off.
24-
self.runCmd("settings set target.disable-aslr true")
2522
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
2623
self.runCmd("run", RUN_SUCCEEDED)
2724
self.expect("thread list", "Thread should be stopped", substrs=["stopped"])

0 commit comments

Comments
 (0)