Created
January 11, 2014 00:55
-
-
Save mikesart/8365549 to your computer and use it in GitHub Desktop.
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
diff --git a/external/libunwind/include/tdep-aarch64/libunwind_i.h b/external/libunwind/include/tdep-aarch64/libunwind_i.h | |
index b162271..a03fbc4 100644 | |
--- a/external/libunwind/include/tdep-aarch64/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-aarch64/libunwind_i.h | |
@@ -255,7 +255,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-arm/libunwind_i.h b/external/libunwind/include/tdep-arm/libunwind_i.h | |
index 291b101..4e2e562 100644 | |
--- a/external/libunwind/include/tdep-arm/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-arm/libunwind_i.h | |
@@ -243,7 +243,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-hppa/libunwind_i.h b/external/libunwind/include/tdep-hppa/libunwind_i.h | |
index b5bbcec..34589bb 100644 | |
--- a/external/libunwind/include/tdep-hppa/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-hppa/libunwind_i.h | |
@@ -238,7 +238,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-ia64/libunwind_i.h b/external/libunwind/include/tdep-ia64/libunwind_i.h | |
index 2bea830..fd5c65f 100644 | |
--- a/external/libunwind/include/tdep-ia64/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-ia64/libunwind_i.h | |
@@ -232,7 +232,7 @@ struct ia64_global_unwind_state | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#define tdep_get_as(c) ((c)->as) | |
#define tdep_get_as_arg(c) ((c)->as_arg) | |
#define tdep_get_ip(c) ((c)->ip) | |
diff --git a/external/libunwind/include/tdep-mips/libunwind_i.h b/external/libunwind/include/tdep-mips/libunwind_i.h | |
index 3ef1cef..4a89d5c 100644 | |
--- a/external/libunwind/include/tdep-mips/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-mips/libunwind_i.h | |
@@ -291,7 +291,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-ppc32/libunwind_i.h b/external/libunwind/include/tdep-ppc32/libunwind_i.h | |
index 06c0023..2b134f1 100644 | |
--- a/external/libunwind/include/tdep-ppc32/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-ppc32/libunwind_i.h | |
@@ -266,7 +266,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#define tdep_get_func_addr UNW_OBJ(get_func_addr) | |
#ifdef UNW_LOCAL_ONLY | |
diff --git a/external/libunwind/include/tdep-ppc64/libunwind_i.h b/external/libunwind/include/tdep-ppc64/libunwind_i.h | |
index 6d72858..7bb0dcd 100644 | |
--- a/external/libunwind/include/tdep-ppc64/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-ppc64/libunwind_i.h | |
@@ -266,7 +266,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#define tdep_get_func_addr UNW_OBJ(get_func_addr) | |
#ifdef UNW_LOCAL_ONLY | |
diff --git a/external/libunwind/include/tdep-sh/libunwind_i.h b/external/libunwind/include/tdep-sh/libunwind_i.h | |
index 51234d1..1698916 100644 | |
--- a/external/libunwind/include/tdep-sh/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-sh/libunwind_i.h | |
@@ -239,7 +239,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-x86/libunwind_i.h b/external/libunwind/include/tdep-x86/libunwind_i.h | |
index f59a3cf..e8b7367 100644 | |
--- a/external/libunwind/include/tdep-x86/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-x86/libunwind_i.h | |
@@ -252,7 +252,7 @@ dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) | |
#define tdep_cache_frame(c,rs) do {} while(0) | |
#define tdep_reuse_frame(c,rs) do {} while(0) | |
#define tdep_stash_frame(c,rs) do {} while(0) | |
-#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) | |
+#define tdep_trace(cur,addr,n,skip) (-UNW_ENOINFO) | |
#ifdef UNW_LOCAL_ONLY | |
# define tdep_find_proc_info(c,ip,n) \ | |
diff --git a/external/libunwind/include/tdep-x86_64/libunwind_i.h b/external/libunwind/include/tdep-x86_64/libunwind_i.h | |
index 8c9cd05..a237204 100644 | |
--- a/external/libunwind/include/tdep-x86_64/libunwind_i.h | |
+++ b/external/libunwind/include/tdep-x86_64/libunwind_i.h | |
@@ -247,6 +247,6 @@ extern void tdep_stash_frame (struct dwarf_cursor *c, | |
#endif | |
extern int tdep_getcontext_trace (unw_tdep_context_t *); | |
-extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); | |
+extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n, int skip); | |
#endif /* X86_64_LIBUNWIND_I_H */ | |
diff --git a/external/libunwind/src/mi/backtrace.c b/external/libunwind/src/mi/backtrace.c | |
index 91d6597..363f82e 100644 | |
--- a/external/libunwind/src/mi/backtrace.c | |
+++ b/external/libunwind/src/mi/backtrace.c | |
@@ -33,7 +33,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | |
/* See glibc manual for a description of this function. */ | |
static ALWAYS_INLINE int | |
-slow_backtrace (void **buffer, int size, unw_context_t *uc) | |
+slow_backtrace (void **buffer, int size, unw_context_t *uc, int skip) | |
{ | |
unw_cursor_t cursor; | |
unw_word_t ip; | |
@@ -49,7 +49,11 @@ slow_backtrace (void **buffer, int size, unw_context_t *uc) | |
if (unw_get_reg (&cursor, UNW_REG_IP, &ip) < 0) | |
return n; | |
- buffer[n++] = (void *) (uintptr_t) ip; | |
+ | |
+ if (skip > 0) | |
+ skip--; | |
+ else | |
+ buffer[n++] = (void *) (uintptr_t) ip; | |
} | |
return n; | |
} | |
@@ -66,16 +70,37 @@ unw_backtrace (void **buffer, int size) | |
if (unlikely (unw_init_local (&cursor, &uc) < 0)) | |
return 0; | |
- if (unlikely (tdep_trace (&cursor, buffer, &n) < 0)) | |
+ if (unlikely (tdep_trace (&cursor, buffer, &n, 0) < 0)) | |
+ { | |
+ unw_getcontext (&uc); | |
+ return slow_backtrace (buffer, size, &uc, 0); | |
+ } | |
+ | |
+ return n; | |
+} | |
+ | |
+int | |
+unw_backtrace_skip (void **buffer, int size, int skip) | |
+{ | |
+ unw_cursor_t cursor; | |
+ unw_context_t uc; | |
+ int n = size; | |
+ | |
+ tdep_getcontext_trace (&uc); | |
+ | |
+ if (unlikely (unw_init_local (&cursor, &uc) < 0)) | |
+ return 0; | |
+ | |
+ if (unlikely (tdep_trace (&cursor, buffer, &n, skip) < 0)) | |
{ | |
unw_getcontext (&uc); | |
- return slow_backtrace (buffer, size, &uc); | |
+ return slow_backtrace (buffer, size, &uc, skip); | |
} | |
return n; | |
} | |
-extern int backtrace (void **buffer, int size) | |
- WEAK ALIAS(unw_backtrace); | |
+extern int backtrace_skip (void **buffer, int size, int skip) | |
+ WEAK ALIAS(unw_backtrace_skip); | |
#endif /* !UNW_REMOTE_ONLY */ | |
diff --git a/external/libunwind/src/x86_64/Gtrace.c b/external/libunwind/src/x86_64/Gtrace.c | |
index 9a86a06..69a64e9 100644 | |
--- a/external/libunwind/src/x86_64/Gtrace.c | |
+++ b/external/libunwind/src/x86_64/Gtrace.c | |
@@ -394,7 +394,7 @@ trace_lookup (unw_cursor_t *cursor, | |
} | |
*/ | |
HIDDEN int | |
-tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) | |
+tdep_trace (unw_cursor_t *cursor, void **buffer, int *size, int skip) | |
{ | |
struct cursor *c = (struct cursor *) cursor; | |
struct dwarf_cursor *d = &c->dwarf; | |
@@ -522,7 +522,10 @@ tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) | |
break; | |
/* Record this address in stack trace. We skipped the first address. */ | |
- buffer[depth++] = (void *) (rip - d->use_prev_instr); | |
+ if (skip > 0) | |
+ skip--; | |
+ else | |
+ buffer[depth++] = (void *) (rip - d->use_prev_instr); | |
} | |
#if UNW_DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changing the weak symbol from 'backtrace' to 'backtrace_skip' is wrong, as this exists to overrule the glibc 'backtrace' function. glibc does not have a 'backtrace_skip' function to overrrule.