Skip to content

Commit 251165b

Browse files
committed
[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
1 parent 56ab966 commit 251165b

File tree

4 files changed

+22
-40
lines changed

4 files changed

+22
-40
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-server/fork_testbase.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class GdbRemoteForkTestBase(gdbremote_testcase.GdbRemoteTestCaseBase):
88
"{}:p([0-9a-f]+)[.]([0-9a-f]+).*")
99
fork_capture = {1: "parent_pid", 2: "parent_tid",
1010
3: "child_pid", 4: "child_tid"}
11+
stop_regex_base = "T[0-9a-fA-F]{{2}}thread:p{}.{};.*reason:signal.*"
12+
stop_regex = "^[$]" + stop_regex_base
1113

1214
def start_fork_test(self, args, variant="fork", nonstop=False):
1315
self.build()
@@ -149,14 +151,14 @@ def vkill_test(self, kill_parent=False, kill_child=False, nonstop=False):
149151

150152
def resume_one_test(self, run_order, use_vCont=False, nonstop=False):
151153
parent_pid, parent_tid, child_pid, child_tid = (
152-
self.start_fork_test(["fork", "trap"], nonstop=nonstop))
154+
self.start_fork_test(["fork", "stop"], nonstop=nonstop))
153155

154156
parent_expect = [
155-
"T05thread:p{}.{};.*".format(parent_pid, parent_tid),
157+
self.stop_regex_base.format(parent_pid, parent_tid),
156158
"W00;process:{}#.*".format(parent_pid),
157159
]
158160
child_expect = [
159-
"T05thread:p{}.{};.*".format(child_pid, child_tid),
161+
self.stop_regex_base.format(child_pid, child_tid),
160162
"W00;process:{}#.*".format(child_pid),
161163
]
162164

lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

+13-33
Original file line numberDiff line numberDiff line change
@@ -154,73 +154,53 @@ def test_vkill_both(self):
154154
self.vkill_test(kill_parent=True, kill_child=True)
155155

