Lines Matching defs:self

29     def test_thread_suffix_supported(self):
30 server = self.connect_to_debug_monitor()
31 self.assertIsNotNone(server)
33 self.do_handshake()
34 self.test_sequence.add_log_lines(
42 self.expect_gdbremote_sequence()
44 def test_list_threads_in_stop_reply_supported(self):
45 server = self.connect_to_debug_monitor()
46 self.assertIsNotNone(server)
48 self.do_handshake()
49 self.test_sequence.add_log_lines(
56 self.expect_gdbremote_sequence()
58 def test_c_packet_works(self):
59 self.build()
60 procs = self.prep_debug_monitor_and_inferior()
61 self.test_sequence.add_log_lines(
65 self.expect_gdbremote_sequence()
68 def test_inferior_print_exit(self):
69 self.build()
70 procs = self.prep_debug_monitor_and_inferior(inferior_args=["hello, world"])
71 self.test_sequence.add_log_lines(
76 "regex": self.maybe_strict_output_regex(r"hello, world\r\n"),
83 context = self.expect_gdbremote_sequence()
84 self.assertIsNotNone(context)
86 def test_first_launch_stop_reply_thread_matches_first_qC(self):
87 self.build()
88 procs = self.prep_debug_monitor_and_inferior()
89 self.test_sequence.add_log_lines(
106 context = self.expect_gdbremote_sequence()
107 self.assertEqual(context.get("thread_id_QC"), context.get("thread_id_?"))
109 def test_attach_commandline_continue_app_exits(self):
110 self.build()
111 self.set_inferior_startup_attach()
112 procs = self.prep_debug_monitor_and_inferior()
113 self.test_sequence.add_log_lines(
116 self.expect_gdbremote_sequence()
125 self.assertIsNotNone(poll_result)
129 self.assertFalse(
133 def test_qRegisterInfo_returns_one_valid_result(self):
134 self.build()
135 self.prep_debug_monitor_and_inferior()
136 self.test_sequence.add_log_lines(
149 context = self.expect_gdbremote_sequence()
150 self.assertIsNotNone(context)
153 self.assertIsNotNone(reg_info_packet)
154 self.assert_valid_reg_info(
158 def test_qRegisterInfo_returns_all_valid_results(self):
159 self.build()
160 self.prep_debug_monitor_and_inferior()
161 self.add_register_info_collection_packets()
164 context = self.expect_gdbremote_sequence()
165 self.assertIsNotNone(context)
168 for reg_info in self.parse_register_info_packets(context):
169 self.assert_valid_reg_info(reg_info)
171 def test_qRegisterInfo_contains_required_generics_debugserver(self):
172 self.build()
173 self.prep_debug_monitor_and_inferior()
174 self.add_register_info_collection_packets()
177 context = self.expect_gdbremote_sequence()
178 self.assertIsNotNone(context)
181 reg_infos = self.parse_register_info_packets(context)
189 self.assertIn("pc", generic_regs)
192 if self.getArchitecture() != "powerpc64le":
193 self.assertIn("fp", generic_regs)
196 self.assertIn("sp", generic_regs)
199 self.assertIn("flags", generic_regs)
201 def test_qRegisterInfo_contains_at_least_one_register_set(self):
202 self.build()
203 self.prep_debug_monitor_and_inferior()
204 self.add_register_info_collection_packets()
207 context = self.expect_gdbremote_sequence()
208 self.assertIsNotNone(context)
211 reg_infos = self.parse_register_info_packets(context)
217 self.assertGreaterEqual(len(register_sets), 1)
219 def targetHasAVX(self):
220 triple = self.dbg.GetSelectedPlatform().GetTriple()
228 self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
230 self.addTearDownHook(lambda: os.unlink("cpuinfo"))
242 def test_qRegisterInfo_contains_avx_registers(self):
243 self.build()
244 self.prep_debug_monitor_and_inferior()
245 self.add_register_info_collection_packets()
248 context = self.expect_gdbremote_sequence()
249 self.assertIsNotNone(context)
252 reg_infos = self.parse_register_info_packets(context)
258 self.assertEqual(
259 self.targetHasAVX(), "Advanced Vector Extensions" in register_sets
262 def qThreadInfo_contains_thread(self):
263 procs = self.prep_debug_monitor_and_inferior()
264 self.add_threadinfo_collection_packets()
267 context = self.expect_gdbremote_sequence()
268 self.assertIsNotNone(context)
271 threads = self.parse_threadinfo_packets(context)
272 self.assertIsNotNone(threads)
275 self.assertEqual(len(threads), 1)
277 def test_qThreadInfo_contains_thread_launch(self):
278 self.build()
279 self.set_inferior_startup_launch()
280 self.qThreadInfo_contains_thread()
283 def test_qThreadInfo_contains_thread_attach(self):
284 self.build()
285 self.set_inferior_startup_attach()
286 self.qThreadInfo_contains_thread()
288 def qThreadInfo_matches_qC(self):
289 procs = self.prep_debug_monitor_and_inferior()
291 self.add_threadinfo_collection_packets()
292 self.test_sequence.add_log_lines(
305 context = self.expect_gdbremote_sequence()
306 self.assertIsNotNone(context)
309 threads = self.parse_threadinfo_packets(context)
310 self.assertIsNotNone(threads)
313 self.assertEqual(len(threads), 1)
317 self.assertIsNotNone(QC_thread_id_hex)
321 self.assertEqual(threads[0], QC_thread_id)
323 def test_qThreadInfo_matches_qC_launch(self):
324 self.build()
325 self.set_inferior_startup_launch()
326 self.qThreadInfo_matches_qC()
329 def test_qThreadInfo_matches_qC_attach(self):
330 self.build()
331 self.set_inferior_startup_attach()
332 self.qThreadInfo_matches_qC()
334 def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch(self):
335 self.build()
336 self.set_inferior_startup_launch()
337 procs = self.prep_debug_monitor_and_inferior()
338 self.add_register_info_collection_packets()
341 context = self.expect_gdbremote_sequence()
342 self.assertIsNotNone(context)
345 reg_infos = self.parse_register_info_packets(context)
346 self.assertIsNotNone(reg_infos)
347 self.assertGreater(len(reg_infos), 0)
349 byte_order = self.get_target_byte_order()
362 self.reset_test_sequence()
365 self.test_sequence.add_log_lines(
376 context = self.expect_gdbremote_sequence()
377 self.assertIsNotNone(context)
381 self.assertIsNotNone(p_response)
389 self.updateRegInfoBitsize(reg_info, byte_order)
390 self.assertEqual(
397 def Hg_switches_to_3_threads(self, pass_pid=False):
398 _, threads = self.launch_with_threads(3)
407 self.reset_test_sequence()
408 self.test_sequence.add_log_lines(
424 context = self.expect_gdbremote_sequence()
425 self.assertIsNotNone(context)
428 self.assertIsNotNone(context.get("thread_id"))
429 self.assertEqual(int(context.get("thread_id"), 16), thread)
432 def test_Hg_switches_to_3_threads_launch(self):
433 self.build()
434 self.set_inferior_startup_launch()
435 self.Hg_switches_to_3_threads()
437 def Hg_fails_on_pid(self, pass_pid):
438 _, threads = self.launch_with_threads(2)
446 self.test_sequence.add_log_lines(
456 self.expect_gdbremote_sequence()
459 def test_Hg_fails_on_another_pid(self):
460 self.build()
461 self.set_inferior_startup_launch()
462 self.Hg_fails_on_pid(1)
465 def test_Hg_fails_on_zero_pid(self):
466 self.build()
467 self.set_inferior_startup_launch()
468 self.Hg_fails_on_pid(0)
472 def test_Hg_fails_on_minus_one_pid(self):
473 self.build()
474 self.set_inferior_startup_launch()
475 self.Hg_fails_on_pid(-1)
477 def Hc_then_Csignal_signals_correct_thread(self, segfault_signo):
495 procs = self.prep_debug_monitor_and_inferior(inferior_args=inferior_args)
496 self.test_sequence.add_log_lines(["read packet: $c#63"], True)
497 context = self.expect_gdbremote_sequence()
505 self.reset_test_sequence()
506 self.test_sequence.add_log_lines(
517 context = self.expect_gdbremote_sequence()
518 self.assertIsNotNone(context)
520 self.assertEqual(int(signo, 16), segfault_signo)
524 self.assertNotIn(thread_id, signaled_tids)
528 self.reset_test_sequence()
529 self.test_sequence.add_log_lines(
558 context = self.expect_gdbremote_sequence()
559 self.assertIsNotNone(context)
563 # self.assertIsNotNone(stop_signo)
564 # self.assertEqual(int(stop_signo,16), lldbutil.get_signal_number('SIGUSR1'))
568 # self.assertIsNotNone(stop_thread_id)
569 # self.assertEqual(int(stop_thread_id,16), thread_id)
572 # self-obtained thread ids are not guaranteed to match the stub
575 self.assertIsNotNone(print_thread_id)
577 self.assertNotIn(print_thread_id, print_thread_ids)
586 self.assertIsNotNone(post_handle_thread_id)
588 self.assertEqual(post_handle_thread_id, print_thread_id)
593 def test_Hc_then_Csignal_signals_correct_thread_launch(self):
594 self.build()
595 self.set_inferior_startup_launch()
597 if self.platformIsDarwin():
600 self.Hc_then_Csignal_signals_correct_thread(self.TARGET_EXC_BAD_ACCESS)
602 self.Hc_then_Csignal_signals_correct_thread(
607 def test_m_packet_reads_memory(self):
608 self.build()
609 self.set_inferior_startup_launch()
615 procs = self.prep_debug_monitor_and_inferior(
624 self.test_sequence.add_log_lines(
632 "regex": self.maybe_strict_output_regex(
650 context = self.expect_gdbremote_sequence()
651 self.assertIsNotNone(context)
654 self.assertIsNotNone(context.get("message_address"))
658 self.reset_test_sequence()
659 self.test_sequence.add_log_lines(
674 context = self.expect_gdbremote_sequence()
675 self.assertIsNotNone(context)
678 self.assertIsNotNone(context.get("read_contents"))
680 self.assertEqual(read_contents, MEMORY_CONTENTS)
682 def test_qMemoryRegionInfo_is_supported(self):
683 self.build()
684 self.set_inferior_startup_launch()
686 procs = self.prep_debug_monitor_and_inferior()
689 self.test_sequence.add_log_lines(
692 self.expect_gdbremote_sequence()
695 def test_qMemoryRegionInfo_reports_code_address_as_executable(self):
696 self.build()
697 self.set_inferior_startup_launch()
700 procs = self.prep_debug_monitor_and_inferior(
705 self.test_sequence.add_log_lines(
713 "regex": self.maybe_strict_output_regex(
731 context = self.expect_gdbremote_sequence()
732 self.assertIsNotNone(context)
735 self.assertIsNotNone(context.get("code_address"))
739 self.reset_test_sequence()
740 self.add_query_memory_region_packets(code_address)
743 context = self.expect_gdbremote_sequence()
744 self.assertIsNotNone(context)
745 mem_region_dict = self.parse_memory_region_packet(context)
748 self.assertNotIn("error", mem_region_dict)
751 self.assertIn("permissions", mem_region_dict)
752 self.assertIn("r", mem_region_dict["permissions"])
753 self.assertIn("x", mem_region_dict["permissions"])
756 self.assert_address_within_memory_region(code_address, mem_region_dict)
759 def test_qMemoryRegionInfo_reports_stack_address_as_rw(self):
760 self.build()
761 self.set_inferior_startup_launch()
764 procs = self.prep_debug_monitor_and_inferior(
769 self.test_sequence.add_log_lines(
777 "regex": self.maybe_strict_output_regex(
795 context = self.expect_gdbremote_sequence()
796 self.assertIsNotNone(context)
799 self.assertIsNotNone(context.get("stack_address"))
803 self.reset_test_sequence()
804 self.add_query_memory_region_packets(stack_address)
807 context = self.expect_gdbremote_sequence()
808 self.assertIsNotNone(context)
809 mem_region_dict = self.parse_memory_region_packet(context)
812 self.assertNotIn("error", mem_region_dict)
815 self.assertIn("permissions", mem_region_dict)
816 self.assertIn("r", mem_region_dict["permissions"])
817 self.assertIn("w", mem_region_dict["permissions"])
820 self.assert_address_within_memory_region(stack_address, mem_region_dict)
823 def test_qMemoryRegionInfo_reports_heap_address_as_rw(self):
824 self.build()
825 self.set_inferior_startup_launch()
828 procs = self.prep_debug_monitor_and_inferior(
833 self.test_sequence.add_log_lines(
841 "regex": self.maybe_strict_output_regex(
859 context = self.expect_gdbremote_sequence()
860 self.assertIsNotNone(context)
863 self.assertIsNotNone(context.get("heap_address"))
867 self.reset_test_sequence()
868 self.add_query_memory_region_packets(heap_address)
871 context = self.expect_gdbremote_sequence()
872 self.assertIsNotNone(context)
873 mem_region_dict = self.parse_memory_region_packet(context)
876 self.assertNotIn("error", mem_region_dict)
879 self.assertIn("permissions", mem_region_dict)
880 self.assertIn("r", mem_region_dict["permissions"])
881 self.assertIn("w", mem_region_dict["permissions"])
884 self.assert_address_within_memory_region(heap_address, mem_region_dict)
886 def breakpoint_set_and_remove_work(self, want_hardware):
888 procs = self.prep_debug_monitor_and_inferior(
897 self.add_register_info_collection_packets()
898 self.add_process_info_collection_packets()
899 self.test_sequence.add_log_lines(
906 "regex": self.maybe_strict_output_regex(
924 context = self.expect_gdbremote_sequence()
925 self.assertIsNotNone(context)
929 process_info = self.parse_process_info_response(context)
931 self.assertIsNotNone(endian)
934 reg_infos = self.parse_register_info_packets(context)
935 (pc_lldb_reg_index, pc_reg_info) = self.find_pc_reg_info(reg_infos)
936 self.assertIsNotNone(pc_lldb_reg_index)
937 self.assertIsNotNone(pc_reg_info)
940 self.assertIsNotNone(context.get("function_address"))
944 target_arch = self.getArchitecture()
960 self.reset_test_sequence()
961 self.add_set_breakpoint_packets(
969 context = self.expect_gdbremote_sequence()
970 self.assertIsNotNone(context)
974 self.assertIsNotNone(stop_signo)
975 self.assertEqual(int(stop_signo, 16), lldbutil.get_signal_number("SIGTRAP"))
980 self.assertEqual(len(context["O_content"]), 0)
984 self.reset_test_sequence()
985 self.test_sequence.add_log_lines(
999 context = self.expect_gdbremote_sequence()
1000 self.assertIsNotNone(context)
1005 self.assertIsNotNone(p_response)
1011 self.assertEqual(returned_pc, function_address)
1015 self.reset_test_sequence()
1018 self.add_remove_breakpoint_packets(
1022 self.test_sequence.add_log_lines(
1034 context = self.expect_gdbremote_sequence()
1035 self.assertIsNotNone(context)
1038 def test_software_breakpoint_set_and_remove_work(self):
1039 if self.getArchitecture() == "arm":
1041 self.build(dictionary={"CFLAGS_EXTRAS": "-marm"})
1043 self.build()
1044 self.set_inferior_startup_launch()
1045 self.breakpoint_set_and_remove_work(want_hardware=False)
1049 def test_hardware_breakpoint_set_and_remove_work(self):
1050 if self.getArchitecture() == "arm":
1052 self.build(dictionary={"CFLAGS_EXTRAS": "-marm"})
1054 self.build()
1055 self.set_inferior_startup_launch()
1056 self.breakpoint_set_and_remove_work(want_hardware=True)
1058 def get_qSupported_dict(self, features=[]):
1059 self.build()
1060 self.set_inferior_startup_launch()
1063 procs = self.prep_debug_monitor_and_inferior()
1064 self.add_qSupported_packets(features)
1067 context = self.expect_gdbremote_sequence()
1068 self.assertIsNotNone(context)
1071 return self.parse_qSupported_response(context)
1073 def test_qSupported_returns_known_stub_features(self):
1074 supported_dict = self.get_qSupported_dict()
1075 self.assertIsNotNone(supported_dict)
1076 self.assertGreater(len(supported_dict), 0)
1078 def test_qSupported_auvx(self):
1084 supported_dict = self.get_qSupported_dict()
1085 self.assertEqual(supported_dict.get("qXfer:auxv:read", "-"), expected)
1087 def test_qSupported_libraries_svr4(self):
1093 supported_dict = self.get_qSupported_dict()
1094 self.assertEqual(supported_dict.get("qXfer:libraries-svr4:read", "-"), expected)
1096 def test_qSupported_siginfo_read(self):
1100 supported_dict = self.get_qSupported_dict()
1101 self.assertEqual(supported_dict.get("qXfer:siginfo:read", "-"), expected)
1103 def test_qSupported_QPassSignals(self):
1109 supported_dict = self.get_qSupported_dict()
1110 self.assertEqual(supported_dict.get("QPassSignals", "-"), expected)
1113 def test_qSupported_fork_events(self):
1114 supported_dict = self.get_qSupported_dict(["multiprocess+", "fork-events+"])
1115 self.assertEqual(supported_dict.get("multiprocess", "-"), "+")
1116 self.assertEqual(supported_dict.get("fork-events", "-"), "+")
1117 self.assertEqual(supported_dict.get("vfork-events", "-"), "-")
1120 def test_qSupported_fork_events_without_multiprocess(self):
1121 supported_dict = self.get_qSupported_dict(["fork-events+"])
1122 self.assertEqual(supported_dict.get("multiprocess", "-"), "-")
1123 self.assertEqual(supported_dict.get("fork-events", "-"), "-")
1124 self.assertEqual(supported_dict.get("vfork-events", "-"), "-")
1127 def test_qSupported_vfork_events(self):
1128 supported_dict = self.get_qSupported_dict(["multiprocess+", "vfork-events+"])
1129 self.assertEqual(supported_dict.get("multiprocess", "-"), "+")
1130 self.assertEqual(supported_dict.get("fork-events", "-"), "-")
1131 self.assertEqual(supported_dict.get("vfork-events", "-"), "+")
1134 def test_qSupported_vfork_events_without_multiprocess(self):
1135 supported_dict = self.get_qSupported_dict(["vfork-events+"])
1136 self.assertEqual(supported_dict.get("multiprocess", "-"), "-")
1137 self.assertEqual(supported_dict.get("fork-events", "-"), "-")
1138 self.assertEqual(supported_dict.get("vfork-events", "-"), "-")
1140 # We need to be able to self.runCmd to get cpuinfo,
1143 def test_qSupported_memory_tagging(self):
1144 supported_dict = self.get_qSupported_dict()
1145 self.assertEqual(
1147 "+" if self.isAArch64MTE() else "-",
1151 def test_written_M_content_reads_back_correctly(self):
1152 self.build()
1153 self.set_inferior_startup_launch()
1158 procs = self.prep_debug_monitor_and_inferior(
1166 self.test_sequence.add_log_lines(
1174 "regex": self.maybe_strict_output_regex(
1190 context = self.expect_gdbremote_sequence()
1191 self.assertIsNotNone(context)
1194 self.assertIsNotNone(context.get("message_address"))
1202 self.reset_test_sequence()
1203 self.test_sequence.add_log_lines(
1231 context = self.expect_gdbremote_sequence()
1232 self.assertIsNotNone(context)
1236 self.assertIsNotNone(printed_message)
1237 self.assertEqual(printed_message, TEST_MESSAGE + "X")
1242 def test_P_writes_all_gpr_registers(self):
1243 self.build()
1244 self.set_inferior_startup_launch()
1247 procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:2"])
1248 self.add_register_info_collection_packets()
1249 self.add_process_info_collection_packets()
1251 context = self.expect_gdbremote_sequence()
1252 self.assertIsNotNone(context)
1255 reg_infos = self.parse_register_info_packets(context)
1256 self.assertIsNotNone(reg_infos)
1257 self.add_lldb_register_index(reg_infos)
1260 process_info = self.parse_process_info_response(context)
1262 self.assertIsNotNone(endian)
1269 if self.is_bit_flippable_register(reg_info)
1271 self.assertGreater(len(gpr_reg_infos), 0)
1274 (successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
1277 self.trace(
1282 self.assertGreater(successful_writes, 0)
1287 def test_P_and_p_thread_suffix_work(self):
1288 self.build()
1289 self.set_inferior_startup_launch()
1292 _, threads = self.launch_with_threads(3)
1294 self.reset_test_sequence()
1295 self.add_thread_suffix_request_packets()
1296 self.add_register_info_collection_packets()
1297 self.add_process_info_collection_packets()
1299 context = self.expect_gdbremote_sequence()
1300 self.assertIsNotNone(context)
1302 process_info = self.parse_process_info_response(context)
1303 self.assertIsNotNone(process_info)
1305 self.assertIsNotNone(endian)
1307 reg_infos = self.parse_register_info_packets(context)
1308 self.assertIsNotNone(reg_infos)
1309 self.add_lldb_register_index(reg_infos)
1311 reg_index = self.select_modifiable_register(reg_infos)
1312 self.assertIsNotNone(reg_index)
1314 self.assertGreater(reg_byte_size, 0)
1327 self.reset_test_sequence()
1328 self.test_sequence.add_log_lines(
1341 context = self.expect_gdbremote_sequence()
1342 self.assertIsNotNone(context)
1347 self.assertIsNotNone(p_response)
1353 self.reset_test_sequence()
1354 self.test_sequence.add_log_lines(
1367 context = self.expect_gdbremote_sequence()
1368 self.assertIsNotNone(context)
1383 self.reset_test_sequence()
1384 self.test_sequence.add_log_lines(
1395 context = self.expect_gdbremote_sequence()
1396 self.assertIsNotNone(context)
1400 self.assertIsNotNone(p_response)
1406 self.assertEqual(read_value, expected_reg_values[thread_index])
1411 def test_qXfer_siginfo_read(self):
1412 self.build()
1413 self.set_inferior_startup_launch()
1414 procs = self.prep_debug_monitor_and_inferior(
1417 self.test_sequence.add_log_lines(["read packet: $c#63"], True)
1418 self.expect_gdbremote_sequence()
1421 self.reset_test_sequence()
1422 self.test_sequence.add_log_lines(
1434 context = self.expect_gdbremote_sequence()
1435 self.assertIsNotNone(context)
1436 self.assertEqual(
1442 self.reset_test_sequence()
1443 self.add_process_info_collection_packets()
1444 self.test_sequence.add_log_lines(
1459 context = self.expect_gdbremote_sequence()
1460 self.assertIsNotNone(context)
1463 self.assertEqual(context.get("response_type"), "l")
1467 self.assertIsNotNone(content_raw)
1468 content = self.decode_gdbremote_binary(content_raw).encode("latin1")
1471 process_info = self.parse_process_info_response(context)
1496 self.assertEqual(decoded[signo_idx], lldbutil.get_signal_number("SIGSEGV"))
1497 self.assertEqual(decoded[errno_idx], 0) # si_errno
1498 self.assertEqual(decoded[code_idx], SEGV_MAPERR) # si_code
1499 self.assertEqual(decoded[addr_idx], 0) # si_addr