https://github.com/bulbazord updated 
https://github.com/llvm/llvm-project/pull/76766

>From a9b6b6fee19fd19bf1fdce6fe8e9ed35f7c1567a Mon Sep 17 00:00:00 2001
From: Alex Langford <alangf...@apple.com>
Date: Tue, 2 Jan 2024 15:44:30 -0800
Subject: [PATCH] [lldb] Fix breakpoint resolver serialization bug

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).
---
 .../Breakpoint/BreakpointResolverAddress.cpp  | 12 ++++------
 .../serialize/TestBreakpointSerialization.py  | 23 +++++++++++++++++++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
       new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-    ModuleSP module_sp = section_sp->GetModule();
-    ConstString module_name;
-    if (module_sp)
-      module_name.SetCString(module_name.GetCString());
-
-    options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-                                   module_name.GetCString());
+    if (ModuleSP module_sp = section_sp->GetModule()) {
+      const FileSpec &module_fspec = module_sp->GetFileSpec();
+      options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+                                     module_fspec.GetPath().c_str());
+    }
     options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
                                     m_addr.GetOffset());
   } else {
diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..54366b11aa6c00 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,29 @@ def test_scripted_extra_args(self):
         self.setup_targets_and_cleanup()
         self.do_check_extra_args()
 
+    def test_resolver_serialization(self):
+        """Test that breakpoint resolvers contain the expected information"""
+        self.build()
+        self.setup_targets_and_cleanup()
+
+        sym_ctx_list = self.orig_target.FindFunctions("main")
+        self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+        sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+        self.assertTrue(sym_ctx.IsValid(), "SBSymbolContext representing 
function `main' is invalid")
+        main_func = sym_ctx.GetFunction()
+        self.assertTrue(main_func.IsValid(), "SBFunction representing `main' 
is invalid")
+        main_addr = main_func.GetStartAddress()
+
+        bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+        self.assertTrue(bkpt.IsValid(), "Could not place breakpoint on `main' 
by address")
+        stream = lldb.SBStream()
+        sd = bkpt.SerializeToStructuredData()
+        sd.GetAsJSON(stream)
+        serialized_data = json.loads(stream.GetData())
+
+        self.assertIn("a.out",
+                      
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"])
+
     def test_structured_data_serialization(self):
         target = self.dbg.GetDummyTarget()
         self.assertTrue(target.IsValid(), VALID_TARGET)

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

Reply via email to