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 <pavel.v.chupin@intel.com>
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 @@
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 @@
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;