diff --git a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp index 86c1f534fcf56..6fbf7e43fc5d7 100644 --- a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp +++ b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp @@ -1069,6 +1069,11 @@ static bool ParseGlobal(const swift::Demangle::NodePointer &node, for (swift::Demangle::Node::iterator pos = node->begin(); pos != end; ++pos) { swift::Demangle::NodePointer child = *pos; if (child) { + // Peel off static node. + if (child->getKind() == swift::Demangle::Node::Kind::Static && + child->hasChildren()) + child = child->getFirstChild(); + kind = child->getKind(); switch (child->getKind()) { case swift::Demangle::Node::Kind::Allocator: diff --git a/lldb/test/API/lang/swift/break_source_regex_static_function/Makefile b/lldb/test/API/lang/swift/break_source_regex_static_function/Makefile new file mode 100644 index 0000000000000..2a69023633b34 --- /dev/null +++ b/lldb/test/API/lang/swift/break_source_regex_static_function/Makefile @@ -0,0 +1,3 @@ +SWIFT_SOURCES := main.swift + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/break_source_regex_static_function/TestBreakSourceRegexStaticFunction.py b/lldb/test/API/lang/swift/break_source_regex_static_function/TestBreakSourceRegexStaticFunction.py new file mode 100644 index 0000000000000..6c19e341f53a5 --- /dev/null +++ b/lldb/test/API/lang/swift/break_source_regex_static_function/TestBreakSourceRegexStaticFunction.py @@ -0,0 +1,30 @@ +""" +Tests source regex breakpoints scoped to Swift static functions (-X option). +""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestCase(TestBase): + @swiftTest + def test_source_regex_with_static_function_filter(self): + self.build() + target, _, _, _ = lldbutil.run_to_name_breakpoint(self, "main") + self.expect("breakpoint set -p 'break here' -X first") + bp = target.breakpoint[-1] + self.assertTrue(bp.IsEnabled()) + self.assertEqual(bp.GetNumResolvedLocations(), 1) + self.assertIn("Scope.first", str(bp.location[0])) + + @swiftTest + def test_source_regex_with_static_function_filter_and_file(self): + self.build() + target, _, _, _ = lldbutil.run_to_name_breakpoint(self, "main") + self.expect("breakpoint set -f main.swift -p 'break here' -X second") + bp = target.breakpoint[-1] + self.assertTrue(bp.IsEnabled()) + self.assertEqual(bp.GetNumResolvedLocations(), 1) + self.assertIn("Scope.second", str(bp.location[0])) diff --git a/lldb/test/API/lang/swift/break_source_regex_static_function/main.swift b/lldb/test/API/lang/swift/break_source_regex_static_function/main.swift new file mode 100644 index 0000000000000..1f1615a385fd9 --- /dev/null +++ b/lldb/test/API/lang/swift/break_source_regex_static_function/main.swift @@ -0,0 +1,16 @@ +enum Scope { + static func first() { + _ = "break here" + } + + static func second() { + _ = "break here" + } +} + +@main enum Entry { + static func main() { + Scope.first() + Scope.second() + } +}