1 // RUN: %clangxx_msan -O0 %s -o %t && %run %t 2 3 #include <assert.h> 4 #include <execinfo.h> 5 #include <stdio.h> 6 #include <string.h> 7 #include <stdlib.h> 8 9 __attribute__((noinline)) f()10void f() { 11 void *buf[10]; 12 int sz = backtrace(buf, sizeof(buf) / sizeof(*buf)); 13 assert(sz > 0); 14 for (int i = 0; i < sz; ++i) 15 if (!buf[i]) { 16 #if defined(__s390x__) 17 // backtrace() may return a bogus trailing NULL on s390x. 18 if (i == sz - 1) 19 continue; 20 #endif 21 exit(1); 22 } 23 char **s = backtrace_symbols(buf, sz); 24 assert(s != 0); 25 for (int i = 0; i < sz; ++i) 26 printf("%d\n", (int)strlen(s[i])); 27 } 28 main(void)29int main(void) { 30 f(); 31 return 0; 32 } 33