This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi all, I've rebased the previous patch to trunk per Andrew's suggestion. Original patch description/motivation/questions are in https://gcc.gnu.org/ml/gcc-patches/2017-06/msg01869.html -Y
Attachment:
safe-unwind-2.patch
Description: Binary data
#include <string.h> #include <stdio.h> struct _Unwind_Context; typedef int (*_Unwind_Trace_Fn)(struct _Unwind_Context *, void *vdata); extern int _Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument); extern int _Unwind_Backtrace_Checked(_Unwind_Trace_Fn trace, void * trace_argument); #ifdef CHECK_UNWIND #define _Unwind_Backtrace _Unwind_Backtrace_Checked #endif extern void *_Unwind_GetIP (struct _Unwind_Context *context); int simple_unwind (struct _Unwind_Context *context, void *vdata) { printf("Next frame: "); void *pc = _Unwind_GetIP(context); printf("%p\n", pc); return 0; } #define noinline __attribute__((noinline)) noinline int foo() { // Clobber stack to provoke errors in unwinder int x; void *p = &x; asm("" :: "r"(p)); memset(p, 0xa, 128); printf("After clobbering stack\n"); int ret = _Unwind_Backtrace(simple_unwind, 0); printf("After unwind: %d\n", ret); printf("We're going to fail now\n"); return 0; } noinline int bar() { int x = foo(); return x + 1; } int main() { bar(); return 0; }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |