summaryrefslogtreecommitdiffstats
path: root/debuggerd/crasher.c
diff options
context:
space:
mode:
authorBrigid Smith <brigidsmith@google.com>2014-07-07 12:33:50 -0700
committerBrigid Smith <brigidsmith@google.com>2014-07-08 10:53:49 -0700
commit8606eaa7700609a2f9f2383b954b4e64dbc4c827 (patch)
tree7f02593853c64580adfae7801557886f7420e199 /debuggerd/crasher.c
parentf6ef1f53ac1b4dd659d23f418042db8dd556b9c2 (diff)
downloadsystem_core-8606eaa7700609a2f9f2383b954b4e64dbc4c827.zip
system_core-8606eaa7700609a2f9f2383b954b4e64dbc4c827.tar.gz
system_core-8606eaa7700609a2f9f2383b954b4e64dbc4c827.tar.bz2
Improving maps output.
Maps output now displays fault address location more intelligently. If the fault is not in a mapped region, it now shows where that address is with respect to the other maps. In addition, the size of the map is now printed as part of the output. Also, crasher now supports an "mmap" option which mmaps/munmaps a region of memory and then attempts to access it, causing a fault address in between mapped regions that can be used to test that new part of the maps output. Change-Id: Ia5e1926802bdfcbbdb7857e3631ddf395ae0c5b8
Diffstat (limited to 'debuggerd/crasher.c')
-rw-r--r--debuggerd/crasher.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/debuggerd/crasher.c b/debuggerd/crasher.c
index e11d9af..9df3c64 100644
--- a/debuggerd/crasher.c
+++ b/debuggerd/crasher.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/cdefs.h>
+#include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -156,6 +157,10 @@ static int do_action(const char* arg)
return EXIT_SUCCESS;
} else if (!strcmp(arg, "heap-usage")) {
abuse_heap();
+ } else if (!strcmp(arg, "SIGSEGV-unmapped")) {
+ char* map = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ munmap(map, sizeof(int));
+ map[0] = '8';
}
fprintf(stderr, "%s OP\n", __progname);
@@ -175,6 +180,7 @@ static int do_action(const char* arg)
fprintf(stderr, " SIGPIPE cause a SIGPIPE\n");
fprintf(stderr, " SIGSEGV cause a SIGSEGV at address 0x0 (synonym: crash)\n");
fprintf(stderr, " SIGSEGV-non-null cause a SIGSEGV at a non-zero address\n");
+ fprintf(stderr, " SIGSEGV-unmapped mmap/munmap a region of memory and then attempt to access it\n");
fprintf(stderr, " SIGTRAP cause a SIGTRAP\n");
fprintf(stderr, "prefix any of the above with 'thread-' to not run\n");
fprintf(stderr, "on the process' main thread.\n");