char * btp_backtrace_to_text(struct btp_backtrace *backtrace, bool verbose) { struct btp_strbuf *str = btp_strbuf_new(); if (verbose) { btp_strbuf_append_strf(str, "Thread count: %d\n", btp_backtrace_get_thread_count(backtrace)); } if (backtrace->crash && verbose) { btp_strbuf_append_str(str, "Crash frame: "); btp_frame_append_to_str(backtrace->crash, str, verbose); } struct btp_thread *thread = backtrace->threads; while (thread) { btp_thread_append_to_str(thread, str, verbose); thread = thread->next; } return btp_strbuf_free_nobuf(str); }
void btp_thread_append_to_str(struct btp_thread *thread, struct strbuf *str, bool verbose) { int framecount = btp_thread_get_frame_count(thread); if (verbose) { strbuf_append_strf(str, "Thread no. %d (%d frames)\n", thread->number, framecount); } else strbuf_append_str(str, "Thread\n"); struct btp_frame *frame = thread->frames; while (frame) { btp_frame_append_to_str(frame, str, verbose); frame = frame->next; } }