Go to the documentation of this file.00001 
00017 
00018 
00019 
00020 
00021 #include <ecl/config/ecl.hpp>
00022 
00023 #ifndef ECL_IS_WIN32
00024 
00025 
00026 
00027 
00028 
00029 #include <execinfo.h> 
00030 #include <signal.h>
00031 #include <cstdlib>
00032 #include <exception>
00033 #include <iostream>
00034 
00035 
00036 
00037 
00038 
00042 class ExceptionTracer {
00043 public:
00044          ExceptionTracer() {
00045          void * array[25];
00046          int nSize = backtrace(array, 25);
00047          char ** symbols = backtrace_symbols(array, nSize);
00048 
00049          for (int i = 0; i < nSize; i++) {
00050              std::cout << symbols[i] << std::endl;
00051          }
00052          free(symbols);
00053      }
00054 };
00055 
00056 void f() {
00057         std::cout << "f()" << std::endl;
00058         throw ExceptionTracer();
00059 }
00060 
00061 
00062 
00063 
00064 int main(int argc, char **argv) {
00065 
00066         std::cout << "Dude" << std::endl;
00067         f();
00068 
00069         return 0;
00070 }
00071 #else
00072 
00073 #include <iostream>
00074 
00075 int main(int argc, char **argv) {
00076 
00077         std::cout << "No backtrace support in windows (that I know of yet)." << std::endl;
00078         return 0;
00079 }
00080 #endif
00081