summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2021-05-28 17:40:13 -0700
committerKhem Raj <raj.khem@gmail.com>2023-09-08 09:08:54 -0700
commit488d0c94d1fc1062a0de32524b984bcd1a7d663c (patch)
tree732562bc01d0e1390431b22d4ed2c6040396d482
parent142241ab389838cc449fdac26a21b2c8a06fb4b4 (diff)
downloadmeta-clang-488d0c94d1fc1062a0de32524b984bcd1a7d663c.tar.gz
libunwind: Implement unw_backtrace
Signed-off-by: Khem Raj <raj.khem@gmail.com> (cherry picked from commit d45403baedd7ae7755a02cfe0205000b760167bd)
-rw-r--r--recipes-devtools/clang/clang/0033-libunwind-Added-unw_backtrace-method.patch55
-rw-r--r--recipes-devtools/clang/common.inc1
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 @@
1From 79195637cf6cde28baa23e41e7b417e98b036913 Mon Sep 17 00:00:00 2001
2From: Maksim Kita <maksim-kita@yandex-team.ru>
3Date: Sun, 23 May 2021 10:27:29 +0000
4Subject: [PATCH] libunwind: Added unw_backtrace method
5
6Source: https://github.com/ClickHouse-Extras/libunwind/commit/52f0f7861926cbfaef7e6c97d8a6d7ba2a1f6747#diff-a82fc885e2e4facf4b92d26171c13aa4aa5db296f77e1158ba2f8664e3bd1f5c
7Upstream-Status: Pending
8Signed-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
14diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
15index 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
26diff --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp
27index 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 d68d6f5..7f1a5f3 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 file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \ 46 file://0034-CMake-Installable-find-modules-for-terminfo-and-libf.patch \
46 file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \ 47 file://0035-llvm-Do-not-use-standard-search-paths-in-find_librar.patch \
47" 48"