summaryrefslogtreecommitdiffstats
path: root/debuggerd/utility.c
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2011-09-22 16:37:06 -0700
committerAndy McFadden <fadden@android.com>2011-10-13 12:35:55 -0700
commit136dcc5ce628a1ba600a6818e5cb24d5f15eb016 (patch)
tree51cf599e72e5da60703930198e277d9fa5ac1c2c /debuggerd/utility.c
parentd707fb3fb6448be04d6e14f7e478df7e298ebf35 (diff)
downloadsystem_core-136dcc5ce628a1ba600a6818e5cb24d5f15eb016.zip
system_core-136dcc5ce628a1ba600a6818e5cb24d5f15eb016.tar.gz
system_core-136dcc5ce628a1ba600a6818e5cb24d5f15eb016.tar.bz2
Show maps near native fault address
This adds some additional output to native crashes. For example, if something tried to access a bit of mmap(/dev/zero) memory that had been mprotect()ed, you might see output like this: I DEBUG : memory map around addr 4015a00c: I DEBUG : 40159000-4015a000 /system/lib/libstdc++.so I DEBUG : 4015a000-40162000 /dev/zero I DEBUG : b0001000-b0009000 /system/bin/linker The idea is to see what's in and around the fault address to make it easier to identify bus errors due to file truncation and segmentation faults caused by buffer over/underruns. No output is generated for accesses below 0x1000 (which are likely NULL pointer dereferences) or for signals that don't set si_addr. Also, suppress the fault address for signals that don't set si_addr: I DEBUG : signal 6 (SIGABRT), code 0 (?), fault addr -------- We still print "fault addr" followed by 8 characters for anything that is parsing the contents. The "address" shown for signals like SIGABRT was meaningless and possibly confusing. Bug 5358516 Change-Id: Icae8ef309ea2d89b129f68d30f96b2ca8a69cc6c
Diffstat (limited to 'debuggerd/utility.c')
-rw-r--r--debuggerd/utility.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/debuggerd/utility.c b/debuggerd/utility.c
index 2afdb46..409209c 100644
--- a/debuggerd/utility.c
+++ b/debuggerd/utility.c
@@ -17,6 +17,7 @@
#include <sys/ptrace.h>
#include <sys/exec_elf.h>
+#include <signal.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
@@ -82,3 +83,20 @@ const mapinfo *pc_to_mapinfo(mapinfo *mi, unsigned pc, unsigned *rel_pc)
}
return NULL;
}
+
+/*
+ * Returns true if the specified signal has an associated address (i.e. it
+ * sets siginfo_t.si_addr).
+ */
+bool signal_has_address(int sig)
+{
+ switch (sig) {
+ case SIGILL:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGBUS:
+ return true;
+ default:
+ return false;
+ }
+}