diff options
author | Michał Górny <mgorny@moritz.systems> | 2022-06-28 06:00:46 +0200 |
---|---|---|
committer | Michał Górny <mgorny@moritz.systems> | 2022-07-15 13:01:39 +0200 |
commit | f8605da8758fbae16410e4ed5493a39429fd73ec (patch) | |
tree | c846d12115e5de16de737ca854f10cbd2d24ad63 /lldb/test | |
parent | 7d297de95117e783bbfaecbba1f72fc55de05a30 (diff) | |
download | llvm-f8605da8758fbae16410e4ed5493a39429fd73ec.zip llvm-f8605da8758fbae16410e4ed5493a39429fd73ec.tar.gz llvm-f8605da8758fbae16410e4ed5493a39429fd73ec.tar.bz2 |
[lldb] [llgs] Fix multi-resume bugs with nonstop mode
Improve handling of multiple successive continue packets in non-stop
mode. More specifically:
1. Explicitly send error response (instead of crashing on assertion)
if the user attempts to resume the same process twice. Since we
do not support thread-level non-stop mode, one needs to always stop
the process explicitly before resuming another thread set.
2. Actually stop the process if "vCont;t" is delivered to a running
process. Similarly, we only support stopping all the running threads
simultaneously (via -1) and return an error in any other case.
With this patch, running multiple processes simultaneously is still
unsupported. The patch also employs a hack to avoid enabling stdio
forwarding on "vCont;t" packet. Both of these issues are addressed
by followup patches.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128710
Diffstat (limited to 'lldb/test')
-rw-r--r-- | lldb/test/API/tools/lldb-server/TestNonStop.py | 134 | ||||
-rw-r--r-- | lldb/test/API/tools/lldb-server/vCont-threads/TestPartialResume.py | 51 |
2 files changed, 134 insertions, 51 deletions
diff --git a/lldb/test/API/tools/lldb-server/TestNonStop.py b/lldb/test/API/tools/lldb-server/TestNonStop.py index 83772ad..d544cdd 100644 --- a/lldb/test/API/tools/lldb-server/TestNonStop.py +++ b/lldb/test/API/tools/lldb-server/TestNonStop.py @@ -168,3 +168,137 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase): "send packet: $OK#00", ], True) self.expect_gdbremote_sequence() + + def multiple_resume_test(self, second_command): + self.build() + self.set_inferior_startup_launch() + procs = self.prep_debug_monitor_and_inferior( + inferior_args=["sleep:15"]) + self.test_sequence.add_log_lines( + ["read packet: $QNonStop:1#00", + "send packet: $OK#00", + "read packet: $c#63", + "send packet: $OK#00", + "read packet: ${}#00".format(second_command), + "send packet: $E37#00", + ], True) + self.expect_gdbremote_sequence() + + @add_test_categories(["llgs"]) + def test_multiple_C(self): + self.multiple_resume_test("C05") + + @add_test_categories(["llgs"]) + def test_multiple_c(self): + self.multiple_resume_test("c") + + @add_test_categories(["llgs"]) + def test_multiple_s(self): + self.multiple_resume_test("s") + + @expectedFailureAll(archs=["arm"]) # TODO + @expectedFailureAll(archs=["aarch64"], + bugnumber="https://github.com/llvm/llvm-project/issues/56268") + @add_test_categories(["llgs"]) + def test_multiple_vCont(self): + self.build() + self.set_inferior_startup_launch() + procs = self.prep_debug_monitor_and_inferior( + inferior_args=["thread:new", "trap", "sleep:15"]) + self.test_sequence.add_log_lines( + ["read packet: $QNonStop:1#00", + "send packet: $OK#00", + "read packet: $c#63", + "send packet: $OK#00", + {"direction": "send", + "regex": r"^%Stop:T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", + "capture": {1: "tid1"}, + }, + "read packet: $vStopped#63", + {"direction": "send", + "regex": r"^[$]T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", + "capture": {1: "tid2"}, + }, + "read packet: $vStopped#63", + "send packet: $OK#00", + ], True) + ret = self.expect_gdbremote_sequence() + + self.reset_test_sequence() + self.test_sequence.add_log_lines( + ["read packet: $vCont;c:{}#00".format(ret["tid1"]), + "send packet: $OK#00", + "read packet: $vCont;c:{}#00".format(ret["tid2"]), + "send packet: $E37#00", + ], True) + self.expect_gdbremote_sequence() + + @add_test_categories(["llgs"]) + def test_vCont_then_stop(self): + self.build() + self.set_inferior_startup_launch() + procs = self.prep_debug_monitor_and_inferior( + inferior_args=["sleep:15"]) + self.test_sequence.add_log_lines( + ["read packet: $QNonStop:1#00", + "send packet: $OK#00", + "read packet: $c#63", + "send packet: $OK#00", + "read packet: $vCont;t#00", + "send packet: $OK#00", + ], True) + self.expect_gdbremote_sequence() + + def vCont_then_partial_stop_test(self, run_both): + self.build() + self.set_inferior_startup_launch() + procs = self.prep_debug_monitor_and_inferior( + inferior_args=["thread:new", "trap", "sleep:15"]) + self.test_sequence.add_log_lines( + ["read packet: $QNonStop:1#00", + "send packet: $OK#00", + "read packet: $c#63", + "send packet: $OK#00", + {"direction": "send", + "regex": r"^%Stop:T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", + "capture": {1: "tid1"}, + }, + "read packet: $vStopped#63", + {"direction": "send", + "regex": r"^[$]T[0-9a-fA-F]{2}thread:([0-9a-fA-F]+);", + "capture": {1: "tid2"}, + }, + "read packet: $vStopped#63", + "send packet: $OK#00", + ], True) + ret = self.expect_gdbremote_sequence() + + self.reset_test_sequence() + if run_both: + self.test_sequence.add_log_lines( + ["read packet: $vCont;c#00", + ], True) + else: + self.test_sequence.add_log_lines( + ["read packet: $vCont;c:{}#00".format(ret["tid1"]), + ], True) + self.test_sequence.add_log_lines( + ["send packet: $OK#00", + "read packet: $vCont;t:{}#00".format(ret["tid2"]), + "send packet: $E03#00", + ], True) + self.expect_gdbremote_sequence() + + @expectedFailureAll(archs=["arm"]) # TODO + @expectedFailureAll(archs=["aarch64"], + bugnumber="https://github.com/llvm/llvm-project/issues/56268") + @add_test_categories(["llgs"]) + def test_vCont_then_partial_stop(self): + self.vCont_then_partial_stop_test(False) + + @expectedFailureAll(archs=["arm"]) # TODO + @expectedFailureAll(archs=["aarch64"], + bugnumber="https://github.com/llvm/llvm-project/issues/56268") + @add_test_categories(["llgs"]) + def test_vCont_then_partial_stop_run_both(self): + self.vCont_then_partial_stop_test(True) diff --git a/lldb/test/API/tools/lldb-server/vCont-threads/TestPartialResume.py b/lldb/test/API/tools/lldb-server/vCont-threads/TestPartialResume.py index 2cc60d3..b98b63e 100644 --- a/lldb/test/API/tools/lldb-server/vCont-threads/TestPartialResume.py +++ b/lldb/test/API/tools/lldb-server/vCont-threads/TestPartialResume.py @@ -75,54 +75,3 @@ class TestPartialResume(gdbremote_testcase.GdbRemoteTestCaseBase): main_thread, "c:{:x};c:{:x};t".format(*all_subthreads_list[:2])), set(all_subthreads_list[:2])) - - @skipIfWindows - @add_test_categories(["llgs"]) - def test_vCont_txc(self): - main_thread, all_subthreads_list = ( - self.start_vCont_run_subset_of_threads_test()) - # stop one thread explicitly, resume others - self.assertEqual( - self.continue_and_get_threads_running( - main_thread, - "t:{:x};c".format(all_subthreads_list[-1])), - set(all_subthreads_list[:2])) - - @skipIfWindows - @add_test_categories(["llgs"]) - def test_vCont_cxtxc(self): - main_thread, all_subthreads_list = ( - self.start_vCont_run_subset_of_threads_test()) - # resume one thread explicitly, stop one explicitly, - # resume others - self.assertEqual( - self.continue_and_get_threads_running( - main_thread, - "c:{:x};t:{:x};c".format(*all_subthreads_list[-2:])), - set(all_subthreads_list[:2])) - - @skipIfWindows - @add_test_categories(["llgs"]) - def test_vCont_txcx(self): - main_thread, all_subthreads_list = ( - self.start_vCont_run_subset_of_threads_test()) - # resume one thread explicitly, stop one explicitly, - # stop others implicitly - self.assertEqual( - self.continue_and_get_threads_running( - main_thread, - "t:{:x};c:{:x}".format(*all_subthreads_list[:2])), - set(all_subthreads_list[1:2])) - - @skipIfWindows - @add_test_categories(["llgs"]) - def test_vCont_txcxt(self): - main_thread, all_subthreads_list = ( - self.start_vCont_run_subset_of_threads_test()) - # resume one thread explicitly, stop one explicitly, - # stop others explicitly - self.assertEqual( - self.continue_and_get_threads_running( - main_thread, - "t:{:x};c:{:x};t".format(*all_subthreads_list[:2])), - set(all_subthreads_list[1:2])) |