brintos

brintos / llvm-project-archived public Read only

0
0
Text · 652 B · 7a8e041 Raw
33 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && %run %t2 3#include <assert.h>4#include <execinfo.h>5#include <stdio.h>6#include <string.h>7#include <stdlib.h>8 9__attribute__((noinline))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#endif21      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 29int main(void) {30  f();31  return 0;32}33