-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb] support breakpoint by name on abi_tagged functions #170527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
da-viper
wants to merge
5
commits into
llvm:main
Choose a base branch
from
da-viper:break-on-abi-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lldb/test/API/functionalities/breakpoint/cpp/abi_tag/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| CXX_SOURCES := main.cpp | ||
|
|
||
| include Makefile.rules |
89 changes: 89 additions & 0 deletions
89
lldb/test/API/functionalities/breakpoint/cpp/abi_tag/TestCPPBreakpointLocationsAbiTag.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| """ | ||
| Test breakpoint on function with abi_tags. | ||
| """ | ||
|
|
||
| import lldb | ||
| from typing import List, Set, TypedDict | ||
| from lldbsuite.test.decorators import skipIfWindows | ||
| from lldbsuite.test.lldbtest import VALID_TARGET, TestBase | ||
|
|
||
|
|
||
| class Case(TypedDict, total=True): | ||
| name: str | ||
| matches: Set[str] | ||
|
|
||
|
|
||
| @skipIfWindows # abi_tags is not supported | ||
| class TestCPPBreakpointLocationsAbiTag(TestBase): | ||
| def verify_breakpoint_names(self, target: lldb.SBTarget, bp_dict: Case): | ||
| name = bp_dict["name"] | ||
| matches = bp_dict["matches"] | ||
| bp: lldb.SBBreakpoint = target.BreakpointCreateByName(name) | ||
|
|
||
| for location in bp: | ||
| self.assertTrue(location.IsValid(), f"Expected valid location {location}") | ||
|
|
||
| expected_matches = set(location.addr.function.name for location in bp) | ||
|
|
||
| self.assertSetEqual(expected_matches, matches) | ||
|
|
||
| def test_breakpoint_name_with_abi_tag(self): | ||
| self.build() | ||
| exe = self.getBuildArtifact("a.out") | ||
| target: lldb.SBTarget = self.dbg.CreateTarget(exe) | ||
| self.assertTrue(target, VALID_TARGET) | ||
|
|
||
| test_cases: List[Case] = [ | ||
| Case( | ||
| name="foo", | ||
| matches={ | ||
| "foo[abi:FOO]()", | ||
| "StaticStruct[abi:STATIC_STRUCT]::foo[abi:FOO][abi:FOO2]()", | ||
| "Struct[abi:STRUCT]::foo[abi:FOO]()", | ||
| "ns::NamespaceStruct[abi:NAMESPACE_STRUCT]::foo[abi:FOO]()", | ||
| "ns::foo[abi:NAMESPACE_FOO]()", | ||
| "TemplateStruct[abi:TEMPLATE_STRUCT]<int>::foo[abi:FOO]()", | ||
| "void TemplateStruct[abi:TEMPLATE_STRUCT]<int>::foo[abi:FOO_TEMPLATE]<long>(long)", | ||
| }, | ||
| ), | ||
| Case( | ||
| name="StaticStruct::foo", | ||
| matches={"StaticStruct[abi:STATIC_STRUCT]::foo[abi:FOO][abi:FOO2]()"}, | ||
| ), | ||
| Case(name="Struct::foo", matches={"Struct[abi:STRUCT]::foo[abi:FOO]()"}), | ||
| Case( | ||
| name="TemplateStruct::foo", | ||
| matches={ | ||
| "TemplateStruct[abi:TEMPLATE_STRUCT]<int>::foo[abi:FOO]()", | ||
| "void TemplateStruct[abi:TEMPLATE_STRUCT]<int>::foo[abi:FOO_TEMPLATE]<long>(long)", | ||
| }, | ||
| ), | ||
| Case(name="ns::foo", matches={"ns::foo[abi:NAMESPACE_FOO]()"}), | ||
| # operators | ||
| Case( | ||
| name="operator<", | ||
| matches={ | ||
| "Struct[abi:STRUCT]::operator<(int)", | ||
| "bool TemplateStruct[abi:TEMPLATE_STRUCT]<int>::operator<[abi:OPERATOR]<int>(int)", | ||
| }, | ||
| ), | ||
| Case( | ||
| name="TemplateStruct::operator<<", | ||
| matches={ | ||
| "bool TemplateStruct[abi:TEMPLATE_STRUCT]<int>::operator<<[abi:operator]<int>(int)" | ||
| }, | ||
| ), | ||
| Case( | ||
| name="operator<<", | ||
| matches={ | ||
| "bool TemplateStruct[abi:TEMPLATE_STRUCT]<int>::operator<<[abi:operator]<int>(int)" | ||
| }, | ||
| ), | ||
| Case( | ||
| name="operator==", | ||
| matches={"operator==[abi:OPERATOR](wrap_int const&, wrap_int const&)"}, | ||
| ), | ||
| ] | ||
|
|
||
| for case in test_cases: | ||
| self.verify_breakpoint_names(target, case) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify the changes to this code by splitting the "full_name" like:
Then nothing else in this function needs to change right? Or are we trying to do something with the ABI name later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the abi_tag may be in the template i.e
Module<SomeType[abi:TAG]>::findand will fail.and we also compare the tag names in case in the future we add support for
breakpoint set --name foo[abi:TAG]Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me why we didnt modify the CPlusPlusNameParser? Not saying we should, but it does parse/skip ABI tags to some extent already
Alternatively, could we search and replace all ABI tags in the name with a "simple" regex? (ignoring the question of whether we want to support setting breakpoint by specific tags, which i have some doubts about). We might be able to get away with a regex because it isnt ever valid c++ syntax. If it does clash, we could change the demangler to output something even less likely to clash with real c++. Just some ideas to avoid hand-parsing these tags.