Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / macosx / unregistered-macho / TestUnregisteredMacho.py
blob54c0f191640156300dcdd1f01d7dbb7ad907568a
1 """Test that debugserver will parse a mach-o in inferior memory even if it's not loaded."""
3 import os
4 import re
5 import subprocess
7 import lldb
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
15 # to support this
16 @skipIfOutOfTreeDebugserver
17 @no_debug_info_test
18 @skipUnlessDarwin
19 def test(self):
20 self.build()
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
29 gdb_packet = (
30 "process plugin packet send 'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'"
31 % macho_addr
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.
40 self.expect(
41 gdb_packet,
42 substrs=['"pathname":""', '"uuid":"1B4E28BA-2FA1-11D2-883F-B9A761BDE3FB"'],
45 no_macho_gdb_packet = (
46 "process plugin packet send 'jGetLoadedDynamicLibrariesInfos:{\"solib_addresses\":[%d]}]'"
47 % invalid_macho_addr
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.
54 both_gdb_packet = (
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])
59 self.expect(
60 both_gdb_packet,
61 substrs=['"load_address":%d,' % invalid_macho_addr],
62 matching=False,