================ @@ -18,6 +18,26 @@ def tearDown(self): if self.background_pid: os.kill(self.background_pid, signal.SIGKILL) + 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) + 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") ---------------- Jlalond wrote:
@labath I think the best case for this API would be returning a valid string identifier when there is no backing file. VDSO is the example I have in mind but a module jitted in memory only could also make sense. Per the code you linked ``` ConstString m_object_name; ///< The name an object within this module that is /// selected, or empty of the module is represented /// by \a m_file. ``` Shouldn't this be the case? I'm very open to how we implement this but my goals align with the comments, which is obtaining a valid identifier when I can't fall back to the file for identification https://github.com/llvm/llvm-project/pull/150331 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits