llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (rchamala)

<details>
<summary>Changes</summary>

Reland of #<!-- -->181334, which was reverted because it caused the quit_speed 
test to time out.

## What changed from the original PR

**Performance fix:** The original design used a `FindModule` helper that 
iterated over all targets and all modules per target (O(targets) * O(modules)) 
to find which target a given module belonged to. This was needed because the 
other 3 SymbolLocator callbacks only receive a `ModuleSpec`, not a `Target`. 
This expensive lookup caused the `quit_speed` test to time out. The new design 
eliminates `FindModule` entirely — since only `LocateSourceFile` is 
implemented, and it already receives a `TargetSP` directly, there is no need to 
search for the owning target.

**Reduced to a single callback:** The original PR implemented all 4 
SymbolLocator callbacks (`LocateExecutableObjectFile`, 
`LocateExecutableSymbolFile`, `DownloadObjectAndSymbolFile`, and 
`LocateSourceFile`). However, the `ScriptedSymbolLocator` is fundamentally 
per-target — users register a Python class on a specific target via `target 
symbols scripted register -C &lt;class&gt;`, and the implementation needs a 
`Target` to access the script interpreter and look up the registered class. The 
PluginManager's SymbolLocator system, on the other hand, registers global 
static callbacks — `LocateExecutableObjectFile`, `LocateExecutableSymbolFile`, 
and `DownloadObjectAndSymbolFile` receive a `ModuleSpec` but no `Target`, so 
there is no way to get to the per-target script interpreter or the user's 
registered Python class. Only `LocateSourceFile` receives a `TargetSP`, making 
it the only callback where a scripted per-target implementation is possible. 
The new design registers only `LocateSourceFile` and passes `nullptr` for the 
other 3

## What this PR adds

- A `ScriptedSymbolLocator` plugin that lets users write Python classes to 
remap source file paths during debugging
- Per-target registration via `target symbols scripted register -C 
&lt;class&gt;`
- Caching of resolved paths per (module UUID, source file) pair
- SB API support via `SBTarget::RegisterScriptedSymbolLocator`
- Base class template, example locator, and documentation

## Test plan

- `ninja lldb lldb-server lldb-dap` builds clean
- `check-lldb-api-functionalities-scripted_symbol_locator` passes
- `check-lldb-api-driver-quit_speed` (previously timing out) passes
- Full `check-lldb` suite: 32,917 passed, 0 failures

---

Patch is 77.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/182336.diff


47 Files Affected:

