[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala edited 
https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala edited 
https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala updated 
https://github.com/llvm/llvm-project/pull/120833

>From d8f99abee76a3d74d6c5c4904304f77cb2142087 Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Thu, 19 Dec 2024 20:56:21 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Call resolve source file
 callback

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

Updated LineEntry::ApplyFileMappings to call resolve source file callback if 
set.

include/lldb/Target/Platform.h, source/Target/Platform.cpp
Implemented SetResolveSourceFileCallback and GetResolveSourceFileCallback

include/lldb/Symbol/LineEntry.h, Source/Symbol/LineEntry.cpp
Implemented CallResolveSourceFileCallbackIfSet

Source/Target/StackFrame.cpp
Source/Target/StackFrameList.cpp
Source/Target/ThreadPlanStepRange.cpp
Updated the caller  to ApplyFileMappings


unittests/Symbol/TestLineEntry.cpp
Added comprehensive ResolveSourceFileCallback tests.

Test Plan:
Added unittests for LineEntry.

```
ninja check-lldb-unit
```
---
 lldb/include/lldb/Symbol/LineEntry.h  |   5 +-
 lldb/include/lldb/Target/Platform.h   |  19 ++
 lldb/source/Symbol/LineEntry.cpp  |  37 +++-
 lldb/source/Target/Platform.cpp   |  55 ++
 lldb/source/Target/StackFrame.cpp |   2 +-
 lldb/source/Target/StackFrameList.cpp |   3 +-
 lldb/source/Target/ThreadPlanStepRange.cpp|   7 +-
 lldb/unittests/Symbol/CMakeLists.txt  |   2 +
 .../Symbol/Inputs/inlined-functions.cpp   |  22 +++
 lldb/unittests/Symbol/TestLineEntry.cpp   | 164 +-
 10 files changed, 302 insertions(+), 14 deletions(-)
 create mode 100644 lldb/unittests/Symbol/Inputs/inlined-functions.cpp

diff --git a/lldb/include/lldb/Symbol/LineEntry.h 
b/lldb/include/lldb/Symbol/LineEntry.h
index 8da59cf0bd24aa..9fc334ed87fdab 100644
--- a/lldb/include/lldb/Symbol/LineEntry.h
+++ b/lldb/include/lldb/Symbol/LineEntry.h
@@ -128,7 +128,10 @@ struct LineEntry {
   ///
   /// \param[in] target_sp
   /// Shared pointer to the target this LineEntry belongs to.
-  void ApplyFileMappings(lldb::TargetSP target_sp);
+  ///
+  /// \param[in] module_sp
+  /// Shared pointer to the module this LineEntry belongs to.
+  void ApplyFileMappings(lldb::TargetSP target_sp, lldb::ModuleSP module_sp);
 
   /// Helper to access the file.
   const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); }
diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index a702abb540fd93..3265d0d2145dd6 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -316,6 +316,12 @@ class Platform : public PluginInterface {
   virtual bool GetModuleSpec(const FileSpec &module_file_spec,
  const ArchSpec &arch, ModuleSpec &module_spec);
 
+  void
+  CallResolveSourceFileCallbackIfSet(const lldb::ModuleSP &module_sp,
+ const FileSpec &original_source_file_spec,
+ FileSpec &resolved_source_file_spec,
+ bool *did_create_ptr);
+
   virtual Status ConnectRemote(Args &args);
 
   virtual Status DisconnectRemote();
@@ -967,6 +973,11 @@ class Platform : public PluginInterface {
FileSpec &symbol_file_spec)>
   LocateModuleCallback;
 
+  typedef std::function
+  ResolveSourceFileCallback;
+
   /// Set locate module callback. This allows users to implement their own
   /// module cache system. For example, to leverage artifacts of build system,
   /// to bypass pulling files from remote platform, or to search symbol files
@@ -975,6 +986,13 @@ class Platform : public PluginInterface {
 
   LocateModuleCallback GetLocateModuleCallback() const;
 
+  /// Set resolve source file callback. This allows users to implement their 
own
+  /// source file cache system. For example, to search source files from source
+  /// servers.
+  void SetResolveSourceFileCallback(ResolveSourceFileCallback callback);
+
+  ResolveSourceFileCallback GetResolveSourceFileCallback() const;
+
 protected:
   /// Create a list of ArchSpecs with the given OS and a architectures. The
   /// vendor field is left as an "unspecified unknown".
@@ -1022,6 +1040,7 @@ class Platform : public PluginInterface {
   bool m_calculated_trap_handlers;
   const std::unique_ptr m_module_cache;
   LocateModuleCallback m_locate_module_callback;
+  ResolveSourceFileCallback m_resolve_source_file_callback;
 
   /// Ask the Platform subclass to fill in the list of trap handler names
   ///
diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp
index c941a6927cb93f..1a966cc1c8387d 100644
--- a/lldb/source/Symbol/LineEntry.cpp
+++ b/lldb/source/Symbol/LineEntry.cpp
@@ -7,7 +7,10 @@
 
//===--===//
 
 #include "lldb/Symbol/LineEntry.h"
+#include "lldb

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala updated 
https://github.com/llvm/llvm-project/pull/120834

>From 126ba755d58aa74c6d0c5727ec08593cfcfb57ee Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Fri, 20 Dec 2024 15:55:36 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Implement API, Python
 interface

Summary:
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580

Use SWIG for the resolve source file callback the same as other Python 
callbacks. TestResolveSourceFileCallback.py verifies the functionalities.

Test Plan:
Added shell tests for validation

```
./llvm-lit -sv TestResolveSourceFileCallback.py
```

Differential Revision: https://phabricator.intern.facebook.com/D67541203
---
 lldb/bindings/python/python-typemaps.swig |  44 
 lldb/bindings/python/python-wrapper.swig  |  49 -
 lldb/include/lldb/API/SBDefines.h |   5 +
 lldb/include/lldb/API/SBPlatform.h|   3 +
 lldb/source/API/SBPlatform.cpp|  37 
 .../TestResolveSourceFileCallback.py  | 196 ++
 lldb/test/API/python_api/sbplatform/test.exe  | Bin 0 -> 21704 bytes
 .../API/python_api/sbplatform/test_new.cpp|  15 ++
 8 files changed, 347 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/test/API/python_api/sbplatform/TestResolveSourceFileCallback.py
 create mode 100755 lldb/test/API/python_api/sbplatform/test.exe
 create mode 100644 lldb/test/API/python_api/sbplatform/test_new.cpp

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index f8c33e15c03e66..84d26986104d31 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -713,3 +713,47 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBPlatformResolveSourceFileCallback
+%typemap(in) (lldb::SBPlatformResolveSourceFileCallback callback, void 
*callback_baton) {
+  if (!($input == Py_None ||
+   PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+   }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+  llvm::Expected arg_info = callable.GetArgInfo();
+  if (!arg_info) {
+PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());
+  SWIG_fail;
+  }
+
+  if (arg_info.get().max_positional_args != 3) {
+PyErr_SetString(PyExc_TypeError, "Expected 3 argument callable object");
+SWIG_fail;
+  }
+
+Py_INCREF($input);
+
+$1 = LLDBSwigPythonCallResolveSourceFileCallback;
+$2 = $input;
+  }
+}
+
+%typemap(typecheck) (lldb::SBPlatformResolveSourceFileCallback callback,
+ void *callback_baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index b72a462d04643b..fb0b0368914fbf 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -727,7 +727,7 @@ 
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionFo
 dict_sp->AddBooleanItem("no-completion", true);
 return dict_sp;
   }
-
+
 
   // Convert the return dictionary to a DictionarySP.
   StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
@@ -753,7 +753,7 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
   auto pfunc = self.ResolveName("__call__");
 
   if (!pfunc.IsAllocated()) {
-cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class"); 
+cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class");
 return false;
   }
 
@@ -1095,4 +1095,49 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+static SBError LLDBSwigPythonCallResolveSourceFileCallback(
+void *callback_baton,
+ const lldb::ModuleSP &module_sp,
+const SBFileSpec &original_source_file_spec_sb,
+SBFileSpec &resolved_source_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject module_sb_arg = SWIGBridge::ToSWIGWrapper(module_sp);
+  PythonObject original_source_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(original_source_file_spec_sb));
+  PythonObject resolved_source_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(resolved_source_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (rchamala)


Changes

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

Updated LineEntry::ApplyFileMappings to call resolve source file callback if 
set.

include/lldb/Target/Platform.h, source/Target/Platform.cpp Implemented 
SetResolveSourceFileCallback and GetResolveSourceFileCallback

include/lldb/Symbol/LineEntry.h, Source/Symbol/LineEntry.cpp Implemented 
CallResolveSourceFileCallbackIfSet

Source/Target/StackFrame.cpp
Source/Target/StackFrameList.cpp
Source/Target/ThreadPlanStepRange.cpp
Updated the caller  to ApplyFileMappings


unittests/Symbol/TestLineEntry.cpp
Added comprehensive ResolveSourceFileCallback tests.

Test Plan:
Added unittests for LineEntry.

```
ninja check-lldb-unit
```

---
Full diff: https://github.com/llvm/llvm-project/pull/120833.diff


10 Files Affected:

- (modified) lldb/include/lldb/Symbol/LineEntry.h (+4-1) 
- (modified) lldb/include/lldb/Target/Platform.h (+19) 
- (modified) lldb/source/Symbol/LineEntry.cpp (+30-7) 
- (modified) lldb/source/Target/Platform.cpp (+55) 
- (modified) lldb/source/Target/StackFrame.cpp (+1-1) 
- (modified) lldb/source/Target/StackFrameList.cpp (+2-1) 
- (modified) lldb/source/Target/ThreadPlanStepRange.cpp (+5-2) 
- (modified) lldb/unittests/Symbol/CMakeLists.txt (+2) 
- (added) lldb/unittests/Symbol/Inputs/inlined-functions.cpp (+22) 
- (modified) lldb/unittests/Symbol/TestLineEntry.cpp (+162-2) 


``diff
diff --git a/lldb/include/lldb/Symbol/LineEntry.h 
b/lldb/include/lldb/Symbol/LineEntry.h
index 8da59cf0bd24aa..9fc334ed87fdab 100644
--- a/lldb/include/lldb/Symbol/LineEntry.h
+++ b/lldb/include/lldb/Symbol/LineEntry.h
@@ -128,7 +128,10 @@ struct LineEntry {
   ///
   /// \param[in] target_sp
   /// Shared pointer to the target this LineEntry belongs to.
-  void ApplyFileMappings(lldb::TargetSP target_sp);
+  ///
+  /// \param[in] module_sp
+  /// Shared pointer to the module this LineEntry belongs to.
+  void ApplyFileMappings(lldb::TargetSP target_sp, lldb::ModuleSP module_sp);
 
   /// Helper to access the file.
   const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); }
diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index a702abb540fd93..3265d0d2145dd6 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -316,6 +316,12 @@ class Platform : public PluginInterface {
   virtual bool GetModuleSpec(const FileSpec &module_file_spec,
  const ArchSpec &arch, ModuleSpec &module_spec);
 
+  void
+  CallResolveSourceFileCallbackIfSet(const lldb::ModuleSP &module_sp,
+ const FileSpec &original_source_file_spec,
+ FileSpec &resolved_source_file_spec,
+ bool *did_create_ptr);
+
   virtual Status ConnectRemote(Args &args);
 
   virtual Status DisconnectRemote();
@@ -967,6 +973,11 @@ class Platform : public PluginInterface {
FileSpec &symbol_file_spec)>
   LocateModuleCallback;
 
+  typedef std::function
+  ResolveSourceFileCallback;
+
   /// Set locate module callback. This allows users to implement their own
   /// module cache system. For example, to leverage artifacts of build system,
   /// to bypass pulling files from remote platform, or to search symbol files
@@ -975,6 +986,13 @@ class Platform : public PluginInterface {
 
   LocateModuleCallback GetLocateModuleCallback() const;
 
+  /// Set resolve source file callback. This allows users to implement their 
own
+  /// source file cache system. For example, to search source files from source
+  /// servers.
+  void SetResolveSourceFileCallback(ResolveSourceFileCallback callback);
+
+  ResolveSourceFileCallback GetResolveSourceFileCallback() const;
+
 protected:
   /// Create a list of ArchSpecs with the given OS and a architectures. The
   /// vendor field is left as an "unspecified unknown".
@@ -1022,6 +1040,7 @@ class Platform : public PluginInterface {
   bool m_calculated_trap_handlers;
   const std::unique_ptr m_module_cache;
   LocateModuleCallback m_locate_module_callback;
+  ResolveSourceFileCallback m_resolve_source_file_callback;
 
   /// Ask the Platform subclass to fill in the list of trap handler names
   ///
diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp
index c941a6927cb93f..1a966cc1c8387d 100644
--- a/lldb/source/Symbol/LineEntry.cpp
+++ b/lldb/source/Symbol/LineEntry.cpp
@@ -7,7 +7,10 @@
 
//===--===//
 
 #include "lldb/Symbol/LineEntry.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
@@ -241,13 +244,33 @@ AddressRange LineEntry::G

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (rchamala)


Changes

Summary:
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580

Use SWIG for the resolve source file callback the same as other Python 
callbacks. TestResolveSourceFileCallback.py verifies the functionalities.

Test Plan:
Added shell tests for validation

```
./llvm-lit -sv TestResolveSourceFileCallback.py
```

Differential Revision: https://phabricator.intern.facebook.com/D67541203

---
Full diff: https://github.com/llvm/llvm-project/pull/120834.diff


8 Files Affected:

- (modified) lldb/bindings/python/python-typemaps.swig (+44) 
- (modified) lldb/bindings/python/python-wrapper.swig (+47-2) 
- (modified) lldb/include/lldb/API/SBDefines.h (+5) 
- (modified) lldb/include/lldb/API/SBPlatform.h (+3) 
- (modified) lldb/source/API/SBPlatform.cpp (+37) 
- (added) lldb/test/API/python_api/sbplatform/TestResolveSourceFileCallback.py 
(+196) 
- (added) lldb/test/API/python_api/sbplatform/test.exe () 
- (added) lldb/test/API/python_api/sbplatform/test_new.cpp (+15) 


``diff
diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index f8c33e15c03e66..84d26986104d31 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -713,3 +713,47 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBPlatformResolveSourceFileCallback
+%typemap(in) (lldb::SBPlatformResolveSourceFileCallback callback, void 
*callback_baton) {
+  if (!($input == Py_None ||
+   PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+   }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+  llvm::Expected arg_info = callable.GetArgInfo();
+  if (!arg_info) {
+PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());
+  SWIG_fail;
+  }
+
+  if (arg_info.get().max_positional_args != 3) {
+PyErr_SetString(PyExc_TypeError, "Expected 3 argument callable object");
+SWIG_fail;
+  }
+
+Py_INCREF($input);
+
+$1 = LLDBSwigPythonCallResolveSourceFileCallback;
+$2 = $input;
+  }
+}
+
+%typemap(typecheck) (lldb::SBPlatformResolveSourceFileCallback callback,
+ void *callback_baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index b72a462d04643b..fb0b0368914fbf 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -727,7 +727,7 @@ 
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionFo
 dict_sp->AddBooleanItem("no-completion", true);
 return dict_sp;
   }
-
+
 
   // Convert the return dictionary to a DictionarySP.
   StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
@@ -753,7 +753,7 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
   auto pfunc = self.ResolveName("__call__");
 
   if (!pfunc.IsAllocated()) {
-cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class"); 
+cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class");
 return false;
   }
 
@@ -1095,4 +1095,49 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+static SBError LLDBSwigPythonCallResolveSourceFileCallback(
+void *callback_baton,
+ const lldb::ModuleSP &module_sp,
+const SBFileSpec &original_source_file_spec_sb,
+SBFileSpec &resolved_source_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject module_sb_arg = SWIGBridge::ToSWIGWrapper(module_sp);
+  PythonObject original_source_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(original_source_file_spec_sb));
+  PythonObject resolved_source_file_spec_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(resolved_source_file_spec_sb));
+
+  PythonCallable callable =
+  Retain(reinterpret_cast(callback_baton));
+  if (!callable.IsValid()) {
+return SBError("The callback callable is not valid.");
+  }
+
+  PythonObject result = callable(module_sb_arg, original_source_file_spec_arg,
+ resolved_source_file_spec_arg);
+
+  if (!result.IsAllocated())
+return SBError("No result.");
+  lldb::SBError *sb_error_ptr = nullptr;
+  if (SWIG_C

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (rchamala)


Changes

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

SBFileSpec and SBModule will be used for resolve source file callback as Python 
function arguments. This diff allows these things.

Can be instantiated from SBPlatform.
Can be passed to/from Python.

Test Plan:
N/A. The next set of diffs in the stack have unittests and shell test validation

---
Full diff: https://github.com/llvm/llvm-project/pull/120832.diff


3 Files Affected:

- (modified) lldb/bindings/python/python-swigsafecast.swig (+5) 
- (modified) lldb/include/lldb/API/SBModule.h (+3) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+1) 


``diff
diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 7a4f7e81f1cc3b..429baad158ca5d 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -23,6 +23,11 @@ PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP 
process_sp) {
   SWIGTYPE_p_lldb__SBProcess);
 }
 
+PythonObject SWIGBridge::ToSWIGWrapper(lldb::ModuleSP module_sp) {
+  return ToSWIGHelper(new lldb::SBModule(std::move(module_sp)),
+  SWIGTYPE_p_lldb__SBModule);
+}
+
 PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
   return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)),
   SWIGTYPE_p_lldb__SBThreadPlan);
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 7200a1ef53fd82..85332066ee6875 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -301,9 +301,12 @@ class LLDB_API SBModule {
   friend class SBFrame;
   friend class SBSection;
   friend class SBSymbolContext;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBType;
 
+  friend class lldb_private::python::SWIGBridge;
+
   explicit SBModule(const lldb::ModuleSP &module_sp);
 
   ModuleSP GetSP() const;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 518a478af5f6a8..0f0e4a563e8b2b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -84,6 +84,7 @@ class SWIGBridge {
   static PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp);
   static PythonObject ToSWIGWrapper(lldb::TargetSP target_sp);
   static PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp);
+  static PythonObject ToSWIGWrapper(lldb::ModuleSP module_sp);
   static PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp);
   static PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp);
   static PythonObject ToSWIGWrapper(Status &&status);

``




https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala ready_for_review 
https://github.com/llvm/llvm-project/pull/120834
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

rchamala wrote:

@labath @splhack @clayborg @cs01

https://github.com/llvm/llvm-project/pull/120834
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

rchamala wrote:

@labath @splhack @clayborg @cs01

https://github.com/llvm/llvm-project/pull/120833
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

rchamala wrote:

Will rebase the changes from https://github.com/llvm/llvm-project/pull/120832 
after it is approved

https://github.com/llvm/llvm-project/pull/120833
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

rchamala wrote:

@labath @splhack @clayborg @cs01

https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

rchamala wrote:

Will rebase changes from https://github.com/llvm/llvm-project/pull/120832 and 
https://github.com/llvm/llvm-project/pull/120832 once they are approved which 
should fix the errors

https://github.com/llvm/llvm-project/pull/120834
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala ready_for_review 
https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala ready_for_review 
https://github.com/llvm/llvm-project/pull/120833
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala created 
https://github.com/llvm/llvm-project/pull/120833

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

Updated LineEntry::ApplyFileMappings to call resolve source file callback if 
set.

include/lldb/Target/Platform.h, source/Target/Platform.cpp Implemented 
SetResolveSourceFileCallback and GetResolveSourceFileCallback

include/lldb/Symbol/LineEntry.h, Source/Symbol/LineEntry.cpp Implemented 
CallResolveSourceFileCallbackIfSet

Source/Target/StackFrame.cpp
Source/Target/StackFrameList.cpp
Source/Target/ThreadPlanStepRange.cpp
Updated the caller  to ApplyFileMappings


unittests/Symbol/TestLineEntry.cpp
Added comprehensive ResolveSourceFileCallback tests.

Test Plan:
Added unittests for LineEntry.

```
ninja check-lldb-unit
```

>From d8f99abee76a3d74d6c5c4904304f77cb2142087 Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Thu, 19 Dec 2024 20:56:21 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Call resolve source file
 callback

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

Updated LineEntry::ApplyFileMappings to call resolve source file callback if 
set.

include/lldb/Target/Platform.h, source/Target/Platform.cpp
Implemented SetResolveSourceFileCallback and GetResolveSourceFileCallback

include/lldb/Symbol/LineEntry.h, Source/Symbol/LineEntry.cpp
Implemented CallResolveSourceFileCallbackIfSet

Source/Target/StackFrame.cpp
Source/Target/StackFrameList.cpp
Source/Target/ThreadPlanStepRange.cpp
Updated the caller  to ApplyFileMappings


