Use libcorkscrew in debuggerd.

Change-Id: I5e3645a39d96c808f87075b49111d0262a19a0c8
diff --git a/debuggerd/x86/machine.c b/debuggerd/x86/machine.c
index 9d418cf..57f51c8 100644
--- a/debuggerd/x86/machine.c
+++ b/debuggerd/x86/machine.c
@@ -31,31 +31,43 @@
 #include <cutils/sockets.h>
 #include <cutils/properties.h>
 
+#include <corkscrew/backtrace.h>
+#include <corkscrew/ptrace.h>
+
 #include <linux/input.h>
 
+#include "../machine.h"
 #include "../utility.h"
-#include "x86_utility.h"
 
-void dump_registers(int tfd, int pid, bool at_fault)
-{
+static void dump_registers(ptrace_context_t* context __attribute((unused)),
+        int tfd, pid_t pid, bool at_fault) {
     struct pt_regs_x86 r;
     bool only_in_tombstone = !at_fault;
 
     if(ptrace(PTRACE_GETREGS, pid, 0, &r)) {
-        _LOG(tfd, only_in_tombstone,
-             "cannot get registers: %s\n", strerror(errno));
+        _LOG(tfd, only_in_tombstone, "cannot get registers: %s\n", strerror(errno));
         return;
     }
-//if there is no stack, no print just like arm
+    //if there is no stack, no print just like arm
     if(!r.ebp)
         return;
-    _LOG(tfd, only_in_tombstone, " eax %08x  ebx %08x  ecx %08x  edx %08x\n",
+    _LOG(tfd, only_in_tombstone, "    eax %08x  ebx %08x  ecx %08x  edx %08x\n",
          r.eax, r.ebx, r.ecx, r.edx);
-    _LOG(tfd, only_in_tombstone, " esi %08x  edi %08x\n",
+    _LOG(tfd, only_in_tombstone, "    esi %08x  edi %08x\n",
          r.esi, r.edi);
-    _LOG(tfd, only_in_tombstone, " xcs %08x  xds %08x  xes %08x  xfs %08x xss %08x\n",
+    _LOG(tfd, only_in_tombstone, "    xcs %08x  xds %08x  xes %08x  xfs %08x  xss %08x\n",
          r.xcs, r.xds, r.xes, r.xfs, r.xss);
-    _LOG(tfd, only_in_tombstone,
-         " eip %08x  ebp %08x  esp %08x  flags %08x\n",
+    _LOG(tfd, only_in_tombstone, "    eip %08x  ebp %08x  esp %08x  flags %08x\n",
          r.eip, r.ebp, r.esp, r.eflags);
 }
+
+void dump_thread(ptrace_context_t* context, int tfd, pid_t tid, bool at_fault) {
+    dump_registers(context, tfd, tid, at_fault);
+
+    dump_backtrace_and_stack(context, tfd, tid, at_fault);
+
+    if (at_fault) {
+        dump_nearby_maps(context, tfd, tid);
+    }
+}
+