[Lldb-commits] [PATCH] D80724: [lldb] Only set the executable module for a target once
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 16 23:36:16 PDT 2020
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16926115ed28: [lldb] Only set the executable module for a target once (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80724/new/
https://reviews.llvm.org/D80724
Files:
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/test/API/functionalities/dlopen_other_executable/Makefile
lldb/test/API/functionalities/dlopen_other_executable/TestDlopenOtherExecutable.py
lldb/test/API/functionalities/dlopen_other_executable/main.c
lldb/test/API/functionalities/dlopen_other_executable/other.c
Index: lldb/test/API/functionalities/dlopen_other_executable/other.c
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/dlopen_other_executable/other.c
@@ -0,0 +1 @@
+int main() {}
Index: lldb/test/API/functionalities/dlopen_other_executable/main.c
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/dlopen_other_executable/main.c
@@ -0,0 +1,10 @@
+#include <dlfcn.h>
+#include <assert.h>
+
+int main() {
+ int i = 0; // break here
+ // dlopen the 'other' test executable.
+ int h = dlopen("other", RTLD_LAZY);
+ assert(h && "dlopen failed?");
+ return i; // break after dlopen
+}
Index: lldb/test/API/functionalities/dlopen_other_executable/TestDlopenOtherExecutable.py
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/dlopen_other_executable/TestDlopenOtherExecutable.py
@@ -0,0 +1,42 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfRemote
+ @skipIfWindows
+ # glibc's dlopen doesn't support opening executables.
+ # https://sourceware.org/bugzilla/show_bug.cgi?id=11754
+ @skipIfLinux
+ @no_debug_info_test
+ def test(self):
+ self.build()
+ # Launch and stop before the dlopen call.
+ lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
+
+ # Delete the breakpoint we no longer need.
+ self.target().DeleteAllBreakpoints()
+
+ # Check that the executable is the test binary.
+ self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out")
+
+ # Continue so that dlopen is called.
+ breakpoint = self.target().BreakpointCreateBySourceRegex(
+ "// break after dlopen", lldb.SBFileSpec("main.c"))
+ self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0)
+ stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint)
+ self.assertEqual(len(stopped_threads), 1)
+
+ # Check that the executable is still the test binary and not "other".
+ self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out")
+
+ # Kill the process and run the program again.
+ err = self.process().Kill()
+ self.assertTrue(err.Success(), str(err))
+
+ # Test that we hit the breakpoint after dlopen.
+ lldbutil.run_to_breakpoint_do_run(self, self.target(), breakpoint)
Index: lldb/test/API/functionalities/dlopen_other_executable/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/dlopen_other_executable/Makefile
@@ -0,0 +1,8 @@
+C_SOURCES := main.c
+USE_LIBDL := 1
+
+other:
+ $(MAKE) -f $(MAKEFILE_RULES) C_SOURCES=other.c EXE=other
+all: other
+
+include Makefile.rules
Index: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
===================================================================
--- lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -577,7 +577,8 @@
}
}
- if (exe_idx != UINT32_MAX) {
+ // Set the target executable if we haven't found one so far.
+ if (exe_idx != UINT32_MAX && !target.GetExecutableModule()) {
const bool can_create = true;
ModuleSP exe_module_sp(FindTargetModuleForImageInfo(image_infos[exe_idx],
can_create, nullptr));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80724.278665.patch
Type: text/x-patch
Size: 3718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200717/16cb0555/attachment.bin>
More information about the lldb-commits
mailing list