2 Test the solution to issue 11581.
3 valobj.AddressOf() returns None when an address is
4 expected in a SyntheticChildrenProvider
7 from __future__ import print_function
13 import lldbsuite.test.lldbutil as lldbutil
14 from lldbsuite.test.lldbtest import *
16 class Issue11581TestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
20 @expectedFailureWindows("llvm.org/pr24778")
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.
25 self.runCmd('type synthetic clear', check=False)
28 # Execute the cleanup function during test case tear down.
29 self.addTearDownHook(cleanup)
31 """valobj.AddressOf() should return correct values."""
34 exe = os.path.join(os.getcwd(), "a.out")
36 target = self.dbg.CreateTarget(exe)
37 self.assertTrue(target, VALID_TARGET)
39 breakpoint = target.BreakpointCreateBySourceRegex('Set breakpoint here.',lldb.SBFileSpec ("main.cpp", False))
41 process = target.LaunchSimple (None, None, self.get_process_working_directory())
42 self.assertTrue (process, "Created a process.")
43 self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.")
45 thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
46 self.assertTrue (len(thread_list) == 1)
47 thread = thread_list[0]
49 self.runCmd("command script import --allow-reload s11588.py")
50 self.runCmd("type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure")
52 self.expect("expr --show-types -- *((StgClosure*)(r14-1))",
53 substrs = ["(StgClosure) $",
54 "(StgClosure *) &$","0x",
58 # register r14 is an x86_64 extension let's skip this part of the test
59 # if we are on a different architecture
60 if self.getArchitecture() == 'x86_64':
61 target = lldb.debugger.GetSelectedTarget()
62 process = target.GetProcess()
63 frame = process.GetSelectedThread().GetSelectedFrame()
64 pointer = frame.FindVariable("r14")
65 addr = pointer.GetValueAsUnsigned(0)
66 self.assertTrue(addr != 0, "could not read pointer to StgClosure")
68 self.runCmd("register write r14 %d" % addr)
69 self.expect("register read r14",
70 substrs = ["0x",hex(addr)[2:].rstrip("L")]) # Remove trailing 'L' if it exists
71 self.expect("expr --show-types -- *(StgClosure*)$r14",
72 substrs = ["(StgClosure) $",
73 "(StgClosure *) &$","0x",
76 hex(addr)[2:].rstrip("L"),