diff libunwind/test/unwind_leaffunction.pass.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 5f17cb93ff66
children 1f2b6ac9f198
line wrap: on
line diff
--- a/libunwind/test/unwind_leaffunction.pass.cpp	Wed Jul 21 10:27:27 2021 +0900
+++ b/libunwind/test/unwind_leaffunction.pass.cpp	Wed Nov 09 17:45:10 2022 +0900
@@ -8,8 +8,12 @@
 //===----------------------------------------------------------------------===//
 
 // Ensure that leaf function can be unwund.
-// REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
+// REQUIRES: linux && (target={{aarch64-.+}} || target={{s390x-.+}} || target={{x86_64-.+}})
 
+// TODO: Figure out why this fails with Memory Sanitizer.
+// XFAIL: msan
+
+#undef NDEBUG
 #include <assert.h>
 #include <dlfcn.h>
 #include <signal.h>
@@ -24,7 +28,8 @@
   (void)arg;
   Dl_info info = { 0, 0, 0, 0 };
 
-  // Unwind util the main is reached, above frames deeped on the platfrom and architecture.
+  // Unwind until the main is reached, above frames deeped on the platform and
+  // architecture.
   if (dladdr(reinterpret_cast<void *>(_Unwind_GetIP(ctx)), &info) &&
       info.dli_sname && !strcmp("main", info.dli_sname)) {
     _Exit(0);
@@ -38,14 +43,18 @@
   _Exit(-1);
 }
 
-int* faultyPointer = NULL;
-
 __attribute__((noinline)) void crashing_leaf_func(void) {
-  *faultyPointer = 0;
+  // libunwind searches for the address before the return address which points
+  // to the trap instruction. NOP guarantees the trap instruction is not the
+  // first instruction of the function.
+  // We should keep this here for other unwinders that also decrement pc.
+  __asm__ __volatile__("nop");
+  __builtin_trap();
 }
 
 int main(int, char**) {
-  signal(SIGSEGV, signal_handler);
+  signal(SIGTRAP, signal_handler);
+  signal(SIGILL, signal_handler);
   crashing_leaf_func();
   return -2;
-}
\ No newline at end of file
+}