From af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040 Mon Sep 17 00:00:00 2001 From: Pavel Chupin Date: Fri, 8 Mar 2013 13:17:35 +0400 Subject: Unwinding implementation via eh_frame sections for x86 Backtracing through eh_frame section is more effective allowing to reuse ebp register for other purposes within routine. GCC with turned on optimizations (-O1 and above) implicitly defines -fomit-frame-pointer anyway. eh_frame sections are generated by default with GCC on any optimization level. This change implements remote unwinding (separate process unwinding). Local unwinding is already implemented through _Unwind_Backtrace call which is implemented in libgcc. Change-Id: I1aea1ecd19c21710f9cf5f05dc272fc51b67b7aa Signed-off-by: Pavel Chupin --- debuggerd/crasher.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'debuggerd') diff --git a/debuggerd/crasher.c b/debuggerd/crasher.c index 134fe80..630d980 100644 --- a/debuggerd/crasher.c +++ b/debuggerd/crasher.c @@ -101,6 +101,21 @@ int do_action_on_thread(const char* arg) return (int) result; } +__attribute__((noinline)) int crash3(int a) { + *((int*) 0xdead) = a; + return a*4; +} + +__attribute__((noinline)) int crash2(int a) { + a = crash3(a) + 2; + return a*3; +} + +__attribute__((noinline)) int crash(int a) { + a = crash2(a) + 1; + return a*2; +} + int do_action(const char* arg) { if(!strncmp(arg, "thread-", strlen("thread-"))) { @@ -111,6 +126,7 @@ int do_action(const char* arg) if(!strcmp(arg,"nostack")) crashnostack(); if(!strcmp(arg,"ctest")) return ctest(); if(!strcmp(arg,"exit")) exit(1); + if(!strcmp(arg,"crash")) return crash(42); if(!strcmp(arg,"abort")) maybeabort(); pthread_t thr; -- cgit v1.1