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

>From 140f4053e6601585a3e27b285f1c00204fca0728 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 23 Jul 2025 15:17:29 -0700
Subject: [PATCH 01/10] [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 8241fcd33c12d9bdef2e7b640fd0953a675e1c5a Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 23 Jul 2025 16:00:07 -0700
Subject: [PATCH 02/10] 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 fcfe476957e21270a86cccfcb6985d5be6ac56ae Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Thu, 24 Jul 2025 10:53:45 -0700
Subject: [PATCH 03/10] 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 e741ae64935262edbb33d7749138001a04a859c2 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 28 Jul 2025 11:33:41 -0700
Subject: [PATCH 04/10] 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 35c8da623b12a56fdc6ac524f23f1f68080fddf2 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 28 Jul 2025 12:04:36 -0700
Subject: [PATCH 05/10] 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 4a085c336dcaf6cb49ebc3b8aa8161803df54eb9 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Wed, 30 Jul 2025 11:45:08 -0700
Subject: [PATCH 06/10] 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 f1b1ac589a72a2d07042a1a40b4d394150faee35 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 4 Aug 2025 12:52:13 -0700
Subject: [PATCH 07/10] 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:

>From c1d0e304c3e7d2213a7d8cfef9fa852d1a381672 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Mon, 4 Aug 2025 13:25:42 -0700
Subject: [PATCH 08/10] format errors

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

diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index d197587e5ccda..5a57f45f0d475 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -676,6 +676,6 @@ const char *SBModule::GetObjectName() const {
   LLDB_INSTRUMENT_VA(this);
 
   if (!m_opaque_sp)
-    return nullptr; 
+    return nullptr;
   return m_opaque_sp->GetObjectName().AsCString();
 }

>From 24b22eddecdbdb31208705673bfda1deec8f1772 Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Tue, 5 Aug 2025 13:27:56 -0700
Subject: [PATCH 09/10] added test that check archive names

---
 lldb/test/API/python_api/sbmodule/Makefile    | 12 ++++-
 .../API/python_api/sbmodule/TestSBModule.py   | 50 ++++++++++++-------
 lldb/test/API/python_api/sbmodule/a.c         | 11 ++++
 lldb/test/API/python_api/sbmodule/b.c         | 12 +++++
 lldb/test/API/python_api/sbmodule/c.c         | 12 +++++
 lldb/test/API/python_api/sbmodule/main.c      |  2 +
 6 files changed, 80 insertions(+), 19 deletions(-)
 create mode 100644 lldb/test/API/python_api/sbmodule/a.c
 create mode 100644 lldb/test/API/python_api/sbmodule/b.c
 create mode 100644 lldb/test/API/python_api/sbmodule/c.c

diff --git a/lldb/test/API/python_api/sbmodule/Makefile 
b/lldb/test/API/python_api/sbmodule/Makefile
index 10495940055b6..360c59d789095 100644
--- a/lldb/test/API/python_api/sbmodule/Makefile
+++ b/lldb/test/API/python_api/sbmodule/Makefile
@@ -1,3 +1,13 @@
-C_SOURCES := main.c
+C_SOURCES := main.c a.c b.c c.c
+EXE :=  # Define a.out explicitly
+MAKE_DSYM := NO
+
+all: a.out 
+
+a.out: main.o libfoo.a
+       $(LD) $(LDFLAGS) $^ -o $@
+
+libfoo.a: a.o b.o
+       $(AR) $(ARFLAGS) $@ $^
 
 include Makefile.rules
diff --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py 
b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index bcfc4981e0d5b..18b31efc7e871 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -18,26 +18,40 @@ def tearDown(self):
         if self.background_pid:
             os.kill(self.background_pid, signal.SIGKILL)
 
-    def test_getname(self):
-        """Test the SBModule::GetName() method"""
+    @skipIfRemote
+    def test_GetObjectName(self):
+        """Test the SBModule::GetObjectName() method"""
         self.build()
-        target, _, _, _ = lldbutil.run_to_source_breakpoint(
-            self, "// break here", lldb.SBFileSpec("main.c")
-        )
+        exe = self.getBuildArtifact("a.out")
+        libfoo_path = self.getBuildArtifact("libfoo.a")
+        target_exe = self.dbg.CreateTarget(exe)
+        self.assertTrue(target_exe.IsValid(), "Target for a.out is valid")
+
+        # Test that the executable module has no object name (usually the 
first module in the target)
+        exe_module = target_exe.GetModuleAtIndex(0)
+        self.assertTrue(exe_module.IsValid(), "Executable module is valid")
+        self.assertIsNone(exe_module.GetObjectName(), "a.out should have no 
object name")
+
+        # check archive member names
+        module_specs = 
lldb.SBModuleSpecList.GetModuleSpecifications(libfoo_path)
+        self.assertGreater(module_specs.GetSize(), 0, "Archive should have at 
least one module spec")
+        target = self.dbg.CreateTarget(None)
+        self.assertTrue(target.IsValid(), "Target is valid")
+        found = set()
+        expected = {"a.o", "b.o"}
+        for i in range(module_specs.GetSize()):
+            spec = module_specs.GetSpecAtIndex(i)
+            obj_name = spec.GetObjectName()
+            self.assertIsInstance(obj_name, str)
+            self.assertIn(obj_name, expected, f"Unexpected object name: 
{obj_name}")
+            #create a module from the arhive using the sepc
+            module = target.AddModule(spec)
+            self.assertTrue(module.IsValid(), "Module is valid")
+            self.assertTrue(module.IsValid(), f"Module for {obj_name} is 
valid")
+            self.assertEqual(module.GetObjectName(), obj_name, f"Object name 
for {obj_name} matches")
+            found.add(obj_name)
+        self.assertEqual(found, expected, "Did not find all expected archive 
members")
 
-        self.assertGreater(target.GetNumModules(), 0)
-        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):
diff --git a/lldb/test/API/python_api/sbmodule/a.c 
b/lldb/test/API/python_api/sbmodule/a.c
new file mode 100644
index 0000000000000..420e106d5bf54
--- /dev/null
+++ b/lldb/test/API/python_api/sbmodule/a.c
@@ -0,0 +1,11 @@
+int __a_global = 1;
+
+int a(int arg) {
+    int result = arg + __a_global;
+    return result; // Set file and line breakpoint inside a().
+}
+
+int aa(int arg1) {
+    int result1 = arg1 - __a_global;
+    return result1;
+}
diff --git a/lldb/test/API/python_api/sbmodule/b.c 
b/lldb/test/API/python_api/sbmodule/b.c
new file mode 100644
index 0000000000000..33f09937f07eb
--- /dev/null
+++ b/lldb/test/API/python_api/sbmodule/b.c
@@ -0,0 +1,12 @@
+static int __b_global = 2;
+char __extra[4096]; // Make sure sizeof b.o differs from a.o and c.o
+
+int b(int arg) {
+    int result = arg + __b_global;
+    return result;
+}
+
+int bb(int arg1) {
+    int result2 = arg1 - __b_global;
+    return result2;
+}
diff --git a/lldb/test/API/python_api/sbmodule/c.c 
b/lldb/test/API/python_api/sbmodule/c.c
new file mode 100644
index 0000000000000..698e54475d44c
--- /dev/null
+++ b/lldb/test/API/python_api/sbmodule/c.c
@@ -0,0 +1,12 @@
+static int __c_global = 3;
+char __extra[4096]; // Make sure sizeof b.o differs from a.o and c.o
+char __extra2[4096]; // Make sure sizeof b.o differs from a.o and c.o
+int c(int arg) {
+  int result = arg + __c_global;
+  return result;
+}
+
+int cc(int arg1) {
+  int result3 = arg1 - __c_global;
+  return result3;
+}
diff --git a/lldb/test/API/python_api/sbmodule/main.c 
b/lldb/test/API/python_api/sbmodule/main.c
index 101d495698f45..574d57d5fd0bb 100644
--- a/lldb/test/API/python_api/sbmodule/main.c
+++ b/lldb/test/API/python_api/sbmodule/main.c
@@ -1,3 +1,5 @@
+extern int a(int);
+extern int b(int);
 int main() {
   while (1) // break here
     ;

>From 94543dec45534a54fa442fdac3514e8b8516805b Mon Sep 17 00:00:00 2001
From: Bar Soloveychik <bars...@fb.com>
Date: Tue, 5 Aug 2025 13:50:15 -0700
Subject: [PATCH 10/10] fixed small issues.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
---
 lldb/test/API/python_api/sbmodule/Makefile        |  3 +--
 lldb/test/API/python_api/sbmodule/TestSBModule.py |  1 +
 lldb/test/API/python_api/sbmodule/a.c             |  2 +-
 lldb/test/API/python_api/sbmodule/b.c             |  3 +--
 lldb/test/API/python_api/sbmodule/c.c             | 12 ------------
 5 files changed, 4 insertions(+), 17 deletions(-)
 delete mode 100644 lldb/test/API/python_api/sbmodule/c.c

diff --git a/lldb/test/API/python_api/sbmodule/Makefile 
b/lldb/test/API/python_api/sbmodule/Makefile
index 360c59d789095..81df9049e13cd 100644
--- a/lldb/test/API/python_api/sbmodule/Makefile
+++ b/lldb/test/API/python_api/sbmodule/Makefile
@@ -1,5 +1,4 @@
-C_SOURCES := main.c a.c b.c c.c
-EXE :=  # Define a.out explicitly
+C_SOURCES := main.c a.c b.c
 MAKE_DSYM := NO
 
 all: a.out 
diff --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py 
b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index 18b31efc7e871..243d7609d875e 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -50,6 +50,7 @@ def test_GetObjectName(self):
             self.assertTrue(module.IsValid(), f"Module for {obj_name} is 
valid")
             self.assertEqual(module.GetObjectName(), obj_name, f"Object name 
for {obj_name} matches")
             found.add(obj_name)
+            
         self.assertEqual(found, expected, "Did not find all expected archive 
members")
 
     @skipUnlessDarwin
diff --git a/lldb/test/API/python_api/sbmodule/a.c 
b/lldb/test/API/python_api/sbmodule/a.c
index 420e106d5bf54..21720f3b79d8a 100644
--- a/lldb/test/API/python_api/sbmodule/a.c
+++ b/lldb/test/API/python_api/sbmodule/a.c
@@ -2,7 +2,7 @@ int __a_global = 1;
 
 int a(int arg) {
     int result = arg + __a_global;
-    return result; // Set file and line breakpoint inside a().
+    return result; 
 }
 
 int aa(int arg1) {
diff --git a/lldb/test/API/python_api/sbmodule/b.c 
b/lldb/test/API/python_api/sbmodule/b.c
index 33f09937f07eb..4ccd3976fe30f 100644
--- a/lldb/test/API/python_api/sbmodule/b.c
+++ b/lldb/test/API/python_api/sbmodule/b.c
@@ -1,6 +1,5 @@
 static int __b_global = 2;
-char __extra[4096]; // Make sure sizeof b.o differs from a.o and c.o
-
+char __extra[4096]; // Make sure sizeof b.o differs from a.o
 int b(int arg) {
     int result = arg + __b_global;
     return result;
diff --git a/lldb/test/API/python_api/sbmodule/c.c 
b/lldb/test/API/python_api/sbmodule/c.c
deleted file mode 100644
index 698e54475d44c..0000000000000
--- a/lldb/test/API/python_api/sbmodule/c.c
+++ /dev/null
@@ -1,12 +0,0 @@
-static int __c_global = 3;
-char __extra[4096]; // Make sure sizeof b.o differs from a.o and c.o
-char __extra2[4096]; // Make sure sizeof b.o differs from a.o and c.o
-int c(int arg) {
-  int result = arg + __c_global;
-  return result;
-}
-
-int cc(int arg1) {
-  int result3 = arg1 - __c_global;
-  return result3;
-}

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

Reply via email to