void xbt_ex_setup_backtrace(xbt_ex_t *e) {
int i;
/* to get the backtrace from the libc */
- char **backtrace = backtrace_symbols (e->bt, e->used);
+ char **backtrace_syms = backtrace_symbols (e->bt, e->used);
/* To build the commandline of addr2line */
char *cmd, *curr;
struct stat stat_buf;
char *binary_name = NULL;
+ e->used = backtrace((void**)e->bt,XBT_BACKTRACE_SIZE);
+ e->bt_strings = NULL;
+
/* Some arches only have stubs of backtrace, no implementation (hppa comes to mind) */
if (!e->used)
return;
for (i=0; i<e->used;i++) {
/* retrieve this address */
- DEBUG2("Retrieving address number %d from '%s'", i, backtrace[i]);
- snprintf(buff,256,"%s",strchr(backtrace[i],'[')+1);
+ DEBUG2("Retrieving address number %d from '%s'", i, backtrace_syms[i]);
+ snprintf(buff,256,"%s",strchr(backtrace_syms[i],'[')+1);
p=strchr(buff,']');
*p='\0';
if (strcmp(buff,"(nil)"))
if (!found) {
VERB0("Problem while reading the maps file. Following backtrace will be mangled.");
- DEBUG1("No dynamic. Static symbol: %s", backtrace[i]);
- e->bt_strings[i] = bprintf("** In ?? (%s)", backtrace[i]);
+ DEBUG1("No dynamic. Static symbol: %s", backtrace_syms[i]);
+ e->bt_strings[i] = bprintf("** In ?? (%s)", backtrace_syms[i]);
continue;
}
/* Got it. We have our new address. Let's get the library path and we
are set */
- p = xbt_strdup(backtrace[i]);
+ p = xbt_strdup(backtrace_syms[i]);
if (p[0]=='[') {
/* library path not displayed in the map file either... */
free(p);
e->bt_strings[i] = bprintf("** In %s() at %s", line_func,line_pos);
} else {
/* damn, nothing to do here. Let's print the raw address */
- DEBUG1("Dynamic symbol not found. Raw address = %s", backtrace[i]);
- e->bt_strings[i] = bprintf("** In ?? at %s", backtrace[i]);
+ DEBUG1("Dynamic symbol not found. Raw address = %s", backtrace_syms[i]);
+ e->bt_strings[i] = bprintf("** In ?? at %s", backtrace_syms[i]);
}
}
}
pclose(pipe);
free(addrs);
- free(backtrace);
+ free(backtrace_syms);
free(cmd);
}
void xbt_ex_setup_backtrace(xbt_ex_t *e) {
int i;
-char **backtrace = backtrace_symbols (e->bt, e->used);
+char **backtrace_syms = backtrace_symbols (e->bt, e->used);
+ e->used = backtrace((void**)e->bt,XBT_BACKTRACE_SIZE);
+ e->bt_strings = NULL;
/* parse the output and build a new backtrace */
e->bt_strings = xbt_new(char*,e->used);
for(i=0; i<e->used; i++)
{
- e->bt_strings[i] = xbt_strdup(backtrace[i]);
- free(backtrace[i]);
+ e->bt_strings[i] = xbt_strdup(backtrace_syms[i]);
+ free(backtrace_syms[i]);
}
- free(backtrace);
+ free(backtrace_syms);
}
int