180c04c66SMichał Górnyfrom lldbsuite.test.decorators import * 2bc04d240SMichał Górnyfrom lldbsuite.test.lldbtest import * 3bc04d240SMichał Górny 4bc04d240SMichał Górnyimport gdbremote_testcase 5bc04d240SMichał Górny 6bc04d240SMichał Górny 7bc04d240SMichał Górnyclass LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): 880c04c66SMichał Górny @skipIfWindows # no SIGSEGV support 95e9aed1bSMichał Górny @add_test_categories(["llgs"]) 10bc04d240SMichał Górny def test_run(self): 11bc04d240SMichał Górny self.build() 12bc04d240SMichał Górny self.set_inferior_startup_launch() 13bc04d240SMichał Górny thread_num = 3 14bc04d240SMichał Górny procs = self.prep_debug_monitor_and_inferior( 152238dcc3SJonas Devlieghere inferior_args=["thread:segfault"] + thread_num * ["thread:new"] 162238dcc3SJonas Devlieghere ) 17bc04d240SMichał Górny self.test_sequence.add_log_lines( 182238dcc3SJonas Devlieghere [ 192238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 20bc04d240SMichał Górny "send packet: $OK#00", 21bc04d240SMichał Górny "read packet: $c#63", 22bc04d240SMichał Górny "send packet: $OK#00", 232238dcc3SJonas Devlieghere ], 242238dcc3SJonas Devlieghere True, 252238dcc3SJonas Devlieghere ) 26bc04d240SMichał Górny self.expect_gdbremote_sequence() 27bc04d240SMichał Górny 282238dcc3SJonas Devlieghere segv_signo = lldbutil.get_signal_number("SIGSEGV") 29bc04d240SMichał Górny all_threads = set() 30bc04d240SMichał Górny all_segv_threads = [] 31bc04d240SMichał Górny 32bc04d240SMichał Górny # we should get segfaults from all the threads 33bc04d240SMichał Górny for segv_no in range(thread_num): 34bc04d240SMichał Górny # first wait for the notification event 35bc04d240SMichał Górny self.reset_test_sequence() 36bc04d240SMichał Górny self.test_sequence.add_log_lines( 372238dcc3SJonas Devlieghere [ 382238dcc3SJonas Devlieghere { 392238dcc3SJonas Devlieghere "direction": "send", 40bc04d240SMichał Górny "regex": r"^%Stop:(T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)", 41bc04d240SMichał Górny "capture": {1: "packet", 2: "signo", 3: "thread_id"}, 42bc04d240SMichał Górny }, 432238dcc3SJonas Devlieghere ], 442238dcc3SJonas Devlieghere True, 452238dcc3SJonas Devlieghere ) 46bc04d240SMichał Górny m = self.expect_gdbremote_sequence() 47bc04d240SMichał Górny del m["O_content"] 48bc04d240SMichał Górny threads = [m] 49bc04d240SMichał Górny 50bc04d240SMichał Górny # then we may get events for the remaining threads 51bc04d240SMichał Górny # (but note that not all threads may have been started yet) 52bc04d240SMichał Górny while True: 53bc04d240SMichał Górny self.reset_test_sequence() 54bc04d240SMichał Górny self.test_sequence.add_log_lines( 552238dcc3SJonas Devlieghere [ 562238dcc3SJonas Devlieghere "read packet: $vStopped#00", 572238dcc3SJonas Devlieghere { 582238dcc3SJonas Devlieghere "direction": "send", 59bc04d240SMichał Górny "regex": r"^\$(OK|T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)", 60bc04d240SMichał Górny "capture": {1: "packet", 2: "signo", 3: "thread_id"}, 61bc04d240SMichał Górny }, 622238dcc3SJonas Devlieghere ], 632238dcc3SJonas Devlieghere True, 642238dcc3SJonas Devlieghere ) 65bc04d240SMichał Górny m = self.expect_gdbremote_sequence() 66bc04d240SMichał Górny if m["packet"] == "OK": 67bc04d240SMichał Górny break 68bc04d240SMichał Górny del m["O_content"] 69bc04d240SMichał Górny threads.append(m) 70bc04d240SMichał Górny 71bc04d240SMichał Górny segv_threads = [] 72bc04d240SMichał Górny other_threads = [] 73bc04d240SMichał Górny for t in threads: 74bc04d240SMichał Górny signo = int(t["signo"], 16) 75bc04d240SMichał Górny if signo == segv_signo: 76bc04d240SMichał Górny segv_threads.append(t["thread_id"]) 77bc04d240SMichał Górny else: 78bc04d240SMichał Górny self.assertEqual(signo, 0) 79bc04d240SMichał Górny other_threads.append(t["thread_id"]) 80bc04d240SMichał Górny 81bc04d240SMichał Górny # verify that exactly one thread segfaulted 82bc04d240SMichał Górny self.assertEqual(len(segv_threads), 1) 83bc04d240SMichał Górny # we should get only one segv from every thread 84bc04d240SMichał Górny self.assertNotIn(segv_threads[0], all_segv_threads) 85bc04d240SMichał Górny all_segv_threads.extend(segv_threads) 86bc04d240SMichał Górny # segv_threads + other_threads should always be a superset 87bc04d240SMichał Górny # of all_threads, i.e. we should get states for all threads 88bc04d240SMichał Górny # already started 892238dcc3SJonas Devlieghere self.assertFalse(all_threads.difference(other_threads + segv_threads)) 90bc04d240SMichał Górny all_threads.update(other_threads + segv_threads) 91bc04d240SMichał Górny 92bc04d240SMichał Górny # verify that `?` returns the same result 93bc04d240SMichał Górny self.reset_test_sequence() 94bc04d240SMichał Górny self.test_sequence.add_log_lines( 952238dcc3SJonas Devlieghere [ 962238dcc3SJonas Devlieghere "read packet: $?#00", 972238dcc3SJonas Devlieghere ], 982238dcc3SJonas Devlieghere True, 992238dcc3SJonas Devlieghere ) 100bc04d240SMichał Górny threads_verify = [] 101bc04d240SMichał Górny while True: 102bc04d240SMichał Górny self.test_sequence.add_log_lines( 1032238dcc3SJonas Devlieghere [ 1042238dcc3SJonas Devlieghere { 1052238dcc3SJonas Devlieghere "direction": "send", 106bc04d240SMichał Górny "regex": r"^\$(OK|T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)", 107bc04d240SMichał Górny "capture": {1: "packet", 2: "signo", 3: "thread_id"}, 108bc04d240SMichał Górny }, 1092238dcc3SJonas Devlieghere ], 1102238dcc3SJonas Devlieghere True, 1112238dcc3SJonas Devlieghere ) 112bc04d240SMichał Górny m = self.expect_gdbremote_sequence() 113bc04d240SMichał Górny if m["packet"] == "OK": 114bc04d240SMichał Górny break 115bc04d240SMichał Górny del m["O_content"] 116bc04d240SMichał Górny threads_verify.append(m) 117bc04d240SMichał Górny self.reset_test_sequence() 118bc04d240SMichał Górny self.test_sequence.add_log_lines( 1192238dcc3SJonas Devlieghere [ 1202238dcc3SJonas Devlieghere "read packet: $vStopped#00", 1212238dcc3SJonas Devlieghere ], 1222238dcc3SJonas Devlieghere True, 1232238dcc3SJonas Devlieghere ) 124bc04d240SMichał Górny 125bc04d240SMichał Górny self.assertEqual(threads, threads_verify) 126bc04d240SMichał Górny 127bc04d240SMichał Górny self.reset_test_sequence() 128bc04d240SMichał Górny self.test_sequence.add_log_lines( 1292238dcc3SJonas Devlieghere [ 1302238dcc3SJonas Devlieghere "read packet: $vCont;C{:02x}:{};c#00".format( 1312238dcc3SJonas Devlieghere segv_signo, segv_threads[0] 1322238dcc3SJonas Devlieghere ), 133bc04d240SMichał Górny "send packet: $OK#00", 1342238dcc3SJonas Devlieghere ], 1352238dcc3SJonas Devlieghere True, 1362238dcc3SJonas Devlieghere ) 137bc04d240SMichał Górny self.expect_gdbremote_sequence() 138bc04d240SMichał Górny 139bc04d240SMichał Górny # finally, verify that all threads have started 140bc04d240SMichał Górny self.assertEqual(len(all_threads), thread_num + 1) 141bc04d240SMichał Górny 1425e9aed1bSMichał Górny @add_test_categories(["llgs"]) 143bc04d240SMichał Górny def test_vCtrlC(self): 144bc04d240SMichał Górny self.build() 145bc04d240SMichał Górny self.set_inferior_startup_launch() 1462238dcc3SJonas Devlieghere procs = self.prep_debug_monitor_and_inferior(inferior_args=["thread:new"]) 147bc04d240SMichał Górny self.test_sequence.add_log_lines( 1482238dcc3SJonas Devlieghere [ 1492238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 150bc04d240SMichał Górny "send packet: $OK#00", 151bc04d240SMichał Górny "read packet: $c#63", 152bc04d240SMichał Górny "send packet: $OK#00", 153bc04d240SMichał Górny "read packet: $vCtrlC#00", 154bc04d240SMichał Górny "send packet: $OK#00", 1552238dcc3SJonas Devlieghere { 1562238dcc3SJonas Devlieghere "direction": "send", 15780c04c66SMichał Górny "regex": r"^%Stop:T", 158bc04d240SMichał Górny }, 1592238dcc3SJonas Devlieghere ], 1602238dcc3SJonas Devlieghere True, 1612238dcc3SJonas Devlieghere ) 162bc04d240SMichał Górny self.expect_gdbremote_sequence() 163bc04d240SMichał Górny 1645e9aed1bSMichał Górny @add_test_categories(["llgs"]) 165bc04d240SMichał Górny def test_exit(self): 166bc04d240SMichał Górny self.build() 167bc04d240SMichał Górny self.set_inferior_startup_launch() 168bc04d240SMichał Górny procs = self.prep_debug_monitor_and_inferior() 169bc04d240SMichał Górny self.test_sequence.add_log_lines( 1702238dcc3SJonas Devlieghere [ 1712238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 172bc04d240SMichał Górny "send packet: $OK#00", 173bc04d240SMichał Górny "read packet: $c#63", 174bc04d240SMichał Górny "send packet: $OK#00", 175bc04d240SMichał Górny "send packet: %Stop:W00#00", 176bc04d240SMichał Górny "read packet: $vStopped#00", 177bc04d240SMichał Górny "send packet: $OK#00", 1782238dcc3SJonas Devlieghere ], 1792238dcc3SJonas Devlieghere True, 1802238dcc3SJonas Devlieghere ) 181bc04d240SMichał Górny self.expect_gdbremote_sequence() 182bc04d240SMichał Górny 18380c04c66SMichał Górny @skipIfWindows # no clue, the result makes zero sense 1845e9aed1bSMichał Górny @add_test_categories(["llgs"]) 185bc04d240SMichał Górny def test_exit_query(self): 186bc04d240SMichał Górny self.build() 187bc04d240SMichał Górny self.set_inferior_startup_launch() 188bc04d240SMichał Górny procs = self.prep_debug_monitor_and_inferior() 189bc04d240SMichał Górny self.test_sequence.add_log_lines( 1902238dcc3SJonas Devlieghere [ 1912238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 192bc04d240SMichał Górny "send packet: $OK#00", 193bc04d240SMichał Górny "read packet: $c#63", 194bc04d240SMichał Górny "send packet: $OK#00", 195bc04d240SMichał Górny "send packet: %Stop:W00#00", 196bc04d240SMichał Górny "read packet: $?#00", 197bc04d240SMichał Górny "send packet: $W00#00", 198bc04d240SMichał Górny "read packet: $vStopped#00", 199bc04d240SMichał Górny "send packet: $OK#00", 2002238dcc3SJonas Devlieghere ], 2012238dcc3SJonas Devlieghere True, 2022238dcc3SJonas Devlieghere ) 203bc04d240SMichał Górny self.expect_gdbremote_sequence() 204eb43e43bSMichał Górny 205eb43e43bSMichał Górny def multiple_resume_test(self, second_command): 206eb43e43bSMichał Górny self.build() 207eb43e43bSMichał Górny self.set_inferior_startup_launch() 2082238dcc3SJonas Devlieghere procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:15"]) 209eb43e43bSMichał Górny self.test_sequence.add_log_lines( 2102238dcc3SJonas Devlieghere [ 2112238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 212eb43e43bSMichał Górny "send packet: $OK#00", 213eb43e43bSMichał Górny "read packet: $c#63", 214eb43e43bSMichał Górny "send packet: $OK#00", 215eb43e43bSMichał Górny "read packet: ${}#00".format(second_command), 216eb43e43bSMichał Górny "send packet: $E37#00", 2172238dcc3SJonas Devlieghere ], 2182238dcc3SJonas Devlieghere True, 2192238dcc3SJonas Devlieghere ) 220eb43e43bSMichał Górny self.expect_gdbremote_sequence() 221eb43e43bSMichał Górny 222eb43e43bSMichał Górny @add_test_categories(["llgs"]) 223a1bbba06SDavid Spickett def test_multiple_C_continue_with_signal(self): 224eb43e43bSMichał Górny self.multiple_resume_test("C05") 225eb43e43bSMichał Górny 226eb43e43bSMichał Górny @add_test_categories(["llgs"]) 227a1bbba06SDavid Spickett def test_multiple_c_continue_with_addr(self): 228eb43e43bSMichał Górny self.multiple_resume_test("c") 229eb43e43bSMichał Górny 230eb43e43bSMichał Górny @add_test_categories(["llgs"]) 231a1bbba06SDavid Spickett def test_multiple_s_single_step_with_addr(self): 232eb43e43bSMichał Górny self.multiple_resume_test("s") 233eb43e43bSMichał Górny 2345a6f1f32SMichał Górny @skipIfWindows 235eb43e43bSMichał Górny @add_test_categories(["llgs"]) 236eb43e43bSMichał Górny def test_multiple_vCont(self): 237eb43e43bSMichał Górny self.build() 238eb43e43bSMichał Górny self.set_inferior_startup_launch() 239eb43e43bSMichał Górny procs = self.prep_debug_monitor_and_inferior( 2402238dcc3SJonas Devlieghere inferior_args=["thread:new", "stop", "sleep:15"] 2412238dcc3SJonas Devlieghere ) 242eb43e43bSMichał Górny self.test_sequence.add_log_lines( 2432238dcc3SJonas Devlieghere [ 2442238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 245eb43e43bSMichał Górny "send packet: $OK#00", 246eb43e43bSMichał Górny "read packet: $c#63", 247eb43e43bSMichał Górny "send packet: $OK#00", 2482238dcc3SJonas Devlieghere { 2492238dcc3SJonas Devlieghere "direction": "send", 250eb43e43bSMichał Górny "regex": r"^%Stop:T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", 251eb43e43bSMichał Górny "capture": {1: "tid1"}, 252eb43e43bSMichał Górny }, 253eb43e43bSMichał Górny "read packet: $vStopped#63", 2542238dcc3SJonas Devlieghere { 2552238dcc3SJonas Devlieghere "direction": "send", 256eb43e43bSMichał Górny "regex": r"^[$]T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", 257eb43e43bSMichał Górny "capture": {1: "tid2"}, 258eb43e43bSMichał Górny }, 259eb43e43bSMichał Górny "read packet: $vStopped#63", 260eb43e43bSMichał Górny "send packet: $OK#00", 2612238dcc3SJonas Devlieghere ], 2622238dcc3SJonas Devlieghere True, 2632238dcc3SJonas Devlieghere ) 264eb43e43bSMichał Górny ret = self.expect_gdbremote_sequence() 265eb43e43bSMichał Górny 266eb43e43bSMichał Górny self.reset_test_sequence() 267eb43e43bSMichał Górny self.test_sequence.add_log_lines( 2682238dcc3SJonas Devlieghere [ 2692238dcc3SJonas Devlieghere "read packet: $vCont;c:{}#00".format(ret["tid1"]), 270eb43e43bSMichał Górny "send packet: $OK#00", 271eb43e43bSMichał Górny "read packet: $vCont;c:{}#00".format(ret["tid2"]), 272eb43e43bSMichał Górny "send packet: $E37#00", 2732238dcc3SJonas Devlieghere ], 2742238dcc3SJonas Devlieghere True, 2752238dcc3SJonas Devlieghere ) 276eb43e43bSMichał Górny self.expect_gdbremote_sequence() 277eb43e43bSMichał Górny 278eb43e43bSMichał Górny @add_test_categories(["llgs"]) 279*5a658ee9SDavid Spickett @skipIfWindows # Sometimes results in '$E37' instead of expected '$OK' 280eb43e43bSMichał Górny def test_vCont_then_stop(self): 281eb43e43bSMichał Górny self.build() 282eb43e43bSMichał Górny self.set_inferior_startup_launch() 2832238dcc3SJonas Devlieghere procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:15"]) 284eb43e43bSMichał Górny self.test_sequence.add_log_lines( 2852238dcc3SJonas Devlieghere [ 2862238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 287eb43e43bSMichał Górny "send packet: $OK#00", 288eb43e43bSMichał Górny "read packet: $c#63", 289eb43e43bSMichał Górny "send packet: $OK#00", 290eb43e43bSMichał Górny "read packet: $vCont;t#00", 291eb43e43bSMichał Górny "send packet: $OK#00", 2922238dcc3SJonas Devlieghere ], 2932238dcc3SJonas Devlieghere True, 2942238dcc3SJonas Devlieghere ) 295eb43e43bSMichał Górny self.expect_gdbremote_sequence() 296eb43e43bSMichał Górny 297eb43e43bSMichał Górny def vCont_then_partial_stop_test(self, run_both): 298eb43e43bSMichał Górny self.build() 299eb43e43bSMichał Górny self.set_inferior_startup_launch() 300eb43e43bSMichał Górny procs = self.prep_debug_monitor_and_inferior( 3012238dcc3SJonas Devlieghere inferior_args=["thread:new", "stop", "sleep:15"] 3022238dcc3SJonas Devlieghere ) 303eb43e43bSMichał Górny self.test_sequence.add_log_lines( 3042238dcc3SJonas Devlieghere [ 3052238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 306eb43e43bSMichał Górny "send packet: $OK#00", 307eb43e43bSMichał Górny "read packet: $c#63", 308eb43e43bSMichał Górny "send packet: $OK#00", 3092238dcc3SJonas Devlieghere { 3102238dcc3SJonas Devlieghere "direction": "send", 311eb43e43bSMichał Górny "regex": r"^%Stop:T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", 312eb43e43bSMichał Górny "capture": {1: "tid1"}, 313eb43e43bSMichał Górny }, 314eb43e43bSMichał Górny "read packet: $vStopped#63", 3152238dcc3SJonas Devlieghere { 3162238dcc3SJonas Devlieghere "direction": "send", 317eb43e43bSMichał Górny "regex": r"^[$]T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", 318eb43e43bSMichał Górny "capture": {1: "tid2"}, 319eb43e43bSMichał Górny }, 320eb43e43bSMichał Górny "read packet: $vStopped#63", 321eb43e43bSMichał Górny "send packet: $OK#00", 3222238dcc3SJonas Devlieghere ], 3232238dcc3SJonas Devlieghere True, 3242238dcc3SJonas Devlieghere ) 325eb43e43bSMichał Górny ret = self.expect_gdbremote_sequence() 326eb43e43bSMichał Górny 327eb43e43bSMichał Górny self.reset_test_sequence() 328eb43e43bSMichał Górny if run_both: 329eb43e43bSMichał Górny self.test_sequence.add_log_lines( 3302238dcc3SJonas Devlieghere [ 3312238dcc3SJonas Devlieghere "read packet: $vCont;c#00", 3322238dcc3SJonas Devlieghere ], 3332238dcc3SJonas Devlieghere True, 3342238dcc3SJonas Devlieghere ) 335eb43e43bSMichał Górny else: 336eb43e43bSMichał Górny self.test_sequence.add_log_lines( 3372238dcc3SJonas Devlieghere [ 3382238dcc3SJonas Devlieghere "read packet: $vCont;c:{}#00".format(ret["tid1"]), 3392238dcc3SJonas Devlieghere ], 3402238dcc3SJonas Devlieghere True, 3412238dcc3SJonas Devlieghere ) 342eb43e43bSMichał Górny self.test_sequence.add_log_lines( 3432238dcc3SJonas Devlieghere [ 3442238dcc3SJonas Devlieghere "send packet: $OK#00", 345eb43e43bSMichał Górny "read packet: $vCont;t:{}#00".format(ret["tid2"]), 346eb43e43bSMichał Górny "send packet: $E03#00", 3472238dcc3SJonas Devlieghere ], 3482238dcc3SJonas Devlieghere True, 3492238dcc3SJonas Devlieghere ) 350eb43e43bSMichał Górny self.expect_gdbremote_sequence() 351eb43e43bSMichał Górny 3525a6f1f32SMichał Górny @skipIfWindows 353eb43e43bSMichał Górny @add_test_categories(["llgs"]) 354eb43e43bSMichał Górny def test_vCont_then_partial_stop(self): 355eb43e43bSMichał Górny self.vCont_then_partial_stop_test(False) 356eb43e43bSMichał Górny 3575a6f1f32SMichał Górny @skipIfWindows 358eb43e43bSMichał Górny @add_test_categories(["llgs"]) 359eb43e43bSMichał Górny def test_vCont_then_partial_stop_run_both(self): 360eb43e43bSMichał Górny self.vCont_then_partial_stop_test(True) 3611903f358SMichał Górny 36281e993f0SMichał Górny @skipIfWindows 3631903f358SMichał Górny @add_test_categories(["llgs"]) 3641903f358SMichał Górny def test_stdio(self): 3651903f358SMichał Górny self.build() 3661903f358SMichał Górny self.set_inferior_startup_launch() 3671903f358SMichał Górny # Since we can't easily ensure that lldb will send output in two parts, 3681903f358SMichał Górny # just put a stop in the middle. Since we don't clear vStdio, 3691903f358SMichał Górny # the second message won't be delivered immediately. 3701903f358SMichał Górny self.prep_debug_monitor_and_inferior( 3712238dcc3SJonas Devlieghere inferior_args=["message 1", "stop", "message 2"] 3722238dcc3SJonas Devlieghere ) 3731903f358SMichał Górny self.test_sequence.add_log_lines( 3742238dcc3SJonas Devlieghere [ 3752238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 3761903f358SMichał Górny "send packet: $OK#00", 3771903f358SMichał Górny "read packet: $c#63", 3781903f358SMichał Górny "send packet: $OK#00", 3791903f358SMichał Górny {"direction": "send", "regex": r"^%Stop:T.*"}, 3801903f358SMichał Górny "read packet: $vStopped#00", 3811903f358SMichał Górny "send packet: $OK#00", 3821903f358SMichał Górny "read packet: $c#63", 3831903f358SMichał Górny "send packet: $OK#00", 3841903f358SMichał Górny "send packet: %Stop:W00#00", 3852238dcc3SJonas Devlieghere ], 3862238dcc3SJonas Devlieghere True, 3872238dcc3SJonas Devlieghere ) 3881903f358SMichał Górny ret = self.expect_gdbremote_sequence() 3891903f358SMichał Górny 390cd18e2eaSPavel Labath # We know there will be at least two messages, but there may be more. 391cd18e2eaSPavel Labath # Loop until we have everything. The first message waiting for us in the 392cd18e2eaSPavel Labath # packet queue. 393cd18e2eaSPavel Labath count = 1 394cd18e2eaSPavel Labath output = self._server.get_raw_output_packet() 395cd18e2eaSPavel Labath while not (b"message 2\r\n" in output): 396cd18e2eaSPavel Labath self._server.send_packet(b"vStdio") 397cd18e2eaSPavel Labath output += self._server.get_raw_output_packet() 398cd18e2eaSPavel Labath count += 1 399cd18e2eaSPavel Labath self.assertGreaterEqual(count, 2) 400cd18e2eaSPavel Labath 4011903f358SMichał Górny self.reset_test_sequence() 4021903f358SMichał Górny self.test_sequence.add_log_lines( 4032238dcc3SJonas Devlieghere [ 4042238dcc3SJonas Devlieghere "read packet: $vStdio#00", 4051903f358SMichał Górny "send packet: $OK#00", 406cd18e2eaSPavel Labath "read packet: $vStopped#00", 4071903f358SMichał Górny "send packet: $OK#00", 4082238dcc3SJonas Devlieghere ], 4092238dcc3SJonas Devlieghere True, 4102238dcc3SJonas Devlieghere ) 4111903f358SMichał Górny self.expect_gdbremote_sequence() 412ab9f1e88SMichał Górny 4135d665973SMichał Górny @skipIfWindows 414ab9f1e88SMichał Górny @add_test_categories(["llgs"]) 415ab9f1e88SMichał Górny def test_stop_reason_while_running(self): 416ab9f1e88SMichał Górny self.build() 417ab9f1e88SMichał Górny self.set_inferior_startup_launch() 418ab9f1e88SMichał Górny procs = self.prep_debug_monitor_and_inferior( 4192238dcc3SJonas Devlieghere inferior_args=["thread:new", "thread:new", "stop", "sleep:15"] 4202238dcc3SJonas Devlieghere ) 421ab9f1e88SMichał Górny self.test_sequence.add_log_lines( 4222238dcc3SJonas Devlieghere [ 4232238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 424ab9f1e88SMichał Górny "send packet: $OK#00", 425ab9f1e88SMichał Górny # stop is used to synchronize starting threads 426ab9f1e88SMichał Górny "read packet: $c#63", 427ab9f1e88SMichał Górny "send packet: $OK#00", 428ab9f1e88SMichał Górny {"direction": "send", "regex": "%Stop:T.*"}, 429ab9f1e88SMichał Górny "read packet: $c#63", 430ab9f1e88SMichał Górny "send packet: $OK#00", 431ab9f1e88SMichał Górny "read packet: $?#00", 432ab9f1e88SMichał Górny "send packet: $OK#00", 4332238dcc3SJonas Devlieghere ], 4342238dcc3SJonas Devlieghere True, 4352238dcc3SJonas Devlieghere ) 436ab9f1e88SMichał Górny self.expect_gdbremote_sequence() 437c732afa2SMichał Górny 438fc92f114SMichał Górny @skipIfWindows 439c732afa2SMichał Górny @add_test_categories(["llgs"]) 440c732afa2SMichał Górny def test_leave_nonstop(self): 441c732afa2SMichał Górny self.build() 442c732afa2SMichał Górny self.set_inferior_startup_launch() 443c732afa2SMichał Górny procs = self.prep_debug_monitor_and_inferior( 4442238dcc3SJonas Devlieghere inferior_args=["thread:new", "thread:new", "stop", "sleep:15"] 4452238dcc3SJonas Devlieghere ) 446c732afa2SMichał Górny self.test_sequence.add_log_lines( 4472238dcc3SJonas Devlieghere [ 4482238dcc3SJonas Devlieghere "read packet: $QNonStop:1#00", 449c732afa2SMichał Górny "send packet: $OK#00", 450c732afa2SMichał Górny # stop is used to synchronize starting threads 451c732afa2SMichał Górny "read packet: $c#63", 452c732afa2SMichał Górny "send packet: $OK#00", 453c732afa2SMichał Górny {"direction": "send", "regex": "%Stop:T.*"}, 454c732afa2SMichał Górny "read packet: $c#63", 455c732afa2SMichał Górny "send packet: $OK#00", 456c732afa2SMichał Górny # verify that the threads are running now 457c732afa2SMichał Górny "read packet: $?#00", 458c732afa2SMichał Górny "send packet: $OK#00", 459c732afa2SMichał Górny "read packet: $QNonStop:0#00", 460c732afa2SMichał Górny "send packet: $OK#00", 461c732afa2SMichał Górny # we should issue some random request now to verify that the stub 462c732afa2SMichał Górny # did not send stop reasons -- we may verify whether notification 463c732afa2SMichał Górny # queue was cleared while at it 464c732afa2SMichał Górny "read packet: $vStopped#00", 465c732afa2SMichał Górny "send packet: $Eff#00", 466c732afa2SMichał Górny "read packet: $?#00", 467c732afa2SMichał Górny {"direction": "send", "regex": "[$]T.*"}, 4682238dcc3SJonas Devlieghere ], 4692238dcc3SJonas Devlieghere True, 4702238dcc3SJonas Devlieghere ) 471c732afa2SMichał Górny self.expect_gdbremote_sequence() 472