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 @skipIfWindows #This test is now flaky on windows, see llvm.org/pr24778 18 def test_11581_commands(self): 19 # This is the function to remove the custom commands in order to have a 20 # clean slate for the next test case. 21 def cleanup(): 22 self.runCmd('type synthetic clear', check=False) 23 24 # Execute the cleanup function during test case tear down. 25 self.addTearDownHook(cleanup) 26 27 """valobj.AddressOf() should return correct values.""" 28 self.build() 29 30 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 31 'Set breakpoint here.', 32 lldb.SBFileSpec("main.cpp", False)) 33 self.runCmd("command script import --allow-reload s11588.py") 34 self.runCmd( 35 "type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure") 36 37 self.expect("expr --show-types -- *((StgClosure*)(r14-1))", 38 substrs=["(StgClosure) $", 39 "(StgClosure *) &$", "0x", 40 "addr = ", 41 "load_address = "]) 42 43 # register r14 is an x86_64 extension let's skip this part of the test 44 # if we are on a different architecture 45 if self.getArchitecture() == 'x86_64': 46 target = self.dbg.GetSelectedTarget() 47 process = target.GetProcess() 48 frame = process.GetSelectedThread().GetSelectedFrame() 49 pointer = frame.FindVariable("r14") 50 addr = pointer.GetValueAsUnsigned(0) 51 self.assertNotEqual(addr, 0, "could not read pointer to StgClosure") 52 addr = addr - 1 53 self.runCmd("register write r14 %d" % addr) 54 self.expect( 55 "register read r14", substrs=[ 56 "0x", hex(addr)[ 57 2:].rstrip("L")]) # Remove trailing 'L' if it exists 58 self.expect("expr --show-types -- *(StgClosure*)$r14", 59 substrs=["(StgClosure) $", 60 "(StgClosure *) &$", "0x", 61 hex(addr)[2:].rstrip("L"), 62 "addr = ", 63 str(addr), 64 "load_address = ", 65 str(addr)]) 66