1 """Test that debugserver will parse a mach-o in inferior memory even if it's not loaded."""
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class TestUnregisteredMacho(TestBase
):
14 # newer debugserver required for jGetLoadedDynamicLibrariesInfos
16 @skipIfOutOfTreeDebugserver
21 target
, process
, thread
, bkpt
= lldbutil
.run_to_source_breakpoint(
22 self
, "// break here", lldb
.SBFileSpec("main.c")
25 frame
= thread
.GetFrameAtIndex(0)
26 macho_buf
= frame
.GetValueForVariablePath("macho_buf")
27 macho_addr
= macho_buf
.GetValueAsUnsigned()
28 invalid_macho_addr
= macho_buf
.GetValueAsUnsigned() + 4
30 "process plugin packet send 'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'"
34 # Send the jGetLoadedDynamicLibrariesInfos packet
35 # to debugserver, asking it to parse the mach-o binary
36 # at this address and give us the UUID etc, even though
37 # dyld doesn't think there is a binary at that address.
38 # We won't get a pathname for the binary (from dyld), but
39 # we will get to the LC_UUID and include that.
42 substrs
=['"pathname":""', '"uuid":"1B4E28BA-2FA1-11D2-883F-B9A761BDE3FB"'],
45 no_macho_gdb_packet
= (
46 "process plugin packet send 'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'"
49 self
.expect(no_macho_gdb_packet
, substrs
=['response: {"images":[]}'])
51 # Test that we get back the information for the properly
52 # formatted Mach-O binary in memory, but do not get an
53 # entry for the invalid Mach-O address.
55 "process plugin packet send 'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d,%d]}]'"
56 % (macho_addr
, invalid_macho_addr
)
58 self
.expect(both_gdb_packet
, substrs
=['"load_address":%d,' % macho_addr
])
61 substrs
=['"load_address":%d,' % invalid_macho_addr
],