diff options
Diffstat (limited to 'recipes-devtools/clang/clang/0027-libunwind-Added-unw_backtrace-method.patch')
-rw-r--r-- | recipes-devtools/clang/clang/0027-libunwind-Added-unw_backtrace-method.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0027-libunwind-Added-unw_backtrace-method.patch b/recipes-devtools/clang/clang/0027-libunwind-Added-unw_backtrace-method.patch new file mode 100644 index 0000000..3ad6b4f --- /dev/null +++ b/recipes-devtools/clang/clang/0027-libunwind-Added-unw_backtrace-method.patch | |||
@@ -0,0 +1,55 @@ | |||
1 | From 0177c3239a1b44e123ab656b46d62fe0ce740936 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 9a74faa48d6f..f7480c9cf27a 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 03f8b75b5bba..730e2393a8f8 100644 | ||
28 | --- a/libunwind/src/libunwind.cpp | ||
29 | +++ b/libunwind/src/libunwind.cpp | ||
30 | @@ -326,7 +326,25 @@ void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) { | ||
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 | ||