summaryrefslogtreecommitdiffstats
path: root/debuggerd/x86
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-06-06 16:25:03 -0700
committerJeff Brown <jeffbrown@google.com>2012-06-08 13:29:23 -0700
commit053b865412d1982ad1dc0e840898d82527deeb99 (patch)
tree2312442a46a05d24230e832700ad1300af9a2d9f /debuggerd/x86
parent5f2d00b0677cbe9ad42ea0394def0a51aef7bdda (diff)
downloadcore-053b865412d1982ad1dc0e840898d82527deeb99.tar.gz
core-053b865412d1982ad1dc0e840898d82527deeb99.tar.bz2
core-053b865412d1982ad1dc0e840898d82527deeb99.zip
Enhance native stack dumps.
Provides a new mechanism for dumpstate (while running as root) to request that debuggerd dump the stacks of native processes that we care about in bug reports. In this mode, the backtrace is formatted to look similar to a Dalvik backtrace. Moved the tombstone generating code into a separate file to make it easier to maintain. Fixed a bug where sometimes the stack traces would be incomplete because we were not waiting for each thread to stop after issuing PTRACE_ATTACH, only the main thread. So sometimes we were missing traces for some threads. Refactored the logging code to prevent accidentally writing data to logcat when explicitly dumping a tombstone or backtrace from the console. Only root or system server can request to dump backtraces but only root can dump tombstones. Bug: 6615693 Change-Id: Ib3edcc16f9f3a687e414e3f2d250d9500566123b
Diffstat (limited to 'debuggerd/x86')
-rw-r--r--debuggerd/x86/machine.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/debuggerd/x86/machine.c b/debuggerd/x86/machine.c
index 2729c7edc..01da5fef0 100644
--- a/debuggerd/x86/machine.c
+++ b/debuggerd/x86/machine.c
@@ -15,59 +15,44 @@
** limitations under the License.
*/
+#include <stddef.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
#include <stdio.h>
#include <errno.h>
-#include <signal.h>
-#include <pthread.h>
-#include <fcntl.h>
#include <sys/types.h>
-#include <dirent.h>
-
#include <sys/ptrace.h>
-#include <sys/wait.h>
-#include <sys/exec_elf.h>
-#include <sys/stat.h>
-
-#include <cutils/sockets.h>
-#include <cutils/properties.h>
-#include <corkscrew/backtrace.h>
#include <corkscrew/ptrace.h>
-#include <linux/input.h>
+#include <linux/user.h>
-#include "../machine.h"
#include "../utility.h"
+#include "../machine.h"
+
+void dump_memory_and_code(const ptrace_context_t* context __attribute((unused)),
+ log_t* log, pid_t tid, bool at_fault) {
+}
-static void dump_registers(const ptrace_context_t* context __attribute((unused)),
- int tfd, pid_t tid, bool at_fault) {
+void dump_registers(const ptrace_context_t* context __attribute((unused)),
+ log_t* log, pid_t tid, bool at_fault) {
struct pt_regs_x86 r;
bool only_in_tombstone = !at_fault;
if(ptrace(PTRACE_GETREGS, tid, 0, &r)) {
- _LOG(tfd, only_in_tombstone, "cannot get registers: %s\n", strerror(errno));
+ _LOG(log, only_in_tombstone, "cannot get registers: %s\n", strerror(errno));
return;
}
//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(log, 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(log, 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(log, 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(log, only_in_tombstone, " eip %08x ebp %08x esp %08x flags %08x\n",
r.eip, r.ebp, r.esp, r.eflags);
}
-
-void dump_thread(const 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);
- }
-}
-