156156
@expectedFailureAll(archs=["arm"]) # TODO
157-
@expectedFailureAll(archs=["aarch64"],
158-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
159157
@add_test_categories(["fork"])
160158
def test_c_parent(self):
161159
self.resume_one_test(run_order=["parent", "parent"])
162160

163161
@expectedFailureAll(archs=["arm"]) # TODO
164-
@expectedFailureAll(archs=["aarch64"],
165-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
166162
@add_test_categories(["fork"])
167163
def test_c_child(self):
168164
self.resume_one_test(run_order=["child", "child"])
169165

170166
@expectedFailureAll(archs=["arm"]) # TODO
171-
@expectedFailureAll(archs=["aarch64"],
172-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
173167
@add_test_categories(["fork"])
174168
def test_c_parent_then_child(self):
175169
self.resume_one_test(run_order=["parent", "parent", "child", "child"])
176170

177171
@expectedFailureAll(archs=["arm"]) # TODO
178-
@expectedFailureAll(archs=["aarch64"],
179-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
180172
@add_test_categories(["fork"])
181173
def test_c_child_then_parent(self):
182174
self.resume_one_test(run_order=["child", "child", "parent", "parent"])
183175

184176
@expectedFailureAll(archs=["arm"]) # TODO
185-
@expectedFailureAll(archs=["aarch64"],
186-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
187177
@add_test_categories(["fork"])
188178
def test_c_interspersed(self):
189179
self.resume_one_test(run_order=["parent", "child", "parent", "child"])
190180

191181
@expectedFailureAll(archs=["arm"]) # TODO
192-
@expectedFailureAll(archs=["aarch64"],
193-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
194182
@add_test_categories(["fork"])
195183
def test_vCont_parent(self):
196184
self.resume_one_test(run_order=["parent", "parent"], use_vCont=True)
197185

198186
@expectedFailureAll(archs=["arm"]) # TODO
199-
@expectedFailureAll(archs=["aarch64"],
200-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
201187
@add_test_categories(["fork"])
202188
def test_vCont_child(self):
203189
self.resume_one_test(run_order=["child", "child"], use_vCont=True)
204190

205191
@expectedFailureAll(archs=["arm"]) # TODO
206-
@expectedFailureAll(archs=["aarch64"],
207-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
208192
@add_test_categories(["fork"])
209193
def test_vCont_parent_then_child(self):
210194
self.resume_one_test(run_order=["parent", "parent", "child", "child"],
211195
use_vCont=True)
212196

213197
@expectedFailureAll(archs=["arm"]) # TODO
214-
@expectedFailureAll(archs=["aarch64"],
215-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
216198
@add_test_categories(["fork"])
217199
def test_vCont_child_then_parent(self):
218200
self.resume_one_test(run_order=["child", "child", "parent", "parent"],
219201
use_vCont=True)
220202

221203
@expectedFailureAll(archs=["arm"]) # TODO
222-
@expectedFailureAll(archs=["aarch64"],
223-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
224204
@add_test_categories(["fork"])
225205
def test_vCont_interspersed(self):
226206
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
@@ -229,7 +209,7 @@ def test_vCont_interspersed(self):
229209
@add_test_categories(["fork"])
230210
def test_vCont_two_processes(self):
231211
parent_pid, parent_tid, child_pid, child_tid = (
232-
self.start_fork_test(["fork", "trap"]))
212+
self.start_fork_test(["fork", "stop"]))
233213

234214
self.test_sequence.add_log_lines([
235215
# try to resume both processes
@@ -241,7 +221,7 @@ def test_vCont_two_processes(self):
241221

242222
@add_test_categories(["fork"])
243223
def test_vCont_all_processes_explicit(self):
244-
self.start_fork_test(["fork", "trap"])
224+
self.start_fork_test(["fork", "stop"])
245225

246226
self.test_sequence.add_log_lines([
247227
# try to resume all processes implicitly
@@ -252,7 +232,7 @@ def test_vCont_all_processes_explicit(self):
252232

253233
@add_test_categories(["fork"])
254234
def test_vCont_all_processes_implicit(self):
255-
self.start_fork_test(["fork", "trap"])
235+
self.start_fork_test(["fork", "stop"])
256236

257237
self.test_sequence.add_log_lines([
258238
# try to resume all processes implicitly
@@ -265,7 +245,7 @@ def test_vCont_all_processes_implicit(self):
265245
@add_test_categories(["fork"])
266246
def test_threadinfo(self):
267247
parent_pid, parent_tid, child_pid, child_tid = (
268-
self.start_fork_test(["fork", "thread:new", "trap"]))
248+
self.start_fork_test(["fork", "thread:new", "stop"]))
269249
pidtids = [
270250
(parent_pid, parent_tid),
271251
(child_pid, child_tid),
@@ -285,7 +265,7 @@ def test_threadinfo(self):
285265
"send packet: $OK#00",
286266
"read packet: $c#00",
287267
{"direction": "send",
288-
"regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
268+
"regex": self.stop_regex.format(*pidtid),
289269
},
290270
], True)
291271
self.add_threadinfo_collection_packets()
@@ -317,7 +297,7 @@ def test_memory_read_write(self):
317297
"get-data-address-hex:g_message",
318298
"fork",
319299
"print-message:",
320-
"trap",
300+
"stop",
321301
])
322302
self.add_qSupported_packets(["multiprocess+",
323303
"fork-events+"])
@@ -366,7 +346,7 @@ def test_memory_read_write(self):
366346
"regex": self.maybe_strict_output_regex(r"message: (.*)\r\n"),
367347
"capture": {1: "printed_message"}},
368348
{"direction": "send",
369-
"regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
349+
"regex": self.stop_regex.format(*pidtid),
370350
},
371351
], True)
372352
ret = self.expect_gdbremote_sequence()
@@ -399,7 +379,7 @@ def test_memory_read_write(self):
399379
@add_test_categories(["fork"])
400380
def test_register_read_write(self):
401381
parent_pid, parent_tid, child_pid, child_tid = (
402-
self.start_fork_test(["fork", "thread:new", "trap"]))
382+
self.start_fork_test(["fork", "thread:new", "stop"]))
403383
pidtids = [
404384
(parent_pid, parent_tid),
405385
(child_pid, child_tid),
@@ -411,7 +391,7 @@ def test_register_read_write(self):
411391
"send packet: $OK#00",
412392
"read packet: $c#00",
413393
{"direction": "send",
414-
"regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
394+
"regex": self.stop_regex.format(*pidtid),
415395
},
416396
], True)
417397

@@ -496,7 +476,7 @@ def test_register_read_write(self):
496476
@add_test_categories(["fork"])
497477
def test_qC(self):
498478
parent_pid, parent_tid, child_pid, child_tid = (
499-
self.start_fork_test(["fork", "thread:new", "trap"]))
479+
self.start_fork_test(["fork", "thread:new", "stop"]))
500480
pidtids = [
501481
(parent_pid, parent_tid),
502482
(child_pid, child_tid),
@@ -508,7 +488,7 @@ def test_qC(self):
508488
"send packet: $OK#00",
509489
"read packet: $c#00",
510490
{"direction": "send",
511-
"regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
491+
"regex": self.stop_regex.format(*pidtid),
512492
},
513493
], True)
514494

@@ -531,7 +511,7 @@ def test_qC(self):
531511
@add_test_categories(["fork"])
532512
def test_T(self):
533513
parent_pid, parent_tid, child_pid, child_tid = (
534-
self.start_fork_test(["fork", "thread:new", "trap"]))
514+
self.start_fork_test(["fork", "thread:new", "stop"]))
535515
pidtids = [
536516
(parent_pid, parent_tid),
537517
(child_pid, child_tid),
@@ -543,7 +523,7 @@ def test_T(self):
543523
"send packet: $OK#00",
544524
"read packet: $c#00",
545525
{"direction": "send",
546-
"regex": "^[$]T05thread:p{}.{}.*".format(*pidtid),
526+
"regex": self.stop_regex.format(*pidtid),
547527
},
548528
], True)
549529

lldb/test/API/tools/lldb-server/TestGdbRemoteForkNonStop.py

-4
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,12 @@ def test_vkill_both_nonstop(self):
9999
self.vkill_test(kill_parent=True, kill_child=True, nonstop=True)
100100

101101
@expectedFailureAll(archs=["arm"]) # TODO
102-
@expectedFailureAll(archs=["aarch64"],
103-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
104102
@add_test_categories(["fork"])
105103
def test_c_interspersed_nonstop(self):
106104
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
107105
nonstop=True)
108106

109107
@expectedFailureAll(archs=["arm"]) # TODO
110-
@expectedFailureAll(archs=["aarch64"],
111-
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
112108
@add_test_categories(["fork"])
113109
def test_vCont_interspersed_nonstop(self):
114110
self.resume_one_test(run_order=["parent", "child", "parent", "child"],

lldb/test/API/tools/lldb-server/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ int main(int argc, char **argv) {
353353
printf("%s\n", value ? value : "__unset__");
354354
} else if (consume_front(arg, "trap")) {
355355
trap();
356+
#if !defined(_WIN32)
357+
} else if (arg == "stop") {
358+
raise(SIGSTOP);
359+
#endif
356360
} else {
357361
// Treat the argument as text for stdout.
358362
printf("%s\n", argv[i]);

0 commit comments

Comments
 (0)