/** Print backtrace entry for a given object * * @param cbuff to search in. * @param obj pointer to original object */ void backtrace_print(fr_cbuff_t *cbuff, void *obj) { fr_bt_info_t *p; bool found = false; int i = 0; char **frames; while ((p = fr_cbuff_rp_next(cbuff, NULL))) { if ((p == obj) || !obj) { found = true; frames = backtrace_symbols(p->frames, p->count); fprintf(stderr, "Stacktrace for: %p\n", p); for (i = 0; i < p->count; i++) { fprintf(stderr, "%s\n", frames[i]); } /* We were only asked to look for one */ if (obj) { return; } } }; if (!found) { fprintf(stderr, "No backtrace available for %p", obj); } }
/** Print backtrace entry for a given object * * @param cbuff to search in. * @param obj pointer to original object */ void backtrace_print(fr_cbuff_t *cbuff, void *obj) { fr_bt_info_t *p; bool found = false; while ((p = fr_cbuff_rp_next(cbuff, NULL))) { if ((p->obj == obj) || !obj) { found = true; fprintf(stderr, "Stacktrace for: %p\n", p->obj); backtrace_symbols_fd(p->frames, p->count, STDERR_FILENO); } }; if (!found) { fprintf(stderr, "No backtrace available for %p", obj); } }