blob: 57330c1e767ad885273abaded1a89f00f71b13b5 [file] [log] [blame]
Elliott Hughes18ddd422013-11-14 17:06:46 -08001/*
Christopher Ferris20303f82014-01-10 16:33:16 -08002 * 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 */
Bruce Beare6cc49232010-10-13 16:11:15 -070016
Jeff Brown053b8652012-06-06 16:25:03 -070017#include <stddef.h>
Jeff Brown053b8652012-06-06 16:25:03 -070018#include <stdlib.h>
19#include <string.h>
Bruce Beare6cc49232010-10-13 16:11:15 -070020#include <stdio.h>
21#include <errno.h>
Bruce Beare6cc49232010-10-13 16:11:15 -070022#include <sys/types.h>
Bruce Beare6cc49232010-10-13 16:11:15 -070023#include <sys/ptrace.h>
Bruce Beare6cc49232010-10-13 16:11:15 -070024
Bruce Beare6cc49232010-10-13 16:11:15 -070025#include "../utility.h"
Jeff Brown053b8652012-06-06 16:25:03 -070026#include "../machine.h"
Bruce Beare6cc49232010-10-13 16:11:15 -070027
Brigid Smith62ba4892014-06-10 11:53:08 -070028void dump_memory_and_code(log_t*, pid_t) {
Jeff Brown053b8652012-06-06 16:25:03 -070029}
30
Brigid Smith62ba4892014-06-10 11:53:08 -070031void dump_registers(log_t* log, pid_t tid) {
Christopher Ferris20303f82014-01-10 16:33:16 -080032 struct pt_regs r;
33 if (ptrace(PTRACE_GETREGS, tid, 0, &r) == -1) {
Brigid Smithe17f2672014-06-19 11:33:38 -070034 _LOG(log, logtype::ERROR, "cannot get registers: %s\n", strerror(errno));
Christopher Ferris20303f82014-01-10 16:33:16 -080035 return;
36 }
Brigid Smith62ba4892014-06-10 11:53:08 -070037 _LOG(log, logtype::REGISTERS, " eax %08lx ebx %08lx ecx %08lx edx %08lx\n",
Christopher Ferris20303f82014-01-10 16:33:16 -080038 r.eax, r.ebx, r.ecx, r.edx);
Brigid Smith62ba4892014-06-10 11:53:08 -070039 _LOG(log, logtype::REGISTERS, " esi %08lx edi %08lx\n",
Christopher Ferris20303f82014-01-10 16:33:16 -080040 r.esi, r.edi);
Brigid Smith62ba4892014-06-10 11:53:08 -070041 _LOG(log, logtype::REGISTERS, " xcs %08x xds %08x xes %08x xfs %08x xss %08x\n",
Christopher Ferris20303f82014-01-10 16:33:16 -080042 r.xcs, r.xds, r.xes, r.xfs, r.xss);
Brigid Smith62ba4892014-06-10 11:53:08 -070043 _LOG(log, logtype::REGISTERS, " eip %08lx ebp %08lx esp %08lx flags %08lx\n",
Christopher Ferris20303f82014-01-10 16:33:16 -080044 r.eip, r.ebp, r.esp, r.eflags);
Bruce Beare6cc49232010-10-13 16:11:15 -070045}