Changing how debuggerd filters log messages to different locations.
The system by which debuggerd filters its output to different locations
is now based on an enum called logtype with easy to understand
categories for log messages (like THREAD, MEMORY, etc.) instead of the
old, fairly esoteric scope_flags variable. Now much of the output that
previously went to logcat does not show up on the screen, but all output
can be found in the tombstone file. In addition, the tombstone's
location is now printed so it can be located easily.
Bug: 15341747
Change-Id: Ia2f2051d1dfdea934d0e6ed220f24345e35ba6a2
diff --git a/debuggerd/arm64/machine.cpp b/debuggerd/arm64/machine.cpp
index 2413d5e..f3409d5 100644
--- a/debuggerd/arm64/machine.cpp
+++ b/debuggerd/arm64/machine.cpp
@@ -37,68 +37,66 @@
* If configured to do so, dump memory around *all* registers
* for the crashing thread.
*/
-void dump_memory_and_code(log_t* log, pid_t tid, int scope_flags) {
+void dump_memory_and_code(log_t* log, pid_t tid) {
struct user_pt_regs regs;
struct iovec io;
io.iov_base = ®s;
io.iov_len = sizeof(regs);
if (ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, &io) == -1) {
- _LOG(log, scope_flags, "%s: ptrace failed to get registers: %s\n",
+ LOG_ERROR("%s: ptrace failed to get registers: %s\n",
__func__, strerror(errno));
return;
}
- if (IS_AT_FAULT(scope_flags) && DUMP_MEMORY_FOR_ALL_REGISTERS) {
- for (int reg = 0; reg < 31; reg++) {
- uintptr_t addr = regs.regs[reg];
+ for (int reg = 0; reg < 31; reg++) {
+ uintptr_t addr = regs.regs[reg];
- /*
- * Don't bother if it looks like a small int or ~= null, or if
- * it's in the kernel area.
- */
- if (addr < 4096 || addr >= (1UL<<63)) {
- continue;
- }
-
- _LOG(log, scope_flags | SCOPE_SENSITIVE, "\nmemory near x%d:\n", reg);
- dump_memory(log, tid, addr, scope_flags | SCOPE_SENSITIVE);
+ /*
+ * Don't bother if it looks like a small int or ~= null, or if
+ * it's in the kernel area.
+ */
+ if (addr < 4096 || addr >= (1UL<<63)) {
+ continue;
}
+
+ _LOG(log, logtype::MEMORY, "\nmemory near x%d:\n", reg);
+ dump_memory(log, tid, addr);
}
- _LOG(log, scope_flags, "\ncode around pc:\n");
- dump_memory(log, tid, (uintptr_t)regs.pc, scope_flags);
+ _LOG(log, logtype::MEMORY, "\ncode around pc:\n");
+ dump_memory(log, tid, (uintptr_t)regs.pc);
if (regs.pc != regs.sp) {
- _LOG(log, scope_flags, "\ncode around sp:\n");
- dump_memory(log, tid, (uintptr_t)regs.sp, scope_flags);
+ _LOG(log, logtype::MEMORY, "\ncode around sp:\n");
+ dump_memory(log, tid, (uintptr_t)regs.sp);
}
}
-void dump_registers(log_t* log, pid_t tid, int scope_flags)
-{
+void dump_registers(log_t* log, pid_t tid) {
struct user_pt_regs r;
struct iovec io;
io.iov_base = &r;
io.iov_len = sizeof(r);
if (ptrace(PTRACE_GETREGSET, tid, (void*) NT_PRSTATUS, (void*) &io) == -1) {
- _LOG(log, scope_flags, "ptrace error: %s\n", strerror(errno));
+ LOG_ERROR("ptrace error: %s\n", strerror(errno));
return;
}
for (int i = 0; i < 28; i += 4) {
- _LOG(log, scope_flags, " x%-2d %016lx x%-2d %016lx x%-2d %016lx x%-2d %016lx\n",
+ _LOG(log, logtype::REGISTERS,
+ " x%-2d %016lx x%-2d %016lx x%-2d %016lx x%-2d %016lx\n",
i, (uint64_t)r.regs[i],
i+1, (uint64_t)r.regs[i+1],
i+2, (uint64_t)r.regs[i+2],
i+3, (uint64_t)r.regs[i+3]);
}
- _LOG(log, scope_flags, " x28 %016lx x29 %016lx x30 %016lx\n",
+ _LOG(log, logtype::REGISTERS, " x28 %016lx x29 %016lx x30 %016lx\n",
(uint64_t)r.regs[28], (uint64_t)r.regs[29], (uint64_t)r.regs[30]);
- _LOG(log, scope_flags, " sp %016lx pc %016lx\n",
+ _LOG(log, logtype::REGISTERS, " sp %016lx pc %016lx\n",
(uint64_t)r.sp, (uint64_t)r.pc);
@@ -107,12 +105,12 @@
io.iov_len = sizeof(f);
if (ptrace(PTRACE_GETREGSET, tid, (void*) NT_PRFPREG, (void*) &io) == -1) {
- _LOG(log, scope_flags, "ptrace error: %s\n", strerror(errno));
+ LOG_ERROR("ptrace error: %s\n", strerror(errno));
return;
}
for (int i = 0; i < 32; i += 4) {
- _LOG(log, scope_flags, " v%-2d %016lx v%-2d %016lx v%-2d %016lx v%-2d %016lx\n",
+ _LOG(log, logtype::REGISTERS, " v%-2d %016lx v%-2d %016lx v%-2d %016lx v%-2d %016lx\n",
i, (uint64_t)f.vregs[i],
i+1, (uint64_t)f.vregs[i+1],
i+2, (uint64_t)f.vregs[i+2],