Home | History | Annotate | Download | only in src
      1 // Copyright (c) 2009, Google Inc.
      2 // All rights reserved.
      3 //
      4 // Redistribution and use in source and binary forms, with or without
      5 // modification, are permitted provided that the following conditions are
      6 // met:
      7 //
      8 //     * Redistributions of source code must retain the above copyright
      9 // notice, this list of conditions and the following disclaimer.
     10 //     * Redistributions in binary form must reproduce the above
     11 // copyright notice, this list of conditions and the following disclaimer
     12 // in the documentation and/or other materials provided with the
     13 // distribution.
     14 //     * Neither the name of Google Inc. nor the names of its
     15 // contributors may be used to endorse or promote products derived from
     16 // this software without specific prior written permission.
     17 //
     18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29 
     30 // ---
     31 // Author: Paul Pluzhnikov
     32 //
     33 // Figure out which unwinder to use on a given platform.
     34 //
     35 // Defines STACKTRACE_INL_HEADER to the *-inl.h containing
     36 // actual unwinder implementation.
     37 //
     38 // Defines STACKTRACE_SKIP_CONTEXT_ROUTINES if a separate
     39 // GetStack{Trace,Frames}WithContext should not be provided.
     40 //
     41 // This header is "private" to stacktrace.cc and
     42 // stacktrace_with_context.cc.
     43 //
     44 // DO NOT include it into any other files.
     45 
     46 #ifndef BASE_STACKTRACE_CONFIG_H_
     47 #define BASE_STACKTRACE_CONFIG_H_
     48 
     49 // First, the i386 and x86_64 case.
     50 #if (defined(__i386__) || defined(__x86_64__)) && __GNUC__ >= 2
     51 # if !defined(NO_FRAME_POINTER)
     52 #   define STACKTRACE_INL_HEADER "stacktrace_x86-inl.h"
     53 #   define STACKTRACE_SKIP_CONTEXT_ROUTINES 1
     54 # elif defined(HAVE_LIBUNWIND_H)  // a proxy for having libunwind installed
     55 #   define STACKTRACE_INL_HEADER "stacktrace_libunwind-inl.h"
     56 #   define STACKTRACE_USES_LIBUNWIND 1
     57 # elif defined(__linux)
     58 #   error Cannnot calculate stack trace: need either libunwind or frame-pointers (see INSTALL file)
     59 # else
     60 #   error Cannnot calculate stack trace: need libunwind (see INSTALL file)
     61 # endif
     62 
     63 // The PowerPC case
     64 #elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
     65 # if !defined(NO_FRAME_POINTER)
     66 #   define STACKTRACE_INL_HEADER "stacktrace_powerpc-inl.h"
     67 # else
     68 #   define STACKTRACE_INL_HEADER "stacktrace_generic-inl.h"
     69 # endif
     70 
     71 // The Android case
     72 #elif defined(__ANDROID__)
     73 #define STACKTRACE_INL_HEADER "stacktrace_android-inl.h"
     74 
     75 // The ARM case
     76 #elif defined(__arm__)  && __GNUC__ >= 2
     77 # if !defined(NO_FRAME_POINTER)
     78 #   define STACKTRACE_INL_HEADER "stacktrace_arm-inl.h"
     79 # else
     80 #   error stacktrace without frame pointer is not supported on ARM
     81 # endif
     82 
     83 // The Windows case -- probably cygwin and mingw will use one of the
     84 // x86-includes above, but if not, we can fall back to windows intrinsics.
     85 #elif defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(__MINGW32__)
     86 # define STACKTRACE_INL_HEADER "stacktrace_win32-inl.h"
     87 
     88 #endif  // all the cases
     89 #endif  // BASE_STACKTRACE_CONFIG_H_
     90