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.
18 #define EXPECTED_NUM_FRAMES 50
19 #define NUM_FRAMES_UPPER_BOUND 100
21 _Unwind_Reason_Code
callback(_Unwind_Context
*context
, void *cnt
) {
25 if (*i
> NUM_FRAMES_UPPER_BOUND
) {
28 return _URC_NO_REASON
;
31 void test_backtrace() {
33 _Unwind_Backtrace(&callback
, &n
);
34 if (n
< EXPECTED_NUM_FRAMES
) {
44 return i
+ test(i
- 1);
48 int main(int, char**) {
50 assert(total
== 1275);