Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
core/example/show_stack/cxx_main.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teuchos_stacktrace.hpp"
11 
12 
13 void g()
14 {
15 #ifdef HAVE_TEUCHOS_STACKTRACE
16  Teuchos::show_stacktrace();
17 #endif
18 }
19 
20 
21 void f()
22 {
23  g();
24 }
25 
26 
27 int main()
28 {
29 #ifdef HAVE_TEUCHOS_STACKTRACE
30  Teuchos::print_stack_on_segfault();
31 #endif
32  f();
33 
34  // This will segfault:
35  char *p = NULL; *p = 0;
36 
37  return 0;
38 }
Functions for returning stacktrace info (GCC only initially).
int main(int argc, char *argv[])