[Lldb-commits] [lldb] [lldb] Preserve TargetSP in Platform module lookup (PR #186323)

Emre Kultursay via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 12 23:28:19 PDT 2026


https://github.com/emrekultursay created https://github.com/llvm/llvm-project/pull/186323

When `Platform::GetRemoteSharedModule` resolves a module specification by calling `GetModuleSpec` on the process, the target context (`TargetSP`) is lost. This happens because the underlying process plugin populates a new `ModuleSpec` object that does not inherit the target context.

This causes failures in subsequent symbol resolution steps. For example, when `ModuleList` relies on the `TargetSP` to query target-specific settings like `target.exec-search-paths` and `target.symbols-search-paths`, the lookup fails because `TargetSP` evaluates to null. This prevents LLDB from finding local unstripped libraries.

This commit fixes the issue by transferring the target context from the original `module_spec` over to the `resolved_module_spec` before proceeding with the lookup.

>From 02af4c22e61f48ba2374475395cbf6f410c42a1e Mon Sep 17 00:00:00 2001
From: Emre Kultursay <emrekultursay at google.com>
Date: Fri, 13 Mar 2026 06:08:32 +0000
Subject: [PATCH] [lldb] Preserve TargetSP in Platform module lookup

When Platform::GetRemoteSharedModule resolves a
module specification by calling GetModuleSpec on
the process, the target context (TargetSP) is
lost. This happens because the underlying process
plugin populates a new ModuleSpec object that does
not inherit the target context.

This causes failures in subsequent symbol
resolution steps. For example, when ModuleList
relies on the TargetSP to query target-specific
settings like target.exec-search-paths and
target.symbols-search-paths, the lookup fails
because TargetSP evaluates to null. This prevents
LLDB from finding local unstripped libraries.

This commit fixes the issue by transferring the
target context from the original module_spec over
to the resolved_module_spec before proceeding with
the lookup.
---
 lldb/source/Target/Platform.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index c47ef47b0f60c..181adcaac00c0 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1525,6 +1525,10 @@ Status Platform::GetRemoteSharedModule(const ModuleSpec &module_spec,
     resolved_module_spec.GetUUID() = module_spec.GetUUID();
   }
 
+  // Retain the target context from the original module_spec since
+  // process->GetModuleSpec might have cleared it.
+  resolved_module_spec.SetTarget(module_spec.GetTargetSP());
+
   // Call locate module callback if set. This allows users to implement their
   // own module cache system. For example, to leverage build system artifacts,
   // to bypass pulling files from remote platform, or to search symbol files



More information about the lldb-commits mailing list