Skip to content

Commit d1280f6

Browse files
committed
[lldb] [test] Add tests for coredumps with multiple threads
Differential Revision: https://reviews.llvm.org/D101157
1 parent 9d4896f commit d1280f6

15 files changed

+341
-0
lines changed
Binary file not shown.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This program is used to generate a core dump for testing multithreading
2+
// support.
3+
4+
#include <atomic>
5+
#include <chrono>
6+
#include <cstdint>
7+
#include <thread>
8+
9+
std::atomic_int start_counter{3};
10+
11+
void pseudobarrier_wait() {
12+
start_counter--;
13+
while (start_counter > 0);
14+
}
15+
16+
void fcommon(uint32_t a, uint32_t b, uint32_t c, uint32_t d, double fa, double fb, double fc, double fd, bool segv) {
17+
if (segv) {
18+
int *foo = nullptr;
19+
*foo = 0;
20+
}
21+
while (1);
22+
}
23+
24+
void f1() {
25+
volatile uint32_t a = 0x01010101;
26+
volatile uint32_t b = 0x02020202;
27+
volatile uint32_t c = 0x03030303;
28+
volatile uint32_t d = 0x04040404;
29+
volatile double fa = 2.0;
30+
volatile double fb = 4.0;
31+
volatile double fc = 8.0;
32+
volatile double fd = 16.0;
33+
34+
pseudobarrier_wait();
35+
std::this_thread::sleep_for(std::chrono::milliseconds(200));
36+
fcommon(a, b, c, d, fa, fb, fc, fd, true);
37+
}
38+
39+
void f2() {
40+
volatile uint32_t a = 0x11111111;
41+
volatile uint32_t b = 0x12121212;
42+
volatile uint32_t c = 0x13131313;
43+
volatile uint32_t d = 0x14141414;
44+
volatile double fa = 3.0;
45+
volatile double fb = 6.0;
46+
volatile double fc = 9.0;
47+
volatile double fd = 12.0;
48+
49+
pseudobarrier_wait();
50+
fcommon(a, b, c, d, fa, fb, fc, fd, false);
51+
}
52+
53+
void f3() {
54+
volatile uint32_t a = 0x21212121;
55+
volatile uint32_t b = 0x22222222;
56+
volatile uint32_t c = 0x23232323;
57+
volatile uint32_t d = 0x24242424;
58+
volatile double fa = 5.0;
59+
volatile double fb = 10.0;
60+
volatile double fc = 15.0;
61+
volatile double fd = 20.0;
62+
63+
pseudobarrier_wait();
64+
fcommon(a, b, c, d, fa, fb, fc, fd, false);
65+
}
66+
67+
int main() {
68+
std::thread t1{f1};
69+
std::thread t2{f2};
70+
std::thread t3{f3};
71+
72+
t3.join();
73+
t2.join();
74+
t1.join();
75+
76+
return 0;
77+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# RUN: %lldb -b -s %s -c %p/Inputs/aarch64-freebsd-multithread.core | FileCheck %s
2+
3+
thread list
4+
# CHECK: * thread #1: tid = 100160, 0x0000000000211fc4, name = 'a.out', stop reason = signal SIGSEGV
5+
# CHECK-NEXT: thread #2: tid = 100115, 0x00000000406267a8, name = 'a.out', stop reason = signal SIGSEGV
6+
# CHECK-NEXT: thread #3: tid = 100161, 0x0000000000211fc8, name = 'a.out', stop reason = signal SIGSEGV
7+
# CHECK-NEXT: thread #4: tid = 100162, 0x0000000000211fc8, name = 'a.out', stop reason = signal SIGSEGV
8+
9+
10+
register read --all
11+
# CHECK-DAG: w0 = 0x01010101
12+
# CHECK-DAG: w1 = 0x02020202
13+
# CHECK-DAG: w2 = 0x03030303
14+
# CHECK-DAG: w3 = 0x04040404
15+
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
16+
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
17+
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
18+
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
19+
20+
thread select 3
21+
# CHECK: (lldb) thread select 3
22+
register read --all
23+
# CHECK-DAG: w0 = 0x11111111
24+
# CHECK-DAG: w1 = 0x12121212
25+
# CHECK-DAG: w2 = 0x13131313
26+
# CHECK-DAG: w3 = 0x14141414
27+
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
28+
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
29+
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
30+
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x28 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
31+
32+
thread select 4
33+
# CHECK: (lldb) thread select 4
34+
register read --all
35+
# CHECK-DAG: w0 = 0x21212121
36+
# CHECK-DAG: w1 = 0x22222222
37+
# CHECK-DAG: w2 = 0x23232323
38+
# CHECK-DAG: w3 = 0x24242424
39+
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
40+
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
41+
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
42+
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-freebsd-multithread.core | FileCheck %s
2+
3+
thread list
4+
# CHECK: * thread #1: tid = 100761, 0x00402ed1, name = 'a.out', stop reason = signal SIGSEGV
5+
# CHECK-NEXT: thread #2: tid = 100744, 0x2057f78b, name = 'a.out', stop reason = signal SIGSEGV
6+
# CHECK-NEXT: thread #3: tid = 100762, 0x00402edc, name = 'a.out', stop reason = signal SIGSEGV
7+
# CHECK-NEXT: thread #4: tid = 100763, 0x00402edc, name = 'a.out', stop reason = signal SIGSEGV
8+
9+
10+
register read --all
11+
# CHECK-DAG: ecx = 0x04040404
12+
# CHECK-DAG: edx = 0x03030303
13+
# CHECK-DAG: edi = 0x01010101
14+
# CHECK-DAG: esi = 0x02020202
15+
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
16+
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x01 0x40}
17+
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x02 0x40}
18+
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x03 0x40}
19+
20+
thread select 3
21+
# CHECK: (lldb) thread select 3
22+
register read --all
23+
# CHECK-DAG: ecx = 0x14141414
24+
# CHECK-DAG: edx = 0x13131313
25+
# CHECK-DAG: edi = 0x11111111
26+
# CHECK-DAG: esi = 0x12121212
27+
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x40}
28+
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x01 0x40}
29+
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x90 0x02 0x40}
30+
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x02 0x40}
31+
32+
thread select 4
33+
# CHECK: (lldb) thread select 4
34+
register read --all
35+
# CHECK-DAG: ecx = 0x24242424
36+
# CHECK-DAG: edx = 0x23232323
37+
# CHECK-DAG: edi = 0x21212121
38+
# CHECK-DAG: esi = 0x22222222
39+
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x01 0x40}
40+
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x02 0x40}
41+
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xf0 0x02 0x40}
42+
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x03 0x40}

0 commit comments

Comments
 (0)