Elliott Hughes | 18ddd42 | 2013-11-14 17:06:46 -0800 | [diff] [blame] | 1 | /* |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 2 | ** Copyright 2006, The Android Open Source Project |
| 3 | ** |
| 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | ** you may not use this file except in compliance with the License. |
| 6 | ** You may obtain a copy of the License at |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 10 | ** Unless required by applicable law or agreed to in writing, software |
| 11 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | ** See the License for the specific language governing permissions and |
| 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 17 | #include <stddef.h> |
| 18 | #include <stdbool.h> |
| 19 | #include <stdlib.h> |
| 20 | #include <string.h> |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 21 | #include <stdio.h> |
| 22 | #include <errno.h> |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 23 | #include <sys/types.h> |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 24 | #include <sys/ptrace.h> |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 25 | |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 26 | #include "../utility.h" |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 27 | #include "../machine.h" |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 28 | |
Christopher Ferris | 365e4ae | 2013-10-02 12:26:48 -0700 | [diff] [blame] | 29 | void dump_memory_and_code(log_t* log, pid_t tid, int scope_flags) { |
Jeff Brown | 053b865 | 2012-06-06 16:25:03 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Christopher Ferris | 365e4ae | 2013-10-02 12:26:48 -0700 | [diff] [blame] | 32 | void dump_registers(log_t* log, pid_t tid, int scope_flags) { |
Elliott Hughes | 18ddd42 | 2013-11-14 17:06:46 -0800 | [diff] [blame] | 33 | struct pt_regs r; |
| 34 | if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) { |
Christopher Ferris | 365e4ae | 2013-10-02 12:26:48 -0700 | [diff] [blame] | 35 | _LOG(log, scope_flags, "cannot get registers: %s\n", strerror(errno)); |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 36 | return; |
| 37 | } |
Elliott Hughes | 18ddd42 | 2013-11-14 17:06:46 -0800 | [diff] [blame] | 38 | _LOG(log, scope_flags, " eax %08lx ebx %08lx ecx %08lx edx %08lx\n", |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 39 | r.eax, r.ebx, r.ecx, r.edx); |
Elliott Hughes | 18ddd42 | 2013-11-14 17:06:46 -0800 | [diff] [blame] | 40 | _LOG(log, scope_flags, " esi %08lx edi %08lx\n", |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 41 | r.esi, r.edi); |
Christopher Ferris | 365e4ae | 2013-10-02 12:26:48 -0700 | [diff] [blame] | 42 | _LOG(log, scope_flags, " xcs %08x xds %08x xes %08x xfs %08x xss %08x\n", |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 43 | r.xcs, r.xds, r.xes, r.xfs, r.xss); |
Elliott Hughes | 18ddd42 | 2013-11-14 17:06:46 -0800 | [diff] [blame] | 44 | _LOG(log, scope_flags, " eip %08lx ebp %08lx esp %08lx flags %08lx\n", |
Bruce Beare | 6cc4923 | 2010-10-13 16:11:15 -0700 | [diff] [blame] | 45 | r.eip, r.ebp, r.esp, r.eflags); |
| 46 | } |