2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // TODO: Figure out why this fails with Memory Sanitizer.
13 // This test fails on older llvm, when built with picolibc.
14 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
21 #define EXPECTED_NUM_FRAMES 50
22 #define NUM_FRAMES_UPPER_BOUND 100
24 _Unwind_Reason_Code
callback(_Unwind_Context
*context
, void *cnt
) {
28 if (*i
> NUM_FRAMES_UPPER_BOUND
) {
31 return _URC_NO_REASON
;
34 void test_backtrace() {
36 _Unwind_Backtrace(&callback
, &n
);
37 if (n
< EXPECTED_NUM_FRAMES
) {
47 return i
+ test(i
- 1);
51 int main(int, char**) {
53 assert(total
== 1275);