]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / tools / lldb-server / TestGdbRemoteExpeditedRegisters.py
1 from __future__ import print_function
2
3
4 import gdbremote_testcase
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
8
9
10 class TestGdbRemoteExpeditedRegisters(
11         gdbremote_testcase.GdbRemoteTestCaseBase):
12
13     mydir = TestBase.compute_mydir(__file__)
14
15     def gather_expedited_registers(self):
16         # Setup the stub and set the gdb remote command stream.
17         procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:2"])
18         self.test_sequence.add_log_lines([
19             # Start up the inferior.
20             "read packet: $c#63",
21             # Immediately tell it to stop.  We want to see what it reports.
22             "read packet: {}".format(chr(3)),
23             {"direction": "send",
24              "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
25              "capture": {1: "stop_result",
26                          2: "key_vals_text"}},
27         ], True)
28
29         # Run the gdb remote command stream.
30         context = self.expect_gdbremote_sequence()
31         self.assertIsNotNone(context)
32
33         # Pull out expedited registers.
34         key_vals_text = context.get("key_vals_text")
35         self.assertIsNotNone(key_vals_text)
36
37         expedited_registers = self.extract_registers_from_stop_notification(
38             key_vals_text)
39         self.assertIsNotNone(expedited_registers)
40
41         return expedited_registers
42
43     def stop_notification_contains_generic_register(
44             self, generic_register_name):
45         # Generate a stop reply, parse out expedited registers from stop
46         # notification.
47         expedited_registers = self.gather_expedited_registers()
48         self.assertIsNotNone(expedited_registers)
49         self.assertTrue(len(expedited_registers) > 0)
50
51         # Gather target register infos.
52         reg_infos = self.gather_register_infos()
53
54         # Find the generic register.
55         reg_info = self.find_generic_register_with_name(
56             reg_infos, generic_register_name)
57         self.assertIsNotNone(reg_info)
58
59         # Ensure the expedited registers contained it.
60         self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
61         # print("{} reg_info:{}".format(generic_register_name, reg_info))
62
63     def stop_notification_contains_any_registers(self):
64         # Generate a stop reply, parse out expedited registers from stop
65         # notification.
66         expedited_registers = self.gather_expedited_registers()
67         # Verify we have at least one expedited register.
68         self.assertTrue(len(expedited_registers) > 0)
69
70     @debugserver_test
71     def test_stop_notification_contains_any_registers_debugserver(self):
72         self.init_debugserver_test()
73         self.build()
74         self.set_inferior_startup_launch()
75         self.stop_notification_contains_any_registers()
76
77     @llgs_test
78     def test_stop_notification_contains_any_registers_llgs(self):
79         self.init_llgs_test()
80         self.build()
81         self.set_inferior_startup_launch()
82         self.stop_notification_contains_any_registers()
83
84     def stop_notification_contains_no_duplicate_registers(self):
85         # Generate a stop reply, parse out expedited registers from stop
86         # notification.
87         expedited_registers = self.gather_expedited_registers()
88         # Verify no expedited register was specified multiple times.
89         for (reg_num, value) in list(expedited_registers.items()):
90             if (isinstance(value, list)) and (len(value) > 0):
91                 self.fail(
92                     "expedited register number {} specified more than once ({} times)".format(
93                         reg_num, len(value)))
94
95     @debugserver_test
96     def test_stop_notification_contains_no_duplicate_registers_debugserver(
97             self):
98         self.init_debugserver_test()
99         self.build()
100         self.set_inferior_startup_launch()
101         self.stop_notification_contains_no_duplicate_registers()
102
103     @llgs_test
104     def test_stop_notification_contains_no_duplicate_registers_llgs(self):
105         self.init_llgs_test()
106         self.build()
107         self.set_inferior_startup_launch()
108         self.stop_notification_contains_no_duplicate_registers()
109
110     def stop_notification_contains_pc_register(self):
111         self.stop_notification_contains_generic_register("pc")
112
113     @debugserver_test
114     def test_stop_notification_contains_pc_register_debugserver(self):
115         self.init_debugserver_test()
116         self.build()
117         self.set_inferior_startup_launch()
118         self.stop_notification_contains_pc_register()
119
120     @llgs_test
121     def test_stop_notification_contains_pc_register_llgs(self):
122         self.init_llgs_test()
123         self.build()
124         self.set_inferior_startup_launch()
125         self.stop_notification_contains_pc_register()
126
127     def stop_notification_contains_fp_register(self):
128         self.stop_notification_contains_generic_register("fp")
129
130     @debugserver_test
131     def test_stop_notification_contains_fp_register_debugserver(self):
132         self.init_debugserver_test()
133         self.build()
134         self.set_inferior_startup_launch()
135         self.stop_notification_contains_fp_register()
136
137     @llgs_test
138     def test_stop_notification_contains_fp_register_llgs(self):
139         self.init_llgs_test()
140         self.build()
141         self.set_inferior_startup_launch()
142         self.stop_notification_contains_fp_register()
143
144     def stop_notification_contains_sp_register(self):
145         self.stop_notification_contains_generic_register("sp")
146
147     @debugserver_test
148     def test_stop_notification_contains_sp_register_debugserver(self):
149         self.init_debugserver_test()
150         self.build()
151         self.set_inferior_startup_launch()
152         self.stop_notification_contains_sp_register()
153
154     @llgs_test
155     def test_stop_notification_contains_sp_register_llgs(self):
156         self.init_llgs_test()
157         self.build()
158         self.set_inferior_startup_launch()
159         self.stop_notification_contains_sp_register()