hawkinsw updated this revision to Diff 427791. hawkinsw added a comment. Updated patch including responses to helpful feedback from @jingham.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124731/new/ 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