https://github.com/barsolo2000 updated 
https://github.com/llvm/llvm-project/pull/150331

>From b79edf938d49d03498ec3a9228344a684d0cbf6e Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 23 Jul 2025 15:17:29 -0700
Subject: [PATCH 1/7] [LLDB] added getName method in SBModule

---
 lldb/include/lldb/API/SBModule.h | 3 +++
 lldb/source/API/SBModule.cpp     | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 85332066ee687..ed90c48849699 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -296,6 +296,9 @@ class LLDB_API SBModule {
   /// Remove any global modules which are no longer needed.
   static void GarbageCollectAllocatedModules();
 
+  /// Return the name of the module.
+  const char *GetName() const;
+
 private:
   friend class SBAddress;
   friend class SBFrame;
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 985107ec68efd..9eb0ae3cb3dba 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -671,3 +671,11 @@ void SBModule::GarbageCollectAllocatedModules() {
   const bool mandatory = false;
   ModuleList::RemoveOrphanSharedModules(mandatory);
 }
+
+const char *SBModule::GetName() const {
+  LLDB_INSTRUMENT_VA(this);
+  if (!m_opaque_sp) {
+    return nullptr;
+  }
+  return m_opaque_sp->GetObjectName().AsCString();
+}
\ No newline at end of file

>From 019261475ee073345aac9faba2e20ac2ef980b79 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 23 Jul 2025 16:00:07 -0700
Subject: [PATCH 2/7] added nullptr check

---
 lldb/source/API/SBModule.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 9eb0ae3cb3dba..88cff3d6bcbf2 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -677,5 +677,9 @@ const char *SBModule::GetName() const {
   if (!m_opaque_sp) {
     return nullptr;
   }
-  return m_opaque_sp->GetObjectName().AsCString();
+  auto mod_name = m_opaque_sp->GetObjectName();
+  if (!mod_name) {
+    return nullptr;
+  }
+  return mod_name.AsCString();
 }
\ No newline at end of file

>From 8a03abc421b049c98ca74da21b02bd44feb87c4b Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Thu, 24 Jul 2025 10:53:45 -0700
Subject: [PATCH 3/7] changed format and added a test to run darwin

---
 lldb/source/API/SBModule.cpp                      | 12 ++++--------
 lldb/test/API/python_api/sbmodule/TestSBModule.py | 11 +++++++++++
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 88cff3d6bcbf2..31508cb5ff1f4 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -674,12 +674,8 @@ void SBModule::GarbageCollectAllocatedModules() {
 
 const char *SBModule::GetName() const {
   LLDB_INSTRUMENT_VA(this);
-  if (!m_opaque_sp) {
-    return nullptr;
-  }
-  auto mod_name = m_opaque_sp->GetObjectName();
-  if (!mod_name) {
-    return nullptr;
-  }
-  return mod_name.AsCString();
+
+  if (!m_opaque_sp)
+    return nullptr; 
+  return m_opaque_sp->GetObjectName().AsCString();
 }
\ No newline at end of file
diff --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py 
b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index c04e2fa55e8cf..cc1019d2e8434 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -20,6 +20,17 @@ def tearDown(self):
 
     @skipUnlessDarwin
     @skipIfRemote
+    def test_getname(self):
+        """Test the SBModule::GetName() method"""
+        self.build()
+        target, _, _, _ = lldbutil.run_to_source_breakpoint(
+            self, "// break here", lldb.SBFileSpec("main.c")
+        )
+
+        self.assertGreater(target.GetNumModules(), 0)
+        module_names = {target.GetModuleAtIndex(i).GetName() for i in 
range(target.GetNumModules())}
+        self.assertIn("a.out", module_names)
+
     def test_module_is_file_backed(self):
         """Test the SBModule::IsFileBacked() method"""
         self.build()

>From 3998acd722abcad83b2a7ff2ffa6b671f7d1158c Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 28 Jul 2025 11:33:41 -0700
Subject: [PATCH 4/7] added GetObjectfile and upgraded test to expect None

---
 .../API/python_api/sbmodule/TestSBModule.py   | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py 
b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index cc1019d2e8434..bcfc4981e0d5b 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -18,8 +18,6 @@ def tearDown(self):
         if self.background_pid:
             os.kill(self.background_pid, signal.SIGKILL)
 
-    @skipUnlessDarwin
-    @skipIfRemote
     def test_getname(self):
         """Test the SBModule::GetName() method"""
         self.build()
@@ -28,9 +26,20 @@ def test_getname(self):
         )
 
         self.assertGreater(target.GetNumModules(), 0)
-        module_names = {target.GetModuleAtIndex(i).GetName() for i in 
range(target.GetNumModules())}
-        self.assertIn("a.out", module_names)
-
+        for i in range(target.GetNumModules()):
+            module = target.GetModuleAtIndex(i)
+            file_spec = module.GetFileSpec()
+            name = module.GetName()
+            if file_spec.IsValid() and file_spec.exists:
+#If file is valid and file exist, expect GetName() to be None
+                self.assertIsNone(name, f"Expected None for module with valid 
file {file_spec.GetFilename()}, got {name!r}")
+            else:
+#If no valid file, expect GetName() to be a non - empty string
+                self.assertIsInstance(name, str)
+                self.assertTrue(name, "Expected a non-empty name for module 
without a valid file")
+        
+    @skipUnlessDarwin
+    @skipIfRemote
     def test_module_is_file_backed(self):
         """Test the SBModule::IsFileBacked() method"""
         self.build()

>From c8e1fcc7dee554499259d7f085b1781bf2f7de3a Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 28 Jul 2025 12:04:36 -0700
Subject: [PATCH 5/7] added changes to SBModule GetName

---
 lldb/source/API/SBModule.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 31508cb5ff1f4..e12ee47543a2d 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -677,5 +677,6 @@ const char *SBModule::GetName() const {
 
   if (!m_opaque_sp)
     return nullptr; 
+  m_opaque_sp->GetObjectFile();
   return m_opaque_sp->GetObjectName().AsCString();
-}
\ No newline at end of file
+}

>From 416b749973dd80f8268a83add42b2c83161194eb Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 30 Jul 2025 11:45:08 -0700
Subject: [PATCH 6/7] changed to GetObjectName()

---
 lldb/include/lldb/API/SBModule.h | 4 ++--
 lldb/source/API/SBModule.cpp     | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index ed90c48849699..5ff5403923cfa 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -296,8 +296,8 @@ class LLDB_API SBModule {
   /// Remove any global modules which are no longer needed.
   static void GarbageCollectAllocatedModules();
 
-  /// Return the name of the module.
-  const char *GetName() const;
+  /// Return the name of the module (m_object_name).
+  const char *GetObjectName() const;
 
 private:
   friend class SBAddress;
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index e12ee47543a2d..d197587e5ccda 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -672,11 +672,10 @@ void SBModule::GarbageCollectAllocatedModules() {
   ModuleList::RemoveOrphanSharedModules(mandatory);
 }
 
-const char *SBModule::GetName() const {
+const char *SBModule::GetObjectName() const {
   LLDB_INSTRUMENT_VA(this);
 
   if (!m_opaque_sp)
     return nullptr; 
-  m_opaque_sp->GetObjectFile();
   return m_opaque_sp->GetObjectName().AsCString();
 }

>From 1a1c5a5e526d67b89ff79576be796b06605f786c Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 4 Aug 2025 12:52:13 -0700
Subject: [PATCH 7/7] added fixed description of function

---
 lldb/include/lldb/API/SBModule.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 5ff5403923cfa..4009ca1461e51 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -296,7 +296,9 @@ class LLDB_API SBModule {
   /// Remove any global modules which are no longer needed.
   static void GarbageCollectAllocatedModules();
 
-  /// Return the name of the module (m_object_name).
+  /// If this Module represents a specific object or part within a larger file,
+  /// returns the name of that object or part. Otherwise, returns
+  /// nullptr.
   const char *GetObjectName() const;
 
 private:

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

Reply via email to