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