diff options
author | Christopher Ferris <cferris@google.com> | 2015-05-22 14:26:13 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2015-05-28 11:45:34 -0700 |
commit | 0c3f1ae66b693ef0f37066b697cc10a07ef56acc (patch) | |
tree | 2696c72439d9b049b43476cb4d96d96f9518e95e /debuggerd/x86/machine.cpp | |
parent | b37c45e90aa311b4d32a5b21dad5fce93c9761a7 (diff) | |
download | system_core-0c3f1ae66b693ef0f37066b697cc10a07ef56acc.zip system_core-0c3f1ae66b693ef0f37066b697cc10a07ef56acc.tar.gz system_core-0c3f1ae66b693ef0f37066b697cc10a07ef56acc.tar.bz2 |
Refactor dump_memory function.
- Add dumping memory around registers for x86/x86_64.
- Add unit tests for new dump_memory function.
- Cleanup all of the machine.cpp files.
- Increase the high address check for 32 bit, and decrease the high
address allowed for 64 bit slightly to match mips64.
Bug: 21206576
(cherry picked from commit e8bc77eb845ab5557a4c98fe0da604d4a3740bef)
Change-Id: I49ec237e30076a232f084da1072bf9aba15dc0cd
Diffstat (limited to 'debuggerd/x86/machine.cpp')
-rw-r--r-- | debuggerd/x86/machine.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/debuggerd/x86/machine.cpp b/debuggerd/x86/machine.cpp index 57330c1..c5f9259 100644 --- a/debuggerd/x86/machine.cpp +++ b/debuggerd/x86/machine.cpp @@ -14,18 +14,31 @@ * limitations under the License. */ -#include <stddef.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> #include <errno.h> -#include <sys/types.h> +#include <stdint.h> +#include <string.h> #include <sys/ptrace.h> -#include "../utility.h" -#include "../machine.h" +#include <backtrace/Backtrace.h> + +#include "machine.h" +#include "utility.h" + +void dump_memory_and_code(log_t* log, Backtrace* backtrace) { + struct pt_regs r; + if (ptrace(PTRACE_GETREGS, backtrace->Tid(), 0, &r) == -1) { + _LOG(log, logtype::ERROR, "cannot get registers: %s\n", strerror(errno)); + return; + } + + dump_memory(log, backtrace, static_cast<uintptr_t>(r.eax), "memory near eax:"); + dump_memory(log, backtrace, static_cast<uintptr_t>(r.ebx), "memory near ebx:"); + dump_memory(log, backtrace, static_cast<uintptr_t>(r.ecx), "memory near ecx:"); + dump_memory(log, backtrace, static_cast<uintptr_t>(r.edx), "memory near edx:"); + dump_memory(log, backtrace, static_cast<uintptr_t>(r.esi), "memory near esi:"); + dump_memory(log, backtrace, static_cast<uintptr_t>(r.edi), "memory near edi:"); -void dump_memory_and_code(log_t*, pid_t) { + dump_memory(log, backtrace, static_cast<uintptr_t>(r.eip), "code around eip:"); } void dump_registers(log_t* log, pid_t tid) { @@ -34,6 +47,7 @@ void dump_registers(log_t* log, pid_t tid) { _LOG(log, logtype::ERROR, "cannot get registers: %s\n", strerror(errno)); return; } + _LOG(log, logtype::REGISTERS, " eax %08lx ebx %08lx ecx %08lx edx %08lx\n", r.eax, r.ebx, r.ecx, r.edx); _LOG(log, logtype::REGISTERS, " esi %08lx edi %08lx\n", |