]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/msan/backtrace.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / msan / backtrace.cc
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))
10 void 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 exit(1);
17 char **s = backtrace_symbols(buf, sz);
18 assert(s > 0);
19 for (int i = 0; i < sz; ++i)
20 printf("%d\n", (int)strlen(s[i]));
21 }
22
23 int main(void) {
24 f();
25 return 0;
26 }