fix incorrect region opacity after move + undo
[ardour.git] / libs / pbd / stacktrace.cc
1 #include <pbd/stacktrace.h>
2 #include <iostream>
3
4 /* Obtain a backtrace and print it to stdout. */
5
6 #ifdef HAVE_EXECINFO
7
8 #include <execinfo.h>
9 #include <stdlib.h>
10
11 void
12 PBD::stacktrace (std::ostream& out, int levels)
13 {
14         void *array[200];
15         size_t size;
16         char **strings;
17         size_t i;
18      
19         size = backtrace (array, 200);
20         strings = backtrace_symbols (array, size);
21      
22         if (strings) {
23
24                 printf ("Obtained %zd stack frames.\n", size);
25                 
26                 for (i = 0; i < size && (levels == 0 || i < levels); i++) {
27                         out << strings[i] << std::endl;
28                 }
29                 
30                 free (strings);
31         }
32 }
33
34 #else
35
36 void
37 PBD::stacktrace (std::ostream& out, int levels)
38 {
39         out << "stack tracing is not enabled on this platform" << std::endl;
40 }
41
42 #endif /* HAVE_EXECINFO */