Skip to content
Browse files

Handle wraparound correctly.

The following case was observed for stack dumps of certain Flash Player
crashes: p = 0xffffffbc, end = 0xfffffffc. This should equal to 16 loops
(64 bytes dumped), but actually the dump was limited by /data size only,
as after the wraparound 0xfffffffc -> 0x0 the condition p <= end was
still true.

Change-Id: I4f3e357377b326a3443d814800fd5b159e61990a
  • Loading branch information...
1 parent b5e8f2c commit 00591626677693ae96194da853734bd706162c69 @maniac103 maniac103 committed May 19, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 debuggerd/arm/machine.c
View
18 debuggerd/arm/machine.c
@@ -59,7 +59,7 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
int unwind_depth, unsigned int sp_list[],
bool at_fault)
{
- unsigned int sp, pc, p, end, data;
+ unsigned int sp, pc, p, end, data, last;
struct pt_regs r;
int sp_depth;
bool only_in_tombstone = !at_fault;
@@ -74,15 +74,17 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
end = p = pc & ~3;
p -= 32;
end += 32;
+ last = p;
/* Dump the code around PC as:
* addr contents
* 00008d34 fffffcd0 4c0eb530 b0934a0e 1c05447c
* 00008d44 f7ff18a0 490ced94 68035860 d0012b00
*/
- while (p <= end) {
+ while (p <= end && last <= p) {
int i;
+ last = p;
sprintf(code_buffer, "%08x ", p);
for (i = 0; i < 4; i++) {
data = ptrace(PTRACE_PEEKTEXT, pid, (void*)p, NULL);
@@ -98,15 +100,17 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
end = p = r.ARM_lr & ~3;
p -= 32;
end += 32;
+ last = p;
/* Dump the code around LR as:
* addr contents
* 00008d34 fffffcd0 4c0eb530 b0934a0e 1c05447c
* 00008d44 f7ff18a0 490ced94 68035860 d0012b00
*/
- while (p <= end) {
+ while (p <= end && last <= p) {
int i;
+ last = p;
sprintf(code_buffer, "%08x ", p);
for (i = 0; i < 4; i++) {
data = ptrace(PTRACE_PEEKTEXT, pid, (void*)p, NULL);
@@ -119,6 +123,8 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
p = sp - 64;
p &= ~3;
+ last = p;
+
if (unwind_depth != 0) {
if (unwind_depth < STACK_CONTENT_DEPTH) {
end = sp_list[unwind_depth-1];
@@ -148,7 +154,7 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
end = p + MAX_STACK_DUMP_SIZE;
}
- while (p <= end) {
+ while (p <= end && last <= p) {
char *prompt;
char level[16];
data = ptrace(PTRACE_PEEKTEXT, pid, (void*)p, NULL);
@@ -166,16 +172,18 @@ void dump_stack_and_code(int tfd, int pid, mapinfo *map,
_LOG(tfd, (sp_depth > 2) || only_in_tombstone,
"%s %08x %08x %s\n", prompt, p, data,
map_to_name(map, data, ""));
+ last = p;
p += 4;
}
/* print another 64-byte of stack data after the last frame */
end = p+64;
- while (p <= end) {
+ while (p <= end && last <= p) {
data = ptrace(PTRACE_PEEKTEXT, pid, (void*)p, NULL);
_LOG(tfd, (sp_depth > 2) || only_in_tombstone,
" %08x %08x %s\n", p, data,
map_to_name(map, data, ""));
+ last = p;
p += 4;
}
}

0 comments on commit 0059162

Please sign in to comment.
Something went wrong with that request. Please try again.