diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp --- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp @@ -122,8 +122,9 @@ sc_ctx .GetFunctionName( Mangled::NamePreference::ePreferDemangledWithoutArguments) - .AsCString()); - if (!m_function_names.count(name)) { + .AsCString("")); + + if (name.empty() || !m_function_names.count(name)) { sc_to_remove.push_back(i); } } diff --git a/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py @@ -0,0 +1,51 @@ +""" +Test lldb breakpoint setting by source regular expression. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +class TestSourceRegexBreakpointsWithAsm(TestBase): + + @skipIfWindows + def test_restrictions(self): + self.build() + self.source_regex_restrictions() + + def source_regex_restrictions(self): + """ Test restricting source expressions to to functions with non-standard mangling.""" + # Create a target by the debugger. + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + asm_tag = "NonStandardMangling" + + # Sanity check that we can set breakpoint on non-standard mangled name + main_break = target.BreakpointCreateByName(asm_tag) + + expected_num_locations = 1 + num_locations = main_break.GetNumLocations() + self.assertEqual( + num_locations, expected_num_locations, + "We should have gotten %d matches, got %d." % + (expected_num_locations, num_locations)) + + # Check regex on asm tag restricted to function names + func_names = lldb.SBStringList() + func_names.AppendString('main') + func_names.AppendString('func') + func_names.AppendString('') + func_names.AppendString('NonStandardMangling') + + main_break = target.BreakpointCreateBySourceRegex( + asm_tag, lldb.SBFileSpecList(), lldb.SBFileSpecList(), func_names) + + expected_num_locations = 0 + num_locations = main_break.GetNumLocations() + self.assertEqual( + num_locations, expected_num_locations, + "We should have gotten %d matches, got %d." % + (expected_num_locations, num_locations)) diff --git a/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp @@ -0,0 +1,8 @@ +int func_with_asm(void) asm("NonStandardMangling"); + +int func_with_asm(void) { return 10; } + +int main() { + func_with_asm(); + return 0; +}