import json
import re
+import time
import gdbremote_testcase
from lldbsuite.test.decorators import *
# start the process and wait for output
self.test_sequence.add_log_lines([
"read packet: $c#63",
- {"type": "output_match", "regex": self.maybe_strict_output_regex(
- r"@started\r\n")},
+ {"type": "output_match", "regex": r".*@started\r\n.*"},
], True)
# then interrupt it
self.add_interrupt_packets()
self.test_sequence.add_log_lines([
"read packet: $vCont;{0}#00".format(vCont_data),
{"type": "output_match",
- "regex": self.maybe_strict_output_regex(
- len(threads) *
- r"received SIGUSR1 on thread id: ([0-9a-f]+)\r\n"),
+ "regex": len(threads) *
+ r".*received SIGUSR1 on thread id: ([0-9a-f]+)\r\n.*",
"capture": dict((i, "tid{0}".format(i)) for i
in range(1, len(threads)+1)),
},
context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)
+
+ THREAD_MATCH_RE = re.compile(r"thread ([0-9a-f]+) running")
+
+ def continue_and_get_threads_running(self, continue_packet):
+ self.test_sequence.add_log_lines(
+ ["read packet: ${}#00".format(continue_packet),
+ ], True)
+ self.expect_gdbremote_sequence()
+ self.reset_test_sequence()
+ time.sleep(1)
+ self.add_interrupt_packets()
+ exp = self.expect_gdbremote_sequence()
+ found = set()
+ for line in exp["O_content"].decode().splitlines():
+ m = self.THREAD_MATCH_RE.match(line)
+ if m is not None:
+ found.add(int(m.group(1), 16))
+ return found
+
+ @add_test_categories(["llgs"])
+ def test_vCont_run_subset_of_threads(self):
+ self.build()
+ self.set_inferior_startup_launch()
+
+ threads = set(self.start_threads(3))
+ all_subthreads = self.continue_and_get_threads_running("c")
+ all_subthreads_list = list(all_subthreads)
+ self.assertEqual(len(all_subthreads), 3)
+ self.assertEqual(threads & all_subthreads, all_subthreads)
+
+ # resume two threads explicitly, stop the third one implicitly
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;c:{:x};c:{:x}".format(*all_subthreads_list[:2])),
+ set(all_subthreads_list[:2]))
+
+ # resume two threads explicitly, stop others explicitly
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;c:{:x};c:{:x};t".format(*all_subthreads_list[:2])),
+ set(all_subthreads_list[:2]))
+
+ # stop one thread explicitly, resume others
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;t:{:x};c".format(all_subthreads_list[-1])),
+ set(all_subthreads_list[:2]))
+
+ # resume one thread explicitly, stop one explicitly,
+ # resume others
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;c:{:x};t:{:x};c".format(*all_subthreads_list[-2:])),
+ set(all_subthreads_list[:2]))
+
+ # resume one thread explicitly, stop one explicitly,
+ # stop others implicitly
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;t:{:x};c:{:x}".format(*all_subthreads_list[:2])),
+ set(all_subthreads_list[1:2]))
+
+ # resume one thread explicitly, stop one explicitly,
+ # stop others explicitly
+ self.assertEqual(
+ self.continue_and_get_threads_running(
+ "vCont;t:{:x};c:{:x};t".format(*all_subthreads_list[:2])),
+ set(all_subthreads_list[1:2]))