Index: src/client/linux/minidump_writer/linux_dumper.cc |
=================================================================== |
--- src/client/linux/minidump_writer/linux_dumper.cc (revision 400) |
+++ src/client/linux/minidump_writer/linux_dumper.cc (working copy) |
@@ -80,7 +80,7 @@ |
LinuxDumper::LinuxDumper(int pid) |
: pid_(pid), |
- threads_suspened_(false), |
+ threads_suspended_(false), |
threads_(&allocator_, 8), |
mappings_(&allocator_) { |
} |
@@ -91,22 +91,22 @@ |
} |
bool LinuxDumper::ThreadsSuspend() { |
- if (threads_suspened_) |
+ if (threads_suspended_) |
return true; |
bool good = true; |
for (size_t i = 0; i < threads_.size(); ++i) |
good &= SuspendThread(threads_[i]); |
- threads_suspened_ = true; |
+ threads_suspended_ = true; |
return good; |
} |
bool LinuxDumper::ThreadsResume() { |
- if (!threads_suspened_) |
+ if (!threads_suspended_) |
return false; |
bool good = true; |
for (size_t i = 0; i < threads_.size(); ++i) |
good &= ResumeThread(threads_[i]); |
- threads_suspened_ = false; |
+ threads_suspended_ = false; |
return good; |
} |
@@ -280,9 +280,9 @@ |
} |
// Read thread info from /proc/$pid/status. |
-// Fill out the |tgid|, |ppid| and |pid| members of |info|. If unavailible, |
+// Fill out the |tgid|, |ppid| and |pid| members of |info|. If unavailable, |
// these members are set to -1. Returns true iff all three members are |
-// availible. |
+// available. |
bool LinuxDumper::ThreadInfoGet(pid_t tid, ThreadInfo* info) { |
assert(info != NULL); |
char status_path[80]; |
@@ -337,6 +337,8 @@ |
memcpy(&stack_pointer, &info->regs.esp, sizeof(info->regs.esp)); |
#elif defined(__x86_64) |
memcpy(&stack_pointer, &info->regs.rsp, sizeof(info->regs.rsp)); |
+#elif defined(__ARM_EABI__) |
+ memcpy(&stack_pointer, &info->regs.uregs[R13], sizeof(info->regs.uregs[R13])); |
#else |
#error "This code hasn't been ported to your platform yet." |
#endif |
@@ -353,42 +355,31 @@ |
// unwind. So we just grab, up to, 32k of stack. |
bool LinuxDumper::GetStackInfo(const void** stack, size_t* stack_len, |
uintptr_t int_stack_pointer) { |
-#if defined(__i386) || defined(__x86_64) |
- static const bool stack_grows_down = true; |
- static const uintptr_t page_size = 4096; |
-#else |
-#error "This code has not been ported to your platform yet." |
-#endif |
// Move the stack pointer to the bottom of the page that it's in. |
+ const uintptr_t page_size = getpagesize(); |
+ |
uint8_t* const stack_pointer = |
reinterpret_cast<uint8_t*>(int_stack_pointer & ~(page_size - 1)); |
// The number of bytes of stack which we try to capture. |
- static unsigned kStackToCapture = 32 * 1024; |
+ static int kStackToCapture = 32 * 1024; |
const MappingInfo* mapping = FindMapping(stack_pointer); |
if (!mapping) |
return false; |
- if (stack_grows_down) { |
- const ptrdiff_t offset = stack_pointer - (uint8_t*) mapping->start_addr; |
- const ptrdiff_t distance_to_end = |
- static_cast<ptrdiff_t>(mapping->size) - offset; |
- *stack_len = distance_to_end > kStackToCapture ? |
- kStackToCapture : distance_to_end; |
- *stack = stack_pointer; |
- } else { |
- const ptrdiff_t offset = stack_pointer - (uint8_t*) mapping->start_addr; |
- *stack_len = offset > kStackToCapture ? kStackToCapture : offset; |
- *stack = stack_pointer - *stack_len; |
- } |
- |
+ const ptrdiff_t offset = stack_pointer - (uint8_t*) mapping->start_addr; |
awong
2010/02/08 20:52:55
so...we're assuming a single stack direction now?
|
+ const ptrdiff_t distance_to_end = |
+ static_cast<ptrdiff_t>(mapping->size) - offset; |
+ *stack_len = distance_to_end > kStackToCapture ? |
+ kStackToCapture : distance_to_end; |
+ *stack = stack_pointer; |
return true; |
} |
// static |
void LinuxDumper::CopyFromProcess(void* dest, pid_t child, const void* src, |
size_t length) { |
- unsigned long tmp; |
+ unsigned long tmp = 55; |
awong
2010/02/08 20:52:55
Magic number alert! What's this number for?
|
size_t done = 0; |
static const size_t word_size = sizeof(tmp); |
uint8_t* const local = (uint8_t*) dest; |
@@ -396,8 +387,9 @@ |
while (done < length) { |
const size_t l = length - done > word_size ? word_size : length - done; |
- if (sys_ptrace(PTRACE_PEEKDATA, child, remote + done, &tmp) == -1) |
+ if (sys_ptrace(PTRACE_PEEKDATA, child, remote + done, &tmp) == -1) { |
tmp = 0; |
+ } |
memcpy(local + done, &tmp, l); |
done += l; |
} |