• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 #include <stddef.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <stdio.h>
21 #include <errno.h>
22 #include <sys/types.h>
23 #include <sys/ptrace.h>
24 
25 #include "../utility.h"
26 #include "../machine.h"
27 
dump_memory_and_code(log_t *,pid_t)28 void dump_memory_and_code(log_t*, pid_t) {
29 }
30 
dump_registers(log_t * log,pid_t tid)31 void dump_registers(log_t* log, pid_t tid) {
32   struct pt_regs r;
33   if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) {
34     _LOG(log, logtype::ERROR, "cannot get registers: %s\n", strerror(errno));
35     return;
36   }
37   _LOG(log, logtype::REGISTERS, "    eax %08lx  ebx %08lx  ecx %08lx  edx %08lx\n",
38        r.eax, r.ebx, r.ecx, r.edx);
39   _LOG(log, logtype::REGISTERS, "    esi %08lx  edi %08lx\n",
40        r.esi, r.edi);
41   _LOG(log, logtype::REGISTERS, "    xcs %08x  xds %08x  xes %08x  xfs %08x  xss %08x\n",
42        r.xcs, r.xds, r.xes, r.xfs, r.xss);
43   _LOG(log, logtype::REGISTERS, "    eip %08lx  ebp %08lx  esp %08lx  flags %08lx\n",
44        r.eip, r.ebp, r.esp, r.eflags);
45 }
46