unittests/Symbol/TestLineEntry.cpp
Added comprehensive ResolveSourceFileCallback tests.

Test Plan:
Added unittests for LineEntry.

```
ninja check-lldb-unit
```
---
 lldb/include/lldb/Symbol/LineEntry.h  |   5 +-
 lldb/include/lldb/Target/Platform.h   |  19 ++
 lldb/source/Symbol/LineEntry.cpp  |  37 +++-
 lldb/source/Target/Platform.cpp   |  55 ++
 lldb/source/Target/StackFrame.cpp |   2 +-
 lldb/source/Target/StackFrameList.cpp |   3 +-
 lldb/source/Target/ThreadPlanStepRange.cpp|   7 +-
 lldb/unittests/Symbol/CMakeLists.txt  |   2 +
 .../Symbol/Inputs/inlined-functions.cpp   |  22 +++
 lldb/unittests/Symbol/TestLineEntry.cpp   | 164 +-
 10 files changed, 302 insertions(+), 14 deletions(-)
 create mode 100644 lldb/unittests/Symbol/Inputs/inlined-functions.cpp

diff --git a/lldb/include/lldb/Symbol/LineEntry.h 
b/lldb/include/lldb/Symbol/LineEntry.h
index 8da59cf0bd24aa..9fc334ed87fdab 100644
--- a/lldb/include/lldb/Symbol/LineEntry.h
+++ b/lldb/include/lldb/Symbol/LineEntry.h
@@ -128,7 +128,10 @@ struct LineEntry {
   ///
   /// \param[in] target_sp
   /// Shared pointer to the target this LineEntry belongs to.
-  void ApplyFileMappings(lldb::TargetSP target_sp);
+  ///
+  /// \param[in] module_sp
+  /// Shared pointer to the module this LineEntry belongs to.
+  void ApplyFileMappings(lldb::TargetSP target_sp, lldb::ModuleSP module_sp);
 
   /// Helper to access the file.
   const FileSpec &GetFile() const { return file_sp->GetSpecOnly(); }
diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index a702abb540fd93..3265d0d2145dd6 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -316,6 +316,12 @@ class Platform : public PluginInterface {
   virtual bool GetModuleSpec(const FileSpec &module_file_spec,
  const ArchSpec &arch, ModuleSpec &module_spec);
 
+  void
+  CallResolveSourceFileCallbackIfSet(const lldb::ModuleSP &module_sp,
+ const FileSpec &original_source_file_spec,
+ FileSpec &resolved_source_file_spec,
+ bool *did_create_ptr);
+
   virtual Status ConnectRemote(Args &args);
 
   virtual Status DisconnectRemote();
@@ -967,6 +973,11 @@ class Platform : public PluginInterface {
FileSpec &symbol_file_spec)>
   LocateModuleCallback;
 
+  typedef std::function
+  ResolveSourceFileCallback;
+
   /// Set locate module callback. This allows users to implement their own
   /// module cache system. For example, to leverage artifacts of build system,
   /// to bypass pulling files from remote platform, or to search symbol files
@@ -975,6 +986,13 @@ class Platform : public PluginInterface {
 
   LocateModuleCallback GetLocateModuleCallback() const;
 
+  /// Set resolve source file callback. This allows users to implement their 
own
+  /// source file cache system. For example, to search source files from source
+  /// servers.
+  void SetResolveSourceFileCallback(ResolveSourceFileCallback callback);
+
+  ResolveSourceFileCallback GetResolveSourceFileCallback() const;
+
 protected:
   /// Create a list of ArchSpecs with the given OS and a architectures. The
   /// vendor fie

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala created 
https://github.com/llvm/llvm-project/pull/120834

Summary:
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580

Use SWIG for the resolve source file callback the same as other Python 
callbacks. TestResolveSourceFileCallback.py verifies the functionalities.

Test Plan:
Added shell tests for validation

```
./llvm-lit -sv TestResolveSourceFileCallback.py
```

Differential Revision: https://phabricator.intern.facebook.com/D67541203

>From 126ba755d58aa74c6d0c5727ec08593cfcfb57ee Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Fri, 20 Dec 2024 15:55:36 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Implement API, Python
 interface

Summary:
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580

Use SWIG for the resolve source file callback the same as other Python 
callbacks. TestResolveSourceFileCallback.py verifies the functionalities.

Test Plan:
Added shell tests for validation

```
./llvm-lit -sv TestResolveSourceFileCallback.py
```

Differential Revision: https://phabricator.intern.facebook.com/D67541203
---
 lldb/bindings/python/python-typemaps.swig |  44 
 lldb/bindings/python/python-wrapper.swig  |  49 -
 lldb/include/lldb/API/SBDefines.h |   5 +
 lldb/include/lldb/API/SBPlatform.h|   3 +
 lldb/source/API/SBPlatform.cpp|  37 
 .../TestResolveSourceFileCallback.py  | 196 ++
 lldb/test/API/python_api/sbplatform/test.exe  | Bin 0 -> 21704 bytes
 .../API/python_api/sbplatform/test_new.cpp|  15 ++
 8 files changed, 347 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/test/API/python_api/sbplatform/TestResolveSourceFileCallback.py
 create mode 100755 lldb/test/API/python_api/sbplatform/test.exe
 create mode 100644 lldb/test/API/python_api/sbplatform/test_new.cpp

diff --git a/lldb/bindings/python/python-typemaps.swig 
b/lldb/bindings/python/python-typemaps.swig
index f8c33e15c03e66..84d26986104d31 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -713,3 +713,47 @@ template <> bool SetNumberFromPyObject(double 
&number, PyObject *obj) {
   $1 = $input == Py_None;
   $1 = $1 || PyCallable_Check(reinterpret_cast($input));
 }
+
+// For lldb::SBPlatformResolveSourceFileCallback
+%typemap(in) (lldb::SBPlatformResolveSourceFileCallback callback, void 
*callback_baton) {
+  if (!($input == Py_None ||
+   PyCallable_Check(reinterpret_cast($input {
+PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+SWIG_fail;
+   }
+
+  if ($input == Py_None) {
+$1 = nullptr;
+$2 = nullptr;
+  } else {
+PythonCallable callable = Retain($input);
+if (!callable.IsValid()) {
+  PyErr_SetString(PyExc_TypeError, "Need a valid callable object");
+  SWIG_fail;
+}
+
+  llvm::Expected arg_info = callable.GetArgInfo();
+  if (!arg_info) {
+PyErr_SetString(PyExc_TypeError,
+  ("Could not get arguments: " +
+  llvm::toString(arg_info.takeError())).c_str());
+  SWIG_fail;
+  }
+
+  if (arg_info.get().max_positional_args != 3) {
+PyErr_SetString(PyExc_TypeError, "Expected 3 argument callable object");
+SWIG_fail;
+  }
+
+Py_INCREF($input);
+
+$1 = LLDBSwigPythonCallResolveSourceFileCallback;
+$2 = $input;
+  }
+}
+
+%typemap(typecheck) (lldb::SBPlatformResolveSourceFileCallback callback,
+ void *callback_baton) {
+  $1 = $input == Py_None;
+  $1 = $1 || PyCallable_Check(reinterpret_cast($input));
+}
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index b72a462d04643b..fb0b0368914fbf 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -727,7 +727,7 @@ 
lldb_private::python::SWIGBridge::LLDBSwigPythonHandleOptionArgumentCompletionFo
 dict_sp->AddBooleanItem("no-completion", true);
 return dict_sp;
   }
-
+
 
   // Convert the return dictionary to a DictionarySP.
   StructuredData::ObjectSP result_obj_sp = result.CreateStructuredObject();
@@ -753,7 +753,7 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
   auto pfunc = self.ResolveName("__call__");
 
   if (!pfunc.IsAllocated()) {
-cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class"); 
+cmd_retobj.AppendError("Could not find '__call__' method in implementation 
class");
 return false;
   }
 
@@ -1095,4 +1095,49 @@ static SBError LLDBSwigPythonCallLocateModuleCallback(
 
   return *sb_error_ptr;
 }
+
+static SBError LLDBSwigPythonCallResolveSourceFileCallback(
+void *callback_baton,
+ const lldb::ModuleSP &module_sp,
+const SBFileSpec &original_source_file_spec_sb,
+SBFileSpec &resolved_source_file_spec_sb) {
+  SWIG_Python_Thread_Block swig_thread_block;
+
+  PyErr_Cleaner

[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Call resolve source file callback (PR #120833)

2024-12-21 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/120833
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Implement API, Python interface (PR #120834)

2024-12-21 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/120834
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala created 
https://github.com/llvm/llvm-project/pull/120832

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

SBFileSpec and SBModule will be used for resolve source file callback as Python 
function arguments. This diff allows these things.

Can be instantiated from SBPlatform.
Can be passed to/from Python.

Test Plan:
N/A. The next set of diffs in the stack have unittests and shell test validation

>From 7cc031dbd888fdfa993c08da837df956f263877f Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Thu, 19 Dec 2024 19:09:34 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

SBFileSpec and SBModule will be used for resolve source file callback as Python
function arguments. This diff allows these things.

Can be instantiated from SBPlatform.
Can be passed to/from Python.

Test Plan:
N/A. The next set of diffs in the stack have unittests and shell test validation
---
 lldb/bindings/python/python-swigsafecast.swig| 5 +
 lldb/include/lldb/API/SBModule.h | 3 +++
 .../Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h  | 1 +
 3 files changed, 9 insertions(+)

diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 7a4f7e81f1cc3b..429baad158ca5d 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -23,6 +23,11 @@ PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP 
process_sp) {
   SWIGTYPE_p_lldb__SBProcess);
 }
 
+PythonObject SWIGBridge::ToSWIGWrapper(lldb::ModuleSP module_sp) {
+  return ToSWIGHelper(new lldb::SBModule(std::move(module_sp)),
+  SWIGTYPE_p_lldb__SBModule);
+}
+
 PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
   return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)),
   SWIGTYPE_p_lldb__SBThreadPlan);
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 7200a1ef53fd82..85332066ee6875 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -301,9 +301,12 @@ class LLDB_API SBModule {
   friend class SBFrame;
   friend class SBSection;
   friend class SBSymbolContext;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBType;
 
+  friend class lldb_private::python::SWIGBridge;
+
   explicit SBModule(const lldb::ModuleSP &module_sp);
 
   ModuleSP GetSP() const;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 518a478af5f6a8..0f0e4a563e8b2b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -84,6 +84,7 @@ class SWIGBridge {
   static PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp);
   static PythonObject ToSWIGWrapper(lldb::TargetSP target_sp);
   static PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp);
+  static PythonObject ToSWIGWrapper(lldb::ModuleSP module_sp);
   static PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp);
   static PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp);
   static PythonObject ToSWIGWrapper(Status &&status);

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

https://github.com/rchamala updated 
https://github.com/llvm/llvm-project/pull/120832

>From 7cc031dbd888fdfa993c08da837df956f263877f Mon Sep 17 00:00:00 2001
From: Rahul Reddy Chamala 
Date: Thu, 19 Dec 2024 19:09:34 -0800
Subject: [PATCH] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule

Summary:
RFC 
https://discourse.llvm.org/t/rfc-python-callback-for-source-file-resolution/83545

SBFileSpec and SBModule will be used for resolve source file callback as Python
function arguments. This diff allows these things.

Can be instantiated from SBPlatform.
Can be passed to/from Python.

Test Plan:
N/A. The next set of diffs in the stack have unittests and shell test validation
---
 lldb/bindings/python/python-swigsafecast.swig| 5 +
 lldb/include/lldb/API/SBModule.h | 3 +++
 .../Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h  | 1 +
 3 files changed, 9 insertions(+)

diff --git a/lldb/bindings/python/python-swigsafecast.swig 
b/lldb/bindings/python/python-swigsafecast.swig
index 7a4f7e81f1cc3b..429baad158ca5d 100644
--- a/lldb/bindings/python/python-swigsafecast.swig
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -23,6 +23,11 @@ PythonObject SWIGBridge::ToSWIGWrapper(lldb::ProcessSP 
process_sp) {
   SWIGTYPE_p_lldb__SBProcess);
 }
 
+PythonObject SWIGBridge::ToSWIGWrapper(lldb::ModuleSP module_sp) {
+  return ToSWIGHelper(new lldb::SBModule(std::move(module_sp)),
+  SWIGTYPE_p_lldb__SBModule);
+}
+
 PythonObject SWIGBridge::ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp) {
   return ToSWIGHelper(new lldb::SBThreadPlan(std::move(thread_plan_sp)),
   SWIGTYPE_p_lldb__SBThreadPlan);
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 7200a1ef53fd82..85332066ee6875 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -301,9 +301,12 @@ class LLDB_API SBModule {
   friend class SBFrame;
   friend class SBSection;
   friend class SBSymbolContext;
+  friend class SBPlatform;
   friend class SBTarget;
   friend class SBType;
 
+  friend class lldb_private::python::SWIGBridge;
+
   explicit SBModule(const lldb::ModuleSP &module_sp);
 
   ModuleSP GetSP() const;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
index 518a478af5f6a8..0f0e4a563e8b2b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
@@ -84,6 +84,7 @@ class SWIGBridge {
   static PythonObject ToSWIGWrapper(lldb::ValueObjectSP value_sp);
   static PythonObject ToSWIGWrapper(lldb::TargetSP target_sp);
   static PythonObject ToSWIGWrapper(lldb::ProcessSP process_sp);
+  static PythonObject ToSWIGWrapper(lldb::ModuleSP module_sp);
   static PythonObject ToSWIGWrapper(lldb::ThreadPlanSP thread_plan_sp);
   static PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp);
   static PythonObject ToSWIGWrapper(Status &&status);

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][ResolveSourceFileCallback] Update SBFileSpec/SBModule (PR #120832)

2024-12-21 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/120832
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits