forked from kraj/meta-clang
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
From 79195637cf6cde28baa23e41e7b417e98b036913 Mon Sep 17 00:00:00 2001 | ||
From: Maksim Kita <maksim-kita@yandex-team.ru> | ||
Date: Sun, 23 May 2021 10:27:29 +0000 | ||
Subject: [PATCH] libunwind: Added unw_backtrace method | ||
|
||
Source: https://github.com/ClickHouse-Extras/libunwind/commit/52f0f7861926cbfaef7e6c97d8a6d7ba2a1f6747#diff-a82fc885e2e4facf4b92d26171c13aa4aa5db296f77e1158ba2f8664e3bd1f5c | ||
Upstream-Status: Pending | ||
Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
--- | ||
libunwind/include/libunwind.h | 1 + | ||
libunwind/src/libunwind.cpp | 18 ++++++++++++++++++ | ||
2 files changed, 19 insertions(+) | ||
|
||
diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h | ||
index 0feecd7bd6fc..670cfa3ed71d 100644 | ||
--- a/libunwind/include/libunwind.h | ||
+++ b/libunwind/include/libunwind.h | ||
@@ -127,6 +127,7 @@ extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL; | ||
extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL; | ||
extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL; | ||
//extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*); | ||
+extern int unw_backtrace(void **, int) LIBUNWIND_AVAIL; | ||
|
||
extern unw_addr_space_t unw_local_addr_space; | ||
|
||
diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp | ||
index 9b3b92bdff09..986ef62f9231 100644 | ||
--- a/libunwind/src/libunwind.cpp | ||
+++ b/libunwind/src/libunwind.cpp | ||
@@ -289,7 +289,25 @@ void __unw_remove_dynamic_fde(unw_word_t fde) { | ||
#endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) | ||
#endif // !defined(__USING_SJLJ_EXCEPTIONS__) | ||
|
||
+int unw_backtrace(void **buffer, int size) { | ||
+ unw_context_t context; | ||
+ unw_cursor_t cursor; | ||
+ if (unw_getcontext(&context) || unw_init_local(&cursor, &context)) { | ||
+ return 0; | ||
+ } | ||
+ | ||
+ unw_word_t ip; | ||
+ int current = 0; | ||
+ while (unw_step(&cursor) > 0) { | ||
+ if (current >= size || unw_get_reg(&cursor, UNW_REG_IP, &ip)) { | ||
+ break; | ||
+ } | ||
|
||
+ buffer[current++] = reinterpret_cast<void *>(static_cast<uintptr_t>(ip)); | ||
+ } | ||
+ | ||
+ return current; | ||
+} | ||
|
||
// Add logging hooks in Debug builds only | ||
#ifndef NDEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters