#include <stdio.h>
#include <stdlib.h>
-#include <execinfo.h>
+#include "portable.h" /* execinfo when available */
#include "xbt/ex.h"
/* default __ex_ctx callback function */
/* default __ex_terminate callback function */
void __xbt_ex_terminate_default(xbt_ex_t *e) {
- char **strings;
- size_t i;
fprintf(stderr,
"** SimGrid: UNCAUGHT EXCEPTION: category: %s; value: %d\n"
e->procname, (e->host?"@":""),(e->host?e->host:"localhost"),
e->file,e->line,e->func);
+#ifdef HAVE_EXECINFO_H
+ {
+ char **strings;
+ size_t i;
+
fprintf(stderr,"** Backtrace:\n");
strings = backtrace_symbols (e->bt, e->used);
printf (" %s\n", strings[i]);
free (strings);
+ }
+#endif
+
abort();
}
ex_term_cb_t __xbt_ex_terminate = &__xbt_ex_terminate_default;
void xbt_ex_free(xbt_ex_t e) {
- free(e.msg);
+ if (e.msg) free(e.msg);
+ free(e.procname);
}
/** \brief returns a short name for the given exception category */
default: return "INVALID_ERR";
}
}
+
+#ifndef HAVE_EXECINFO_H
+/* dummy implementation. We won't use the result, but ex.h needs it to be defined */
+int backtrace (void **__array, int __size) {
+ return 0;
+}
+
+#endif