Home | History | Annotate | Download | only in x86_64
      1 /*
      2 ** Copyright 2013, 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 <stdbool.h>
     19 #include <stdlib.h>
     20 #include <string.h>
     21 #include <stdio.h>
     22 #include <errno.h>
     23 #include <sys/types.h>
     24 #include <sys/ptrace.h>
     25 #include <sys/user.h>
     26 
     27 #include "../utility.h"
     28 #include "../machine.h"
     29 
     30 void dump_memory_and_code(log_t*, pid_t) {
     31 }
     32 
     33 void dump_registers(log_t* log, pid_t tid) {
     34     struct user_regs_struct r;
     35     if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) {
     36         _LOG(log, logtype::ERROR, "cannot get registers: %s\n", strerror(errno));
     37         return;
     38     }
     39     _LOG(log, logtype::REGISTERS, "    rax %016lx  rbx %016lx  rcx %016lx  rdx %016lx\n",
     40          r.rax, r.rbx, r.rcx, r.rdx);
     41     _LOG(log, logtype::REGISTERS, "    rsi %016lx  rdi %016lx\n",
     42          r.rsi, r.rdi);
     43     _LOG(log, logtype::REGISTERS, "    r8  %016lx  r9  %016lx  r10 %016lx  r11 %016lx\n",
     44          r.r8, r.r9, r.r10, r.r11);
     45     _LOG(log, logtype::REGISTERS, "    r12 %016lx  r13 %016lx  r14 %016lx  r15 %016lx\n",
     46          r.r12, r.r13, r.r14, r.r15);
     47     _LOG(log, logtype::REGISTERS, "    cs  %016lx  ss  %016lx\n",
     48          r.cs, r.ss);
     49     _LOG(log, logtype::REGISTERS, "    rip %016lx  rbp %016lx  rsp %016lx  eflags %016lx\n",
     50          r.rip, r.rbp, r.rsp, r.eflags);
     51 }
     52