[lldb] [test] Add tests for coredumps with multiple threads

Differential Revision: https://reviews.llvm.org/D101157
This commit is contained in:
Michał Górny 2021-04-22 21:39:53 +02:00
parent 9d4896f50e
commit d1280f6967
15 changed files with 341 additions and 0 deletions

View File

@ -0,0 +1,77 @@
// This program is used to generate a core dump for testing multithreading
// support.
#include <atomic>
#include <chrono>
#include <cstdint>
#include <thread>
std::atomic_int start_counter{3};
void pseudobarrier_wait() {
start_counter--;
while (start_counter > 0);
}
void fcommon(uint32_t a, uint32_t b, uint32_t c, uint32_t d, double fa, double fb, double fc, double fd, bool segv) {
if (segv) {
int *foo = nullptr;
*foo = 0;
}
while (1);
}
void f1() {
volatile uint32_t a = 0x01010101;
volatile uint32_t b = 0x02020202;
volatile uint32_t c = 0x03030303;
volatile uint32_t d = 0x04040404;
volatile double fa = 2.0;
volatile double fb = 4.0;
volatile double fc = 8.0;
volatile double fd = 16.0;
pseudobarrier_wait();
std::this_thread::sleep_for(std::chrono::milliseconds(200));
fcommon(a, b, c, d, fa, fb, fc, fd, true);
}
void f2() {
volatile uint32_t a = 0x11111111;
volatile uint32_t b = 0x12121212;
volatile uint32_t c = 0x13131313;
volatile uint32_t d = 0x14141414;
volatile double fa = 3.0;
volatile double fb = 6.0;
volatile double fc = 9.0;
volatile double fd = 12.0;
pseudobarrier_wait();
fcommon(a, b, c, d, fa, fb, fc, fd, false);
}
void f3() {
volatile uint32_t a = 0x21212121;
volatile uint32_t b = 0x22222222;
volatile uint32_t c = 0x23232323;
volatile uint32_t d = 0x24242424;
volatile double fa = 5.0;
volatile double fb = 10.0;
volatile double fc = 15.0;
volatile double fd = 20.0;
pseudobarrier_wait();
fcommon(a, b, c, d, fa, fb, fc, fd, false);
}
int main() {
std::thread t1{f1};
std::thread t2{f2};
std::thread t3{f3};
t3.join();
t2.join();
t1.join();
return 0;
}

View File

@ -0,0 +1,42 @@
# RUN: %lldb -b -s %s -c %p/Inputs/aarch64-freebsd-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 100160, 0x0000000000211fc4, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 100115, 0x00000000406267a8, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #3: tid = 100161, 0x0000000000211fc8, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #4: tid = 100162, 0x0000000000211fc8, name = 'a.out', stop reason = signal SIGSEGV
register read --all
# CHECK-DAG: w0 = 0x01010101
# CHECK-DAG: w1 = 0x02020202
# CHECK-DAG: w2 = 0x03030303
# CHECK-DAG: w3 = 0x04040404
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: w0 = 0x11111111
# CHECK-DAG: w1 = 0x12121212
# CHECK-DAG: w2 = 0x13131313
# CHECK-DAG: w3 = 0x14141414
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x28 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 4
# CHECK: (lldb) thread select 4
register read --all
# CHECK-DAG: w0 = 0x21212121
# CHECK-DAG: w1 = 0x22222222
# CHECK-DAG: w2 = 0x23232323
# CHECK-DAG: w3 = 0x24242424
# CHECK-DAG: v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: v3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}

View File

@ -0,0 +1,42 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-freebsd-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 100761, 0x00402ed1, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 100744, 0x2057f78b, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #3: tid = 100762, 0x00402edc, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #4: tid = 100763, 0x00402edc, name = 'a.out', stop reason = signal SIGSEGV
register read --all
# CHECK-DAG: ecx = 0x04040404
# CHECK-DAG: edx = 0x03030303
# CHECK-DAG: edi = 0x01010101
# CHECK-DAG: esi = 0x02020202
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40}
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x01 0x40}
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x02 0x40}
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x03 0x40}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x14141414
# CHECK-DAG: edx = 0x13131313
# CHECK-DAG: edi = 0x11111111
# CHECK-DAG: esi = 0x12121212
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x00 0x40}
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x01 0x40}
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x90 0x02 0x40}
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xc0 0x02 0x40}
thread select 4
# CHECK: (lldb) thread select 4
register read --all
# CHECK-DAG: ecx = 0x24242424
# CHECK-DAG: edx = 0x23232323
# CHECK-DAG: edi = 0x21212121
# CHECK-DAG: esi = 0x22222222
# CHECK-DAG: st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x01 0x40}
# CHECK-DAG: st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x02 0x40}
# CHECK-DAG: st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xf0 0x02 0x40}
# CHECK-DAG: st7 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xa0 0x03 0x40}

View File

