1 import gdbremote_testcase
2 from lldbsuite
.test
.decorators
import *
3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
import lldbutil
7 class TestGdbRemoteExpeditedRegisters(gdbremote_testcase
.GdbRemoteTestCaseBase
):
8 # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
9 def gather_expedited_registers(self
):
10 # Setup the stub and set the gdb remote command stream.
11 procs
= self
.prep_debug_monitor_and_inferior(inferior_args
=["sleep:2"])
12 self
.test_sequence
.add_log_lines(
14 # Start up the inferior.
16 # Immediately tell it to stop. We want to see what it reports.
17 "read packet: {}".format(chr(3)),
20 "regex": r
"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$",
21 "capture": {1: "stop_result", 2: "key_vals_text"},
27 # Run the gdb remote command stream.
28 context
= self
.expect_gdbremote_sequence()
29 self
.assertIsNotNone(context
)
31 # Pull out expedited registers.
32 key_vals_text
= context
.get("key_vals_text")
33 self
.assertIsNotNone(key_vals_text
)
35 expedited_registers
= self
.extract_registers_from_stop_notification(
38 self
.assertIsNotNone(expedited_registers
)
40 return expedited_registers
42 def stop_notification_contains_generic_register(self
, generic_register_name
):
43 # Generate a stop reply, parse out expedited registers from stop
45 expedited_registers
= self
.gather_expedited_registers()
46 self
.assertIsNotNone(expedited_registers
)
47 self
.assertTrue(len(expedited_registers
) > 0)
49 # Gather target register infos.
50 reg_infos
= self
.gather_register_infos()
52 # Find the generic register.
53 reg_info
= self
.find_generic_register_with_name(
54 reg_infos
, generic_register_name
56 self
.assertIsNotNone(reg_info
)
58 # Ensure the expedited registers contained it.
59 self
.assertIn(reg_info
["lldb_register_index"], expedited_registers
)
60 self
.trace("{} reg_info:{}".format(generic_register_name
, reg_info
))
62 def test_stop_notification_contains_any_registers(self
):
64 self
.set_inferior_startup_launch()
66 # Generate a stop reply, parse out expedited registers from stop
68 expedited_registers
= self
.gather_expedited_registers()
69 # Verify we have at least one expedited register.
70 self
.assertTrue(len(expedited_registers
) > 0)
72 def test_stop_notification_contains_no_duplicate_registers(self
):
74 self
.set_inferior_startup_launch()
76 # Generate a stop reply, parse out expedited registers from stop
78 expedited_registers
= self
.gather_expedited_registers()
79 # Verify no expedited register was specified multiple times.
80 for reg_num
, value
in list(expedited_registers
.items()):
81 if (isinstance(value
, list)) and (len(value
) > 0):
83 "expedited register number {} specified more than once ({} times)".format(
88 def test_stop_notification_contains_pc_register(self
):
90 self
.set_inferior_startup_launch()
91 self
.stop_notification_contains_generic_register("pc")
93 @skipIf(triple
="^powerpc64") # powerpc64 has no FP register
94 def test_stop_notification_contains_fp_register(self
):
96 self
.set_inferior_startup_launch()
97 self
.stop_notification_contains_generic_register("fp")
99 def test_stop_notification_contains_sp_register(self
):
101 self
.set_inferior_startup_launch()
102 self
.stop_notification_contains_generic_register("sp")
104 @skipIf(archs
=no_match(["aarch64"]))
105 @skipIf(oslist
=no_match(["linux"]))
106 def test_stop_notification_contains_vg_register(self
):
107 if not self
.isAArch64SVE():
108 self
.skipTest("SVE registers must be supported.")
110 self
.set_inferior_startup_launch()
112 # Generate a stop reply, parse out expedited registers from stop
114 expedited_registers
= self
.gather_expedited_registers()
115 self
.assertIsNotNone(expedited_registers
)
116 self
.assertTrue(len(expedited_registers
) > 0)
118 # Gather target register infos.
119 reg_infos
= self
.gather_register_infos()
121 # Find the vg register.
122 reg_info
= self
.find_register_with_name_and_dwarf_regnum(reg_infos
, "vg", "46")
123 self
.assertIsNotNone(reg_info
)
125 # Ensure the expedited registers contained it.
126 self
.assertIn(reg_info
["lldb_register_index"], expedited_registers
)
127 self
.trace("{} reg_info:{}".format("vg", reg_info
))