1 /* 2 Copyright (c) 2010, Ondrej Certik 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions are met: 7 8 * Redistributions of source code must retain the above copyright notice, this 9 list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright notice, 11 this list of conditions and the following disclaimer in the documentation 12 and/or other materials provided with the distribution. 13 * Neither the name of the Sandia Corporation nor the names of its contributors 14 may be used to endorse or promote products derived from this software without 15 specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef TEUCHOS_STACKTRACE_HPP 30 #define TEUCHOS_STACKTRACE_HPP 31 32 /*! \file Teuchos_stacktrace.hpp 33 34 \brief Functions for returning stacktrace info (GCC only initially). 35 */ 36 37 #include "Teuchos_ConfigDefs.hpp" 38 39 40 #ifdef HAVE_TEUCHOS_STACKTRACE 41 42 43 /*! \defgroup TeuchosStackTrace_grp Utility code for generating stacktraces. 44 * 45 * \ingroup teuchos_language_support_grp 46 */ 47 48 namespace Teuchos { 49 50 51 /** \brief Stores the current stacktrace into an internal global variable. 52 * 53 * \ingroup TeuchosStackTrace_grp 54 */ 55 void store_stacktrace(); 56 57 /** \brief Returns the last stored stacktrace as a string. 58 * 59 * \ingroup TeuchosStackTrace_grp 60 */ 61 std::string get_stored_stacktrace(); 62 63 /** \brief Returns the current stacktrace as a string. 64 * 65 * \param impl_stacktrace_depth [in] The stacktrace depth to remove from the 66 * stacktrace printout to avoid showing users implementation functions in the 67 * stacktrace. 68 * 69 * \ingroup TeuchosStackTrace_grp 70 */ 71 std::string get_stacktrace(int impl_stacktrace_depth=0); 72 73 /** \brief Prints the current stacktrace to stdout. 74 * 75 * \ingroup TeuchosStackTrace_grp 76 */ 77 void show_stacktrace(); 78 79 /** \brief Prints the current stacktrace to stdout on segfault. 80 * 81 * \ingroup TeuchosStackTrace_grp 82 */ 83 void print_stack_on_segfault(); 84 85 } // end namespace Teuchos 86 87 #endif // HAVE_TEUCHOS_STACKTRACE 88 89 #endif // TEUCHOS_STACKTRACE_HPP 90 91