-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Fix breakpoint resolver serialization bug #76766
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
Conversation
@llvm/pr-subscribers-lldb Author: Alex Langford (bulbazord) ChangesBreakpointResolverAddress 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). Full diff: https://github.com/llvm/llvm-project/pull/76766.diff 1 Files Affected:
diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..dcdcea101045f7 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,9 @@ 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())
+ options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_sp->GetObjectName().GetCString());
options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
m_addr.GetOffset());
} else {
|
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 this be tested?
I took a look at existing tests, but I'm not sure how to best test this. I think we would need to create a breakpoint in a module by address and make sure the resolver correctly serializes the name (in |
That can work. Another idea is to create a test that sets a breakpoint by function name where we will find one match. After setting this breakpoint, get the one and only SBBreakpointLocation from this breakpoint and get the SBAddress from the location. Then delete the breakpoint by function name and create one using the SBAddress using:
You can then serialize the breakpoints to a JSON file using:
Then you can use the JSON to verify the bug is fixed? |
519f2db
to
a9b6b6f
Compare
@clayborg I was able to write a test similar to what you suggested (without needing to set two breakpoints). I also changed the actual fix since a module's object name isn't quite what I wanted in the first place. |
✅ With the latest revision this PR passed the Python code formatter. |
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).
a9b6b6f
to
9688e85
Compare
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.
One quick fix suggested, but looks good.
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
Outdated
Show resolved
Hide resolved
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.
Looks good!
Looks like this broke on aarch64-windows. Taking a look now. https://lab.llvm.org/buildbot/#/builders/219/builds/7961/steps/6/logs/stdio |
@clayborg Any idea why the executable module wouldn't be found here? Looks like |
You can just use "a.out" when doing the lookup, do this:
The full path isn't needed. I would guess there might be some sort of path issue with the value returned from |
Speculative fix in bdaedff |
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).