From 9454e83a07cf243dcdf995e55bafa71ba7a47e69 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Sat, 7 Oct 2023 15:58:56 +0800 Subject: [PATCH] 2 --- be/src/common/stack_trace.cpp | 26 ++++++++++++-------------- be/src/common/status.h | 4 ++-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/be/src/common/stack_trace.cpp b/be/src/common/stack_trace.cpp index aca5de6a8c6095f..39e7f1317faaa0b 100644 --- a/be/src/common/stack_trace.cpp +++ b/be/src/common/stack_trace.cpp @@ -402,12 +402,13 @@ static void toStringEveryLineImpl([[maybe_unused]] const std::string dwarf_locat out << " ?"; } - if (shouldShowAddress(physical_addr)) { - out << " @ "; - writePointerHex(physical_addr, out); - } + // Do not display the stack address and file name, it is not important. + // if (shouldShowAddress(physical_addr)) { + // out << " @ "; + // writePointerHex(physical_addr, out); + // } - out << " in " << (object ? object->name : "?"); + // out << " in " << (object ? object->name : "?"); callback(out.str()); @@ -459,15 +460,12 @@ std::string toStringCached(const StackTrace::FramePointers& pointers, size_t off } std::string StackTrace::toString(int start_pointers_index) const { - if (start_pointers_index == 0) { - return toStringCached(frame_pointers, offset, size); - } else { - // Start output from the start_pointers_index position of frame pointers. - StackTrace::FramePointers frame_pointers_raw {}; - std::copy(frame_pointers.begin() + start_pointers_index, frame_pointers.end(), - frame_pointers_raw.begin()); - return toStringCached(frame_pointers_raw, offset, size - start_pointers_index); - } + // Default delete the first three frame pointers, which are inside the stack_trace.cpp. + start_pointers_index += 3; + StackTrace::FramePointers frame_pointers_raw {}; + std::copy(frame_pointers.begin() + start_pointers_index, frame_pointers.end(), + frame_pointers_raw.begin()); + return toStringCached(frame_pointers_raw, offset, size - start_pointers_index); } std::string StackTrace::toString(void** frame_pointers_raw, size_t offset, size_t size) { diff --git a/be/src/common/status.h b/be/src/common/status.h index 72c9175710cb49a..5c8a56c65fdb4d3 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -376,8 +376,8 @@ class [[nodiscard]] Status { } #ifdef ENABLE_STACKTRACE if constexpr (stacktrace && capture_stacktrace(code)) { - // Delete the first four frame pointers, which are inside the StackTrace and Status. - status._err_msg->_stack = get_stack_trace(4); + // Delete the first one frame pointers, which are inside the status.h + status._err_msg->_stack = get_stack_trace(1); LOG(WARNING) << "meet error status: " << status; // may print too many stacks. } #endif