- for (i = 0; i < e->used; i++) {
- char *fgets_res;
- DEBUG2("Looking for symbol %d, addr = '%s'", i, addrs[i]);
- fgets_res = fgets(line_func, 1024, pipe);
- if (fgets_res == NULL)
- THROW2(system_error, 0,
- "Cannot run fgets to look for symbol %d, addr %s", i,
- addrs[i]);
- line_func[strlen(line_func) - 1] = '\0';
- fgets_res = fgets(line_pos, 1024, pipe);
- if (fgets_res == NULL)
- THROW2(system_error, 0,
- "Cannot run fgets to look for symbol %d, addr %s", i,
- addrs[i]);
- line_pos[strlen(line_pos) - 1] = '\0';
-
- if (strcmp("??", line_func)) {
- DEBUG2("Found static symbol %s() at %s", line_func, line_pos);
- e->bt_strings[i] =
- bprintf("** In %s() at %s", line_func, line_pos);
+ for (std::size_t i = 0; i < e->bt.size(); i++) {
+ XBT_DEBUG("Looking for symbol %zd, addr = '%s'", i, addrs[i]);
+ if (fgets(line_func, 1024, pipe)) {
+ line_func[strlen(line_func) - 1] = '\0';
+ } else {
+ XBT_VERB("Cannot run fgets to look for symbol %zd, addr %s", i, addrs[i]);
+ strncpy(line_func, "???",3);
+ }
+ if (fgets(line_pos, 1024, pipe)) {
+ line_pos[strlen(line_pos) - 1] = '\0';
+ } else {
+ XBT_VERB("Cannot run fgets to look for symbol %zd, addr %s", i, addrs[i]);
+ strncpy(line_pos, backtrace_syms[i],1024);
+ }
+
+ if (strcmp("??", line_func) != 0) {
+ XBT_DEBUG("Found static symbol %s() at %s", line_func, line_pos);
+ char* s = bprintf("** In %s() at %s", line_func, line_pos);
+ e->bt_strings[i] = s;
+ free(s);