summaryrefslogtreecommitdiff
path: root/debuggerd/arm
diff options
context:
space:
mode:
authorPaul Eastham <eastham@google.com>2010-12-14 16:07:58 -0800
committerPaul Eastham <eastham@google.com>2010-12-14 16:07:58 -0800
commit3227b5c25f17b19d65e1fe7ec27e62c5430bd258 (patch)
treecbee6fe2915637438646e7d278af3c262c1b3eb3 /debuggerd/arm
parent4387ed13567b243416ba8af3d0ee39c8e746b45b (diff)
Prevent rollover when dumping data around PC, SP, etc.
Change-Id: Ifc5f0e8eb5fed191c39f0878869e04b4d4f3b9ca
Diffstat (limited to 'debuggerd/arm')
-rw-r--r--debuggerd/arm/machine.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/debuggerd/arm/machine.c b/debuggerd/arm/machine.c
index ccd0baf18..4eb97a340 100644
--- a/debuggerd/arm/machine.c
+++ b/debuggerd/arm/machine.c
@@ -67,7 +67,11 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
end = p = pc & ~3;
p -= 32;
+ if (p > end)
+ p = 0;
end += 32;
+ if (end < p)
+ end = ~0;
/* Dump the code around PC as:
* addr contents
@@ -91,7 +95,11 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
end = p = r.ARM_lr & ~3;
p -= 32;
+ if (p > end)
+ p = 0;
end += 32;
+ if (end < p)
+ end = ~0;
/* Dump the code around LR as:
* addr contents
@@ -112,6 +120,8 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
}
p = sp - 64;
+ if (p > sp)
+ p = 0;
p &= ~3;
if (unwind_depth != 0) {
if (unwind_depth < STACK_CONTENT_DEPTH) {
@@ -124,6 +134,8 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
else {
end = sp | 0x000000ff;
end += 0xff;
+ if (end < sp)
+ end = ~0;
}
_LOG(tfd, only_in_tombstone, "\nstack:\n");
@@ -161,6 +173,9 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
/* print another 64-byte of stack data after the last frame */
end = p+64;
+ if (end < p)
+ end = ~0;
+
while (p <= end) {
data = ptrace(PTRACE_PEEKTEXT, pid, (void*)p, NULL);
_LOG(tfd, (sp_depth > 2) || only_in_tombstone,