|
Packit Service |
82fcde |
/* Dump registers.
|
|
Packit Service |
82fcde |
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Philip Blundell <pb@nexus.co.uk>, 1998.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library. If not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sys/uio.h>
|
|
Packit Service |
82fcde |
#include <_itoa.h>
|
|
Packit Service |
82fcde |
#include <sys/ucontext.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We will print the register dump in this format:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX
|
|
Packit Service |
82fcde |
R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX
|
|
Packit Service |
82fcde |
R8: XXXXXXXX R9: XXXXXXXX SL: XXXXXXXX FP: XXXXXXXX
|
|
Packit Service |
82fcde |
IP: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX PC: XXXXXXXX
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
CPSR: XXXXXXXX
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Trap: XXXXXXXX Error: XXXXXXXX OldMask: XXXXXXXX
|
|
Packit Service |
82fcde |
Addr: XXXXXXXX
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static void
|
|
Packit Service |
82fcde |
hexvalue (unsigned long int value, char *buf, size_t len)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
char *cp = _itoa_word (value, buf + len, 16, 0);
|
|
Packit Service |
82fcde |
while (cp > buf)
|
|
Packit Service |
82fcde |
*--cp = '0';
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static void
|
|
Packit Service |
82fcde |
register_dump (int fd, const ucontext_t *ctx)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
char regs[21][8];
|
|
Packit Service |
82fcde |
struct iovec iov[97];
|
|
Packit Service |
82fcde |
size_t nr = 0;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define ADD_STRING(str) \
|
|
Packit Service |
82fcde |
iov[nr].iov_base = (char *) str; \
|
|
Packit Service |
82fcde |
iov[nr].iov_len = strlen (str); \
|
|
Packit Service |
82fcde |
++nr
|
|
Packit Service |
82fcde |
#define ADD_MEM(str, len) \
|
|
Packit Service |
82fcde |
iov[nr].iov_base = str; \
|
|
Packit Service |
82fcde |
iov[nr].iov_len = len; \
|
|
Packit Service |
82fcde |
++nr
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Generate strings of register contents. */
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r0, regs[0], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r1, regs[1], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r2, regs[2], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r3, regs[3], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r4, regs[4], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r5, regs[5], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r6, regs[6], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r7, regs[7], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r8, regs[8], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r9, regs[9], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_r10, regs[10], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_fp, regs[11], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_ip, regs[12], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_sp, regs[13], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_lr, regs[14], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_pc, regs[15], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.arm_cpsr, regs[16], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.trap_no, regs[17], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.error_code, regs[18], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.oldmask, regs[19], 8);
|
|
Packit Service |
82fcde |
hexvalue (ctx->uc_mcontext.fault_address, regs[20], 8);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Generate the output. */
|
|
Packit Service |
82fcde |
ADD_STRING ("Register dump:\n\n R0: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[0], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R1: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[1], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R2: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[2], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R3: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[3], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n R4: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[4], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R5: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[5], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R6: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[6], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R7: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[7], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n R8: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[8], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" R9: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[9], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" SL: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[10], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" FP: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[11], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n IP: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[12], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" SP: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[13], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" LR: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[14], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" PC: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[15], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n\n CPSR: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[16], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n\n Trap: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[17], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" Error: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[18], 8);
|
|
Packit Service |
82fcde |
ADD_STRING (" OldMask: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[19], 8);
|
|
Packit Service |
82fcde |
ADD_STRING ("\n Addr: ");
|
|
Packit Service |
82fcde |
ADD_MEM (regs[20], 8);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ADD_STRING ("\n");
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Write the stuff out. */
|
|
Packit Service |
82fcde |
writev (fd, iov, nr);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define REGISTER_DUMP register_dump (fd, ctx)
|