aeubanks created this revision. Herald added a subscriber: arphaman. Herald added a project: All. aeubanks requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
This makes setting breakpoints work with -gsimple-template-names. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D137098 Files: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py =================================================================== --- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -12,7 +12,16 @@ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test(self): - self.build() + self.do_test(dict()) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + @skipIf(compiler=no_match("clang")) + @skipIf(compiler_version=["<", "15.0"]) + def test_simple_template_names(self): + self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names")) + + def do_test(self, debug_flags): + self.build(dictionary=debug_flags) self.breakpoint_id_tests() def verify_breakpoint_locations(self, target, bp_dict): @@ -57,7 +66,11 @@ # Template cases {'name': 'func<float>', 'loc_names': []}, + {'name': 'Foo::func<float>', 'loc_names': []}, + {'name': 'ns::Foo::func<float>', 'loc_names': []}, {'name': 'func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, + {'name': 'Foo<double>::func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, + {'name': 'ns::Foo<double>::func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, {'name': 'func', 'loc_names': ['auto ns::Foo<double>::func<int>()', 'auto ns::Foo<double>::func<ns::Foo<int>>()']}, Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -464,6 +464,17 @@ if (!m_set.function_methods.Find( name, DIERefCallback(callback, name.GetStringRef()))) return; + // With -gsimple-template-names, the die name may not contain template + // parameters. Try stripping the template parameters and try again. + const llvm::StringRef name_ref = name.AsCString(); + auto it = name_ref.find('<'); + if (it != llvm::StringRef::npos) { + const llvm::StringRef name_no_template_params = name_ref.slice(0, it); + if (!m_set.function_methods.Find( + ConstString(name_no_template_params), + DIERefCallback(callback, name_no_template_params))) + return; + } } if (name_type_mask & eFunctionNameTypeSelector &&
Index: lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py =================================================================== --- lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py +++ lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py @@ -12,7 +12,16 @@ @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") def test(self): - self.build() + self.do_test(dict()) + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764") + @skipIf(compiler=no_match("clang")) + @skipIf(compiler_version=["<", "15.0"]) + def test_simple_template_names(self): + self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names")) + + def do_test(self, debug_flags): + self.build(dictionary=debug_flags) self.breakpoint_id_tests() def verify_breakpoint_locations(self, target, bp_dict): @@ -57,7 +66,11 @@ # Template cases {'name': 'func<float>', 'loc_names': []}, + {'name': 'Foo::func<float>', 'loc_names': []}, + {'name': 'ns::Foo::func<float>', 'loc_names': []}, {'name': 'func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, + {'name': 'Foo<double>::func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, + {'name': 'ns::Foo<double>::func<int>', 'loc_names': ['auto ns::Foo<double>::func<int>()']}, {'name': 'func', 'loc_names': ['auto ns::Foo<double>::func<int>()', 'auto ns::Foo<double>::func<ns::Foo<int>>()']}, Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -464,6 +464,17 @@ if (!m_set.function_methods.Find( name, DIERefCallback(callback, name.GetStringRef()))) return; + // With -gsimple-template-names, the die name may not contain template + // parameters. Try stripping the template parameters and try again. + const llvm::StringRef name_ref = name.AsCString(); + auto it = name_ref.find('<'); + if (it != llvm::StringRef::npos) { + const llvm::StringRef name_no_template_params = name_ref.slice(0, it); + if (!m_set.function_methods.Find( + ConstString(name_no_template_params), + DIERefCallback(callback, name_no_template_params))) + return; + } } if (name_type_mask & eFunctionNameTypeSelector &&
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits