[Lldb-commits] [PATCH] D124731: [lldb] Consider binary as module of last resort
Will Hawkins via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sun May 1 00:05:33 PDT 2022
hawkinsw created this revision.
hawkinsw added reviewers: tatyana-krasnukha, jingham.
Herald added a project: All.
hawkinsw requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
When setting an address breakpoint using a non-section address
in lldb before having ever run the program, the binary itself
is not considered a module. As a result, the breakpoint is
unresolved (and never gets resolved subsequently).
This patch changes that behavior: as a last resort, the binary
is considered as a module when resolving a non-section address
breakpoint.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124731
Files:
lldb/source/Breakpoint/BreakpointResolverAddress.cpp
Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -121,16 +121,27 @@
if (filter.AddressPasses(m_addr)) {
if (breakpoint.GetNumLocations() == 0) {
- // If the address is just an offset, and we're given a module, see if we
- // can find the appropriate module loaded in the binary, and fix up
- // m_addr to use that.
- if (!m_addr.IsSectionOffset() && m_module_filespec) {
+ // If the address is just an offset ...
+ if (!m_addr.IsSectionOffset()) {
+ ModuleSP containing_module_sp = nullptr;
Target &target = breakpoint.GetTarget();
- ModuleSpec module_spec(m_module_filespec);
- ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
- if (module_sp) {
+ if (m_module_filespec) {
+ // ... and we're given a module, see if we can find the
+ // appropriate module loaded in the binary, and fix up
+ // m_addr to use that.
+ ModuleSpec module_spec(m_module_filespec);
+ containing_module_sp =
+ target.GetImages().FindFirstModule(module_spec);
+ } else {
+ // ... and we're not given a module, see if the offset is
+ // somewhere in the executable module. If it is, then we'll
+ // fix up m_addr to use that.
+ containing_module_sp = target.GetExecutableModule();
+ }
+ if (containing_module_sp) {
Address tmp_address;
- if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
+ if (containing_module_sp->ResolveFileAddress(m_addr.GetOffset(),
+ tmp_address))
m_addr = tmp_address;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124731.426273.patch
Type: text/x-patch
Size: 1917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220501/4541f4e1/attachment-0001.bin>
More information about the lldb-commits
mailing list