[Lldb-commits] [lldb] [lldb] Fix TestDiagnoseDereferenceFunctionReturn on linux (PR #128512)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 24 06:09:40 PST 2025
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/128512
>From ed3003bd1ea04f4758fe91e0badaf203a60d80ec Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Mon, 24 Feb 2025 14:32:02 +0100
Subject: [PATCH 1/2] [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.
---
lldb/source/Target/StackFrame.cpp | 11 ++++++-----
.../TestDiagnoseDereferenceFunctionReturn.py | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 4d068638f42b6..f8061ffad1466 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1670,13 +1670,14 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
break;
case Instruction::Operand::Type::Immediate: {
SymbolContext sc;
- Address load_address;
- if (!frame.CalculateTarget()->ResolveLoadAddress(
- operands[0].m_immediate, load_address)) {
+ if (!pc.GetModule())
+ break;
+ Address address(operands[0].m_immediate,
+ pc.GetModule()->GetSectionList());
+ if (!address.IsValid())
break;
- }
frame.CalculateTarget()->GetImages().ResolveSymbolContextForAddress(
- load_address, eSymbolContextFunction, sc);
+ address, eSymbolContextFunction, sc);
if (!sc.function) {
break;
}
diff --git a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
index d0f6ebefa334a..8ada9a2369602 100644
--- a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
+++ b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
@@ -10,7 +10,7 @@
class TestDiagnoseDereferenceFunctionReturn(TestBase):
- @expectedFailureAll(oslist=no_match(lldbplatformutil.getDarwinOSTriples()))
+ @expectedFailureAll(oslist=["windows"])
@skipIf(
archs=no_match(["x86_64"])
) # <rdar://problem/33842388> frame diagnose doesn't work for armv7 or arm64
>From 13147ef1691a85772ffe629ba7dc6dc5fd683bdc Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Mon, 24 Feb 2025 15:09:31 +0100
Subject: [PATCH 2/2] Re-enable ASLR
---
.../TestDiagnoseDereferenceFunctionReturn.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
index 8ada9a2369602..f7b596606134b 100644
--- a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
+++ b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
@@ -19,9 +19,6 @@ def test_diagnose_dereference_function_return(self):
TestBase.setUp(self)
self.build()
exe = self.getBuildArtifact("a.out")
- # FIXME: This default changed in lldbtest.py and this test
- # seems to rely on having it turned off.
- self.runCmd("settings set target.disable-aslr true")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.runCmd("run", RUN_SUCCEEDED)
self.expect("thread list", "Thread should be stopped", substrs=["stopped"])
More information about the lldb-commits
mailing list