1""" 2Test the solution to issue 11581. 3valobj.AddressOf() returns None when an address is 4expected in a SyntheticChildrenProvider 5""" 6 7 8 9import lldb 10from lldbsuite.test.decorators import * 11from lldbsuite.test.lldbtest import * 12from lldbsuite.test import lldbutil 13 14 15class Issue11581TestCase(TestBase): 16 17 mydir = TestBase.compute_mydir(__file__) 18 19 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") 20 @skipIfReproducer # Unexpected packet during replay 21 def test_11581_commands(self): 22 # This is the function to remove the custom commands in order to have a 23 # clean slate for the next test case. 24 def cleanup(): 25 self.runCmd('type synthetic clear', check=False) 26 27 # Execute the cleanup function during test case tear down. 28 self.addTearDownHook(cleanup) 29 30 """valobj.AddressOf() should return correct values.""" 31 self.build() 32 33 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 34 'Set breakpoint here.', 35 lldb.SBFileSpec("main.cpp", False)) 36 self.runCmd("command script import --allow-reload s11588.py") 37 self.runCmd( 38 "type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure") 39 40 self.expect("expr --show-types -- *((StgClosure*)(r14-1))", 41 substrs=["(StgClosure) $", 42 "(StgClosure *) &$", "0x", 43 "addr = ", 44 "load_address = "]) 45 46 # register r14 is an x86_64 extension let's skip this part of the test 47 # if we are on a different architecture 48 if self.getArchitecture() == 'x86_64': 49 target = self.dbg.GetSelectedTarget() 50 process = target.GetProcess() 51 frame = process.GetSelectedThread().GetSelectedFrame() 52 pointer = frame.FindVariable("r14") 53 addr = pointer.GetValueAsUnsigned(0) 54 self.assertNotEqual(addr, 0, "could not read pointer to StgClosure") 55 addr = addr - 1 56 self.runCmd("register write r14 %d" % addr) 57 self.expect( 58 "register read r14", substrs=[ 59 "0x", hex(addr)[ 60 2:].rstrip("L")]) # Remove trailing 'L' if it exists 61 self.expect("expr --show-types -- *(StgClosure*)$r14", 62 substrs=["(StgClosure) $", 63 "(StgClosure *) &$", "0x", 64 hex(addr)[2:].rstrip("L"), 65 "addr = ", 66 str(addr), 67 "load_address = ", 68 str(addr)]) 69