1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
|
/* $NetBSD: t_ptrace_threads_wait.h,v 1.1 2020/05/05 00:50:39 kamil Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define TRACE_THREADS_NUM 100
static volatile int done;
pthread_mutex_t trace_threads_mtx = PTHREAD_MUTEX_INITIALIZER;
static void *
trace_threads_cb(void *arg __unused)
{
pthread_mutex_lock(&trace_threads_mtx);
done++;
pthread_mutex_unlock(&trace_threads_mtx);
while (done < TRACE_THREADS_NUM)
sched_yield();
return NULL;
}
static void
trace_threads(bool trace_create, bool trace_exit, bool masked)
{
const int sigval = SIGSTOP;
pid_t child, wpid;
#if defined(TWAIT_HAVE_STATUS)
int status;
#endif
ptrace_state_t state;
const int slen = sizeof(state);
ptrace_event_t event;
const int elen = sizeof(event);
struct ptrace_siginfo info;
sigset_t intmask;
pthread_t t[TRACE_THREADS_NUM];
int rv;
size_t n;
lwpid_t lid;
/* Track created and exited threads */
struct lwp_event_count traced_lwps[__arraycount(t)] = {{0, 0}};
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
if (masked) {
sigemptyset(&intmask);
sigaddset(&intmask, SIGTRAP);
sigprocmask(SIG_BLOCK, &intmask, NULL);
}
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
for (n = 0; n < __arraycount(t); n++) {
rv = pthread_create(&t[n], NULL, trace_threads_cb,
NULL);
FORKEE_ASSERT(rv == 0);
}
for (n = 0; n < __arraycount(t); n++) {
rv = pthread_join(t[n], NULL);
FORKEE_ASSERT(rv == 0);
}
/*
* There is race between _exit() and pthread_join() detaching
* a thread. For simplicity kill the process after detecting
* LWP events.
*/
while (true)
continue;
FORKEE_ASSERT(0 && "Not reached");
}
DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, sigval);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
DPRINTF("Set LWP event mask for the child %d\n", child);
memset(&event, 0, sizeof(event));
if (trace_create)
event.pe_set_event |= PTRACE_LWP_CREATE;
if (trace_exit)
event.pe_set_event |= PTRACE_LWP_EXIT;
SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
for (n = 0; n < (trace_create ? __arraycount(t) : 0); n++) {
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGTRAP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
validate_status_stopped(status, SIGTRAP);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
"child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
"si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_LWP);
SYSCALL_REQUIRE(
ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
ATF_REQUIRE_EQ_MSG(state.pe_report_event, PTRACE_LWP_CREATE,
"%d != %d", state.pe_report_event, PTRACE_LWP_CREATE);
lid = state.pe_lwp;
DPRINTF("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
*FIND_EVENT_COUNT(traced_lwps, lid) += 1;
DPRINTF("Before resuming the child process where it left off "
"and without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
}
for (n = 0; n < (trace_exit ? __arraycount(t) : 0); n++) {
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGTRAP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
validate_status_stopped(status, SIGTRAP);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
"child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
"si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_LWP);
SYSCALL_REQUIRE(
ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
ATF_REQUIRE_EQ_MSG(state.pe_report_event, PTRACE_LWP_EXIT,
"%d != %d", state.pe_report_event, PTRACE_LWP_EXIT);
lid = state.pe_lwp;
DPRINTF("Reported PTRACE_LWP_EXIT event with lid %d\n", lid);
if (trace_create) {
int *count = FIND_EVENT_COUNT(traced_lwps, lid);
ATF_REQUIRE_EQ(*count, 1);
*count = 0;
}
DPRINTF("Before resuming the child process where it left off "
"and without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
}
kill(child, SIGKILL);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_signaled(status, SIGKILL, 0);
DPRINTF("Before calling %s() for the child - expected no process\n",
TWAIT_FNAME);
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
#define TRACE_THREADS(test, trace_create, trace_exit, mask) \
ATF_TC(test); \
ATF_TC_HEAD(test, tc) \
{ \
atf_tc_set_md_var(tc, "descr", \
"Verify spawning threads with%s tracing LWP create and" \
"with%s tracing LWP exit", trace_create ? "" : "out", \
trace_exit ? "" : "out"); \
} \
\
ATF_TC_BODY(test, tc) \
{ \
\
trace_threads(trace_create, trace_exit, mask); \
}
TRACE_THREADS(trace_thread_nolwpevents, false, false, false)
TRACE_THREADS(trace_thread_lwpexit, false, true, false)
TRACE_THREADS(trace_thread_lwpcreate, true, false, false)
TRACE_THREADS(trace_thread_lwpcreate_and_exit, true, true, false)
TRACE_THREADS(trace_thread_lwpexit_masked_sigtrap, false, true, true)
TRACE_THREADS(trace_thread_lwpcreate_masked_sigtrap, true, false, true)
TRACE_THREADS(trace_thread_lwpcreate_and_exit_masked_sigtrap, true, true, true)
/// ----------------------------------------------------------------------------
static void *
thread_and_exec_thread_cb(void *arg __unused)
{
execlp("/bin/echo", "/bin/echo", NULL);
abort();
}
static void
threads_and_exec(void)
{
const int sigval = SIGSTOP;
pid_t child, wpid;
#if defined(TWAIT_HAVE_STATUS)
int status;
#endif
ptrace_state_t state;
const int slen = sizeof(state);
ptrace_event_t event;
const int elen = sizeof(event);
struct ptrace_siginfo info;
pthread_t t;
lwpid_t lid;
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
FORKEE_ASSERT(pthread_create(&t, NULL,
thread_and_exec_thread_cb, NULL) == 0);
for (;;)
continue;
FORKEE_ASSERT(0 && "Not reached");
}
DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, sigval);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
DPRINTF("Set LWP event mask for the child %d\n", child);
memset(&event, 0, sizeof(event));
event.pe_set_event |= PTRACE_LWP_CREATE | PTRACE_LWP_EXIT;
SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGTRAP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
validate_status_stopped(status, SIGTRAP);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
"child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
"si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_LWP);
SYSCALL_REQUIRE(
ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
ATF_REQUIRE_EQ_MSG(state.pe_report_event, PTRACE_LWP_CREATE,
"%d != %d", state.pe_report_event, PTRACE_LWP_CREATE);
lid = state.pe_lwp;
DPRINTF("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
DPRINTF("Before resuming the child process where it left off "
"and without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGTRAP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
validate_status_stopped(status, SIGTRAP);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
"child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
"si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_LWP);
SYSCALL_REQUIRE(
ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
ATF_REQUIRE_EQ_MSG(state.pe_report_event, PTRACE_LWP_EXIT,
"%d != %d", state.pe_report_event, PTRACE_LWP_EXIT);
lid = state.pe_lwp;
DPRINTF("Reported PTRACE_LWP_EXIT event with lid %d\n", lid);
DPRINTF("Before resuming the child process where it left off "
"and without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGTRAP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
validate_status_stopped(status, SIGTRAP);
DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
"child\n");
SYSCALL_REQUIRE(
ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
"si_errno=%#x\n",
info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
info.psi_siginfo.si_errno);
ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_signaled(status, SIGKILL, 0);
DPRINTF("Before calling %s() for the child - expected no process\n",
TWAIT_FNAME);
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
ATF_TC(threads_and_exec);
ATF_TC_HEAD(threads_and_exec, tc)
{
atf_tc_set_md_var(tc, "descr",
"Verify that multithreaded application on exec() will report "
"LWP_EXIT events");
}
ATF_TC_BODY(threads_and_exec, tc)
{
threads_and_exec();
}
/// ----------------------------------------------------------------------------
ATF_TC(suspend_no_deadlock);
ATF_TC_HEAD(suspend_no_deadlock, tc)
{
atf_tc_set_md_var(tc, "descr",
"Verify that the while the only thread within a process is "
"suspended, the whole process cannot be unstopped");
}
ATF_TC_BODY(suspend_no_deadlock, tc)
{
const int exitval = 5;
const int sigval = SIGSTOP;
pid_t child, wpid;
#if defined(TWAIT_HAVE_STATUS)
int status;
#endif
struct ptrace_siginfo psi;
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
DPRINTF("Before exiting of the child process\n");
_exit(exitval);
}
DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, sigval);
DPRINTF("Before reading siginfo and lwpid_t\n");
SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &psi, sizeof(psi)) != -1);
DPRINTF("Before suspending LWP %d\n", psi.psi_lwpid);
SYSCALL_REQUIRE(ptrace(PT_SUSPEND, child, NULL, psi.psi_lwpid) != -1);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
ATF_REQUIRE_ERRNO(EDEADLK,
ptrace(PT_CONTINUE, child, (void *)1, 0) == -1);
DPRINTF("Before resuming LWP %d\n", psi.psi_lwpid);
SYSCALL_REQUIRE(ptrace(PT_RESUME, child, NULL, psi.psi_lwpid) != -1);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_exited(status, exitval);
DPRINTF("Before calling %s() for the child - expected no process\n",
TWAIT_FNAME);
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
/// ----------------------------------------------------------------------------
static pthread_barrier_t barrier1_resume;
static pthread_barrier_t barrier2_resume;
static void *
resume_thread(void *arg)
{
raise(SIGUSR1);
pthread_barrier_wait(&barrier1_resume);
/* Debugger will suspend the process here */
pthread_barrier_wait(&barrier2_resume);
raise(SIGUSR2);
return infinite_thread(arg);
}
ATF_TC(resume);
ATF_TC_HEAD(resume, tc)
{
atf_tc_set_md_var(tc, "descr",
"Verify that a thread can be suspended by a debugger and later "
"resumed by the debugger");
}
ATF_TC_BODY(resume, tc)
{
const int sigval = SIGSTOP;
pid_t child, wpid;
#if defined(TWAIT_HAVE_STATUS)
int status;
#endif
lwpid_t lid;
struct ptrace_siginfo psi;
pthread_t t;
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
pthread_barrier_init(&barrier1_resume, NULL, 2);
pthread_barrier_init(&barrier2_resume, NULL, 2);
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
DPRINTF("Before creating new thread in child\n");
FORKEE_ASSERT(pthread_create(&t, NULL, resume_thread, NULL) == 0);
pthread_barrier_wait(&barrier1_resume);
pthread_barrier_wait(&barrier2_resume);
infinite_thread(NULL);
}
DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, sigval);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGUSR1\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, SIGUSR1);
DPRINTF("Before reading siginfo and lwpid_t\n");
SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &psi, sizeof(psi)) != -1);
DPRINTF("Before suspending LWP %d\n", psi.psi_lwpid);
SYSCALL_REQUIRE(ptrace(PT_SUSPEND, child, NULL, psi.psi_lwpid) != -1);
lid = psi.psi_lwpid;
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before suspending the parent for 1 second, we expect no signals\n");
SYSCALL_REQUIRE(sleep(1) == 0);
#if defined(TWAIT_HAVE_OPTIONS)
DPRINTF("Before calling %s() for the child - expected no status\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, WNOHANG), 0);
#endif
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_STOP, child, NULL, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGSTOP\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, SIGSTOP);
DPRINTF("Before resuming LWP %d\n", lid);
SYSCALL_REQUIRE(ptrace(PT_RESUME, child, NULL, lid) != -1);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected stopped "
"SIGUSR2\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, SIGUSR2);
DPRINTF("Before resuming the child process where it left off and "
"without signal to be sent\n");
SYSCALL_REQUIRE(ptrace(PT_KILL, child, (void *)1, 0) != -1);
DPRINTF("Before calling %s() for the child - expected exited\n",
TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_signaled(status, SIGKILL, 0);
DPRINTF("Before calling %s() for the child - expected no process\n",
TWAIT_FNAME);
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
/// ----------------------------------------------------------------------------
#if defined(TWAIT_HAVE_STATUS)
#define THREAD_CONCURRENT_BREAKPOINT_NUM 50
#define THREAD_CONCURRENT_SIGNALS_NUM 50
#define THREAD_CONCURRENT_WATCHPOINT_NUM 50
/* List of signals to use for the test */
const int thread_concurrent_signals_list[] = {
SIGIO,
SIGXCPU,
SIGXFSZ,
SIGVTALRM,
SIGPROF,
SIGWINCH,
SIGINFO,
SIGUSR1,
SIGUSR2
};
enum thread_concurrent_signal_handling {
/* the signal is discarded by debugger */
TCSH_DISCARD,
/* the handler is set to SIG_IGN */
TCSH_SIG_IGN,
/* an actual handler is used */
TCSH_HANDLER
};
static pthread_barrier_t thread_concurrent_barrier;
static pthread_key_t thread_concurrent_key;
static uint32_t thread_concurrent_watchpoint_var = 0;
static void *
thread_concurrent_breakpoint_thread(void *arg)
{
static volatile int watchme = 1;
pthread_barrier_wait(&thread_concurrent_barrier);
DPRINTF("Before entering breakpoint func from LWP %d\n", _lwp_self());
check_happy(watchme);
return NULL;
}
static void
thread_concurrent_sig_handler(int sig)
{
void *tls_val = pthread_getspecific(thread_concurrent_key);
DPRINTF("Before increment, LWP %d tls_val=%p\n", _lwp_self(), tls_val);
FORKEE_ASSERT(pthread_setspecific(thread_concurrent_key,
(void*)((uintptr_t)tls_val + 1)) == 0);
}
static void *
thread_concurrent_signals_thread(void *arg)
{
int sigval = thread_concurrent_signals_list[
_lwp_self() % __arraycount(thread_concurrent_signals_list)];
enum thread_concurrent_signal_handling *signal_handle = arg;
void *tls_val;
pthread_barrier_wait(&thread_concurrent_barrier);
DPRINTF("Before raising %s from LWP %d\n", strsignal(sigval),
_lwp_self());
pthread_kill(pthread_self(), sigval);
if (*signal_handle == TCSH_HANDLER) {
tls_val = pthread_getspecific(thread_concurrent_key);
DPRINTF("After raising, LWP %d tls_val=%p\n", _lwp_self(), tls_val);
FORKEE_ASSERT(tls_val == (void*)1);
}
return NULL;
}
static void *
thread_concurrent_watchpoint_thread(void *arg)
{
pthread_barrier_wait(&thread_concurrent_barrier);
DPRINTF("Before modifying var from LWP %d\n", _lwp_self());
thread_concurrent_watchpoint_var = 1;
return NULL;
}
#if defined(__i386__) || defined(__x86_64__)
enum thread_concurrent_sigtrap_event {
TCSE_UNKNOWN,
TCSE_BREAKPOINT,
TCSE_WATCHPOINT
};
static void
thread_concurrent_lwp_setup(pid_t child, lwpid_t lwpid);
static enum thread_concurrent_sigtrap_event
thread_concurrent_handle_sigtrap(pid_t child, ptrace_siginfo_t *info);
#endif
static void
thread_concurrent_test(enum thread_concurrent_signal_handling signal_handle,
int breakpoint_threads, int signal_threads, int watchpoint_threads)
{
const int exitval = 5;
const int sigval = SIGSTOP;
pid_t child, wpid;
int status;
struct lwp_event_count signal_counts[THREAD_CONCURRENT_SIGNALS_NUM]
= {{0, 0}};
struct lwp_event_count bp_counts[THREAD_CONCURRENT_BREAKPOINT_NUM]
= {{0, 0}};
struct lwp_event_count wp_counts[THREAD_CONCURRENT_BREAKPOINT_NUM]
= {{0, 0}};
ptrace_event_t event;
int i;
#if defined(HAVE_DBREGS)
if (!can_we_set_dbregs()) {
atf_tc_skip("Either run this test as root or set sysctl(3) "
"security.models.extensions.user_set_dbregs to 1");
}
#endif
atf_tc_skip("PR kern/54960");
/* Protect against out-of-bounds array access. */
ATF_REQUIRE(breakpoint_threads <= THREAD_CONCURRENT_BREAKPOINT_NUM);
ATF_REQUIRE(signal_threads <= THREAD_CONCURRENT_SIGNALS_NUM);
ATF_REQUIRE(watchpoint_threads <= THREAD_CONCURRENT_WATCHPOINT_NUM);
DPRINTF("Before forking process PID=%d\n", getpid());
SYSCALL_REQUIRE((child = fork()) != -1);
if (child == 0) {
pthread_t bp_threads[THREAD_CONCURRENT_BREAKPOINT_NUM];
pthread_t sig_threads[THREAD_CONCURRENT_SIGNALS_NUM];
pthread_t wp_threads[THREAD_CONCURRENT_WATCHPOINT_NUM];
DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
DPRINTF("Before raising %s from child\n", strsignal(sigval));
FORKEE_ASSERT(raise(sigval) == 0);
if (signal_handle != TCSH_DISCARD) {
struct sigaction sa;
unsigned int j;
memset(&sa, 0, sizeof(sa));
if (signal_handle == TCSH_SIG_IGN)
sa.sa_handler = SIG_IGN;
else
sa.sa_handler = thread_concurrent_sig_handler;
sigemptyset(&sa.sa_mask);
for (j = 0;
j < __arraycount(thread_concurrent_signals_list);
j++)
FORKEE_ASSERT(sigaction(
thread_concurrent_signals_list[j], &sa, NULL)
!= -1);
}
DPRINTF("Before starting threads from the child\n");
FORKEE_ASSERT(pthread_barrier_init(
&thread_concurrent_barrier, NULL,
breakpoint_threads + signal_threads + watchpoint_threads)
== 0);
FORKEE_ASSERT(pthread_key_create(&thread_concurrent_key, NULL)
== 0);
for (i = 0; i < signal_threads; i++) {
FORKEE_ASSERT(pthread_create(&sig_threads[i], NULL,
thread_concurrent_signals_thread,
&signal_handle) == 0);
}
for (i = 0; i < breakpoint_threads; i++) {
FORKEE_ASSERT(pthread_create(&bp_threads[i], NULL,
thread_concurrent_breakpoint_thread, NULL) == 0);
}
for (i = 0; i < watchpoint_threads; i++) {
FORKEE_ASSERT(pthread_create(&wp_threads[i], NULL,
thread_concurrent_watchpoint_thread, NULL) == 0);
}
DPRINTF("Before joining threads from the child\n");
for (i = 0; i < watchpoint_threads; i++) {
FORKEE_ASSERT(pthread_join(wp_threads[i], NULL) == 0);
}
for (i = 0; i < breakpoint_threads; i++) {
FORKEE_ASSERT(pthread_join(bp_threads[i], NULL) == 0);
}
for (i = 0; i < signal_threads; i++) {
FORKEE_ASSERT(pthread_join(sig_threads[i], NULL) == 0);
}
FORKEE_ASSERT(pthread_key_delete(thread_concurrent_key) == 0);
FORKEE_ASSERT(pthread_barrier_destroy(
&thread_concurrent_barrier) == 0);
DPRINTF("Before exiting of the child process\n");
_exit(exitval);
}
DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
validate_status_stopped(status, sigval);
DPRINTF("Set LWP event mask for the child process\n");
memset(&event, 0, sizeof(event));
event.pe_set_event |= PTRACE_LWP_CREATE;
SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, sizeof(event))
!= -1);
DPRINTF("Before resuming the child process where it left off\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
DPRINTF("Before entering signal collection loop\n");
while (1) {
ptrace_siginfo_t info;
DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
child);
if (WIFEXITED(status))
break;
/* Note: we use validate_status_stopped() to get nice error
* message. Signal is irrelevant since it won't be reached.
*/
else if (!WIFSTOPPED(status))
validate_status_stopped(status, 0);
DPRINTF("Before calling PT_GET_SIGINFO\n");
SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info,
sizeof(info)) != -1);
DPRINTF("Received signal %d from LWP %d (wait: %d)\n",
info.psi_siginfo.si_signo, info.psi_lwpid,
WSTOPSIG(status));
ATF_CHECK_EQ_MSG(info.psi_siginfo.si_signo, WSTOPSIG(status),
"lwp=%d, WSTOPSIG=%d, psi_siginfo=%d", info.psi_lwpid,
WSTOPSIG(status), info.psi_siginfo.si_signo);
if (WSTOPSIG(status) != SIGTRAP) {
int expected_sig =
thread_concurrent_signals_list[info.psi_lwpid %
__arraycount(thread_concurrent_signals_list)];
ATF_CHECK_EQ_MSG(WSTOPSIG(status), expected_sig,
"lwp=%d, expected %d, got %d", info.psi_lwpid,
expected_sig, WSTOPSIG(status));
*FIND_EVENT_COUNT(signal_counts, info.psi_lwpid) += 1;
} else if (info.psi_siginfo.si_code == TRAP_LWP) {
#if defined(__i386__) || defined(__x86_64__)
thread_concurrent_lwp_setup(child, info.psi_lwpid);
#endif
} else {
#if defined(__i386__) || defined(__x86_64__)
switch (thread_concurrent_handle_sigtrap(child, &info)) {
case TCSE_UNKNOWN:
/* already reported inside the function */
break;
case TCSE_BREAKPOINT:
*FIND_EVENT_COUNT(bp_counts,
info.psi_lwpid) += 1;
break;
case TCSE_WATCHPOINT:
*FIND_EVENT_COUNT(wp_counts,
info.psi_lwpid) += 1;
break;
}
#else
ATF_CHECK_MSG(0, "Unexpected SIGTRAP, si_code=%d\n",
info.psi_siginfo.si_code);
#endif
}
DPRINTF("Before resuming the child process\n");
SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1,
signal_handle != TCSH_DISCARD && WSTOPSIG(status) != SIGTRAP
? WSTOPSIG(status) : 0) != -1);
}
for (i = 0; i < signal_threads; i++)
ATF_CHECK_EQ_MSG(signal_counts[i].lec_count, 1,
"signal_counts[%d].lec_count=%d; lec_lwp=%d",
i, signal_counts[i].lec_count, signal_counts[i].lec_lwp);
for (i = signal_threads; i < THREAD_CONCURRENT_SIGNALS_NUM; i++)
ATF_CHECK_EQ_MSG(signal_counts[i].lec_count, 0,
"extraneous signal_counts[%d].lec_count=%d; lec_lwp=%d",
i, signal_counts[i].lec_count, signal_counts[i].lec_lwp);
for (i = 0; i < breakpoint_threads; i++)
ATF_CHECK_EQ_MSG(bp_counts[i].lec_count, 1,
"bp_counts[%d].lec_count=%d; lec_lwp=%d",
i, bp_counts[i].lec_count, bp_counts[i].lec_lwp);
for (i = breakpoint_threads; i < THREAD_CONCURRENT_BREAKPOINT_NUM; i++)
ATF_CHECK_EQ_MSG(bp_counts[i].lec_count, 0,
"extraneous bp_counts[%d].lec_count=%d; lec_lwp=%d",
i, bp_counts[i].lec_count, bp_counts[i].lec_lwp);
for (i = 0; i < watchpoint_threads; i++)
ATF_CHECK_EQ_MSG(wp_counts[i].lec_count, 1,
"wp_counts[%d].lec_count=%d; lec_lwp=%d",
i, wp_counts[i].lec_count, wp_counts[i].lec_lwp);
for (i = watchpoint_threads; i < THREAD_CONCURRENT_WATCHPOINT_NUM; i++)
ATF_CHECK_EQ_MSG(wp_counts[i].lec_count, 0,
"extraneous wp_counts[%d].lec_count=%d; lec_lwp=%d",
i, wp_counts[i].lec_count, wp_counts[i].lec_lwp);
validate_status_exited(status, exitval);
}
#define THREAD_CONCURRENT_TEST(test, sig_hdl, bps, sigs, wps, descr) \
ATF_TC(test); \
ATF_TC_HEAD(test, tc) \
{ \
atf_tc_set_md_var(tc, "descr", descr); \
} \
\
ATF_TC_BODY(test, tc) \
{ \
thread_concurrent_test(sig_hdl, bps, sigs, wps); \
}
THREAD_CONCURRENT_TEST(thread_concurrent_signals, TCSH_DISCARD,
0, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent signals issued to a single thread are reported "
"correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_signals_sig_ign, TCSH_SIG_IGN,
0, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent signals issued to a single thread are reported "
"correctly and passed back to SIG_IGN handler");
THREAD_CONCURRENT_TEST(thread_concurrent_signals_handler, TCSH_HANDLER,
0, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent signals issued to a single thread are reported "
"correctly and passed back to a handler function");
#if defined(__i386__) || defined(__x86_64__)
THREAD_CONCURRENT_TEST(thread_concurrent_breakpoints, TCSH_DISCARD,
THREAD_CONCURRENT_BREAKPOINT_NUM, 0, 0,
"Verify that concurrent breakpoints are reported correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_watchpoints, TCSH_DISCARD,
0, 0, THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent breakpoints are reported correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_wp, TCSH_DISCARD,
THREAD_CONCURRENT_BREAKPOINT_NUM, 0, THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent breakpoints and watchpoints are reported "
"correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_sig, TCSH_DISCARD,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent breakpoints and signals are reported correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_sig_sig_ign, TCSH_SIG_IGN,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent breakpoints and signals are reported correctly "
"and passed back to SIG_IGN handler");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_sig_handler, TCSH_HANDLER,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM, 0,
"Verify that concurrent breakpoints and signals are reported correctly "
"and passed back to a handler function");
THREAD_CONCURRENT_TEST(thread_concurrent_wp_sig, TCSH_DISCARD,
0, THREAD_CONCURRENT_SIGNALS_NUM, THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent watchpoints and signals are reported correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_wp_sig_sig_ign, TCSH_SIG_IGN,
0, THREAD_CONCURRENT_SIGNALS_NUM, THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent watchpoints and signals are reported correctly "
"and passed back to SIG_IGN handler");
THREAD_CONCURRENT_TEST(thread_concurrent_wp_sig_handler, TCSH_HANDLER,
0, THREAD_CONCURRENT_SIGNALS_NUM, THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent watchpoints and signals are reported correctly "
"and passed back to a handler function");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_wp_sig, TCSH_DISCARD,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM,
THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent breakpoints, watchpoints and signals are reported "
"correctly");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_wp_sig_sig_ign, TCSH_SIG_IGN,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM,
THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent breakpoints, watchpoints and signals are reported "
"correctly and passed back to SIG_IGN handler");
THREAD_CONCURRENT_TEST(thread_concurrent_bp_wp_sig_handler, TCSH_HANDLER,
THREAD_CONCURRENT_BREAKPOINT_NUM, THREAD_CONCURRENT_SIGNALS_NUM,
THREAD_CONCURRENT_WATCHPOINT_NUM,
"Verify that concurrent breakpoints, watchpoints and signals are reported "
"correctly and passed back to a handler function");
#endif
#endif /*defined(TWAIT_HAVE_STATUS)*/
#define ATF_TP_ADD_TCS_PTRACE_WAIT_THREADS() \
ATF_TP_ADD_TC(tp, trace_thread_nolwpevents); \
ATF_TP_ADD_TC(tp, trace_thread_lwpexit); \
ATF_TP_ADD_TC(tp, trace_thread_lwpcreate); \
ATF_TP_ADD_TC(tp, trace_thread_lwpcreate_and_exit); \
ATF_TP_ADD_TC(tp, trace_thread_lwpexit_masked_sigtrap); \
ATF_TP_ADD_TC(tp, trace_thread_lwpcreate_masked_sigtrap); \
ATF_TP_ADD_TC(tp, trace_thread_lwpcreate_and_exit_masked_sigtrap); \
ATF_TP_ADD_TC(tp, threads_and_exec); \
ATF_TP_ADD_TC(tp, suspend_no_deadlock); \
ATF_TP_ADD_TC(tp, resume); \
ATF_TP_ADD_TC_HAVE_STATUS(tp, thread_concurrent_signals); \
ATF_TP_ADD_TC_HAVE_STATUS(tp, thread_concurrent_signals_sig_ign); \
ATF_TP_ADD_TC_HAVE_STATUS(tp, thread_concurrent_signals_handler); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_breakpoints); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_watchpoints); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_wp); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_sig); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_sig_sig_ign); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_sig_handler); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_wp_sig); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_wp_sig_sig_ign); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_wp_sig_handler); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_wp_sig); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_wp_sig_sig_ign); \
ATF_TP_ADD_TC_HAVE_STATUS_X86(tp, thread_concurrent_bp_wp_sig_handler);
|