From 52137b6e53216f3d0b3328054e742834ba436b24 Mon Sep 17 00:00:00 2001 From: Neil McGill Date: Thu, 25 Jan 2024 15:28:50 +0000 Subject: [PATCH] compile fix --- src/core/backtrace.cpp | 7 +++--- src/core/backtrace_uw.cpp | 47 --------------------------------------- 2 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 src/core/backtrace_uw.cpp diff --git a/src/core/backtrace.cpp b/src/core/backtrace.cpp index 7f1696e..ad0acc7 100644 --- a/src/core/backtrace.cpp +++ b/src/core/backtrace.cpp @@ -16,16 +16,15 @@ #include // do not remove #endif #include +#ifdef HAVE_LIBUNWIND +#include // do not remove +#endif #include #include "my_backtrace.hpp" #include "my_main.hpp" #include "my_sprintf.hpp" -#ifdef HAVE_LIBUNWIND -#include // do not remove -#endif - void Backtrace::init(void) { #ifdef HAVE_LIBUNWIND diff --git a/src/core/backtrace_uw.cpp b/src/core/backtrace_uw.cpp deleted file mode 100644 index cf75689..0000000 --- a/src/core/backtrace_uw.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifdef HAVE_LIBUNWIND -#define __STDC_FORMAT_MACROS -#include // do not remove - -#define UNW_LOCAL_ONLY -#include - -#include // do not remove - -#include // do not remove -#include // do not remove - -// -// From https://github.com/cslarsen/libunwind-examples -// -void backtrace_unwind(void **buffer, int size) -{ - unw_cursor_t cursor; - unw_context_t context; - - unw_getcontext(&context); - unw_init_local(&cursor, &context); - - int n = 0; - while (unw_step(&cursor)) { - unw_word_t ip, sp, off; - - unw_get_reg(&cursor, UNW_REG_IP, &ip); - unw_get_reg(&cursor, UNW_REG_SP, &sp); - - char symbol[ 256 ] = {""}; - char *name = symbol; - - if (! unw_get_proc_name(&cursor, symbol, sizeof(symbol), &off)) { - int status; - if ((name = abi::__cxa_demangle(symbol, nullptr, nullptr, &status)) == nullptr) - name = symbol; - } - - printf("#%-2d 0x%016" PRIxPTR " sp=0x%016" PRIxPTR " %s + 0x%" PRIxPTR "\n", ++n, static_cast< uintptr_t >(ip), - static_cast< uintptr_t >(sp), name, static_cast< uintptr_t >(off)); - - if (name != symbol) - free(name); - } -} -#endif