*/
char **backtrace_symbols(void *const *buffer, int size);
+void xbt_backtrace_current(xbt_ex_t * e) {
+ e->used = backtrace((void **) e->bt, XBT_BACKTRACE_SIZE);
+}
+
+
void xbt_ex_setup_backtrace(xbt_ex_t * e)
{
int i;
- char **backtrace_syms = backtrace_symbols(e->bt, e->used);
+ char **backtrace_syms;
- e->used = backtrace((void **) e->bt, XBT_BACKTRACE_SIZE);
+ xbt_assert0(e && e->used,"Backtrace not setup yet, cannot set it up for display");
+
+ backtrace_syms = backtrace_symbols(e->bt, e->used);
e->bt_strings = NULL;
/* parse the output and build a new backtrace */
e->bt_strings = xbt_new(char *, e->used);
/* ebp points on stack base */
/* esp points on stack pointer, ie on last stacked element (current element) */
-// asm ("call $ + 5"); FIXME: this does not works when cross-compiling. Is this really mandatory?
- asm ("pop %eax");
- asm ("mov context.Eip, %eax");
- asm ("mov %eax, %esp");
- asm ("mov context.Esp, %eax");
- asm ("mov context.Ebp, %ebp");
-
+ _asm call $ + 5
+ _asm pop eax
+ _asm mov context.Eip, eax
+ _asm mov eax, esp
+ _asm mov context.Esp, eax
+ _asm mov context.Ebp, ebp
+
if ((NULL == hlp_dbg_instance) || (size <= 0) || (NULL == buffer)) {
errno = EINVAL;
return 0;