Author: Michał Górny Date: 2022-06-29T15:37:26+02:00 New Revision: 251165b2e48216f8fbeef1960711219afac406f4
URL: https://github.com/llvm/llvm-project/commit/251165b2e48216f8fbeef1960711219afac406f4 DIFF: https://github.com/llvm/llvm-project/commit/251165b2e48216f8fbeef1960711219afac406f4.diff LOG: [lldb] [test] Use raise(SIGSTOP) instead of trap in fork tests Replace the use of "trap" with a new "stop" command in fork tests, that maps to `raise(SIGSTOP)`. Since traps do not increment PC on some architectures (notably ARM), using traps would require special logic to increment it while testing. Using SIGSTOP avoids the problem and is probably more logical, given that the purpose of the "trap"s was to simply stop the inferior at a synchronization point. This fixes tests on AArch64 (and possibly ARM, I'll update XFAILs when it is confirmed by the buildbot). Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.llvm.org/D128780 Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py lldb/test/API/tools/lldb-server/main.cpp Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py index 42833a15318f2..bd9c3843ddfe1 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py @@ -8,6 +8,8 @@ class GdbRemoteForkTestBase(gdbremote_testcase.GdbRemoteTestCaseBase): "{}:p([0-9a-f]+)[.]([0-9a-f]+).*") fork_capture = {1: "parent_pid", 2: "parent_tid", 3: "child_pid", 4: "child_tid"} + stop_regex_base = "T[0-9a-fA-F]{{2}}thread:p{}.{};.*reason:signal.*" + stop_regex = "^[$]" + stop_regex_base def start_fork_test(self, args, variant="fork", nonstop=False): self.build() @@ -149,14 +151,14 @@ def vkill_test(self, kill_parent=False, kill_child=False, nonstop=False): def resume_one_test(self, run_order, use_vCont=False, nonstop=False): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "trap"], nonstop=nonstop)) + self.start_fork_test(["fork", "stop"], nonstop=nonstop)) parent_expect = [ - "T05thread:p{}.{};.*".format(parent_pid, parent_tid), + self.stop_regex_base.format(parent_pid, parent_tid), "W00;process:{}#.*".format(parent_pid), ] child_expect = [ - "T05thread:p{}.{};.*".format(child_pid, child_tid), + self.stop_regex_base.format(child_pid, child_tid), "W00;process:{}#.*".format(child_pid), ] diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py index 81be3c67399e3..fa5b116438c51 100644 --- a/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py @@ -154,73 +154,53 @@ def test_vkill_both(self): self.vkill_test(kill_parent=True, kill_child=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_parent(self): self.resume_one_test(run_order=["parent", "parent"]) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_child(self): self.resume_one_test(run_order=["child", "child"]) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_parent_then_child(self): self.resume_one_test(run_order=["parent", "parent", "child", "child"]) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_child_then_parent(self): self.resume_one_test(run_order=["child", "child", "parent", "parent"]) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_interspersed(self): self.resume_one_test(run_order=["parent", "child", "parent", "child"]) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_parent(self): self.resume_one_test(run_order=["parent", "parent"], use_vCont=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_child(self): self.resume_one_test(run_order=["child", "child"], use_vCont=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_parent_then_child(self): self.resume_one_test(run_order=["parent", "parent", "child", "child"], use_vCont=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_child_then_parent(self): self.resume_one_test(run_order=["child", "child", "parent", "parent"], use_vCont=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_interspersed(self): self.resume_one_test(run_order=["parent", "child", "parent", "child"], @@ -229,7 +209,7 @@ def test_vCont_interspersed(self): @add_test_categories(["fork"]) def test_vCont_two_processes(self): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "trap"])) + self.start_fork_test(["fork", "stop"])) self.test_sequence.add_log_lines([ # try to resume both processes @@ -241,7 +221,7 @@ def test_vCont_two_processes(self): @add_test_categories(["fork"]) def test_vCont_all_processes_explicit(self): - self.start_fork_test(["fork", "trap"]) + self.start_fork_test(["fork", "stop"]) self.test_sequence.add_log_lines([ # try to resume all processes implicitly @@ -252,7 +232,7 @@ def test_vCont_all_processes_explicit(self): @add_test_categories(["fork"]) def test_vCont_all_processes_implicit(self): - self.start_fork_test(["fork", "trap"]) + self.start_fork_test(["fork", "stop"]) self.test_sequence.add_log_lines([ # try to resume all processes implicitly @@ -265,7 +245,7 @@ def test_vCont_all_processes_implicit(self): @add_test_categories(["fork"]) def test_threadinfo(self): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "thread:new", "trap"])) + self.start_fork_test(["fork", "thread:new", "stop"])) pidtids = [ (parent_pid, parent_tid), (child_pid, child_tid), @@ -285,7 +265,7 @@ def test_threadinfo(self): "send packet: $OK#00", "read packet: $c#00", {"direction": "send", - "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid), + "regex": self.stop_regex.format(*pidtid), }, ], True) self.add_threadinfo_collection_packets() @@ -317,7 +297,7 @@ def test_memory_read_write(self): "get-data-address-hex:g_message", "fork", "print-message:", - "trap", + "stop", ]) self.add_qSupported_packets(["multiprocess+", "fork-events+"]) @@ -366,7 +346,7 @@ def test_memory_read_write(self): "regex": self.maybe_strict_output_regex(r"message: (.*)\r\n"), "capture": {1: "printed_message"}}, {"direction": "send", - "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid), + "regex": self.stop_regex.format(*pidtid), }, ], True) ret = self.expect_gdbremote_sequence() @@ -399,7 +379,7 @@ def test_memory_read_write(self): @add_test_categories(["fork"]) def test_register_read_write(self): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "thread:new", "trap"])) + self.start_fork_test(["fork", "thread:new", "stop"])) pidtids = [ (parent_pid, parent_tid), (child_pid, child_tid), @@ -411,7 +391,7 @@ def test_register_read_write(self): "send packet: $OK#00", "read packet: $c#00", {"direction": "send", - "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid), + "regex": self.stop_regex.format(*pidtid), }, ], True) @@ -496,7 +476,7 @@ def test_register_read_write(self): @add_test_categories(["fork"]) def test_qC(self): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "thread:new", "trap"])) + self.start_fork_test(["fork", "thread:new", "stop"])) pidtids = [ (parent_pid, parent_tid), (child_pid, child_tid), @@ -508,7 +488,7 @@ def test_qC(self): "send packet: $OK#00", "read packet: $c#00", {"direction": "send", - "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid), + "regex": self.stop_regex.format(*pidtid), }, ], True) @@ -531,7 +511,7 @@ def test_qC(self): @add_test_categories(["fork"]) def test_T(self): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "thread:new", "trap"])) + self.start_fork_test(["fork", "thread:new", "stop"])) pidtids = [ (parent_pid, parent_tid), (child_pid, child_tid), @@ -543,7 +523,7 @@ def test_T(self): "send packet: $OK#00", "read packet: $c#00", {"direction": "send", - "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid), + "regex": self.stop_regex.format(*pidtid), }, ], True) diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py index bd9484ff0903e..38f6959561702 100644 --- a/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py @@ -99,16 +99,12 @@ def test_vkill_both_nonstop(self): self.vkill_test(kill_parent=True, kill_child=True, nonstop=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_c_interspersed_nonstop(self): self.resume_one_test(run_order=["parent", "child", "parent", "child"], nonstop=True) @expectedFailureAll(archs=["arm"]) # TODO - @expectedFailureAll(archs=["aarch64"], - bugnumber="https://github.com/llvm/llvm-project/issues/56268") @add_test_categories(["fork"]) def test_vCont_interspersed_nonstop(self): self.resume_one_test(run_order=["parent", "child", "parent", "child"], diff --git a/lldb/test/API/tools/lldb-server/main.cpp b/lldb/test/API/tools/lldb-server/main.cpp index 9907a09dfc7d2..36ad21c4fedfe 100644 --- a/lldb/test/API/tools/lldb-server/main.cpp +++ b/lldb/test/API/tools/lldb-server/main.cpp @@ -353,6 +353,10 @@ int main(int argc, char **argv) { printf("%s\n", value ? value : "__unset__"); } else if (consume_front(arg, "trap")) { trap(); +#if !defined(_WIN32) + } else if (arg == "stop") { + raise(SIGSTOP); +#endif } else { // Treat the argument as text for stdout. printf("%s\n", argv[i]); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits