]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/objc/ivar-IMP/TestObjCiVarIMP.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / objc / ivar-IMP / TestObjCiVarIMP.py
1 """
2 Test that dynamically discovered ivars of type IMP do not crash LLDB
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import re
11 import lldb
12 import lldbsuite.test.lldbutil as lldbutil
13 from lldbsuite.test.lldbtest import *
14 import lldbsuite.support.seven as seven
15
16 def execute_command (command):
17     # print('%% %s' % (command))
18     (exit_status, output) = seven.get_command_status_output(command)
19     # if output:
20     #     print(output)
21     # print('status = %u' % (exit_status))
22     return exit_status
23
24 class ObjCiVarIMPTestCase(TestBase):
25
26     mydir = TestBase.compute_mydir(__file__)
27
28     @skipUnlessDarwin
29     @no_debug_info_test
30     def test_imp_ivar_type(self):
31         """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
32         if self.getArchitecture() == 'i386':
33             # rdar://problem/9946499
34             self.skipTest("Dynamic types for ObjC V1 runtime not implemented")
35         
36         execute_command("make repro")
37         def cleanup():
38             execute_command("make cleanup")
39         self.addTearDownHook(cleanup)
40
41         exe = os.path.join(os.getcwd(), "a.out")
42
43         # Create a target from the debugger.
44         target = self.dbg.CreateTarget (exe)
45         self.assertTrue(target, VALID_TARGET)
46
47         # Set up our breakpoint
48
49         bkpt = lldbutil.run_break_set_by_source_regexp (self, "break here")
50
51         # Now launch the process, and do not stop at the entry point.
52         process = target.LaunchSimple (None, None, self.get_process_working_directory())
53
54         self.assertTrue(process.GetState() == lldb.eStateStopped,
55                         PROCESS_STOPPED)
56
57         self.expect('frame variable --ptr-depth=1 --show-types -d run -- object', substrs=[
58             '(MyClass *) object = 0x',
59             '(void *) myImp = 0x'
60         ])
61         self.expect('disassemble --start-address `((MyClass*)object)->myImp`', substrs=[
62             '-[MyClass init]'
63         ])