From 42204611ba9df581a52b192960877cf42f839c62 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 11 May 2022 02:00:09 +0800 Subject: [PATCH] fix(os): add print trace func. --- source/os/src/osMemory.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index b1b91699a6..3400f8c516 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -103,8 +103,10 @@ Dwarf_Debug tDbg; static TdThreadOnce traceThreadInit = PTHREAD_ONCE_INIT; void endTrace() { + if (traceThreadInit != PTHREAD_ONCE_INIT) { delete_lookup_table(&lookup_table); dwarf_finish(tDbg); + } } void startTrace() { int ret; @@ -128,15 +130,15 @@ void startTrace() { atexit(endTrace); } static void print_line(Dwarf_Debug dbg, Dwarf_Line line, Dwarf_Addr pc) { - char *linesrc = "??"; - Dwarf_Unsigned lineno = 0; + char *linesrc = "??"; + Dwarf_Unsigned lineno = 0; - if (line) { - dwarf_linesrc(line, &linesrc, NULL); - dwarf_lineno(line, &lineno, NULL); - } - printf("%s:%" DW_PR_DUu "\n", linesrc, lineno); - if (line) dwarf_dealloc(dbg, linesrc, DW_DLA_STRING); + if (line) { + dwarf_linesrc(line, &linesrc, NULL); + dwarf_lineno(line, &lineno, NULL); + } + printf("%s:%" DW_PR_DUu "\n", linesrc, lineno); + if (line) dwarf_dealloc(dbg, linesrc, DW_DLA_STRING); } void taosPrintBackTrace() { int size = 20;