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;
}
}
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;
}
}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits