diff options
| author | Khem Raj <raj.khem@gmail.com> | 2021-05-28 17:40:13 -0700 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2021-06-08 11:37:54 -0700 |
| commit | d45403baedd7ae7755a02cfe0205000b760167bd (patch) | |
| tree | 42e04bb59a1eb2d69012b145f0478ff54d3da094 /recipes-devtools | |
| parent | c48de926ac54802df7e1e4b7f91caa4fa4ef45b1 (diff) | |
| download | meta-clang-d45403baedd7ae7755a02cfe0205000b760167bd.tar.gz | |
libunwind: Implement unw_backtrace
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'recipes-devtools')
| -rw-r--r-- | recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch | 55 | ||||
| -rw-r--r-- | recipes-devtools/clang/common.inc | 1 |
2 files changed, 56 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch b/recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch new file mode 100644 index 0000000..53f816d --- /dev/null +++ b/recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | From 79195637cf6cde28baa23e41e7b417e98b036913 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Maksim Kita <maksim-kita@yandex-team.ru> | ||
| 3 | Date: Sun, 23 May 2021 10:27:29 +0000 | ||
| 4 | Subject: [PATCH] libunwind: Added unw_backtrace method | ||
| 5 | |||
| 6 | Source: https://github.com/ClickHouse-Extras/libunwind/commit/52f0f7861926cbfaef7e6c97d8a6d7ba2a1f6747#diff-a82fc885e2e4facf4b92d26171c13aa4aa5db296f77e1158ba2f8664e3bd1f5c | ||
| 7 | Upstream-Status: Pending | ||
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 9 | --- | ||
| 10 | libunwind/include/libunwind.h | 1 + | ||
| 11 | libunwind/src/libunwind.cpp | 18 ++++++++++++++++++ | ||
| 12 | 2 files changed, 19 insertions(+) | ||
| 13 | |||
| 14 | diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h | ||
| 15 | index 0feecd7bd6fc..670cfa3ed71d 100644 | ||
| 16 | --- a/libunwind/include/libunwind.h | ||
| 17 | +++ b/libunwind/include/libunwind.h | ||
| 18 | @@ -127,6 +127,7 @@ extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL; | ||
| 19 | extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL; | ||
| 20 | extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL; | ||
| 21 | //extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*); | ||
| 22 | +extern int unw_backtrace(void **, int) LIBUNWIND_AVAIL; | ||
| 23 | |||
| 24 | extern unw_addr_space_t unw_local_addr_space; | ||
| 25 | |||
| 26 | diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp | ||
| 27 | index 9b3b92bdff09..986ef62f9231 100644 | ||
| 28 | --- a/libunwind/src/libunwind.cpp | ||
| 29 | +++ b/libunwind/src/libunwind.cpp | ||
| 30 | @@ -289,7 +289,25 @@ void __unw_remove_dynamic_fde(unw_word_t fde) { | ||
| 31 | #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) | ||
| 32 | #endif // !defined(__USING_SJLJ_EXCEPTIONS__) | ||
| 33 | |||
| 34 | +int unw_backtrace(void **buffer, int size) { | ||
| 35 | + unw_context_t context; | ||
| 36 | + unw_cursor_t cursor; | ||
| 37 | + if (unw_getcontext(&context) || unw_init_local(&cursor, &context)) { | ||
| 38 | + return 0; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + unw_word_t ip; | ||
| 42 | + int current = 0; | ||
| 43 | + while (unw_step(&cursor) > 0) { | ||
| 44 | + if (current >= size || unw_get_reg(&cursor, UNW_REG_IP, &ip)) { | ||
| 45 | + break; | ||
| 46 | + } | ||
| 47 | |||
| 48 | + buffer[current++] = reinterpret_cast<void *>(static_cast<uintptr_t>(ip)); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + return current; | ||
| 52 | +} | ||
| 53 | |||
| 54 | // Add logging hooks in Debug builds only | ||
| 55 | #ifndef NDEBUG | ||
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index ac96ef5..62be08a 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc | |||
| @@ -42,6 +42,7 @@ SRC_URI = "\ | |||
| 42 | file://0030-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch \ | 42 | file://0030-clang-Fix-x86-triple-for-non-debian-multiarch-linux-.patch \ |
| 43 | file://0031-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \ | 43 | file://0031-compiler-rt-Link-scudo-with-SANITIZER_CXX_ABI_LIBRAR.patch \ |
| 44 | file://0032-compiler-rt-Link-scudo-standalone-with-libatomic-on-.patch \ | 44 | file://0032-compiler-rt-Link-scudo-standalone-with-libatomic-on-.patch \ |
| 45 | file://0033-libunwind-Added-unw_backtrace-method.patch \ | ||
| 45 | " | 46 | " |
| 46 | # Fallback to no-PIE if not set | 47 | # Fallback to no-PIE if not set |
| 47 | GCCPIE ??= "" | 48 | GCCPIE ??= "" |