@ -0,0 +1,32 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-linux-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 330633, 0x080492d2, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 330634, 0x080492dd, stop reason = signal 0
# CHECK-NEXT: thread #3: tid = 330635, 0x080492dd, stop reason = signal 0
# CHECK-NEXT: thread #4: tid = 330632, 0xf7f59549, stop reason = signal 0
register read --all
# CHECK-DAG: ecx = 0x01010101
# CHECK-DAG: edx = 0x02020202
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 2
# CHECK: (lldb) thread select 2
register read --all
# CHECK-DAG: ecx = 0x11111111
# CHECK-DAG: edx = 0x12121212
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x21212121
# CHECK-DAG: edx = 0x22222222
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}

View File

@ -0,0 +1,24 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-netbsd-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 2, 0x08048db9, stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 4, 0x08048dbf, stop reason = signal 0
# CHECK-NEXT: thread #3: tid = 3, 0x08048dbf, stop reason = signal 0
# CHECK-NEXT: thread #4: tid = 1, 0xf876a147, stop reason = signal 0
register read --all
# CHECK-DAG: ecx = 0x03030303
# CHECK-DAG: ebx = 0x04040404
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x13131313
# CHECK-DAG: ebx = 0x14141414
thread select 2
# CHECK: (lldb) thread select 2
register read --all
# CHECK-DAG: ecx = 0x23232323
# CHECK-DAG: ebx = 0x24242424

View File

@ -0,0 +1,42 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-64-freebsd-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 100744, 0x00000000002030c2, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 100720, 0x0000000800396b3c, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #3: tid = 100745, 0x00000000002030cd, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #4: tid = 100746, 0x00000000002030cd, name = 'a.out', stop reason = signal SIGSEGV
register read --all
# CHECK-DAG: ecx = 0x04040404
# CHECK-DAG: edx = 0x03030303
# CHECK-DAG: edi = 0x01010101
# CHECK-DAG: esi = 0x02020202
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x14141414
# CHECK-DAG: edx = 0x13131313
# CHECK-DAG: edi = 0x11111111
# CHECK-DAG: esi = 0x12121212
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x28 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 4
# CHECK: (lldb) thread select 4
register read --all
# CHECK-DAG: ecx = 0x24242424
# CHECK-DAG: edx = 0x23232323
# CHECK-DAG: edi = 0x21212121
# CHECK-DAG: esi = 0x22222222
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}

View File

@ -0,0 +1,41 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-64-linux-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 329384, 0x0000000000401262, name = 'a.out', stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 329385, 0x000000000040126d, stop reason = signal 0
# CHECK-NEXT: thread #3: tid = 329386, 0x000000000040126d, stop reason = signal 0
# CHECK-NEXT: thread #4: tid = 329383, 0x00007fcf5582f762, stop reason = signal 0
register read --all
# CHECK-DAG: ecx = 0x04040404
# CHECK-DAG: edx = 0x03030303
# CHECK-DAG: edi = 0x01010101
# CHECK-DAG: esi = 0x02020202
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 2
# CHECK: (lldb) thread select 2
register read --all
# CHECK-DAG: ecx = 0x14141414
# CHECK-DAG: edx = 0x13131313
# CHECK-DAG: edi = 0x11111111
# CHECK-DAG: esi = 0x12121212
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x28 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x24242424
# CHECK-DAG: edx = 0x23232323
# CHECK-DAG: edi = 0x21212121
# CHECK-DAG: esi = 0x22222222
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}

View File

@ -0,0 +1,41 @@
# RUN: %lldb -b -s %s -c %p/Inputs/x86-64-netbsd-multithread.core | FileCheck %s
thread list
# CHECK: * thread #1: tid = 2, 0x0000000000400f82, stop reason = signal SIGSEGV
# CHECK-NEXT: thread #2: tid = 4, 0x0000000000400f88, stop reason = signal 0
# CHECK-NEXT: thread #3: tid = 3, 0x0000000000400f88, stop reason = signal 0
# CHECK-NEXT: thread #4: tid = 1, 0x0000791280ca1faa, stop reason = signal 0
register read --all
# CHECK-DAG: ecx = 0x04040404
# CHECK-DAG: edx = 0x03030303
# CHECK-DAG: edi = 0x01010101
# CHECK-DAG: esi = 0x02020202
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x10 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x20 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 3
# CHECK: (lldb) thread select 3
register read --all
# CHECK-DAG: ecx = 0x14141414
# CHECK-DAG: edx = 0x13131313
# CHECK-DAG: edi = 0x11111111
# CHECK-DAG: esi = 0x12121212
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x18 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x22 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x28 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
thread select 2
# CHECK: (lldb) thread select 2
register read --all
# CHECK-DAG: ecx = 0x24242424
# CHECK-DAG: edx = 0x23232323
# CHECK-DAG: edi = 0x21212121
# CHECK-DAG: esi = 0x22222222
# CHECK-DAG: xmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x24 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
# CHECK-DAG: xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x34 0x40 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}