[llvm-branch-commits] [lldb] 8666b90 - [lldb] [POSIX-DYLD] Add libraries from initial rendezvous brkpt hit
Michał Górny via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Dec 17 00:35:42 PST 2020
Author: Michał Górny
Date: 2020-12-17T09:31:10+01:00
New Revision: 8666b9057f23badfe90548297f3c01937daa4a9c
URL: https://github.com/llvm/llvm-project/commit/8666b9057f23badfe90548297f3c01937daa4a9c
DIFF: https://github.com/llvm/llvm-project/commit/8666b9057f23badfe90548297f3c01937daa4a9c.diff
LOG: [lldb] [POSIX-DYLD] Add libraries from initial rendezvous brkpt hit
Explicitly consider the libraries reported on the initial rendezvous
breakpoint hit added. This is necessary on FreeBSD since the dynamic
loader issues only a single 'consistent' state rendezvous breakpoint hit
for all the libraries present in DT_NEEDED. It is also helpful on Linux
where it ensures that ld-linux is considered loaded as well
as the shared system libraries reported afterwards.
Reenable memory maps on FreeBSD since this fixed the issue triggered
by them.
Differential Revision: https://reviews.llvm.org/D92187
Added:
Modified:
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
lldb/test/API/api/multithreaded/TestMultithreaded.py
lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
Removed:
################################################################################
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index ac60af5336ed..01f746ada3ba 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -76,7 +76,8 @@ DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD(Process *process)
m_load_offset(LLDB_INVALID_ADDRESS), m_entry_point(LLDB_INVALID_ADDRESS),
m_auxv(), m_dyld_bid(LLDB_INVALID_BREAK_ID),
m_vdso_base(LLDB_INVALID_ADDRESS),
- m_interpreter_base(LLDB_INVALID_ADDRESS) {}
+ m_interpreter_base(LLDB_INVALID_ADDRESS), m_initial_modules_added(false) {
+}
DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD() {
if (m_dyld_bid != LLDB_INVALID_BREAK_ID) {
@@ -418,14 +419,38 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
ModuleList &loaded_modules = m_process->GetTarget().GetImages();
- if (m_rendezvous.ModulesDidLoad()) {
+ if (m_rendezvous.ModulesDidLoad() || !m_initial_modules_added) {
ModuleList new_modules;
- E = m_rendezvous.loaded_end();
- for (I = m_rendezvous.loaded_begin(); I != E; ++I) {
+ // If this is the first time rendezvous breakpoint fires, we need
+ // to take care of adding all the initial modules reported by
+ // the loader. This is necessary to list ld-linux.so on Linux,
+ // and all DT_NEEDED entries on *BSD.
+ if (m_initial_modules_added) {
+ I = m_rendezvous.loaded_begin();
+ E = m_rendezvous.loaded_end();
+ } else {
+ I = m_rendezvous.begin();
+ E = m_rendezvous.end();
+ m_initial_modules_added = true;
+ }
+ for (; I != E; ++I) {
ModuleSP module_sp =
LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
if (module_sp.get()) {
+ if (module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress(
+ &m_process->GetTarget()) == m_interpreter_base &&
+ module_sp != m_interpreter_module.lock()) {
+ // If this is a duplicate instance of ld.so, unload it. We may end up
+ // with it if we load it via a
diff erent path than before (symlink
+ // vs real path).
+ // TODO: remove this once we either fix library matching or avoid
+ // loading the interpreter when setting the rendezvous breakpoint.
+ UnloadSections(module_sp);
+ loaded_modules.Remove(module_sp);
+ continue;
+ }
+
loaded_modules.AppendIfNeeded(module_sp);
new_modules.Append(module_sp);
}
@@ -544,6 +569,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() {
true /* notify */)) {
UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_interpreter_base,
false);
+ m_interpreter_module = module_sp;
return module_sp;
}
return nullptr;
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index a7fcdfbadeaf..61567801fdd0 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -81,6 +81,9 @@ class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader {
/// mapped to the address space
lldb::addr_t m_interpreter_base;
+ /// Contains the pointer to the interpret module, if loaded.
+ std::weak_ptr<lldb_private::Module> m_interpreter_module;
+
/// Loaded module list. (link map for each module)
std::map<lldb::ModuleWP, lldb::addr_t, std::owner_less<lldb::ModuleWP>>
m_loaded_modules;
@@ -95,6 +98,9 @@ class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader {
void *baton, lldb_private::StoppointCallbackContext *context,
lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+ /// Indicates whether the initial set of modules was reported added.
+ bool m_initial_modules_added;
+
/// Helper method for RendezvousBreakpointHit. Updates LLDB's current set
/// of loaded modules.
void RefreshModules();
diff --git a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
index e6abab848e12..163093c2ab1f 100644
--- a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -485,9 +485,6 @@ Status NativeProcessFreeBSD::Kill() {
Status NativeProcessFreeBSD::GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
- // TODO: figure out why it breaks stuff
- return Status("currently breaks determining module list");
-
if (m_supports_mem_region == LazyBool::eLazyBoolNo) {
// We're done.
return Status("unsupported");
diff --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py b/lldb/test/API/api/multithreaded/TestMultithreaded.py
index c6c75de386fa..60c2c3b372cb 100644
--- a/lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -31,7 +31,6 @@ def setUp(self):
@skipIfNoSBHeaders
# clang-cl does not support throw or catch (llvm.org/pr24538)
@skipIfWindows
- @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48370')
def test_python_stop_hook(self):
"""Test that you can run a python command in a stop-hook when stdin is File based. """
self.build_and_test('driver.cpp test_stop-hook.cpp',
diff --git a/lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py b/lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
index 81c3798ebba7..4439607d91cf 100644
--- a/lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
+++ b/lldb/test/API/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
@@ -15,7 +15,6 @@ class TestBreakpointInGlobalConstructors(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
- @expectedFailureAll(oslist=["freebsd"], bugnumber='llvm.org/pr48373')
@expectedFailureNetBSD
def test(self):
self.build()
diff --git a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
index 36984b3d1666..61e64d44e794 100644
--- a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
+++ b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
@@ -23,7 +23,6 @@ def setUp(self):
'main.cpp',
'// Run here before printing memory regions')
- @expectedFailureAll(oslist=["freebsd"])
def test(self):
self.build()
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index c3b45c833d53..8a9b7187a716 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -843,7 +843,6 @@ def test_qMemoryRegionInfo_is_supported_debugserver(self):
self.qMemoryRegionInfo_is_supported()
@llgs_test
- @expectedFailureAll(oslist=["freebsd"])
def test_qMemoryRegionInfo_is_supported_llgs(self):
self.init_llgs_test()
self.build()
@@ -908,7 +907,6 @@ def test_qMemoryRegionInfo_reports_code_address_as_executable_debugserver(
self.qMemoryRegionInfo_reports_code_address_as_executable()
@skipIfWindows # No pty support to test any inferior output
- @expectedFailureAll(oslist=["freebsd"])
@llgs_test
def test_qMemoryRegionInfo_reports_code_address_as_executable_llgs(self):
self.init_llgs_test()
@@ -975,7 +973,6 @@ def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_debugserv
self.qMemoryRegionInfo_reports_stack_address_as_readable_writeable()
@skipIfWindows # No pty support to test any inferior output
- @expectedFailureAll(oslist=["freebsd"])
@llgs_test
def test_qMemoryRegionInfo_reports_stack_address_as_readable_writeable_llgs(
self):
@@ -1042,7 +1039,6 @@ def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_debugserve
self.qMemoryRegionInfo_reports_heap_address_as_readable_writeable()
@skipIfWindows # No pty support to test any inferior output
- @expectedFailureAll(oslist=["freebsd"])
@llgs_test
def test_qMemoryRegionInfo_reports_heap_address_as_readable_writeable_llgs(
self):
diff --git a/lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py b/lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
index 6cca0e6c50fa..902a17639d56 100644
--- a/lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
+++ b/lldb/test/API/tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py
@@ -120,7 +120,7 @@ def test_libraries_svr4_well_formed(self):
@llgs_test
@skipUnlessPlatform(["linux", "android", "freebsd", "netbsd"])
- @expectedFailureAll(oslist=["freebsd", "netbsd"])
+ @expectedFailureNetBSD
def test_libraries_svr4_load_addr(self):
self.setup_test()
self.libraries_svr4_has_correct_load_addr()
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 113922ef53b7..682b0e5332b1 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -3,7 +3,6 @@
# REQUIRES: target-x86_64
# UNSUPPORTED: system-windows
-# XFAIL: system-freebsd
# RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t
# RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
More information about the llvm-branch-commits
mailing list