diff --git a/configuration.h b/configuration.h index 20e07dc..67485e3 100644 --- a/configuration.h +++ b/configuration.h @@ -8,6 +8,7 @@ #include #include +#include "simpleskycam.h" #include "videodev.h" #include "json.h" diff --git a/main.cc b/main.cc index d249aab..dc5c529 100644 --- a/main.cc +++ b/main.cc @@ -5,7 +5,9 @@ *****************************************************************************************/ #include +#include +#include "simpleskycam.h" #include "config.h" #include "configuration.h" #include "gui.h" @@ -32,7 +34,7 @@ int main (int argc, char **argv) { char buffer[16]; setvbuf (stdout, buffer, _IONBF, 16); #endif - + printf ("SimpleSkyCam - %s\n", VERSION); printf (" written by Steffen Pohle \n"); printf ("\n"); @@ -88,3 +90,39 @@ float get_cycletime(struct timeval *t) { return f; } + +/* + * print error message and the backtrace + */ +#define SIZE 100 +void errorexit (char *fmt,...) { + // + // error message + va_list args; + char text[4096]; + + va_start (args, fmt); + vsnprintf (text, 4096, fmt, args); + va_end (args); + + printf ("***************************\n"); + printf (" ERROR\n"); + printf ("***************************\n"); + printf ("%s", text); + + // + // backtrace + int j, nptrs; + void *buffer[SIZE]; + char **s; + + nptrs = backtrace(buffer, SIZE); + if ((s = (char**) backtrace_symbols(buffer, nptrs)) == NULL) { + for (j = 0; j < nptrs; j++) printf ("%-5d %p\n", j, buffer[j]); + } + else { + for (j = 0; j < nptrs; j++) printf ("%-5d %s\n", j, s[j]); + } + exit (-1); +} +