- (modified) lldb/bindings/python/CMakeLists.txt (+1) 
- (modified) lldb/bindings/python/python-wrapper.swig (+26) 
- (modified) lldb/docs/CMakeLists.txt (+1) 
- (modified) lldb/docs/python_extensions.rst (+7) 
- (modified) lldb/docs/use/python-reference.rst (+1) 
- (added) lldb/docs/use/tutorials/custom-symbol-resolution.md (+146) 
- (added) lldb/examples/python/templates/scripted_symbol_locator.py (+132) 
- (modified) lldb/include/lldb/API/SBFileSpec.h (+5) 
- (modified) lldb/include/lldb/API/SBModule.h (+1) 
- (modified) lldb/include/lldb/API/SBTarget.h (+16) 
- (modified) lldb/include/lldb/Core/PluginManager.h (+5) 
- (added) 
lldb/include/lldb/Interpreter/Interfaces/ScriptedSymbolLocatorInterface.h (+37) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+13) 
- (modified) lldb/include/lldb/Symbol/LineEntry.h (+1-1) 
- (modified) lldb/include/lldb/Target/Target.h (+22) 
- (modified) lldb/include/lldb/lldb-forward.h (+3) 
- (modified) lldb/include/lldb/lldb-private-interfaces.h (+3) 
- (modified) lldb/source/API/SBTarget.cpp (+30) 
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+130) 
- (modified) lldb/source/Core/Module.cpp (+1-1) 
- (modified) lldb/source/Core/PluginManager.cpp (+21-2) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+12) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+1-2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp
 (+5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h
 (+1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 (+29) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 (+30) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedSymbolLocatorPythonInterface.cpp
 (+76) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedSymbolLocatorPythonInterface.h
 (+58) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (+5) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h (+3) 
- (modified) lldb/source/Plugins/SymbolLocator/CMakeLists.txt (+1) 
- (modified) 
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp (+1-1) 
- (added) lldb/source/Plugins/SymbolLocator/Scripted/CMakeLists.txt (+13) 
- (added) lldb/source/Plugins/SymbolLocator/Scripted/SymbolLocatorScripted.cpp 
(+76) 
- (added) lldb/source/Plugins/SymbolLocator/Scripted/SymbolLocatorScripted.h 
(+40) 
- (modified) lldb/source/Symbol/LineEntry.cpp (+22-1) 
- (modified) lldb/source/Target/StackFrame.cpp (+1-1) 
- (modified) lldb/source/Target/StackFrameList.cpp (+2-1) 
- (modified) lldb/source/Target/Target.cpp (+88) 
- (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+2-2) 
- (added) lldb/test/API/functionalities/scripted_symbol_locator/Makefile (+9) 
- (added) 
lldb/test/API/functionalities/scripted_symbol_locator/TestScriptedSymbolLocator.py
 (+193) 
- (added) lldb/test/API/functionalities/scripted_symbol_locator/main.c (+5) 
- (added) 
lldb/test/API/functionalities/scripted_symbol_locator/source_locator.py (+44) 
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (+10) 


``````````diff
diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 2ebcf5a8e7aca..058b3ceb9b038 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -116,6 +116,7 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
     "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py"
     "${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py"
     "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_thread_plan.py"
+    "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_symbol_locator.py"
     )
 
   if(APPLE)
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index bf59569920470..7e0db42f8f65d 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -595,6 +595,32 @@ void 
*lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFrameList(PyObject *d
   return sb_ptr;
 }
 
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBFileSpec(PyObject *
+                                                                    data) {
+  lldb::SBFileSpec *sb_ptr = NULL;
+
+  int valid_cast = SWIG_ConvertPtr(data, (void **)&sb_ptr,
+                                   SWIGTYPE_p_lldb__SBFileSpec, 0);
+
+  if (valid_cast == -1)
+    return NULL;
+
+  return sb_ptr;
+}
+
+void *lldb_private::python::LLDBSWIGPython_CastPyObjectToSBModule(PyObject *
+                                                                   data) {
+  lldb::SBModule *sb_ptr = NULL;
+
+  int valid_cast = SWIG_ConvertPtr(data, (void **)&sb_ptr,
+                                   SWIGTYPE_p_lldb__SBModule, 0);
+
+  if (valid_cast == -1)
+    return NULL;
+
+  return sb_ptr;
+}
+
 bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommand(
     const char *python_function_name, const char *session_dictionary_name,
     lldb::DebuggerSP debugger, const char *args,
diff --git a/lldb/docs/CMakeLists.txt b/lldb/docs/CMakeLists.txt
index bbecf606f1f8f..51fe9635cc4a3 100644
--- a/lldb/docs/CMakeLists.txt
+++ b/lldb/docs/CMakeLists.txt
@@ -33,6 +33,7 @@ if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
       COMMAND "${CMAKE_COMMAND}" -E copy 
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
       COMMAND "${CMAKE_COMMAND}" -E copy 
"${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
       COMMAND "${CMAKE_COMMAND}" -E copy 
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_thread_plan.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
+      COMMAND "${CMAKE_COMMAND}" -E copy 
"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_symbol_locator.py" 
"${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
       COMMENT "Copying lldb.py to pretend its a Python package.")
 
     add_dependencies(lldb-python-doc-package swig_wrapper_python)
diff --git a/lldb/docs/python_extensions.rst b/lldb/docs/python_extensions.rst
index 8420187efcdcc..f42681281b8e2 100644
--- a/lldb/docs/python_extensions.rst
+++ b/lldb/docs/python_extensions.rst
@@ -45,3 +45,10 @@ Scripted Thread Plan Plugins
     :no-heading:
     :no-inheritance-diagram:
 
+Scripted Symbol Locator Plugins
+-------------------------------
+
+.. automodapi:: lldb.plugins.scripted_symbol_locator
+    :no-heading:
+    :skip: ABCMeta, LocalCacheSymbolLocator
+    :no-inheritance-diagram:
diff --git a/lldb/docs/use/python-reference.rst 
b/lldb/docs/use/python-reference.rst
index afca07520d8ad..3e7d56f4a2096 100644
--- a/lldb/docs/use/python-reference.rst
+++ b/lldb/docs/use/python-reference.rst
@@ -28,3 +28,4 @@ The following tutorials and documentation demonstrate various 
Python capabilitie
    tutorials/implementing-standalone-scripts
    tutorials/custom-frame-recognizers
    tutorials/extending-target-stop-hooks
+   tutorials/custom-symbol-resolution
diff --git a/lldb/docs/use/tutorials/custom-symbol-resolution.md 
b/lldb/docs/use/tutorials/custom-symbol-resolution.md
new file mode 100644
index 0000000000000..6097ea73f7a4a
--- /dev/null
+++ b/lldb/docs/use/tutorials/custom-symbol-resolution.md
@@ -0,0 +1,146 @@
+# Finding Symbols With a Scripted Symbol Locator
+
+The **Scripted Symbol Locator** lets you write a Python class that tells LLDB
+where to find source files for your debug targets. This is useful when your
+build artifacts live in a custom location, such as a symbol server or a local
+build-ID-indexed cache.
+
+## Quick Start
+
+1. **Write a locator class.** Create a Python file (e.g., `my_locator.py`)
+   with a class that implements the methods you need:
+
+   ```python
+   import os
+   import lldb
+   from lldb.plugins.scripted_symbol_locator import ScriptedSymbolLocator
+
+   class MyLocator(ScriptedSymbolLocator):
+       def __init__(self, exe_ctx, args):
+           super().__init__(exe_ctx, args)
+           self.cache_dir = None
+           if self.args and self.args.IsValid():
+               d = self.args.GetValueForKey("cache_dir")
+               if d and d.IsValid():
+                   self.cache_dir = d.GetStringValue(4096)
+
+       def locate_source_file(self, module, original_source_file):
+           """Return the resolved file spec, or None to fall through."""
+           if not self.cache_dir:
+               return None
+           uuid = module.GetUUIDString()
+           basename = os.path.basename(original_source_file)
+           candidate = os.path.join(self.cache_dir, uuid, "src", basename)
+           if os.path.exists(candidate):
+               return lldb.SBFileSpec(candidate, True)
+           return None
+   ```
+
+2. **Import the script and register the locator on a target:**
+
+   ```
+   (lldb) command script import /path/to/my_locator.py
+   (lldb) target symbols scripted register \
+              -C my_locator.MyLocator \
+              -k cache_dir -v /path/to/cache
+   ```
+
+3. **Debug normally.** When LLDB resolves source files for that target,
+   your `locate_source_file` method will be called automatically.
+
+## Available Methods
+
+Your locator class must implement `__init__` and `locate_source_file`.
+
+| Method | Called When |
+|--------|------------|
+| `locate_source_file(module, path)` | LLDB resolves a source file path in 
debug info |
+
+### Method Signatures
+
+```python
+def __init__(self, exe_ctx: lldb.SBExecutionContext,
+             args: lldb.SBStructuredData) -> None:
+    ...
+
+def locate_source_file(self, module: lldb.SBModule,
+                       original_source_file: str) -> Optional[lldb.SBFileSpec]:
+    ...
+```
+
+## Per-Target Registration
+
+The scripted symbol locator is registered **per target**. Different targets
+can use different locator classes or different arguments.
+
+```
+(lldb) target select 0
+(lldb) target symbols scripted register -C my_locator.MyLocator \
+           -k cache_dir -v /cache/project-a
+
+(lldb) target select 1
+(lldb) target symbols scripted register -C my_locator.MyLocator \
+           -k cache_dir -v /cache/project-b
+```
+
+### Commands
+
+| Command | Description |
+|---------|-------------|
+| `target symbols scripted register -C <class> [-k <key> -v <value> ...]` | 
Register a locator |
+| `target symbols scripted clear` | Remove the locator from the current target 
|
+| `target symbols scripted info` | Show the current locator class |
+
+### SB API
+
+You can also register locators programmatically:
+
+```python
+import lldb
+
+error = target.RegisterScriptedSymbolLocator(
+    "my_locator.MyLocator", args)
+# args is an SBStructuredData dictionary
+
+target.ClearScriptedSymbolLocator()
+```
+
+## Caching
+
+Source file resolutions are cached per `(module UUID, source file path)` pair
+within each target. The cache is cleared when:
+
+- A new locator is registered (via `register`)
+- The locator is cleared (via `clear`)
+
+This means your `locate_source_file` method is called at most once per
+unique `(UUID, path)` combination.
+
+## Base Class Template
+
+LLDB ships a base class template at `lldb.plugins.scripted_symbol_locator`.
+You can import and subclass it:
+
+```python
+from lldb.plugins.scripted_symbol_locator import ScriptedSymbolLocator
+
+class MyLocator(ScriptedSymbolLocator):
+    def __init__(self, exe_ctx, args):
+        super().__init__(exe_ctx, args)
+
+    def locate_source_file(self, module, original_source_file):
+        # Your implementation here
+        return None
+```
+
+The base class handles extracting the target and args from the execution
+context. See `lldb/examples/python/templates/scripted_symbol_locator.py`
+for the full template with docstrings.
+
+## Listing Scripting Extensions
+
+To see all registered scripting extensions (including symbol locators):
+
+```
+(lldb) scripting extension list
+```
diff --git a/lldb/examples/python/templates/scripted_symbol_locator.py 
b/lldb/examples/python/templates/scripted_symbol_locator.py
new file mode 100644
index 0000000000000..0ed2d9b9dde00
--- /dev/null
+++ b/lldb/examples/python/templates/scripted_symbol_locator.py
@@ -0,0 +1,132 @@
+from abc import ABCMeta, abstractmethod
+import os
+
+import lldb
+
+
+class ScriptedSymbolLocator(metaclass=ABCMeta):
+    """
+    The base class for a scripted symbol locator.
+
+    Most of the base class methods are optional and return ``None`` to fall
+    through to LLDB's default resolution. Override only the methods you need.
+
+    Configuration::
+
+        (lldb) command script import /path/to/my_locator.py
+        (lldb) target symbols scripted register -C my_locator.MyLocator \\
+                   [-k key -v value ...]
+    """
+
+    @abstractmethod
+    def __init__(self, exe_ctx, args):
+        """Construct a scripted symbol locator.
+
+        Args:
+            exe_ctx (lldb.SBExecutionContext): The execution context for
+                the scripted symbol locator.
+            args (lldb.SBStructuredData): A Dictionary holding arbitrary
+                key/value pairs used by the scripted symbol locator.
+        """
+        target = None
+        self.target = None
+        self.args = None
+        if isinstance(exe_ctx, lldb.SBExecutionContext):
+            target = exe_ctx.target
+        if isinstance(target, lldb.SBTarget) and target.IsValid():
+            self.target = target
+            self.dbg = target.GetDebugger()
+        if isinstance(args, lldb.SBStructuredData) and args.IsValid():
+            self.args = args
+
+    def locate_source_file(self, module, original_source_file):
+        """Locate the source file for a given module.
+
+        Called when LLDB resolves source file paths during stack frame
+        display, breakpoint resolution, or source listing. This is the
+        primary method for implementing source file remapping based on
+        build IDs.
+
+        The module is a fully loaded ``SBModule`` (not an ``SBModuleSpec``),
+        so you can access its UUID, file path, platform file path,
+        symbol file path, sections, and symbols.
+
+        Results are cached per (module UUID, source file) pair, so this
+        method is called at most once per unique combination.
+
+        Args:
+            module (lldb.SBModule): The loaded module containing debug
+                info. Use ``module.GetUUIDString()`` to get the build ID
+                for looking up the correct source revision.
+            original_source_file (str): The original source file path
+                as recorded in the debug info.
+
+        Returns:
+            lldb.SBFileSpec: The resolved file spec, or None to fall
+                through to LLDB's default source resolution.
+        """
+        return None
+
+
+class LocalCacheSymbolLocator(ScriptedSymbolLocator):
+    """Example locator that resolves source files from a local cache directory.
+
+    Demonstrates how to subclass ``ScriptedSymbolLocator`` to implement
+    custom source file resolution. This locator looks up source files
+    in a local directory structure organized by build ID (UUID)::
+
+        <cache_dir>/
+            <uuid>/
+                src/
+                    main.cpp
+                    ...
+
+    Usage::
+
+        (lldb) command script import scripted_symbol_locator
+        (lldb) target symbols scripted register \\
+                   -C scripted_symbol_locator.LocalCacheSymbolLocator \\
+                   -k cache_dir -v "/path/to/cache"
+        (lldb) target create --core /path/to/minidump.dmp
+        (lldb) bt
+
+    The locator searches for:
+      - Source files:   ``<cache_dir>/<uuid>/src/<basename>``
+    """
+
+    cache_dir = None
+
+    def __init__(self, exe_ctx, args):
+        super().__init__(exe_ctx, args)
+
+        # Allow cache_dir to be set via structured data args.
+        if self.args:
+            cache_dir_val = self.args.GetValueForKey("cache_dir")
+            if cache_dir_val and cache_dir_val.IsValid():
+                val = cache_dir_val.GetStringValue(256)
+                if val:
+                    LocalCacheSymbolLocator.cache_dir = val
+
+    def _get_cache_path(self, uuid_str, *components):
+        """Build a path under the cache directory for a given UUID.
+
+        Args:
+            uuid_str (str): The module's UUID string.
+            *components: Additional path components (e.g., filename).
+
+        Returns:
+            str: The full path, or None if cache_dir is not set or the
+                UUID is empty.
+        """
+        if not self.cache_dir or not uuid_str:
+            return None
+        return os.path.join(self.cache_dir, uuid_str, *components)
+
+    def locate_source_file(self, module, original_source_file):
+        """Look up source files under ``<cache_dir>/<uuid>/src/``."""
+        uuid_str = module.GetUUIDString()
+        basename = os.path.basename(original_source_file)
+        path = self._get_cache_path(uuid_str, "src", basename)
+        if path and os.path.exists(path):
+            return lldb.SBFileSpec(path, True)
+        return None
diff --git a/lldb/include/lldb/API/SBFileSpec.h 
b/lldb/include/lldb/API/SBFileSpec.h
index 36641843aabeb..4b0b640dd4dbc 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -11,6 +11,10 @@
 
 #include "lldb/API/SBDefines.h"
 
+namespace lldb_private {
+class ScriptInterpreter;
+}
+
 namespace lldb {
 
 class LLDB_API SBFileSpec {
@@ -79,6 +83,7 @@ class LLDB_API SBFileSpec {
   friend class SBThread;
   friend class SBTrace;
   friend class SBSaveCoreOptions;
+  friend class lldb_private::ScriptInterpreter;
 
   SBFileSpec(const lldb_private::FileSpec &fspec);
 
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 4009ca1461e51..3e8e5b99f6404 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -311,6 +311,7 @@ class LLDB_API SBModule {
   friend class SBType;
 
   friend class lldb_private::python::SWIGBridge;
+  friend class lldb_private::ScriptInterpreter;
 
   explicit SBModule(const lldb::ModuleSP &module_sp);
 
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 93b3aab578f42..80e9d381c377c 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -994,6 +994,22 @@ class LLDB_API SBTarget {
   ///     An error if a Trace already exists or the trace couldn't be created.
   lldb::SBTrace CreateTrace(SBError &error);
 
+  /// Register a scripted symbol locator for this target.
+  ///
+  /// \param[in] class_name
+  ///     The Python class implementing the symbol locator.
+  ///
+  /// \param[in] args
+  ///     Optional structured data arguments passed to the locator.
+  ///
+  /// \return
+  ///     An SBError indicating success or failure.
+  lldb::SBError RegisterScriptedSymbolLocator(const char *class_name,
+                                              lldb::SBStructuredData &args);
+
+  /// Clear the scripted symbol locator for this target.
+  void ClearScriptedSymbolLocator();
+
   lldb::SBMutex GetAPIMutex() const;
 
   /// Register a scripted frame provider for this target.
diff --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 4d116f52460ff..37d672762058d 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -455,6 +455,7 @@ class PluginManager {
       SymbolLocatorDownloadObjectAndSymbolFile download_object_symbol_file =
           nullptr,
       SymbolLocatorFindSymbolFileInBundle find_symbol_file_in_bundle = nullptr,
+      SymbolLocatorLocateSourceFile locate_source_file = nullptr,
       DebuggerInitializeCallback debugger_init_callback = nullptr);
 
   static bool UnregisterPlugin(SymbolLocatorCreateInstance create_callback);
@@ -479,6 +480,10 @@ class PluginManager {
                                          const UUID *uuid,
                                          const ArchSpec *arch);
 
+  static FileSpec LocateSourceFile(const lldb::TargetSP &target_sp,
+                                   const lldb::ModuleSP &module_sp,
+                                   const FileSpec &original_source_file);
+
   // Trace
   static bool RegisterPlugin(
       llvm::StringRef name, llvm::StringRef description,
diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedSymbolLocatorInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedSymbolLocatorInterface.h
new file mode 100644
index 0000000000000..ceee28082f3e2
--- /dev/null
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedSymbolLocatorInterface.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDSYMBOLLOCATORINTERFACE_H
+#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDSYMBOLLOCATORINTERFACE_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/Interfaces/ScriptedInterface.h"
+#include "lldb/Utility/Status.h"
+
+#include "lldb/lldb-private.h"
+
+#include <optional>
+#include <string>
+
+namespace lldb_private {
+class ScriptedSymbolLocatorInterface : virtual public ScriptedInterface {
+public:
+  virtual llvm::Expected<StructuredData::GenericSP>
+  CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
+                     StructuredData::DictionarySP args_sp,
+                     StructuredData::Generic *script_obj = nullptr) = 0;
+
+  virtual std::optional<FileSpec>
+  LocateSourceFile(const lldb::ModuleSP &module_sp,
+                   const FileSpec &original_source_file, Status &error) {
+    return {};
+  }
+};
+} // namespace lldb_private
+
+#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDSYMBOLLOCATORINTERFACE_H
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 557d73a415452..fc6f7192d3135 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -16,9 +16,11 @@
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBEvent.h"
 #include "lldb/API/SBExecutionContext.h"
+#include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFrameList.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBMemoryRegionInfo.h"
+#include "lldb/API/SBModule.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBSymbolContext.h"
 #include "lldb/API/SBThread.h"
@@ -33,6 +35,7 @@
 #include "lldb/Interpreter/Interfaces/ScriptedFrameProviderInterface.h"
 #include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h"
 #include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
+#include "lldb/Interpreter/Interfaces/ScriptedSymbolLocatorInterface.h"
 #include "lldb/Interpreter/Interfaces/ScriptedThreadInterface.h"
 #include "lldb/Interpreter/ScriptObject.h"
 #include "lldb/Symbol/SymbolContext.h"
@@ -545,6 +548,11 @@ class ScriptInterpreter : public PluginInterface {
     return {};
   }
 
+  virtual lldb::ScriptedSymbolLocatorInterfaceSP
+  CreateScriptedSymbolLocatorInterface() {
+    return {};
+  }
+
   virtual lldb::ScriptedThreadPlanInterfaceSP
   CreateScriptedThreadPlanInterface() {
     return {};
@...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/182336
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to