From d7e96b12a3442cb60e9323ce261e09c91fa41ab9 Mon Sep 17 00:00:00 2001 From: Ivan Lezhankin Date: Fri, 25 Dec 2020 22:25:25 +0300 Subject: [PATCH] Minor refactoring of custom exception stacktrace interface --- include/exception | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/exception b/include/exception index f43c84c..4266fa2 100644 --- a/include/exception +++ b/include/exception @@ -105,7 +105,7 @@ class _LIBCPP_EXCEPTION_ABI exception public: _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT { -#ifdef STD_EXCEPTION_HAS_STACK_TRACE +#if defined(STD_EXCEPTION_HAS_STACK_TRACE) capture(); #endif } @@ -113,21 +113,15 @@ public: virtual ~exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; -#ifdef STD_EXCEPTION_HAS_STACK_TRACE +#if defined(STD_EXCEPTION_HAS_STACK_TRACE) /// This is ClickHouse patch to libc++. It breaks ABI, so you cannot link your code with any C++ library /// that has any std::exception-related symbols exported and was built without this patch. - void ** const get_stack_trace_frames() const _NOEXCEPT { return const_cast(frames); } - int get_stack_trace_size() const _NOEXCEPT { return size; } - void set_stack_trace(void ** frames_, int size_) _NOEXCEPT - { - size = size_; - for (int i = 0; i < size; ++i) - frames[i] = frames_[i]; - } + void * const * get_stack_trace_frames() const _NOEXCEPT { return frames; } + size_t get_stack_trace_size() const _NOEXCEPT { return size; } private: - static constexpr int capacity = 32; + static constexpr size_t capacity = 32; void * frames[capacity]; - int size = 0; + size_t size = 0; void capture() _NOEXCEPT { size = unw_backtrace(frames, capacity);