19790406aSMichał Górnyimport re 29790406aSMichał Górny 39790406aSMichał Górnyimport gdbremote_testcase 49790406aSMichał Górnyfrom lldbsuite.test.decorators import * 59790406aSMichał Górnyfrom lldbsuite.test.lldbtest import * 69790406aSMichał Górny 79790406aSMichał Górny 89790406aSMichał Górnyclass TestPartialResume(gdbremote_testcase.GdbRemoteTestCaseBase): 99790406aSMichał Górny THREAD_MATCH_RE = re.compile(r"thread ([0-9a-f]+) running") 109790406aSMichał Górny 119790406aSMichał Górny def start_vCont_run_subset_of_threads_test(self): 129790406aSMichał Górny self.build() 139790406aSMichał Górny self.set_inferior_startup_launch() 149790406aSMichał Górny 159790406aSMichał Górny procs = self.prep_debug_monitor_and_inferior(inferior_args=["3"]) 169790406aSMichał Górny # grab the main thread id 179790406aSMichał Górny self.add_threadinfo_collection_packets() 18*2238dcc3SJonas Devlieghere main_thread = self.parse_threadinfo_packets(self.expect_gdbremote_sequence()) 199790406aSMichał Górny self.assertEqual(len(main_thread), 1) 209790406aSMichał Górny self.reset_test_sequence() 219790406aSMichał Górny 229790406aSMichał Górny # run until threads start, then grab full thread list 23*2238dcc3SJonas Devlieghere self.test_sequence.add_log_lines( 24*2238dcc3SJonas Devlieghere [ 259790406aSMichał Górny "read packet: $c#63", 269790406aSMichał Górny {"direction": "send", "regex": "[$]T.*;reason:signal.*"}, 27*2238dcc3SJonas Devlieghere ], 28*2238dcc3SJonas Devlieghere True, 29*2238dcc3SJonas Devlieghere ) 309790406aSMichał Górny self.add_threadinfo_collection_packets() 319790406aSMichał Górny 32*2238dcc3SJonas Devlieghere all_threads = self.parse_threadinfo_packets(self.expect_gdbremote_sequence()) 339790406aSMichał Górny self.assertEqual(len(all_threads), 4) 349790406aSMichał Górny self.assertIn(main_thread[0], all_threads) 359790406aSMichał Górny self.reset_test_sequence() 369790406aSMichał Górny 379790406aSMichał Górny all_subthreads = set(all_threads) - set(main_thread) 389790406aSMichał Górny self.assertEqual(len(all_subthreads), 3) 399790406aSMichał Górny 409790406aSMichał Górny return (main_thread[0], list(all_subthreads)) 419790406aSMichał Górny 429790406aSMichał Górny def continue_and_get_threads_running(self, main_thread, vCont_req): 439790406aSMichał Górny self.test_sequence.add_log_lines( 44*2238dcc3SJonas Devlieghere [ 45*2238dcc3SJonas Devlieghere "read packet: $vCont;c:{:x};{}#00".format(main_thread, vCont_req), 469790406aSMichał Górny "send packet: $W00#00", 47*2238dcc3SJonas Devlieghere ], 48*2238dcc3SJonas Devlieghere True, 49*2238dcc3SJonas Devlieghere ) 509790406aSMichał Górny exp = self.expect_gdbremote_sequence() 519790406aSMichał Górny self.reset_test_sequence() 529790406aSMichał Górny found = set() 539790406aSMichał Górny for line in exp["O_content"].decode().splitlines(): 549790406aSMichał Górny m = self.THREAD_MATCH_RE.match(line) 559790406aSMichał Górny if m is not None: 569790406aSMichał Górny found.add(int(m.group(1), 16)) 579790406aSMichał Górny return found 589790406aSMichał Górny 599790406aSMichał Górny @skipIfWindows 609790406aSMichał Górny @add_test_categories(["llgs"]) 619790406aSMichał Górny def test_vCont_cxcx(self): 62*2238dcc3SJonas Devlieghere main_thread, all_subthreads_list = self.start_vCont_run_subset_of_threads_test() 639790406aSMichał Górny # resume two threads explicitly, stop the third one implicitly 649790406aSMichał Górny self.assertEqual( 659790406aSMichał Górny self.continue_and_get_threads_running( 66*2238dcc3SJonas Devlieghere main_thread, "c:{:x};c:{:x}".format(*all_subthreads_list[:2]) 67*2238dcc3SJonas Devlieghere ), 68*2238dcc3SJonas Devlieghere set(all_subthreads_list[:2]), 69*2238dcc3SJonas Devlieghere ) 709790406aSMichał Górny 719790406aSMichał Górny @skipIfWindows 729790406aSMichał Górny @add_test_categories(["llgs"]) 739790406aSMichał Górny def test_vCont_cxcxt(self): 74*2238dcc3SJonas Devlieghere main_thread, all_subthreads_list = self.start_vCont_run_subset_of_threads_test() 759790406aSMichał Górny # resume two threads explicitly, stop others explicitly 769790406aSMichał Górny self.assertEqual( 779790406aSMichał Górny self.continue_and_get_threads_running( 78*2238dcc3SJonas Devlieghere main_thread, "c:{:x};c:{:x};t".format(*all_subthreads_list[:2]) 79*2238dcc3SJonas Devlieghere ), 80*2238dcc3SJonas Devlieghere set(all_subthreads_list[:2]), 81*2238dcc3SJonas Devlieghere ) 82