mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: jfb.
mgorny requested review of this revision.

(adding for early review)


https://reviews.llvm.org/D101157

Files:
  lldb/test/Shell/Register/Core/Inputs/multithread.cpp
  lldb/test/Shell/Register/Core/Inputs/x86-32-freebsd-multithread.core
  lldb/test/Shell/Register/Core/Inputs/x86-32-linux-multithread.core
  lldb/test/Shell/Register/Core/Inputs/x86-32-netbsd-multithread.core
  lldb/test/Shell/Register/Core/Inputs/x86-64-freebsd-multithread.core
  lldb/test/Shell/Register/Core/Inputs/x86-64-linux-multithread.core
  lldb/test/Shell/Register/Core/Inputs/x86-64-netbsd-multithread.core
  lldb/test/Shell/Register/Core/x86-64-linux-multithread.test

Index: lldb/test/Shell/Register/Core/x86-64-linux-multithread.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/Core/x86-64-linux-multithread.test
@@ -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: * thread #2, stop reason = signal 0
+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: * thread #3, stop reason = signal 0
+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}
Index: lldb/test/Shell/Register/Core/Inputs/multithread.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/Core/Inputs/multithread.cpp
@@ -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;
+}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to