mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jingham.
Herald added subscribers: kristof.beyls, arichardson.
Herald added a project: All.
mgorny requested review of this revision.

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


https://reviews.llvm.org/D128780

Files:
  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

Index: lldb/test/API/tools/lldb-server/main.cpp
===================================================================
--- lldb/test/API/tools/lldb-server/main.cpp
+++ lldb/test/API/tools/lldb-server/main.cpp
@@ -353,6 +353,10 @@
       printf("%s\n", value ? value : "__unset__");
     } else if (consume_front(arg, "trap")) {
       trap();
+#if !defined(_WIN32)
+    } else if (consume_front(arg, "stop")) {
+      raise(SIGSTOP);
+#endif
     } else {
       // Treat the argument as text for stdout.
       printf("%s\n", argv[i]);
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py
@@ -100,16 +100,12 @@
         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"],
Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
@@ -154,73 +154,53 @@
         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 @@
     @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 @@
 
     @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 @@
 
     @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 @@
     @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 @@
                  "send packet: $OK#00",
                  "read packet: $c#00",
                  {"direction": "send",
-                  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+                  "regex": "^[$]T13thread:p{}.{}.*".format(*pidtid),
                   },
                  ], True)
             self.add_threadinfo_collection_packets()
@@ -317,7 +297,7 @@
                            "get-data-address-hex:g_message",
                            "fork",
                            "print-message:",
-                           "trap",
+                           "stop",
                            ])
         self.add_qSupported_packets(["multiprocess+",
                                      "fork-events+"])
@@ -366,7 +346,7 @@
                   "regex": self.maybe_strict_output_regex(r"message: (.*)\r\n"),
                   "capture": {1: "printed_message"}},
                  {"direction": "send",
-                  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+                  "regex": "^[$]T13thread:p{}.{}.*".format(*pidtid),
                   },
                  ], True)
             ret = self.expect_gdbremote_sequence()
@@ -399,7 +379,7 @@
     @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 @@
                  "send packet: $OK#00",
                  "read packet: $c#00",
                  {"direction": "send",
-                  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+                  "regex": "^[$]T13thread:p{}.{}.*".format(*pidtid),
                   },
                  ], True)
 
@@ -496,7 +476,7 @@
     @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 @@
                  "send packet: $OK#00",
                  "read packet: $c#00",
                  {"direction": "send",
-                  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+                  "regex": "^[$]T13thread:p{}.{}.*".format(*pidtid),
                   },
                  ], True)
 
@@ -531,7 +511,7 @@
     @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 @@
                  "send packet: $OK#00",
                  "read packet: $c#00",
                  {"direction": "send",
-                  "regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
+                  "regex": "^[$]T13thread:p{}.{}.*".format(*pidtid),
                   },
                  ], True)
 
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py
@@ -149,14 +149,14 @@
 
     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),
+            "T13thread:p{}.{};.*".format(parent_pid, parent_tid),
             "W00;process:{}#.*".format(parent_pid),
         ]
         child_expect = [
-            "T05thread:p{}.{};.*".format(child_pid, child_tid),
+            "T13thread:p{}.{};.*".format(child_pid, child_tid),
             "W00;process:{}#.*".format(child_pid),
         ]
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to