forked from OSchip/llvm-project
Revert "[lldb] Consider binary as module of last resort"
This reverts commit a3c3482ceb
.
It broke LLDB API test TestBadAddressBreakpoints.py
Differential revision: https://reviews.llvm.org/D124731
This commit is contained in:
parent
8c40e16fb4
commit
b876c23604
|
@ -121,27 +121,16 @@ Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
|
||||||
|
|
||||||
if (filter.AddressPasses(m_addr)) {
|
if (filter.AddressPasses(m_addr)) {
|
||||||
if (breakpoint.GetNumLocations() == 0) {
|
if (breakpoint.GetNumLocations() == 0) {
|
||||||
// If the address is just an offset ...
|
// If the address is just an offset, and we're given a module, see if we
|
||||||
if (!m_addr.IsSectionOffset()) {
|
// can find the appropriate module loaded in the binary, and fix up
|
||||||
ModuleSP containing_module_sp = nullptr;
|
// m_addr to use that.
|
||||||
|
if (!m_addr.IsSectionOffset() && m_module_filespec) {
|
||||||
Target &target = breakpoint.GetTarget();
|
Target &target = breakpoint.GetTarget();
|
||||||
if (m_module_filespec) {
|
ModuleSpec module_spec(m_module_filespec);
|
||||||
// ... and we're given a module, see if we can find the
|
ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
|
||||||
// appropriate module loaded in the binary, and fix up
|
if (module_sp) {
|
||||||
// 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;
|
Address tmp_address;
|
||||||
if (containing_module_sp->ResolveFileAddress(m_addr.GetOffset(),
|
if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
|
||||||
tmp_address))
|
|
||||||
m_addr = tmp_address;
|
m_addr = tmp_address;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,15 +128,13 @@ let Command = "breakpoint set" in {
|
||||||
Arg<"AddressOrExpression">, Required,
|
Arg<"AddressOrExpression">, Required,
|
||||||
Desc<"Set the breakpoint at the specified address. If the address maps "
|
Desc<"Set the breakpoint at the specified address. If the address maps "
|
||||||
"uniquely to a particular binary, then the address will be converted to "
|
"uniquely to a particular binary, then the address will be converted to "
|
||||||
"a \"file\" address, so that the breakpoint will track that binary+offset "
|
"a \"file\"address, so that the breakpoint will track that binary+offset "
|
||||||
"no matter where the binary eventually loads. Alternately, if you also "
|
"no matter where the binary eventually loads. Alternately, if you also "
|
||||||
"specify the module - with the -s option - then the address will be "
|
"specify the module - with the -s option - then the address will be "
|
||||||
"treated as a file address in that module, and resolved accordingly. "
|
"treated as a file address in that module, and resolved accordingly. "
|
||||||
"Again, this will allow lldb to track that offset on subsequent reloads. "
|
"Again, this will allow lldb to track that offset on subsequent reloads. "
|
||||||
"The module need not have been loaded at the time you specify this "
|
"The module need not have been loaded at the time you specify this "
|
||||||
"breakpoint, and will get resolved when the module is loaded. If no "
|
"breakpoint, and will get resolved when the module is loaded.">;
|
||||||
"module is specified, the binary being debugged is considered as a "
|
|
||||||
"fallback.">;
|
|
||||||
def breakpoint_set_name : Option<"name", "n">, Group<3>, Arg<"FunctionName">,
|
def breakpoint_set_name : Option<"name", "n">, Group<3>, Arg<"FunctionName">,
|
||||||
Completion<"Symbol">, Required,
|
Completion<"Symbol">, Required,
|
||||||
Desc<"Set the breakpoint by function name. Can be repeated multiple times "
|
Desc<"Set the breakpoint by function name. Can be repeated multiple times "
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
C_SOURCES := inferior.c
|
|
||||||
|
|
||||||
include Makefile.rules
|
|
|
@ -1,36 +0,0 @@
|
||||||
import lldb
|
|
||||||
from lldbsuite.test.decorators import *
|
|
||||||
from lldbsuite.test.lldbtest import *
|
|
||||||
from lldbsuite.test import lldbutil
|
|
||||||
|
|
||||||
class TestCase(TestBase):
|
|
||||||
|
|
||||||
mydir = TestBase.compute_mydir(__file__)
|
|
||||||
|
|
||||||
def get_address_from_symbol(self, symbol):
|
|
||||||
target = lldbutil.run_to_breakpoint_make_target(self, "a.out", True)
|
|
||||||
bp = target.BreakpointCreateByName(symbol, None)
|
|
||||||
address = bp.GetLocationAtIndex(0).GetAddress().GetFileAddress()
|
|
||||||
return address
|
|
||||||
|
|
||||||
def test_set_address_no_module(self):
|
|
||||||
self.build()
|
|
||||||
|
|
||||||
main_address = self.get_address_from_symbol("main")
|
|
||||||
|
|
||||||
target = lldbutil.run_to_breakpoint_make_target(self)
|
|
||||||
debugger = target.GetDebugger()
|
|
||||||
|
|
||||||
debugger.HandleCommand(f"break set -a {main_address:#x}")
|
|
||||||
self.assertEquals(target.GetNumBreakpoints(), 1)
|
|
||||||
|
|
||||||
bp = target.GetBreakpointAtIndex(0)
|
|
||||||
self.assertIsNotNone(bp)
|
|
||||||
|
|
||||||
_, _, thread, _ = lldbutil.run_to_breakpoint_do_run(self, target, bp)
|
|
||||||
self.assertGreaterEqual(thread.GetNumFrames(), 1)
|
|
||||||
|
|
||||||
thread_pc = thread.GetFrameAtIndex(0).GetPCAddress()
|
|
||||||
self.assertNotEqual(thread_pc, None)
|
|
||||||
|
|
||||||
self.assertEquals(main_address, thread_pc.GetFileAddress())
|
|
|
@ -1,6 +0,0 @@
|
||||||
int function(int a) { return a; }
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int f = function(10);
|
|
||||||
return f;
|
|
||||||
}
|
|
Loading…
Reference in New Issue