1fa27255dSFangrui Song /// When the main program doesn't use .eh_frame, the slow unwinder does not work.
2fa27255dSFangrui Song /// Test that we can fall back to the fast unwinder.
3fa27255dSFangrui Song // RUN: %clangxx -O0 -g1 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer %s -o %t
4fa27255dSFangrui Song // RUN: llvm-readelf -S %t | FileCheck %s --check-prefix=SEC
5fa27255dSFangrui Song // RUN: %run %t 2>&1 | FileCheck %s
6fa27255dSFangrui Song 
70a621d33SVitaly Buka // On android %t is a wrapper python script so llvm-readelf will fail.
80a621d33SVitaly Buka // UNSUPPORTED: android
90a621d33SVitaly Buka 
10*11ad9e31SDavid Spickett /// Fast unwinder does not work with Thumb code
11*11ad9e31SDavid Spickett // UNSUPPORTED: thumb
12*11ad9e31SDavid Spickett 
13fa27255dSFangrui Song /// No .eh_frame && -g => .debug_frame
14fa27255dSFangrui Song // SEC: .debug_frame
15fa27255dSFangrui Song 
16fa27255dSFangrui Song #include <sanitizer/common_interface_defs.h>
17fa27255dSFangrui Song #include <vector>
18fa27255dSFangrui Song 
19fa27255dSFangrui Song template <int N>
20fa27255dSFangrui Song struct A {
21fa27255dSFangrui Song   template <class T>
22fa27255dSFangrui Song   void RecursiveTemplateFunction(const T &t);
23fa27255dSFangrui Song };
24fa27255dSFangrui Song 
25fa27255dSFangrui Song template <int N>
26fa27255dSFangrui Song template <class T>
RecursiveTemplateFunction(const T &)27fa27255dSFangrui Song __attribute__((noinline)) void A<N>::RecursiveTemplateFunction(const T &) {
28fa27255dSFangrui Song   std::vector<T> t;
29fa27255dSFangrui Song   return A<N - 1>().RecursiveTemplateFunction(t);
30fa27255dSFangrui Song }
31fa27255dSFangrui Song 
32fa27255dSFangrui Song template <>
33fa27255dSFangrui Song template <class T>
RecursiveTemplateFunction(const T &)34fa27255dSFangrui Song __attribute__((noinline)) void A<0>::RecursiveTemplateFunction(const T &) {
35fa27255dSFangrui Song   __sanitizer_print_stack_trace();
36fa27255dSFangrui Song }
37fa27255dSFangrui Song 
main()38fa27255dSFangrui Song int main() {
39fa27255dSFangrui Song   // CHECK: {{vector<.*vector<.*vector<.*vector<.*vector<}}
403a678fe3SFangrui Song   A<7>().RecursiveTemplateFunction(0);
41fa27255dSFangrui Song }
42