diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-12-20 08:41:55 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2022-01-06 07:59:49 -0300 |
commit | 65ccd641bacea33be23d51da737c2de7543d0f5e (patch) | |
tree | a3dbd16426b4a51dcb8450ede9d47c5a90e58a66 /sysdeps/unix | |
parent | c1fc366ec9e78e17ad3e2ecdb4c4cc662decc32b (diff) | |
download | glibc-65ccd641bacea33be23d51da737c2de7543d0f5e.zip glibc-65ccd641bacea33be23d51da737c2de7543d0f5e.tar.gz glibc-65ccd641bacea33be23d51da737c2de7543d0f5e.tar.bz2 |
debug: Remove catchsegv and libSegfault (BZ #14913)
Trapping SIGSEGV within the process is error-prone, adds security
issues, and modern analysis design tends to happen out of the
process (either by attaching a debugger or by post-mortem analysis).
The libSegfault also has some design problems, it uses non
async-signal-safe function (backtrace) on signal handler.
There are multiple alternatives if users do want to use similar
functionality, such as sigsegv gnulib module or libsegfault.
Diffstat (limited to 'sysdeps/unix')
-rw-r--r-- | sysdeps/unix/sysv/linux/alpha/register-dump.h | 239 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/arm/register-dump.h | 135 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/csky/register-dump.h | 190 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/register-dump.h | 250 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/register-dump.h | 180 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/m68k/register-dump.h | 176 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/mips/register-dump.h | 120 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/riscv/register-dump.h | 63 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h | 128 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h | 131 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/segfault.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sh/register-dump.h | 263 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h | 342 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h | 273 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/register-dump.h | 345 |
15 files changed, 0 insertions, 2837 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/register-dump.h b/sysdeps/unix/sysv/linux/alpha/register-dump.h deleted file mode 100644 index 5ecdd0c..0000000 --- a/sysdeps/unix/sysv/linux/alpha/register-dump.h +++ /dev/null @@ -1,239 +0,0 @@ -/* Dump registers. - Copyright (C) 2004-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <string.h> -#include <ucontext.h> -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - V0: XXXXXXXXXXXXXXXX T0: XXXXXXXXXXXXXXXX T1: XXXXXXXXXXXXXXXX - T2: XXXXXXXXXXXXXXXX T3: XXXXXXXXXXXXXXXX T4: XXXXXXXXXXXXXXXX - T5: XXXXXXXXXXXXXXXX T6: XXXXXXXXXXXXXXXX T7: XXXXXXXXXXXXXXXX - S0: XXXXXXXXXXXXXXXX S1: XXXXXXXXXXXXXXXX S2: XXXXXXXXXXXXXXXX - S3: XXXXXXXXXXXXXXXX S4: XXXXXXXXXXXXXXXX S5: XXXXXXXXXXXXXXXX - S6: XXXXXXXXXXXXXXXX A0: XXXXXXXXXXXXXXXX A1: XXXXXXXXXXXXXXXX - A2: XXXXXXXXXXXXXXXX A3: XXXXXXXXXXXXXXXX A4: XXXXXXXXXXXXXXXX - A5: XXXXXXXXXXXXXXXX T8: XXXXXXXXXXXXXXXX T9: XXXXXXXXXXXXXXXX - T10: XXXXXXXXXXXXXXXX T11: XXXXXXXXXXXXXXXX RA: XXXXXXXXXXXXXXXX - T12: XXXXXXXXXXXXXXXX AT: XXXXXXXXXXXXXXXX GP: XXXXXXXXXXXXXXXX - SP: XXXXXXXXXXXXXXXX PC: XXXXXXXXXXXXXXXX - - FP0: XXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXX FP2: XXXXXXXXXXXXXXXX - FP3: XXXXXXXXXXXXXXXX FP4: XXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXX - FP6: XXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXX FP8: XXXXXXXXXXXXXXXX - FP9: XXXXXXXXXXXXXXXX FP10: XXXXXXXXXXXXXXXX FP11: XXXXXXXXXXXXXXXX - FP12: XXXXXXXXXXXXXXXX FP13: XXXXXXXXXXXXXXXX FP14: XXXXXXXXXXXXXXXX - FP15: XXXXXXXXXXXXXXXX FP16: XXXXXXXXXXXXXXXX FP17: XXXXXXXXXXXXXXXX - FP18: XXXXXXXXXXXXXXXX FP19: XXXXXXXXXXXXXXXX FP20: XXXXXXXXXXXXXXXX - FP21: XXXXXXXXXXXXXXXX FP22: XXXXXXXXXXXXXXXX FP23: XXXXXXXXXXXXXXXX - FP24: XXXXXXXXXXXXXXXX FP25: XXXXXXXXXXXXXXXX FP26: XXXXXXXXXXXXXXXX - FP27: XXXXXXXXXXXXXXXX FP28: XXXXXXXXXXXXXXXX FP29: XXXXXXXXXXXXXXXX - FP30: XXXXXXXXXXXXXXXX FPCR: XXXXXXXXXXXXXXXX - - TA0: XXXXXXXXXXXXXXXX TA1: XXXXXXXXXXXXXXXX TA2: XXXXXXXXXXXXXXXX -*/ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - struct iovec iov[31 * 2 + 2 /* REGS + PC. */ - + 31 * 2 + 2 /* FREGS + FPCR. */ - + (3 * 2) /* TA0, TA1, TA3. */ - + 1 /* '\n'. */]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - char regs[31][16]; - char pc[16]; - for (int i = 0; i < 31; i++) - hexvalue (ctx->uc_mcontext.sc_regs[i], regs[i], 16); - hexvalue (ctx->uc_mcontext.sc_pc, pc, 16); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n V0: "); - ADD_MEM (regs[0], 16); - ADD_STRING (" T0: "); - ADD_MEM (regs[1], 16); - ADD_STRING (" T1: "); - ADD_MEM (regs[2], 16); - ADD_STRING ("\n T2: "); - ADD_MEM (regs[3], 16); - ADD_STRING (" T3: "); - ADD_MEM (regs[4], 16); - ADD_STRING (" T4: "); - ADD_MEM (regs[5], 16); - ADD_STRING ("\n T5: "); - ADD_MEM (regs[6], 16); - ADD_STRING (" T6: "); - ADD_MEM (regs[7], 16); - ADD_STRING (" T7: "); - ADD_MEM (regs[8], 16); - ADD_STRING ("\n S0: "); - ADD_MEM (regs[9], 16); - ADD_STRING (" S1: "); - ADD_MEM (regs[10], 16); - ADD_STRING (" S2: "); - ADD_MEM (regs[11], 16); - ADD_STRING ("\n S3: "); - ADD_MEM (regs[12], 16); - ADD_STRING (" S4: "); - ADD_MEM (regs[13], 16); - ADD_STRING (" S5: "); - ADD_MEM (regs[14], 16); - ADD_STRING ("\n S6: "); - ADD_MEM (regs[15], 16); - ADD_STRING (" A0: "); - ADD_MEM (regs[16], 16); - ADD_STRING (" A1: "); - ADD_MEM (regs[17], 16); - ADD_STRING ("\n A2: "); - ADD_MEM (regs[18], 16); - ADD_STRING (" A3: "); - ADD_MEM (regs[19], 16); - ADD_STRING (" A4: "); - ADD_MEM (regs[20], 16); - ADD_STRING ("\n A5: "); - ADD_MEM (regs[21], 16); - ADD_STRING (" T8: "); - ADD_MEM (regs[22], 16); - ADD_STRING (" T9: "); - ADD_MEM (regs[23], 16); - ADD_STRING ("\n T10: "); - ADD_MEM (regs[24], 16); - ADD_STRING (" T11: "); - ADD_MEM (regs[25], 16); - ADD_STRING (" RA: "); - ADD_MEM (regs[26], 16); - ADD_STRING ("\n T12: "); - ADD_MEM (regs[27], 16); - ADD_STRING (" AT: "); - ADD_MEM (regs[28], 16); - ADD_STRING (" GP: "); - ADD_MEM (regs[29], 16); - ADD_STRING ("\n SP: "); - ADD_MEM (regs[30], 16); - ADD_STRING (" PC: "); - ADD_MEM (pc, 16); - - char fpregs[31][16]; - char fpcr[16]; - for (int i = 0; i < 31; i++) - hexvalue (ctx->uc_mcontext.sc_fpregs[i], fpregs[i], 16); - hexvalue (ctx->uc_mcontext.sc_fpcr, fpcr, 16); - - ADD_STRING ("\n\n FP0: "); - ADD_MEM (fpregs[0], 16); - ADD_STRING (" FP1: "); - ADD_MEM (fpregs[1], 16); - ADD_STRING (" FP2: "); - ADD_MEM (fpregs[2], 16); - ADD_STRING ("\n FP3: "); - ADD_MEM (fpregs[3], 16); - ADD_STRING (" FP4: "); - ADD_MEM (fpregs[4], 16); - ADD_STRING (" FP5: "); - ADD_MEM (fpregs[5], 16); - ADD_STRING ("\n FP6: "); - ADD_MEM (fpregs[6], 16); - ADD_STRING (" FP7: "); - ADD_MEM (fpregs[7], 16); - ADD_STRING (" FP8: "); - ADD_MEM (fpregs[8], 16); - ADD_STRING ("\n FP9: "); - ADD_MEM (fpregs[9], 16); - ADD_STRING (" FP10: "); - ADD_MEM (fpregs[10], 16); - ADD_STRING (" FP11: "); - ADD_MEM (fpregs[11], 16); - ADD_STRING ("\n FP12: "); - ADD_MEM (fpregs[12], 16); - ADD_STRING (" FP13: "); - ADD_MEM (fpregs[13], 16); - ADD_STRING (" FP14: "); - ADD_MEM (fpregs[14], 16); - ADD_STRING ("\n FP15: "); - ADD_MEM (fpregs[15], 16); - ADD_STRING (" FP16: "); - ADD_MEM (fpregs[16], 16); - ADD_STRING (" FP17: "); - ADD_MEM (fpregs[17], 16); - ADD_STRING ("\n FP18: "); - ADD_MEM (fpregs[18], 16); - ADD_STRING (" FP19: "); - ADD_MEM (fpregs[19], 16); - ADD_STRING (" FP20: "); - ADD_MEM (fpregs[20], 16); - ADD_STRING ("\n FP21: "); - ADD_MEM (fpregs[21], 16); - ADD_STRING (" FP22: "); - ADD_MEM (fpregs[22], 16); - ADD_STRING (" FP23: "); - ADD_MEM (fpregs[23], 16); - ADD_STRING ("\n FP24: "); - ADD_MEM (fpregs[24], 16); - ADD_STRING (" FP25: "); - ADD_MEM (fpregs[25], 16); - ADD_STRING (" FP26: "); - ADD_MEM (fpregs[26], 16); - ADD_STRING ("\n FP27: "); - ADD_MEM (fpregs[27], 16); - ADD_STRING (" FP28: "); - ADD_MEM (fpregs[28], 16); - ADD_STRING (" FP29: "); - ADD_MEM (fpregs[29], 16); - ADD_STRING ("\n FP30: "); - ADD_MEM (fpregs[30], 16); - ADD_STRING (" FPCR: "); - ADD_MEM (fpcr, 16); - - char traparg[3][16]; - hexvalue (ctx->uc_mcontext.sc_traparg_a0, traparg[0], 16); - hexvalue (ctx->uc_mcontext.sc_traparg_a1, traparg[1], 16); - hexvalue (ctx->uc_mcontext.sc_traparg_a2, traparg[2], 16); - ADD_STRING ("\n\n TA0: "); - ADD_MEM (traparg[0], 16); - ADD_STRING (" TA1: "); - ADD_MEM (traparg[1], 16); - ADD_STRING (" TA2: "); - ADD_MEM (traparg[2], 16); - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/arm/register-dump.h b/sysdeps/unix/sysv/linux/arm/register-dump.h deleted file mode 100644 index 1cbdbe3..0000000 --- a/sysdeps/unix/sysv/linux/arm/register-dump.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> -#include <sys/ucontext.h> - -/* We will print the register dump in this format: - - R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX - R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX - R8: XXXXXXXX R9: XXXXXXXX SL: XXXXXXXX FP: XXXXXXXX - IP: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX PC: XXXXXXXX - - CPSR: XXXXXXXX - - Trap: XXXXXXXX Error: XXXXXXXX OldMask: XXXXXXXX - Addr: XXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, const ucontext_t *ctx) -{ - char regs[21][8]; - struct iovec iov[97]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.arm_r0, regs[0], 8); - hexvalue (ctx->uc_mcontext.arm_r1, regs[1], 8); - hexvalue (ctx->uc_mcontext.arm_r2, regs[2], 8); - hexvalue (ctx->uc_mcontext.arm_r3, regs[3], 8); - hexvalue (ctx->uc_mcontext.arm_r4, regs[4], 8); - hexvalue (ctx->uc_mcontext.arm_r5, regs[5], 8); - hexvalue (ctx->uc_mcontext.arm_r6, regs[6], 8); - hexvalue (ctx->uc_mcontext.arm_r7, regs[7], 8); - hexvalue (ctx->uc_mcontext.arm_r8, regs[8], 8); - hexvalue (ctx->uc_mcontext.arm_r9, regs[9], 8); - hexvalue (ctx->uc_mcontext.arm_r10, regs[10], 8); - hexvalue (ctx->uc_mcontext.arm_fp, regs[11], 8); - hexvalue (ctx->uc_mcontext.arm_ip, regs[12], 8); - hexvalue (ctx->uc_mcontext.arm_sp, regs[13], 8); - hexvalue (ctx->uc_mcontext.arm_lr, regs[14], 8); - hexvalue (ctx->uc_mcontext.arm_pc, regs[15], 8); - hexvalue (ctx->uc_mcontext.arm_cpsr, regs[16], 8); - hexvalue (ctx->uc_mcontext.trap_no, regs[17], 8); - hexvalue (ctx->uc_mcontext.error_code, regs[18], 8); - hexvalue (ctx->uc_mcontext.oldmask, regs[19], 8); - hexvalue (ctx->uc_mcontext.fault_address, regs[20], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n R0: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" R1: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" R2: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" R3: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n R4: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" R5: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" R6: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" R7: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n R8: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" R9: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" SL: "); - ADD_MEM (regs[10], 8); - ADD_STRING (" FP: "); - ADD_MEM (regs[11], 8); - ADD_STRING ("\n IP: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" SP: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" LR: "); - ADD_MEM (regs[14], 8); - ADD_STRING (" PC: "); - ADD_MEM (regs[15], 8); - ADD_STRING ("\n\n CPSR: "); - ADD_MEM (regs[16], 8); - ADD_STRING ("\n\n Trap: "); - ADD_MEM (regs[17], 8); - ADD_STRING (" Error: "); - ADD_MEM (regs[18], 8); - ADD_STRING (" OldMask: "); - ADD_MEM (regs[19], 8); - ADD_STRING ("\n Addr: "); - ADD_MEM (regs[20], 8); - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/csky/register-dump.h b/sysdeps/unix/sysv/linux/csky/register-dump.h deleted file mode 100644 index f313a69..0000000 --- a/sysdeps/unix/sysv/linux/csky/register-dump.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Dump registers. - Copyright (C) 2018-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> -#include <bits/sigcontext.h> -#include <sys/ucontext.h> - -/* abiv1 register dump in this format: - - PSR: XXXXXXXX PC: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX - MASK: XXXXXXXX - - A0: XXXXXXXX A1: XXXXXXXX A2: XXXXXXXX A3: XXXXXXXX - R6: XXXXXXXX R7: XXXXXXXX R8: XXXXXXXX R9: XXXXXXXX - R10: XXXXXXXX R11: XXXXXXXX R12: XXXXXXXX R13: XXXXXXXX - R14: XXXXXXXX R1: XXXXXXXX - - abiv2 register dump in this format: - - PSR: XXXXXXXX PC: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX - MASK: XXXXXXXX - - A0: XXXXXXXX A1: XXXXXXXX A2: XXXXXXXX A3: XXXXXXXX - R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX - R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX - R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX - R16: XXXXXXXX R17: XXXXXXXX R18: XXXXXXXX R19: XXXXXXXX - R20: XXXXXXXX R21: XXXXXXXX R22: XXXXXXXX R23: XXXXXXXX - R24: XXXXXXXX R25: XXXXXXXX R26: XXXXXXXX R27: XXXXXXXX - R28: XXXXXXXX R29: XXXXXXXX R30: XXXXXXXX R31: XXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, const struct ucontext_t *ctx) -{ - char regs[35][8]; - struct iovec iov[97]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.__gregs.__sr, regs[0], 8); - hexvalue (ctx->uc_mcontext.__gregs.__pc, regs[1], 8); - hexvalue (ctx->uc_mcontext.__gregs.__usp, regs[2], 8); - hexvalue (ctx->uc_mcontext.__gregs.__lr, regs[3], 8); - hexvalue (ctx->uc_mcontext.__gregs.__a0, regs[4], 8); - hexvalue (ctx->uc_mcontext.__gregs.__a1, regs[5], 8); - hexvalue (ctx->uc_mcontext.__gregs.__a2, regs[6], 8); - hexvalue (ctx->uc_mcontext.__gregs.__a3, regs[7], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[0], regs[8], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[1], regs[9], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[2], regs[10], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[3], regs[11], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[4], regs[12], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[5], regs[13], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[6], regs[14], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[7], regs[15], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[8], regs[16], 8); - hexvalue (ctx->uc_mcontext.__gregs.__regs[9], regs[17], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[0], regs[18], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[1], regs[19], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[2], regs[20], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[3], regs[21], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[4], regs[22], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[5], regs[23], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[6], regs[24], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[7], regs[25], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[8], regs[26], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[9], regs[27], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[10], regs[28], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[11], regs[29], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[12], regs[30], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[13], regs[31], 8); - hexvalue (ctx->uc_mcontext.__gregs.__exregs[14], regs[32], 8); - hexvalue (ctx->uc_mcontext.__gregs.__tls, regs[33], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n PSR: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" PC: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" SP: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" LR: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n\n A0: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" A1: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" A2: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" A3: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n R4: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" R5: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" R6: "); - ADD_MEM (regs[10], 8); - ADD_STRING (" R7: "); - ADD_MEM (regs[11], 8); - ADD_STRING ("\n R8: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" R9: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" R10: "); - ADD_MEM (regs[14], 8); - ADD_STRING (" R11: "); - ADD_MEM (regs[15], 8); - ADD_STRING ("\n R12: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" R13: "); - ADD_MEM (regs[17], 8); - ADD_STRING (" R14: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" R15: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n R16: "); - ADD_MEM (regs[18], 8); - ADD_STRING (" R17: "); - ADD_MEM (regs[19], 8); - ADD_STRING (" R18: "); - ADD_MEM (regs[20], 8); - ADD_STRING (" R19: "); - ADD_MEM (regs[21], 8); - ADD_STRING ("\n R20: "); - ADD_MEM (regs[22], 8); - ADD_STRING (" R21: "); - ADD_MEM (regs[23], 8); - ADD_STRING (" R22: "); - ADD_MEM (regs[24], 8); - ADD_STRING (" R23: "); - ADD_MEM (regs[25], 8); - ADD_STRING ("\n R24: "); - ADD_MEM (regs[26], 8); - ADD_STRING (" R25: "); - ADD_MEM (regs[27], 8); - ADD_STRING (" R26: "); - ADD_MEM (regs[28], 8); - ADD_STRING (" R27: "); - ADD_MEM (regs[29], 8); - ADD_STRING ("\n R28: "); - ADD_MEM (regs[30], 8); - ADD_STRING (" R29: "); - ADD_MEM (regs[31], 8); - ADD_STRING (" R30: "); - ADD_MEM (regs[32], 8); - ADD_STRING (" R31: "); - ADD_MEM (regs[33], 8); - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/i386/register-dump.h b/sysdeps/unix/sysv/linux/i386/register-dump.h deleted file mode 100644 index 612424b..0000000 --- a/sysdeps/unix/sysv/linux/i386/register-dump.h +++ /dev/null @@ -1,250 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - EAX: XXXXXXXX EBX: XXXXXXXX ECX: XXXXXXXX EDX: XXXXXXXX - ESI: XXXXXXXX EDI: XXXXXXXX EBP: XXXXXXXX ESP: XXXXXXXX - - EIP: XXXXXXXX EFLAGS: XXXXXXXX - - CS: XXXX DS: XXXX ES: XXXX FS: XXXX GS: XXXX SS: XXXX - - Trap: XXXXXXXX Error: XXXXXXXX OldMask: XXXXXXXX - ESP/SIGNAL: XXXXXXXX CR2: XXXXXXXX - - FPUCW: XXXXXXXX FPUSW: XXXXXXXX TAG: XXXXXXXX - IPOFF: XXXXXXXX CSSEL: XXXX DATAOFF: XXXXXXXX DATASEL: XXXX - - ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX - ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX - ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX - ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - char regs[21][8]; - char fpregs[31][8]; - struct iovec iov[97]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[REG_EAX], regs[0], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_EBX], regs[1], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_ECX], regs[2], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_EDX], regs[3], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_ESI], regs[4], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_EDI], regs[5], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_EBP], regs[6], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_ESP], regs[7], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_EIP], regs[8], 8); - hexvalue (ctx->uc_flags, regs[9], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_CS], regs[10], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_DS], regs[11], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_ES], regs[12], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_FS], regs[13], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_GS], regs[14], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_SS], regs[15], 4); - hexvalue (ctx->uc_mcontext.gregs[REG_TRAPNO], regs[16], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_ERR], regs[17], 8); - hexvalue (ctx->uc_mcontext.oldmask, regs[18], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_UESP], regs[19], 8); - hexvalue (ctx->uc_mcontext.cr2, regs[20], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n EAX: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" EBX: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" ECX: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" EDX: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n ESI: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" EDI: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" EBP: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" ESP: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n\n EIP: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" EFLAGS: "); - ADD_MEM (regs[9], 8); - ADD_STRING ("\n\n CS: "); - ADD_MEM (regs[10], 4); - ADD_STRING (" DS: "); - ADD_MEM (regs[11], 4); - ADD_STRING (" ES: "); - ADD_MEM (regs[12], 4); - ADD_STRING (" FS: "); - ADD_MEM (regs[13], 4); - ADD_STRING (" GS: "); - ADD_MEM (regs[14], 4); - ADD_STRING (" SS: "); - ADD_MEM (regs[15], 4); - ADD_STRING ("\n\n Trap: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" Error: "); - ADD_MEM (regs[17], 8); - ADD_STRING (" OldMask: "); - ADD_MEM (regs[18], 8); - ADD_STRING ("\n ESP/signal: "); - ADD_MEM (regs[19], 8); - ADD_STRING (" CR2: "); - ADD_MEM (regs[20], 8); - - /* Generate output for the FPU control/status registers. */ - hexvalue (ctx->__fpregs_mem.cw, fpregs[0], 8); - hexvalue (ctx->__fpregs_mem.sw, fpregs[1], 8); - hexvalue (ctx->__fpregs_mem.tag, fpregs[2], 8); - hexvalue (ctx->__fpregs_mem.ipoff, fpregs[3], 8); - hexvalue (ctx->__fpregs_mem.cssel, fpregs[4], 4); - hexvalue (ctx->__fpregs_mem.dataoff, fpregs[5], 8); - hexvalue (ctx->__fpregs_mem.datasel, fpregs[6], 4); - - ADD_STRING ("\n\n FPUCW: "); - ADD_MEM (fpregs[0], 8); - ADD_STRING (" FPUSW: "); - ADD_MEM (fpregs[1], 8); - ADD_STRING (" TAG: "); - ADD_MEM (fpregs[2], 8); - ADD_STRING ("\n IPOFF: "); - ADD_MEM (fpregs[3], 8); - ADD_STRING (" CSSEL: "); - ADD_MEM (fpregs[4], 4); - ADD_STRING (" DATAOFF: "); - ADD_MEM (fpregs[5], 8); - ADD_STRING (" DATASEL: "); - ADD_MEM (fpregs[6], 4); - - /* Now the real FPU registers. */ - hexvalue (ctx->__fpregs_mem._st[0].exponent, fpregs[7], 8); - hexvalue (ctx->__fpregs_mem._st[0].significand[3] << 16 - | ctx->__fpregs_mem._st[0].significand[2], fpregs[8], 8); - hexvalue (ctx->__fpregs_mem._st[0].significand[1] << 16 - | ctx->__fpregs_mem._st[0].significand[0], fpregs[9], 8); - hexvalue (ctx->__fpregs_mem._st[1].exponent, fpregs[10], 8); - hexvalue (ctx->__fpregs_mem._st[1].significand[3] << 16 - | ctx->__fpregs_mem._st[1].significand[2], fpregs[11], 8); - hexvalue (ctx->__fpregs_mem._st[1].significand[1] << 16 - | ctx->__fpregs_mem._st[1].significand[0], fpregs[12], 8); - hexvalue (ctx->__fpregs_mem._st[2].exponent, fpregs[13], 8); - hexvalue (ctx->__fpregs_mem._st[2].significand[3] << 16 - | ctx->__fpregs_mem._st[2].significand[2], fpregs[14], 8); - hexvalue (ctx->__fpregs_mem._st[2].significand[1] << 16 - | ctx->__fpregs_mem._st[2].significand[0], fpregs[15], 8); - hexvalue (ctx->__fpregs_mem._st[3].exponent, fpregs[16], 8); - hexvalue (ctx->__fpregs_mem._st[3].significand[3] << 16 - | ctx->__fpregs_mem._st[3].significand[2], fpregs[17], 8); - hexvalue (ctx->__fpregs_mem._st[3].significand[1] << 16 - | ctx->__fpregs_mem._st[3].significand[0], fpregs[18], 8); - hexvalue (ctx->__fpregs_mem._st[4].exponent, fpregs[19], 8); - hexvalue (ctx->__fpregs_mem._st[4].significand[3] << 16 - | ctx->__fpregs_mem._st[4].significand[2], fpregs[20], 8); - hexvalue (ctx->__fpregs_mem._st[4].significand[1] << 16 - | ctx->__fpregs_mem._st[4].significand[0], fpregs[21], 8); - hexvalue (ctx->__fpregs_mem._st[5].exponent, fpregs[22], 8); - hexvalue (ctx->__fpregs_mem._st[5].significand[3] << 16 - | ctx->__fpregs_mem._st[5].significand[2], fpregs[23], 8); - hexvalue (ctx->__fpregs_mem._st[5].significand[1] << 16 - | ctx->__fpregs_mem._st[5].significand[0], fpregs[24], 8); - hexvalue (ctx->__fpregs_mem._st[6].exponent, fpregs[25], 8); - hexvalue (ctx->__fpregs_mem._st[6].significand[3] << 16 - | ctx->__fpregs_mem._st[6].significand[2], fpregs[26], 8); - hexvalue (ctx->__fpregs_mem._st[6].significand[1] << 16 - | ctx->__fpregs_mem._st[6].significand[0], fpregs[27], 8); - hexvalue (ctx->__fpregs_mem._st[7].exponent, fpregs[28], 8); - hexvalue (ctx->__fpregs_mem._st[7].significand[3] << 16 - | ctx->__fpregs_mem._st[7].significand[2], fpregs[29], 8); - hexvalue (ctx->__fpregs_mem._st[7].significand[1] << 16 - | ctx->__fpregs_mem._st[7].significand[0], fpregs[30], 8); - - ADD_STRING ("\n\n ST(0) "); - ADD_MEM (fpregs[7], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[8], 8); - ADD_MEM (fpregs[9], 8); - ADD_STRING (" ST(1) "); - ADD_MEM (fpregs[10], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[11], 8); - ADD_MEM (fpregs[12], 8); - ADD_STRING ("\n ST(2) "); - ADD_MEM (fpregs[13], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[14], 8); - ADD_MEM (fpregs[15], 8); - ADD_STRING (" ST(3) "); - ADD_MEM (fpregs[16], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[17], 8); - ADD_MEM (fpregs[18], 8); - ADD_STRING ("\n ST(4) "); - ADD_MEM (fpregs[19], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[20], 8); - ADD_MEM (fpregs[21], 8); - ADD_STRING (" ST(5) "); - ADD_MEM (fpregs[22], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[23], 8); - ADD_MEM (fpregs[24], 8); - ADD_STRING ("\n ST(6) "); - ADD_MEM (fpregs[25], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[26], 8); - ADD_MEM (fpregs[27], 8); - ADD_STRING (" ST(7) "); - ADD_MEM (fpregs[28], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[29], 8); - ADD_MEM (fpregs[30], 8); - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/ia64/register-dump.h b/sysdeps/unix/sysv/linux/ia64/register-dump.h deleted file mode 100644 index 4c7c400..0000000 --- a/sysdeps/unix/sysv/linux/ia64/register-dump.h +++ /dev/null @@ -1,180 +0,0 @@ -/* Dump registers. - Copyright (C) 2004-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <string.h> -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - GP: XXXXXXXXXXXXXXXX R2: XXXXXXXXXXXXXXXX R3: XXXXXXXXXXXXXXXX - R8: XXXXXXXXXXXXXXXX R9: XXXXXXXXXXXXXXXX R10: XXXXXXXXXXXXXXXX - R11: XXXXXXXXXXXXXXXX SP: XXXXXXXXXXXXXXXX TP: XXXXXXXXXXXXXXXX - R14: XXXXXXXXXXXXXXXX R15: XXXXXXXXXXXXXXXX R16: XXXXXXXXXXXXXXXX - R17: XXXXXXXXXXXXXXXX R18: XXXXXXXXXXXXXXXX R19: XXXXXXXXXXXXXXXX - R20: XXXXXXXXXXXXXXXX R21: XXXXXXXXXXXXXXXX R22: XXXXXXXXXXXXXXXX - R23: XXXXXXXXXXXXXXXX R24: XXXXXXXXXXXXXXXX R25: XXXXXXXXXXXXXXXX - R26: XXXXXXXXXXXXXXXX R27: XXXXXXXXXXXXXXXX R28: XXXXXXXXXXXXXXXX - R29: XXXXXXXXXXXXXXXX R30: XXXXXXXXXXXXXXXX R31: XXXXXXXXXXXXXXXX - - RP: XXXXXXXXXXXXXXXX B6: XXXXXXXXXXXXXXXX B7: XXXXXXXXXXXXXXXX - - IP: XXXXXXXXXXXXXXXX RSC: XXXXXXXXXXXXXXXX PR: XXXXXXXXXXXXXXXX - PFS: XXXXXXXXXXXXXXXX UNAT: XXXXXXXXXXXXXXXX CFM: XXXXXXXXXXXXXXXX - CCV: XXXXXXXXXXXXXXXX FPSR: XXXXXXXXXXXXXXXX - - F32: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F33: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - F34: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F35: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -... - F124: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F125: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - F126: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F127: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -regvalue (unsigned long int *value, char letter, int regno, char *buf) -{ - int n = regno >= 100 ? 3 : regno >= 10 ? 2 : 1; - buf[0] = ' '; - buf[1] = letter; - _itoa_word (regno, buf + 2 + n, 10, 0); - buf[2 + n] = ':'; - for (++n; n <= 4; ++n) - buf[2 + n] = ' '; - hexvalue (value[0], buf + 7, 16); - if (letter == 'F') - { - hexvalue (value[1], buf + 7 + 16, 16); - buf[7 + 32] = '\n'; - } - else - buf[7 + 16] = '\n'; -} - -static void -register_dump (int fd, struct sigcontext *ctx) -{ - char gpregs[32 - 5][8 + 16]; - char fpregs[128 - 32][8 + 32]; - char bpregs[3][8 + 16]; - char spregs[8][16]; - struct iovec iov[146]; - size_t nr = 0; - int i; - -#define ADD_STRING(str) \ - do \ - { \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr; \ - } \ - while (0) -#define ADD_MEM(str, len) \ - do \ - { \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr; \ - } \ - while (0) - - /* Generate strings of register contents. */ - for (i = 1; i < 4; ++i) - { - regvalue (&ctx->sc_gr[i], 'R', i, gpregs[i - 1]); - if (ctx->sc_nat & (1L << i)) - memcpy (gpregs[i - 1] + 7, "NaT ", 16); - } - for (i = 8; i < 32; ++i) - { - regvalue (&ctx->sc_gr[i], 'R', i, gpregs[i - 5]); - if (ctx->sc_nat & (1L << i)) - memcpy (gpregs[i - 1] + 7, "NaT ", 16); - } - memcpy (gpregs[0] + 1, "GP:", 3); - memcpy (gpregs[7] + 1, "SP: ", 4); - memcpy (gpregs[8] + 1, "TP: ", 4); - - regvalue (&ctx->sc_br[0], 'B', 0, bpregs[0]); - regvalue (&ctx->sc_br[6], 'B', 6, bpregs[1]); - regvalue (&ctx->sc_br[7], 'B', 7, bpregs[2]); - memcpy (bpregs[0] + 1, "RP:", 3); - - if (ctx->sc_flags & IA64_SC_FLAG_FPH_VALID) - for (i = 32; i < 128; ++i) - regvalue (&ctx->sc_fr[i].u.bits[0], 'F', i, fpregs[i - 32]); - - hexvalue (ctx->sc_ip, spregs[0], sizeof (spregs[0])); - hexvalue (ctx->sc_ar_rsc, spregs[1], sizeof (spregs[1])); - hexvalue (ctx->sc_pr, spregs[2], sizeof (spregs[2])); - hexvalue (ctx->sc_ar_pfs, spregs[3], sizeof (spregs[3])); - hexvalue (ctx->sc_ar_unat, spregs[4], sizeof (spregs[4])); - hexvalue (ctx->sc_cfm, spregs[5], sizeof (spregs[5])); - hexvalue (ctx->sc_ar_ccv, spregs[6], sizeof (spregs[6])); - hexvalue (ctx->sc_ar_fpsr, spregs[7], sizeof (spregs[7])); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n"); - - for (i = 0; i < 32 - 5; ++i) - ADD_MEM (gpregs[i], sizeof (gpregs[0]) - 1 + ((i % 3) == 2)); - ADD_STRING ("\n"); - - for (i = 0; i < 3; ++i) - ADD_MEM (bpregs[i], sizeof (bpregs[0]) - 1); - - ADD_STRING ("\n\n IP: "); - ADD_MEM (spregs[0], sizeof (spregs[0])); - ADD_STRING (" RSC: "); - ADD_MEM (spregs[1], sizeof (spregs[0])); - ADD_STRING (" PR: "); - ADD_MEM (spregs[2], sizeof (spregs[0])); - ADD_STRING ("\n PFS: "); - ADD_MEM (spregs[3], sizeof (spregs[0])); - ADD_STRING (" UNAT: "); - ADD_MEM (spregs[4], sizeof (spregs[0])); - ADD_STRING (" CFM: "); - ADD_MEM (spregs[5], sizeof (spregs[0])); - ADD_STRING ("\n CCV: "); - ADD_MEM (spregs[6], sizeof (spregs[0])); - ADD_STRING (" FPSR: "); - ADD_MEM (spregs[7], sizeof (spregs[0])); - ADD_STRING ("\n"); - - if (ctx->sc_flags & IA64_SC_FLAG_FPH_VALID) - { - ADD_STRING ("\n"); - - for (i = 0; i < 128 - 32; ++i) - ADD_MEM (fpregs[i], sizeof (fpregs[0]) - 1 + (i & 1)); - } - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/m68k/register-dump.h b/sysdeps/unix/sysv/linux/m68k/register-dump.h deleted file mode 100644 index 38cc401..0000000 --- a/sysdeps/unix/sysv/linux/m68k/register-dump.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <stddef.h> -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - D0: XXXXXXXX D1: XXXXXXXX D2: XXXXXXXX D3: XXXXXXXX - D4: XXXXXXXX D5: XXXXXXXX D6: XXXXXXXX D7: XXXXXXXX - A0: XXXXXXXX A1: XXXXXXXX A2: XXXXXXXX A3: XXXXXXXX - A4: XXXXXXXX A5: XXXXXXXX A6: XXXXXXXX A7: XXXXXXXX - PC: XXXXXXXX SR: XXXX - - OldMask: XXXXXXXX Vector: XXXX - - FP0: XXXXXXXXXXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXXXXXXXXXX - FP2: XXXXXXXXXXXXXXXXXXXXXXXX FP3: XXXXXXXXXXXXXXXXXXXXXXXX - FP4: XXXXXXXXXXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXXXXXXXXXX - FP6: XXXXXXXXXXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXXXXXXXXXX - FPCR: XXXXXXXX FPSR: XXXXXXXX FPIAR: XXXXXXXX - -*/ - -#define FPCONTEXT_SIZE 216 -#define uc_formatvec __glibc_reserved1[FPCONTEXT_SIZE/4] -#define uc_oldmask uc_sigmask.__val[0] - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - char regs[20][8]; - char fpregs[11][24]; - struct iovec iov[63], *next_iov = iov; - int i, j, fpreg_size; - -#define ADD_STRING(str) \ - next_iov->iov_base = (char *) (str); \ - next_iov->iov_len = strlen (str); \ - ++next_iov -#define ADD_MEM(str, len) \ - next_iov->iov_base = (str); \ - next_iov->iov_len = (len); \ - ++next_iov - -#ifdef __mcoldfire__ - fpreg_size = 16; -#else - fpreg_size = 24; -#endif - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[R_D0], regs[0], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D1], regs[1], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D2], regs[2], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D3], regs[3], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D4], regs[4], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D5], regs[5], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D6], regs[6], 8); - hexvalue (ctx->uc_mcontext.gregs[R_D7], regs[7], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A0], regs[8], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A1], regs[9], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A2], regs[10], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A3], regs[11], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A4], regs[12], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A5], regs[13], 8); - hexvalue (ctx->uc_mcontext.gregs[R_A6], regs[14], 8); - hexvalue (ctx->uc_mcontext.gregs[R_SP], regs[15], 8); - hexvalue (ctx->uc_mcontext.gregs[R_PC], regs[16], 8); - hexvalue (ctx->uc_mcontext.gregs[R_PS], regs[17], 4); - hexvalue (ctx->uc_oldmask, regs[18], 8); - hexvalue (ctx->uc_formatvec & 0xfff, regs[19], 4); - - for (i = 0; i < 8; i++) - for (j = 0; j < fpreg_size; j += 8) - hexvalue (ctx->uc_mcontext.fpregs.f_fpregs[i][j/8], fpregs[i] + j, 8); - hexvalue (ctx->uc_mcontext.fpregs.f_pcr, fpregs[8], 8); - hexvalue (ctx->uc_mcontext.fpregs.f_psr, fpregs[9], 8); - hexvalue (ctx->uc_mcontext.fpregs.f_fpiaddr, fpregs[10], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n D0: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" D1: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" D2: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" D3: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n D4: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" D5: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" D6: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" D7: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n A0: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" A1: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" A2: "); - ADD_MEM (regs[10], 8); - ADD_STRING (" A3: "); - ADD_MEM (regs[11], 8); - ADD_STRING ("\n A4: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" A5: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" A6: "); - ADD_MEM (regs[14], 8); - ADD_STRING (" A7: "); - ADD_MEM (regs[15], 8); - ADD_STRING ("\n PC: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" SR: "); - ADD_MEM (regs[17], 4); - - ADD_STRING ("\n\n OldMask: "); - ADD_MEM (regs[18], 8); - ADD_STRING (" Vector: "); - ADD_MEM (regs[19], 4); - - ADD_STRING ("\n\n FP0: "); - ADD_MEM (fpregs[0], fpreg_size); - ADD_STRING (" FP1: "); - ADD_MEM (fpregs[1], fpreg_size); - ADD_STRING ("\n FP2: "); - ADD_MEM (fpregs[2], fpreg_size); - ADD_STRING (" FP3: "); - ADD_MEM (fpregs[3], fpreg_size); - ADD_STRING ("\n FP4: "); - ADD_MEM (fpregs[4], fpreg_size); - ADD_STRING (" FP5: "); - ADD_MEM (fpregs[5], fpreg_size); - ADD_STRING ("\n FP6: "); - ADD_MEM (fpregs[6], fpreg_size); - ADD_STRING (" FP7: "); - ADD_MEM (fpregs[7], fpreg_size); - ADD_STRING ("\n FPCR: "); - ADD_MEM (fpregs[8], 8); - ADD_STRING (" FPSR: "); - ADD_MEM (fpregs[9], 8); - ADD_STRING (" FPIAR: "); - ADD_MEM (fpregs[10], 8); - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, next_iov - iov); -} - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/mips/register-dump.h b/sysdeps/unix/sysv/linux/mips/register-dump.h deleted file mode 100644 index b3ada7b..0000000 --- a/sysdeps/unix/sysv/linux/mips/register-dump.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <sgidefs.h> -#include <sys/uio.h> -#include <_itoa.h> - -#if _MIPS_SIM == _ABIO32 -# define CTX_TYPE struct sigcontext * -# define CTX_REG(ctx, i) ((ctx)->sc_regs[(i)]) -# define CTX_PC(ctx) ((ctx)->sc_pc) -# define CTX_MDHI(ctx) ((ctx)->sc_mdhi) -# define CTX_MDLO(ctx) ((ctx)->sc_mdlo) -# define REG_HEX_SIZE 8 -#else -# define CTX_TYPE ucontext_t * -# define CTX_REG(ctx, i) ((ctx)->uc_mcontext.gregs[(i)]) -# define CTX_PC(ctx) ((ctx)->uc_mcontext.pc) -# define CTX_MDHI(ctx) ((ctx)->uc_mcontext.mdhi) -# define CTX_MDLO(ctx) ((ctx)->uc_mcontext.mdhi) -# define REG_HEX_SIZE 16 -#endif - -/* We will print the register dump in this format: - - R0 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX - R8 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX - R16 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX - R24 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX - pc lo hi - XXXXXXXX XXXXXXXX XXXXXXXX - The FPU registers will not be printed. -*/ - -static void -hexvalue (_ITOA_WORD_TYPE value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, CTX_TYPE ctx) -{ - char regs[38][REG_HEX_SIZE]; - struct iovec iov[38 * 2 + 10]; - size_t nr = 0; - int i; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - for (i = 0; i < 32; i++) - hexvalue (CTX_REG (ctx, i), regs[i], REG_HEX_SIZE); - hexvalue (CTX_PC (ctx), regs[32], REG_HEX_SIZE); - hexvalue (CTX_MDHI (ctx), regs[33], REG_HEX_SIZE); - hexvalue (CTX_MDLO (ctx), regs[34], REG_HEX_SIZE); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n R0 "); - for (i = 0; i < 8; i++) - { - ADD_MEM (regs[i], REG_HEX_SIZE); - ADD_STRING (" "); - } - ADD_STRING ("\n R8 "); - for (i = 8; i < 16; i++) - { - ADD_MEM (regs[i], REG_HEX_SIZE); - ADD_STRING (" "); - } - ADD_STRING ("\n R16 "); - for (i = 16; i < 24; i++) - { - ADD_MEM (regs[i], REG_HEX_SIZE); - ADD_STRING (" "); - } - ADD_STRING ("\n R24 "); - for (i = 24; i < 32; i++) - { - ADD_MEM (regs[i], REG_HEX_SIZE); - ADD_STRING (" "); - } - ADD_STRING ("\n pc lo hi\n "); - for (i = 32; i < 35; i++) - { - ADD_MEM (regs[i], REG_HEX_SIZE); - ADD_STRING (" "); - } - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/riscv/register-dump.h b/sysdeps/unix/sysv/linux/riscv/register-dump.h deleted file mode 100644 index 177636f..0000000 --- a/sysdeps/unix/sysv/linux/riscv/register-dump.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <https://www.gnu.org/licenses/>. */ - -#include <unistd.h> -#include <string.h> -#include <_itoa.h> - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -#define REGDUMP_NREGS 32 -#define REGDUMP_PER_LINE (80 / (__WORDSIZE / 4 + 4)) - -static void -register_dump (int fd, ucontext_t *ctx) -{ - int i; - char regvalue[__WORDSIZE / 4 + 1]; - char str[82 * ((REGDUMP_NREGS + REGDUMP_PER_LINE - 1) / REGDUMP_PER_LINE)]; - - static const char names[REGDUMP_NREGS][4] = { - "pc", "ra", "sp", "gp", "tp", "t0", "t1", "t2", - "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", - "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", - "s8", "s9", "sA", "sB", "t3", "t4", "t5", "t6" - }; - - str[0] = 0; - for (i = 0; i < REGDUMP_NREGS; i++) - { - strcat (str, names[i]); - strcat (str, " "); - hexvalue (ctx->uc_mcontext.__gregs[i], regvalue, __WORDSIZE / 4); - strcat (str, regvalue); - - if ((i + 1) % REGDUMP_PER_LINE == 0) - strcat (str, "\n"); - } - - write (fd, str, strlen (str)); -} - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h b/sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h deleted file mode 100644 index 51aa1e4..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - GPR0: XXXXXXXX GPR1: XXXXXXXX GPR2: XXXXXXXX GPR3: XXXXXXXX - GPR4: XXXXXXXX GPR5: XXXXXXXX GPR6: XXXXXXXX GPR7: XXXXXXXX - GPR8: XXXXXXXX GPR9: XXXXXXXX GPRA: XXXXXXXX GPRB: XXXXXXXX - GPRC: XXXXXXXX GPRD: XXXXXXXX GPRE: XXXXXXXX GPRF: XXXXXXXX - - PSW.MASK: XXXXXXXX PSW.ADDR: XXXXXXXX - - ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX - ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX - ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX - ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - char regs[19][8]; - struct iovec iov[40]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[0], regs[0], 8); - hexvalue (ctx->uc_mcontext.gregs[1], regs[1], 8); - hexvalue (ctx->uc_mcontext.gregs[2], regs[2], 8); - hexvalue (ctx->uc_mcontext.gregs[3], regs[3], 8); - hexvalue (ctx->uc_mcontext.gregs[4], regs[4], 8); - hexvalue (ctx->uc_mcontext.gregs[5], regs[5], 8); - hexvalue (ctx->uc_mcontext.gregs[6], regs[6], 8); - hexvalue (ctx->uc_mcontext.gregs[7], regs[7], 8); - hexvalue (ctx->uc_mcontext.gregs[8], regs[8], 8); - hexvalue (ctx->uc_mcontext.gregs[9], regs[9], 8); - hexvalue (ctx->uc_mcontext.gregs[10], regs[10], 8); - hexvalue (ctx->uc_mcontext.gregs[11], regs[11], 8); - hexvalue (ctx->uc_mcontext.gregs[12], regs[12], 8); - hexvalue (ctx->uc_mcontext.gregs[13], regs[13], 8); - hexvalue (ctx->uc_mcontext.gregs[14], regs[14], 8); - hexvalue (ctx->uc_mcontext.gregs[15], regs[15], 8); - hexvalue (ctx->uc_mcontext.psw.mask, regs[16], 8); - hexvalue (ctx->uc_mcontext.psw.addr, regs[17], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n GPR0: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" GPR1: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" GPR2: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" GPR3: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n GPR4: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" GPR5: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" GPR6: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" GPR7: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n GPR8: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" GPR9: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" GPRA: "); - ADD_MEM (regs[10], 8); - ADD_STRING (" GPRB: "); - ADD_MEM (regs[11], 8); - ADD_STRING ("\n GPRC: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" GPRD: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" GPRE: "); - ADD_MEM (regs[14], 8); - ADD_STRING (" GPRF: "); - ADD_MEM (regs[15], 8); - ADD_STRING ("\n\n PSW.MASK: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" PSW.ADDR: "); - ADD_MEM (regs[17], 8); - ADD_STRING (" TRAP: "); - ADD_MEM (regs[18], 4); - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h b/sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h deleted file mode 100644 index 3fcbfd1..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h +++ /dev/null @@ -1,131 +0,0 @@ -/* Dump registers. 64 bit S/390 version. - Copyright (C) 2001-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - GPR0: XXXXXXXXXXXXXXXX GPR1: XXXXXXXXXXXXXXXX - GPR2: XXXXXXXXXXXXXXXX GPR3: XXXXXXXXXXXXXXXX - GPR4: XXXXXXXXXXXXXXXX GPR5: XXXXXXXXXXXXXXXX - GPR6: XXXXXXXXXXXXXXXX GPR7: XXXXXXXXXXXXXXXX - GPR8: XXXXXXXXXXXXXXXX GPR9: XXXXXXXXXXXXXXXX - GPRA: XXXXXXXXXXXXXXXX GPRB: XXXXXXXXXXXXXXXX - GPRC: XXXXXXXXXXXXXXXX GPRD: XXXXXXXXXXXXXXXX - GPRE: XXXXXXXXXXXXXXXX GPRF: XXXXXXXXXXXXXXXX - - PSW.MASK: XXXXXXXXXXXXXXXX PSW.ADDR: XXXXXXXXXXXXXXXX - - ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX - ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX - ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX - ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - char regs[19][16]; - struct iovec iov[40]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[0], regs[0], 16); - hexvalue (ctx->uc_mcontext.gregs[1], regs[1], 16); - hexvalue (ctx->uc_mcontext.gregs[2], regs[2], 16); - hexvalue (ctx->uc_mcontext.gregs[3], regs[3], 16); - hexvalue (ctx->uc_mcontext.gregs[4], regs[4], 16); - hexvalue (ctx->uc_mcontext.gregs[5], regs[5], 16); - hexvalue (ctx->uc_mcontext.gregs[6], regs[6], 16); - hexvalue (ctx->uc_mcontext.gregs[7], regs[7], 16); - hexvalue (ctx->uc_mcontext.gregs[8], regs[8], 16); - hexvalue (ctx->uc_mcontext.gregs[9], regs[9], 16); - hexvalue (ctx->uc_mcontext.gregs[10], regs[10], 16); - hexvalue (ctx->uc_mcontext.gregs[11], regs[11], 16); - hexvalue (ctx->uc_mcontext.gregs[12], regs[12], 16); - hexvalue (ctx->uc_mcontext.gregs[13], regs[13], 16); - hexvalue (ctx->uc_mcontext.gregs[14], regs[14], 16); - hexvalue (ctx->uc_mcontext.gregs[15], regs[15], 16); - hexvalue (ctx->uc_mcontext.psw.mask, regs[16], 16); - hexvalue (ctx->uc_mcontext.psw.addr, regs[17], 16); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n GPR0: "); - ADD_MEM (regs[0], 16); - ADD_STRING (" GPR1: "); - ADD_MEM (regs[1], 16); - ADD_STRING (" GPR2: "); - ADD_MEM (regs[2], 16); - ADD_STRING (" GPR3: "); - ADD_MEM (regs[3], 16); - ADD_STRING ("\n GPR4: "); - ADD_MEM (regs[4], 16); - ADD_STRING (" GPR5: "); - ADD_MEM (regs[5], 16); - ADD_STRING (" GPR6: "); - ADD_MEM (regs[6], 16); - ADD_STRING (" GPR7: "); - ADD_MEM (regs[7], 16); - ADD_STRING ("\n GPR8: "); - ADD_MEM (regs[8], 16); - ADD_STRING (" GPR9: "); - ADD_MEM (regs[9], 16); - ADD_STRING (" GPRA: "); - ADD_MEM (regs[10], 16); - ADD_STRING (" GPRB: "); - ADD_MEM (regs[11], 16); - ADD_STRING ("\n GPRC: "); - ADD_MEM (regs[12], 16); - ADD_STRING (" GPRD: "); - ADD_MEM (regs[13], 16); - ADD_STRING (" GPRE: "); - ADD_MEM (regs[14], 16); - ADD_STRING (" GPRF: "); - ADD_MEM (regs[15], 16); - ADD_STRING ("\n\n PSW.MASK: "); - ADD_MEM (regs[16], 16); - ADD_STRING (" PSW.ADDR: "); - ADD_MEM (regs[17], 16); - ADD_STRING (" TRAP: "); - ADD_MEM (regs[18], 4); - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/segfault.c b/sysdeps/unix/sysv/linux/segfault.c deleted file mode 100644 index a417df9..0000000 --- a/sysdeps/unix/sysv/linux/segfault.c +++ /dev/null @@ -1,2 +0,0 @@ -#define HAVE_PROC_SELF 1 -#include <debug/segfault.c> diff --git a/sysdeps/unix/sysv/linux/sh/register-dump.h b/sysdeps/unix/sysv/linux/sh/register-dump.h deleted file mode 100644 index b37faa7..0000000 --- a/sysdeps/unix/sysv/linux/sh/register-dump.h +++ /dev/null @@ -1,263 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX - R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX - R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX - R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX - -MACL: XXXXXXXX MACH: XXXXXXXX - - PC: XXXXXXXX PR: XXXXXXXX GBR: XXXXXXXX SR: XXXXXXXX - - FR0: XXXXXXXX FR1: XXXXXXXX FR2: XXXXXXXX FR3: XXXXXXXX - FR4: XXXXXXXX FR5: XXXXXXXX FR6: XXXXXXXX FR7: XXXXXXXX - FR8: XXXXXXXX FR9: XXXXXXXX FR10: XXXXXXXX FR11: XXXXXXXX -FR12: XXXXXXXX FR13: XXXXXXXX FR14: XXXXXXXX FR15: XXXXXXXX - - XR0: XXXXXXXX XR1: XXXXXXXX XR2: XXXXXXXX XR3: XXXXXXXX - XR4: XXXXXXXX XR5: XXXXXXXX XR6: XXXXXXXX XR7: XXXXXXXX - XR8: XXXXXXXX XR9: XXXXXXXX XR10: XXXXXXXX XR11: XXXXXXXX -XR12: XXXXXXXX XR13: XXXXXXXX XR14: XXXXXXXX XR15: XXXXXXXX - -FPSCR: XXXXXXXX FPUL: XXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, struct ucontext_t *ctx) -{ - char regs[22][8]; - struct iovec iov[22 * 2 + 34 * 2 + 2]; - size_t nr = 0; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[REG_R0], regs[0], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R1], regs[1], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R2], regs[2], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R3], regs[3], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R4], regs[4], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R5], regs[5], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R6], regs[6], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R7], regs[7], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R8], regs[8], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R9], regs[9], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R10], regs[10], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R11], regs[11], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R12], regs[12], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R13], regs[13], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R14], regs[14], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_R15], regs[15], 8); - hexvalue (ctx->uc_mcontext.macl, regs[16], 8); - hexvalue (ctx->uc_mcontext.mach, regs[17], 8); - hexvalue (ctx->uc_mcontext.pc, regs[18], 8); - hexvalue (ctx->uc_mcontext.pr, regs[19], 8); - hexvalue (ctx->uc_mcontext.gbr, regs[20], 8); - hexvalue (ctx->uc_mcontext.sr, regs[21], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n R0: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" R1: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" R2: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" R3: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n R4: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" R5: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" R6: "); - ADD_MEM (regs[6], 8); - ADD_STRING (" R7: "); - ADD_MEM (regs[7], 8); - ADD_STRING ("\n R8: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" R9: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" R10: "); - ADD_MEM (regs[10], 8); - ADD_STRING (" R11: "); - ADD_MEM (regs[11], 8); - ADD_STRING ("\n R12: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" R13: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" R14: "); - ADD_MEM (regs[14], 8); - ADD_STRING (" R15: "); - ADD_MEM (regs[15], 8); - - ADD_STRING ("\n\nMACL: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" MACH: "); - ADD_MEM (regs[17], 8); - - ADD_STRING ("\n\n PC: "); - ADD_MEM (regs[18], 8); - ADD_STRING (" PR: "); - ADD_MEM (regs[19], 8); - ADD_STRING (" GBR: "); - ADD_MEM (regs[20], 8); - ADD_STRING (" SR: "); - ADD_MEM (regs[21], 8); - - ADD_STRING ("\n"); - -#ifdef __SH_FPU_ANY__ - char fpregs[34][8]; - if (ctx->uc_mcontext.ownedfp != 0) - { - hexvalue (ctx->uc_mcontext.fpregs[0], fpregs[0], 8); - hexvalue (ctx->uc_mcontext.fpregs[1], fpregs[1], 8); - hexvalue (ctx->uc_mcontext.fpregs[2], fpregs[2], 8); - hexvalue (ctx->uc_mcontext.fpregs[3], fpregs[3], 8); - hexvalue (ctx->uc_mcontext.fpregs[4], fpregs[4], 8); - hexvalue (ctx->uc_mcontext.fpregs[5], fpregs[5], 8); - hexvalue (ctx->uc_mcontext.fpregs[6], fpregs[6], 8); - hexvalue (ctx->uc_mcontext.fpregs[7], fpregs[7], 8); - hexvalue (ctx->uc_mcontext.fpregs[8], fpregs[8], 8); - hexvalue (ctx->uc_mcontext.fpregs[9], fpregs[9], 8); - hexvalue (ctx->uc_mcontext.fpregs[10], fpregs[10], 8); - hexvalue (ctx->uc_mcontext.fpregs[11], fpregs[11], 8); - hexvalue (ctx->uc_mcontext.fpregs[12], fpregs[12], 8); - hexvalue (ctx->uc_mcontext.fpregs[13], fpregs[13], 8); - hexvalue (ctx->uc_mcontext.fpregs[14], fpregs[14], 8); - hexvalue (ctx->uc_mcontext.fpregs[15], fpregs[15], 8); - hexvalue (ctx->uc_mcontext.xfpregs[0], fpregs[16], 8); - hexvalue (ctx->uc_mcontext.xfpregs[1], fpregs[17], 8); - hexvalue (ctx->uc_mcontext.xfpregs[2], fpregs[18], 8); - hexvalue (ctx->uc_mcontext.xfpregs[3], fpregs[19], 8); - hexvalue (ctx->uc_mcontext.xfpregs[4], fpregs[20], 8); - hexvalue (ctx->uc_mcontext.xfpregs[5], fpregs[21], 8); - hexvalue (ctx->uc_mcontext.xfpregs[6], fpregs[22], 8); - hexvalue (ctx->uc_mcontext.xfpregs[7], fpregs[23], 8); - hexvalue (ctx->uc_mcontext.xfpregs[8], fpregs[24], 8); - hexvalue (ctx->uc_mcontext.xfpregs[9], fpregs[25], 8); - hexvalue (ctx->uc_mcontext.xfpregs[10], fpregs[26], 8); - hexvalue (ctx->uc_mcontext.xfpregs[11], fpregs[27], 8); - hexvalue (ctx->uc_mcontext.xfpregs[12], fpregs[28], 8); - hexvalue (ctx->uc_mcontext.xfpregs[13], fpregs[29], 8); - hexvalue (ctx->uc_mcontext.xfpregs[14], fpregs[30], 8); - hexvalue (ctx->uc_mcontext.xfpregs[15], fpregs[31], 8); - hexvalue (ctx->uc_mcontext.fpscr, fpregs[32], 8); - hexvalue (ctx->uc_mcontext.fpul, fpregs[33], 8); - - ADD_STRING ("\n\n FR0: "); - ADD_MEM (fpregs[0], 8); - ADD_STRING (" FR1: "); - ADD_MEM (fpregs[1], 8); - ADD_STRING (" FR2: "); - ADD_MEM (fpregs[2], 8); - ADD_STRING (" FR3: "); - ADD_MEM (fpregs[3], 8); - ADD_STRING ("\n FR4: "); - ADD_MEM (fpregs[4], 8); - ADD_STRING (" FR5: "); - ADD_MEM (fpregs[5], 8); - ADD_STRING (" FR6: "); - ADD_MEM (fpregs[6], 8); - ADD_STRING (" FR7: "); - ADD_MEM (fpregs[7], 8); - ADD_STRING ("\n FR8: "); - ADD_MEM (fpregs[8], 8); - ADD_STRING (" FR9: "); - ADD_MEM (fpregs[9], 8); - ADD_STRING (" FR10: "); - ADD_MEM (fpregs[10], 8); - ADD_STRING (" FR11: "); - ADD_MEM (fpregs[11], 8); - ADD_STRING ("\nFR12: "); - ADD_MEM (fpregs[12], 8); - ADD_STRING (" FR13: "); - ADD_MEM (fpregs[13], 8); - ADD_STRING (" FR14: "); - ADD_MEM (fpregs[14], 8); - ADD_STRING (" FR15: "); - ADD_MEM (fpregs[15], 8); - ADD_STRING ("\n\n XR0: "); - ADD_MEM (fpregs[16], 8); - ADD_STRING (" XR1: "); - ADD_MEM (fpregs[17], 8); - ADD_STRING (" XR2: "); - ADD_MEM (fpregs[18], 8); - ADD_STRING (" XR3: "); - ADD_MEM (fpregs[19], 8); - ADD_STRING ("\n XR4: "); - ADD_MEM (fpregs[20], 8); - ADD_STRING (" XR5: "); - ADD_MEM (fpregs[21], 8); - ADD_STRING (" XR6: "); - ADD_MEM (fpregs[22], 8); - ADD_STRING (" XR7: "); - ADD_MEM (fpregs[23], 8); - ADD_STRING ("\n XR8: "); - ADD_MEM (fpregs[24], 8); - ADD_STRING (" XR9: "); - ADD_MEM (fpregs[25], 8); - ADD_STRING (" XR10: "); - ADD_MEM (fpregs[26], 8); - ADD_STRING (" XR11: "); - ADD_MEM (fpregs[27], 8); - ADD_STRING ("\nXR12: "); - ADD_MEM (fpregs[28], 8); - ADD_STRING (" XR13: "); - ADD_MEM (fpregs[29], 8); - ADD_STRING (" XR14: "); - ADD_MEM (fpregs[30], 8); - ADD_STRING (" XR15: "); - ADD_MEM (fpregs[31], 8); - - ADD_STRING ("\n\nFPSCR: "); - ADD_MEM (fpregs[32], 8); - ADD_STRING (" FPUL: "); - ADD_MEM (fpregs[33], 8); - - ADD_STRING ("\n"); - } -#endif /* __SH_FPU_ANY__ */ - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h b/sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h deleted file mode 100644 index 4c27c1e..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h +++ /dev/null @@ -1,342 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - PSR: XXXXXXXX PC: XXXXXXXX NPC: XXXXXXXX Y: XXXXXXXX - g0: 00000000 g1: XXXXXXXX g2: XXXXXXXX g3: XXXXXXXX - g4: XXXXXXXX g5: XXXXXXXX g6: XXXXXXXX g7: XXXXXXXX - o0: XXXXXXXX o1: XXXXXXXX o2: XXXXXXXX o3: XXXXXXXX - o4: XXXXXXXX o5: XXXXXXXX sp: XXXXXXXX o7: XXXXXXXX - l0: XXXXXXXX l1: XXXXXXXX l2: XXXXXXXX l3: XXXXXXXX - l4: XXXXXXXX l5: XXXXXXXX l6: XXXXXXXX l7: XXXXXXXX - i0: XXXXXXXX i1: XXXXXXXX i2: XXXXXXXX i3: XXXXXXXX - i4: XXXXXXXX i5: XXXXXXXX fp: XXXXXXXX i7: XXXXXXXX - - followed on sun4, sun4c, sun4d, sun4m by: - - Old mask: XXXXXXXX FSR: XXXXXXXX FPQ: XXXXXXXX - f0: XXXXXXXXXXXXXXXX f2: XXXXXXXXXXXXXXXX f4: XXXXXXXXXXXXXXXX - f6: XXXXXXXXXXXXXXXX f8: XXXXXXXXXXXXXXXX f10: XXXXXXXXXXXXXXXX - f12: XXXXXXXXXXXXXXXX f14: XXXXXXXXXXXXXXXX f16: XXXXXXXXXXXXXXXX - f18: XXXXXXXXXXXXXXXX f20: XXXXXXXXXXXXXXXX f22: XXXXXXXXXXXXXXXX - f24: XXXXXXXXXXXXXXXX f26: XXXXXXXXXXXXXXXX f28: XXXXXXXXXXXXXXXX - f30: XXXXXXXXXXXXXXXX - - and on sun4u by: - - Old mask: XXXXXXXX XFSR: XXXXXXXXXXXXXXXX GSR: XX FPRS: X - f0: XXXXXXXXXXXXXXXX f2: XXXXXXXXXXXXXXXX f4: XXXXXXXXXXXXXXXX - f6: XXXXXXXXXXXXXXXX f8: XXXXXXXXXXXXXXXX f10: XXXXXXXXXXXXXXXX - f12: XXXXXXXXXXXXXXXX f14: XXXXXXXXXXXXXXXX f16: XXXXXXXXXXXXXXXX - f18: XXXXXXXXXXXXXXXX f20: XXXXXXXXXXXXXXXX f22: XXXXXXXXXXXXXXXX - f24: XXXXXXXXXXXXXXXX f26: XXXXXXXXXXXXXXXX f28: XXXXXXXXXXXXXXXX - f30: XXXXXXXXXXXXXXXX f32: XXXXXXXXXXXXXXXX f34: XXXXXXXXXXXXXXXX - f36: XXXXXXXXXXXXXXXX f38: XXXXXXXXXXXXXXXX f40: XXXXXXXXXXXXXXXX - f42: XXXXXXXXXXXXXXXX f44: XXXXXXXXXXXXXXXX f46: XXXXXXXXXXXXXXXX - f48: XXXXXXXXXXXXXXXX f50: XXXXXXXXXXXXXXXX f52: XXXXXXXXXXXXXXXX - f54: XXXXXXXXXXXXXXXX f56: XXXXXXXXXXXXXXXX f58: XXXXXXXXXXXXXXXX - f60: XXXXXXXXXXXXXXXX f62: XXXXXXXXXXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -struct __siginfo_sparc32_fpu -{ - unsigned int si_float_regs[32]; - unsigned int si_fsr; - unsigned int si_fpq; -}; -struct __siginfo_sparc64_fpu -{ - unsigned int si_float_regs[64]; - unsigned int si_xfsr; - unsigned int si_fsr; - unsigned int _pad1; - unsigned int si_gsr; - unsigned int _pad2; - unsigned int si_fprs; -}; - -/* Unlike other architectures, sparc32 passes pt_regs32 REGS pointer as - the third argument to a sa_sigaction handler with SA_SIGINFO enabled. */ -static void -register_dump (int fd, void *ctx) -{ - char regs[36][8]; - char fregs[68][8]; - struct iovec iov[150]; - size_t nr = 0; - int i; - struct pt_regs32 *ptregs = (struct pt_regs32 *) ctx; - struct compat_sigset_t - { - unsigned int sig[2]; - }; - struct compat_sigset_t *mask = (struct compat_sigset_t *)(ptregs + 1); - unsigned int *r = (unsigned int *) ptregs->u_regs[14]; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ptregs->psr, regs[0], 8); - hexvalue (ptregs->pc, regs[1], 8); - hexvalue (ptregs->npc, regs[2], 8); - hexvalue (ptregs->y, regs[3], 8); - for (i = 1; i <= 15; i++) - hexvalue (ptregs->u_regs[i], regs[3+i], 8); - for (i = 0; i <= 15; i++) - hexvalue (r[i], regs[19+i], 8); - - hexvalue (mask->sig[0], regs[35], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n PSR: "); - ADD_MEM (regs[0], 8); - ADD_STRING (" PC: "); - ADD_MEM (regs[1], 8); - ADD_STRING (" NPC: "); - ADD_MEM (regs[2], 8); - ADD_STRING (" Y: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n g0: 00000000 g1: "); - ADD_MEM (regs[4], 8); - ADD_STRING (" g2: "); - ADD_MEM (regs[5], 8); - ADD_STRING (" g3: "); - ADD_MEM (regs[6], 8); - ADD_STRING ("\n g4: "); - ADD_MEM (regs[7], 8); - ADD_STRING (" g5: "); - ADD_MEM (regs[8], 8); - ADD_STRING (" g6: "); - ADD_MEM (regs[9], 8); - ADD_STRING (" g7: "); - ADD_MEM (regs[10], 8); - ADD_STRING ("\n o0: "); - ADD_MEM (regs[11], 8); - ADD_STRING (" o1: "); - ADD_MEM (regs[12], 8); - ADD_STRING (" o2: "); - ADD_MEM (regs[13], 8); - ADD_STRING (" o3: "); - ADD_MEM (regs[14], 8); - ADD_STRING ("\n o4: "); - ADD_MEM (regs[15], 8); - ADD_STRING (" o5: "); - ADD_MEM (regs[16], 8); - ADD_STRING (" sp: "); - ADD_MEM (regs[17], 8); - ADD_STRING (" o7: "); - ADD_MEM (regs[18], 8); - ADD_STRING ("\n l0: "); - ADD_MEM (regs[19], 8); - ADD_STRING (" l1: "); - ADD_MEM (regs[20], 8); - ADD_STRING (" l2: "); - ADD_MEM (regs[21], 8); - ADD_STRING (" l3: "); - ADD_MEM (regs[22], 8); - ADD_STRING ("\n l4: "); - ADD_MEM (regs[23], 8); - ADD_STRING (" l5: "); - ADD_MEM (regs[24], 8); - ADD_STRING (" l6: "); - ADD_MEM (regs[25], 8); - ADD_STRING (" l7: "); - ADD_MEM (regs[26], 8); - ADD_STRING ("\n i0: "); - ADD_MEM (regs[27], 8); - ADD_STRING (" i1: "); - ADD_MEM (regs[28], 8); - ADD_STRING (" i2: "); - ADD_MEM (regs[29], 8); - ADD_STRING (" i3: "); - ADD_MEM (regs[30], 8); - ADD_STRING ("\n i4: "); - ADD_MEM (regs[31], 8); - ADD_STRING (" i5: "); - ADD_MEM (regs[32], 8); - ADD_STRING (" fp: "); - ADD_MEM (regs[33], 8); - ADD_STRING (" i7: "); - ADD_MEM (regs[34], 8); - ADD_STRING ("\n\n Old mask: "); - ADD_MEM (regs[35], 8); - - if ((ptregs->psr & 0xff000000) == 0xff000000) - { - struct __siginfo_sparc64_fpu *f = *(struct __siginfo_sparc64_fpu **) - (mask + 1); - - if (f != NULL) - { - for (i = 0; i < 64; i++) - hexvalue (f->si_float_regs[i], fregs[i], 8); - hexvalue (f->si_xfsr, fregs[64], 8); - hexvalue (f->si_fsr, fregs[65], 8); - hexvalue (f->si_gsr, fregs[66], 2); - hexvalue (f->si_fprs, fregs[67], 1); - ADD_STRING (" XFSR: "); - ADD_MEM (fregs[64], 8); - ADD_MEM (fregs[65], 8); - ADD_STRING (" GSR: "); - ADD_MEM (fregs[66], 2); - ADD_STRING (" FPRS: "); - ADD_MEM (fregs[67], 1); - ADD_STRING ("\n f0: "); - ADD_MEM (fregs[0], 16); - ADD_STRING (" f2: "); - ADD_MEM (fregs[2], 16); - ADD_STRING (" f4: "); - ADD_MEM (fregs[4], 16); - ADD_STRING ("\n f6: "); - ADD_MEM (fregs[6], 16); - ADD_STRING (" f8: "); - ADD_MEM (fregs[8], 16); - ADD_STRING (" f10: "); - ADD_MEM (fregs[10], 16); - ADD_STRING ("\n f12: "); - ADD_MEM (fregs[12], 16); - ADD_STRING (" f14: "); - ADD_MEM (fregs[14], 16); - ADD_STRING (" f16: "); - ADD_MEM (fregs[16], 16); - ADD_STRING ("\n f18: "); - ADD_MEM (fregs[18], 16); - ADD_STRING (" f20: "); - ADD_MEM (fregs[20], 16); - ADD_STRING (" f22: "); - ADD_MEM (fregs[22], 16); - ADD_STRING ("\n f24: "); - ADD_MEM (fregs[24], 16); - ADD_STRING (" f26: "); - ADD_MEM (fregs[26], 16); - ADD_STRING (" f28: "); - ADD_MEM (fregs[28], 16); - ADD_STRING ("\n f30: "); - ADD_MEM (fregs[30], 16); - ADD_STRING (" f32: "); - ADD_MEM (fregs[32], 16); - ADD_STRING (" f34: "); - ADD_MEM (fregs[34], 16); - ADD_STRING ("\n f36: "); - ADD_MEM (fregs[36], 16); - ADD_STRING (" f38: "); - ADD_MEM (fregs[38], 16); - ADD_STRING (" f40: "); - ADD_MEM (fregs[40], 16); - ADD_STRING ("\n f42: "); - ADD_MEM (fregs[42], 16); - ADD_STRING (" f44: "); - ADD_MEM (fregs[44], 16); - ADD_STRING (" f46: "); - ADD_MEM (fregs[46], 16); - ADD_STRING ("\n f48: "); - ADD_MEM (fregs[48], 16); - ADD_STRING (" f50: "); - ADD_MEM (fregs[50], 16); - ADD_STRING (" f52: "); - ADD_MEM (fregs[52], 16); - ADD_STRING ("\n f54: "); - ADD_MEM (fregs[54], 16); - ADD_STRING (" f56: "); - ADD_MEM (fregs[56], 16); - ADD_STRING (" f58: "); - ADD_MEM (fregs[58], 16); - ADD_STRING ("\n f60: "); - ADD_MEM (fregs[60], 16); - ADD_STRING (" f62: "); - ADD_MEM (fregs[62], 16); - } - } - else - { - struct __siginfo_sparc32_fpu *f = *(struct __siginfo_sparc32_fpu **) - (mask + 1); - - if (f != NULL) - { - for (i = 0; i < 32; i++) - hexvalue (f->si_float_regs[i], fregs[i], 8); - hexvalue (f->si_fsr, fregs[64], 8); - hexvalue (f->si_fpq, fregs[65], 8); - ADD_STRING (" FSR: "); - ADD_MEM (fregs[64], 8); - ADD_STRING (" FPQ: "); - ADD_MEM (fregs[65], 8); - ADD_STRING ("\n f0: "); - ADD_MEM (fregs[0], 16); - ADD_STRING (" f2: "); - ADD_MEM (fregs[2], 16); - ADD_STRING (" f4: "); - ADD_MEM (fregs[4], 16); - ADD_STRING ("\n f6: "); - ADD_MEM (fregs[6], 16); - ADD_STRING (" f8: "); - ADD_MEM (fregs[8], 16); - ADD_STRING (" f10: "); - ADD_MEM (fregs[10], 16); - ADD_STRING ("\n f12: "); - ADD_MEM (fregs[12], 16); - ADD_STRING (" f14: "); - ADD_MEM (fregs[14], 16); - ADD_STRING (" f16: "); - ADD_MEM (fregs[16], 16); - ADD_STRING ("\n f18: "); - ADD_MEM (fregs[18], 16); - ADD_STRING (" f20: "); - ADD_MEM (fregs[20], 16); - ADD_STRING (" f22: "); - ADD_MEM (fregs[22], 16); - ADD_STRING ("\n f24: "); - ADD_MEM (fregs[24], 16); - ADD_STRING (" f26: "); - ADD_MEM (fregs[26], 16); - ADD_STRING (" f28: "); - ADD_MEM (fregs[28], 16); - ADD_STRING ("\n f30: "); - ADD_MEM (fregs[30], 16); - } - } - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h b/sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h deleted file mode 100644 index de68ccb..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h +++ /dev/null @@ -1,273 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - TSTATE: XXXXXXXXXXXXXXXX TPC: XXXXXXXXXXXXXXXX TNPC: XXXXXXXXXXXXXXXX - Y: XXXXXXXX - g0: 0000000000000000 g1: XXXXXXXXXXXXXXXX g2: XXXXXXXXXXXXXXXX - g3: XXXXXXXXXXXXXXXX g4: XXXXXXXXXXXXXXXX g5: XXXXXXXXXXXXXXXX - g6: XXXXXXXXXXXXXXXX g7: XXXXXXXXXXXXXXXX - o0: XXXXXXXXXXXXXXXX o1: XXXXXXXXXXXXXXXX o2: XXXXXXXXXXXXXXXX - o3: XXXXXXXXXXXXXXXX o4: XXXXXXXXXXXXXXXX o5: XXXXXXXXXXXXXXXX - sp: XXXXXXXXXXXXXXXX o7: XXXXXXXXXXXXXXXX - l0: XXXXXXXXXXXXXXXX l1: XXXXXXXXXXXXXXXX l2: XXXXXXXXXXXXXXXX - l3: XXXXXXXXXXXXXXXX l4: XXXXXXXXXXXXXXXX l5: XXXXXXXXXXXXXXXX - l6: XXXXXXXXXXXXXXXX l7: XXXXXXXXXXXXXXXX - i0: XXXXXXXXXXXXXXXX i1: XXXXXXXXXXXXXXXX i2: XXXXXXXXXXXXXXXX - i3: XXXXXXXXXXXXXXXX i4: XXXXXXXXXXXXXXXX i5: XXXXXXXXXXXXXXXX - fp: XXXXXXXXXXXXXXXX i7: XXXXXXXXXXXXXXXX - - Mask: XXXXXXXXXXXXXXXX XFSR: XXXXXXXXXXXXXXXX GSR: XX FPRS: X - f0: XXXXXXXXXXXXXXXX f2: XXXXXXXXXXXXXXXX f4: XXXXXXXXXXXXXXXX - f6: XXXXXXXXXXXXXXXX f8: XXXXXXXXXXXXXXXX f10: XXXXXXXXXXXXXXXX - f12: XXXXXXXXXXXXXXXX f14: XXXXXXXXXXXXXXXX f16: XXXXXXXXXXXXXXXX - f18: XXXXXXXXXXXXXXXX f20: XXXXXXXXXXXXXXXX f22: XXXXXXXXXXXXXXXX - f24: XXXXXXXXXXXXXXXX f26: XXXXXXXXXXXXXXXX f28: XXXXXXXXXXXXXXXX - f30: XXXXXXXXXXXXXXXX f32: XXXXXXXXXXXXXXXX f34: XXXXXXXXXXXXXXXX - f36: XXXXXXXXXXXXXXXX f38: XXXXXXXXXXXXXXXX f40: XXXXXXXXXXXXXXXX - f42: XXXXXXXXXXXXXXXX f44: XXXXXXXXXXXXXXXX f46: XXXXXXXXXXXXXXXX - f48: XXXXXXXXXXXXXXXX f50: XXXXXXXXXXXXXXXX f52: XXXXXXXXXXXXXXXX - f54: XXXXXXXXXXXXXXXX f56: XXXXXXXXXXXXXXXX f58: XXXXXXXXXXXXXXXX - f60: XXXXXXXXXXXXXXXX f62: XXXXXXXXXXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -/* The sparc64 kernel signal frame for SA_SIGINFO is defined as: - - struct rt_signal_frame - { - struct sparc_stackf ss; - siginfo_t info; - struct pt_regs regs; <- void *ctx - __siginfo_fpu_t *fpu_save; - stack_t stack; - sigset_t mask; - __siginfo_rwin_t *rwin_save; - }; - - Unlike other architectures, sparc32 passes pt_regs32 REGS pointers as - the third argument to a sa_sigaction handler with SA_SIGINFO enabled. */ - -static void -register_dump (int fd, void *ctx) -{ - char regs[36][16]; - char fregs[68][8]; - struct iovec iov[150]; - size_t nr = 0; - int i; - struct pt_regs *ptregs = (struct pt_regs*) ((siginfo_t *)ctx + 1); - unsigned long *r = (unsigned long *) (ptregs->u_regs[14] + STACK_BIAS); - __siginfo_fpu_t *f = (__siginfo_fpu_t *)(ptregs + 1); - struct kernel_sigset_t { - unsigned long sig[1]; - } *mask = (struct kernel_sigset_t *)((stack_t *)(f + 1) + 1); - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ptregs->tstate, regs[0], 16); - hexvalue (ptregs->tpc, regs[1], 16); - hexvalue (ptregs->tnpc, regs[2], 16); - hexvalue (ptregs->y, regs[3], 8); - for (i = 1; i <= 15; i++) - hexvalue (ptregs->u_regs[i], regs[3+i], 16); - for (i = 0; i <= 15; i++) - hexvalue (r[i], regs[19+i], 16); - hexvalue (mask->sig[0], regs[35], 16); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n TSTATE: "); - ADD_MEM (regs[0], 16); - ADD_STRING (" TPC: "); - ADD_MEM (regs[1], 16); - ADD_STRING (" TNPC: "); - ADD_MEM (regs[2], 16); - ADD_STRING ("\n Y: "); - ADD_MEM (regs[3], 8); - ADD_STRING ("\n g0: 0000000000000000 g1: "); - ADD_MEM (regs[4], 16); - ADD_STRING (" g2: "); - ADD_MEM (regs[5], 16); - ADD_STRING ("\n g3: "); - ADD_MEM (regs[6], 16); - ADD_STRING (" g4: "); - ADD_MEM (regs[7], 16); - ADD_STRING (" g5: "); - ADD_MEM (regs[8], 16); - ADD_STRING ("\n g6: "); - ADD_MEM (regs[9], 16); - ADD_STRING (" g7: "); - ADD_MEM (regs[10], 16); - ADD_STRING ("\n o0: "); - ADD_MEM (regs[11], 16); - ADD_STRING (" o1: "); - ADD_MEM (regs[12], 16); - ADD_STRING (" o2: "); - ADD_MEM (regs[13], 16); - ADD_STRING ("\n o3: "); - ADD_MEM (regs[14], 16); - ADD_STRING (" o4: "); - ADD_MEM (regs[15], 16); - ADD_STRING (" o5: "); - ADD_MEM (regs[16], 16); - ADD_STRING ("\n sp: "); - ADD_MEM (regs[17], 16); - ADD_STRING (" o7: "); - ADD_MEM (regs[18], 16); - ADD_STRING ("\n l0: "); - ADD_MEM (regs[19], 16); - ADD_STRING (" l1: "); - ADD_MEM (regs[20], 16); - ADD_STRING (" l2: "); - ADD_MEM (regs[21], 16); - ADD_STRING ("\n l3: "); - ADD_MEM (regs[22], 16); - ADD_STRING (" l4: "); - ADD_MEM (regs[23], 16); - ADD_STRING (" l5: "); - ADD_MEM (regs[24], 16); - ADD_STRING ("\n l6: "); - ADD_MEM (regs[25], 16); - ADD_STRING (" l7: "); - ADD_MEM (regs[26], 16); - ADD_STRING ("\n i0: "); - ADD_MEM (regs[27], 16); - ADD_STRING (" i1: "); - ADD_MEM (regs[28], 16); - ADD_STRING (" i2: "); - ADD_MEM (regs[29], 16); - ADD_STRING ("\n i3: "); - ADD_MEM (regs[30], 16); - ADD_STRING (" i4: "); - ADD_MEM (regs[31], 16); - ADD_STRING (" i5: "); - ADD_MEM (regs[32], 16); - ADD_STRING ("\n fp: "); - ADD_MEM (regs[33], 16); - ADD_STRING (" i7: "); - ADD_MEM (regs[34], 16); - ADD_STRING ("\n\n Mask: "); - ADD_MEM (regs[35], 16); - - if (f != NULL) - { - for (i = 0; i < 64; i++) - hexvalue (f->si_float_regs[i], fregs[i], 8); - hexvalue (f->si_fsr, fregs[64], 16); - hexvalue (f->si_gsr, fregs[66], 2); - hexvalue (f->si_fprs, fregs[67], 1); - ADD_STRING (" XFSR: "); - ADD_MEM (fregs[64], 16); - ADD_STRING (" GSR: "); - ADD_MEM (fregs[66], 2); - ADD_STRING (" FPRS: "); - ADD_MEM (fregs[67], 1); - ADD_STRING ("\n f0: "); - ADD_MEM (fregs[0], 16); - ADD_STRING (" f2: "); - ADD_MEM (fregs[2], 16); - ADD_STRING (" f4: "); - ADD_MEM (fregs[4], 16); - ADD_STRING ("\n f6: "); - ADD_MEM (fregs[6], 16); - ADD_STRING (" f8: "); - ADD_MEM (fregs[8], 16); - ADD_STRING (" f10: "); - ADD_MEM (fregs[10], 16); - ADD_STRING ("\n f12: "); - ADD_MEM (fregs[12], 16); - ADD_STRING (" f14: "); - ADD_MEM (fregs[14], 16); - ADD_STRING (" f16: "); - ADD_MEM (fregs[16], 16); - ADD_STRING ("\n f18: "); - ADD_MEM (fregs[18], 16); - ADD_STRING (" f20: "); - ADD_MEM (fregs[20], 16); - ADD_STRING (" f22: "); - ADD_MEM (fregs[22], 16); - ADD_STRING ("\n f24: "); - ADD_MEM (fregs[24], 16); - ADD_STRING (" f26: "); - ADD_MEM (fregs[26], 16); - ADD_STRING (" f28: "); - ADD_MEM (fregs[28], 16); - ADD_STRING ("\n f30: "); - ADD_MEM (fregs[30], 16); - ADD_STRING (" f32: "); - ADD_MEM (fregs[32], 16); - ADD_STRING (" f34: "); - ADD_MEM (fregs[34], 16); - ADD_STRING ("\n f36: "); - ADD_MEM (fregs[36], 16); - ADD_STRING (" f38: "); - ADD_MEM (fregs[38], 16); - ADD_STRING (" f40: "); - ADD_MEM (fregs[40], 16); - ADD_STRING ("\n f42: "); - ADD_MEM (fregs[42], 16); - ADD_STRING (" f44: "); - ADD_MEM (fregs[44], 16); - ADD_STRING (" f46: "); - ADD_MEM (fregs[46], 16); - ADD_STRING ("\n f48: "); - ADD_MEM (fregs[48], 16); - ADD_STRING (" f50: "); - ADD_MEM (fregs[50], 16); - ADD_STRING (" f52: "); - ADD_MEM (fregs[52], 16); - ADD_STRING ("\n f54: "); - ADD_MEM (fregs[54], 16); - ADD_STRING (" f56: "); - ADD_MEM (fregs[56], 16); - ADD_STRING (" f58: "); - ADD_MEM (fregs[58], 16); - ADD_STRING ("\n f60: "); - ADD_MEM (fregs[60], 16); - ADD_STRING (" f62: "); - ADD_MEM (fregs[62], 16); - } - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) diff --git a/sysdeps/unix/sysv/linux/x86_64/register-dump.h b/sysdeps/unix/sysv/linux/x86_64/register-dump.h deleted file mode 100644 index 0487112..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/register-dump.h +++ /dev/null @@ -1,345 +0,0 @@ -/* Dump registers. - Copyright (C) 2001-2022 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <sys/uio.h> -#include <_itoa.h> - -/* We will print the register dump in this format: - - RAX: XXXXXXXXXXXXXXXX RBX: XXXXXXXXXXXXXXXX RCX: XXXXXXXXXXXXXXXX - RDX: XXXXXXXXXXXXXXXX RSI: XXXXXXXXXXXXXXXX RDI: XXXXXXXXXXXXXXXX - RBP: XXXXXXXXXXXXXXXX R8 : XXXXXXXXXXXXXXXX R9 : XXXXXXXXXXXXXXXX - R10: XXXXXXXXXXXXXXXX R11: XXXXXXXXXXXXXXXX R12: XXXXXXXXXXXXXXXX - R13: XXXXXXXXXXXXXXXX R14: XXXXXXXXXXXXXXXX R15: XXXXXXXXXXXXXXXX - RSP: XXXXXXXXXXXXXXXX - - RIP: XXXXXXXXXXXXXXXX EFLAGS: XXXXXXXX - - CS: XXXX DS: XXXX ES: XXXX FS: XXXX GS: XXXX - - Trap: XXXXXXXX Error: XXXXXXXX OldMask: XXXXXXXX - RSP/SIGNAL: XXXXXXXXXXXXXXXX CR2: XXXXXXXX - - FPUCW: XXXXXXXX FPUSW: XXXXXXXX TAG: XXXXXXXX - IPOFF: XXXXXXXX CSSEL: XXXX DATAOFF: XXXXXXXX DATASEL: XXXX - - ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX - ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX - ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX - ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX - - mxcsr: XXXX - XMM0 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM1 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM2 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM3 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM4 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM5 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM6 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM7 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM8 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM9 : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM10: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM11: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM12: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM13: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - XMM14: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XMM15: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - - */ - -static void -hexvalue (unsigned long int value, char *buf, size_t len) -{ - char *cp = _itoa_word (value, buf + len, 16, 0); - while (cp > buf) - *--cp = '0'; -} - -static void -register_dump (int fd, ucontext_t *ctx) -{ - char regs[25][16]; - char fpregs[30][8]; - char xmmregs[16][32]; - struct iovec iov[147]; - size_t nr = 0; - int i; - -#define ADD_STRING(str) \ - iov[nr].iov_base = (char *) str; \ - iov[nr].iov_len = strlen (str); \ - ++nr -#define ADD_MEM(str, len) \ - iov[nr].iov_base = str; \ - iov[nr].iov_len = len; \ - ++nr - - /* Generate strings of register contents. */ - hexvalue (ctx->uc_mcontext.gregs[REG_RAX], regs[0], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RBX], regs[1], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RCX], regs[2], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RDX], regs[3], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RSI], regs[4], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RDI], regs[5], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RBP], regs[6], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R8], regs[7], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R9], regs[8], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R10], regs[9], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R11], regs[10], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R12], regs[11], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R13], regs[12], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R14], regs[13], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_R15], regs[14], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RSP], regs[15], 16); - hexvalue (ctx->uc_mcontext.gregs[REG_RIP], regs[16], 16); - - hexvalue (ctx->uc_mcontext.gregs[REG_EFL], regs[17], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_CSGSFS] & 0xffff, regs[18], 4); - hexvalue ((ctx->uc_mcontext.gregs[REG_CSGSFS] >> 16) & 0xffff, regs[19], 4); - hexvalue ((ctx->uc_mcontext.gregs[REG_CSGSFS] >> 32) & 0xffff, regs[20], 4); - /* hexvalue (ctx->ss, regs[23], 4); */ - hexvalue (ctx->uc_mcontext.gregs[REG_TRAPNO], regs[21], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_ERR], regs[22], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_OLDMASK], regs[23], 8); - hexvalue (ctx->uc_mcontext.gregs[REG_CR2], regs[24], 8); - - /* Generate the output. */ - ADD_STRING ("Register dump:\n\n RAX: "); - ADD_MEM (regs[0], 16); - ADD_STRING (" RBX: "); - ADD_MEM (regs[1], 16); - ADD_STRING (" RCX: "); - ADD_MEM (regs[2], 16); - ADD_STRING ("\n RDX: "); - ADD_MEM (regs[3], 16); - ADD_STRING (" RSI: "); - ADD_MEM (regs[4], 16); - ADD_STRING (" RDI: "); - ADD_MEM (regs[5], 16); - ADD_STRING ("\n RBP: "); - ADD_MEM (regs[6], 16); - ADD_STRING (" R8 : "); - ADD_MEM (regs[7], 16); - ADD_STRING (" R9 : "); - ADD_MEM (regs[8], 16); - ADD_STRING ("\n R10: "); - ADD_MEM (regs[9], 16); - ADD_STRING (" R11: "); - ADD_MEM (regs[10], 16); - ADD_STRING (" R12: "); - ADD_MEM (regs[11], 16); - ADD_STRING ("\n R13: "); - ADD_MEM (regs[12], 16); - ADD_STRING (" R14: "); - ADD_MEM (regs[13], 16); - ADD_STRING (" R15: "); - ADD_MEM (regs[14], 16); - ADD_STRING ("\n RSP: "); - ADD_MEM (regs[15], 16); - ADD_STRING ("\n\n RIP: "); - ADD_MEM (regs[16], 16); - ADD_STRING (" EFLAGS: "); - ADD_MEM (regs[17], 8); - ADD_STRING ("\n\n CS: "); - ADD_MEM (regs[18], 4); - ADD_STRING (" FS: "); - ADD_MEM (regs[19], 4); - ADD_STRING (" GS: "); - ADD_MEM (regs[20], 4); - /* - ADD_STRING (" SS: "); - ADD_MEM (regs[23], 4); - */ - ADD_STRING ("\n\n Trap: "); - ADD_MEM (regs[21], 8); - ADD_STRING (" Error: "); - ADD_MEM (regs[22], 8); - ADD_STRING (" OldMask: "); - ADD_MEM (regs[23], 8); - ADD_STRING (" CR2: "); - ADD_MEM (regs[24], 8); - - if (ctx->uc_mcontext.fpregs != NULL) - { - - /* Generate output for the FPU control/status registers. */ - hexvalue (ctx->uc_mcontext.fpregs->cwd, fpregs[0], 8); - hexvalue (ctx->uc_mcontext.fpregs->swd, fpregs[1], 8); - hexvalue (ctx->uc_mcontext.fpregs->ftw, fpregs[2], 8); - hexvalue (ctx->uc_mcontext.fpregs->rip, fpregs[3], 8); - hexvalue (ctx->uc_mcontext.fpregs->rdp, fpregs[4], 8); - - ADD_STRING ("\n\n FPUCW: "); - ADD_MEM (fpregs[0], 8); - ADD_STRING (" FPUSW: "); - ADD_MEM (fpregs[1], 8); - ADD_STRING (" TAG: "); - ADD_MEM (fpregs[2], 8); - ADD_STRING ("\n RIP: "); - ADD_MEM (fpregs[3], 8); - ADD_STRING (" RDP: "); - ADD_MEM (fpregs[4], 8); - - /* Now the real FPU registers. */ - hexvalue (ctx->uc_mcontext.fpregs->_st[0].exponent, fpregs[5], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[0].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[0].significand[2], fpregs[6], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[0].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[0].significand[0], fpregs[7], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[1].exponent, fpregs[8], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[1].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[1].significand[2], fpregs[9], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[1].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[1].significand[0], fpregs[10], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[2].exponent, fpregs[11], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[2].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[2].significand[2], fpregs[12], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[2].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[2].significand[0], fpregs[13], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[3].exponent, fpregs[14], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[3].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[3].significand[2], fpregs[15], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[3].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[3].significand[0], fpregs[16], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[4].exponent, fpregs[17], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[4].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[4].significand[2], fpregs[18], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[4].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[4].significand[0], fpregs[19], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[5].exponent, fpregs[20], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[5].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[5].significand[2], fpregs[21], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[5].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[5].significand[0], fpregs[22], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[6].exponent, fpregs[23], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[6].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[6].significand[2], fpregs[24], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[6].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[6].significand[0], fpregs[25], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[7].exponent, fpregs[26], 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[7].significand[3] << 16 - | ctx->uc_mcontext.fpregs->_st[7].significand[2], fpregs[27], - 8); - hexvalue (ctx->uc_mcontext.fpregs->_st[7].significand[1] << 16 - | ctx->uc_mcontext.fpregs->_st[7].significand[0], fpregs[28], - 8); - - hexvalue (ctx->uc_mcontext.fpregs->mxcsr, fpregs[29], 4); - - for (i = 0; i < 16; i++) - hexvalue (ctx->uc_mcontext.fpregs->_xmm[i].element[3] << 24 - | ctx->uc_mcontext.fpregs->_xmm[i].element[2] << 16 - | ctx->uc_mcontext.fpregs->_xmm[i].element[1] << 8 - | ctx->uc_mcontext.fpregs->_xmm[i].element[0], xmmregs[i], - 32); - - - ADD_STRING ("\n\n ST(0) "); - ADD_MEM (fpregs[5], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[6], 8); - ADD_MEM (fpregs[7], 8); - ADD_STRING (" ST(1) "); - ADD_MEM (fpregs[8], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[9], 8); - ADD_MEM (fpregs[10], 8); - ADD_STRING ("\n ST(2) "); - ADD_MEM (fpregs[11], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[12], 8); - ADD_MEM (fpregs[13], 8); - ADD_STRING (" ST(3) "); - ADD_MEM (fpregs[14], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[15], 8); - ADD_MEM (fpregs[16], 8); - ADD_STRING ("\n ST(4) "); - ADD_MEM (fpregs[17], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[18], 8); - ADD_MEM (fpregs[19], 8); - ADD_STRING (" ST(5) "); - ADD_MEM (fpregs[20], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[21], 8); - ADD_MEM (fpregs[22], 8); - ADD_STRING ("\n ST(6) "); - ADD_MEM (fpregs[23], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[24], 8); - ADD_MEM (fpregs[25], 8); - ADD_STRING (" ST(7) "); - ADD_MEM (fpregs[27], 4); - ADD_STRING (" "); - ADD_MEM (fpregs[27], 8); - ADD_MEM (fpregs[28], 8); - - ADD_STRING ("\n mxcsr: "); - ADD_MEM (fpregs[29], 4); - - ADD_STRING ("\n XMM0: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM1: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM2: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM3: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM4: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM5: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM6: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM7: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM8: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM9: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM10: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM11: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM12: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM13: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING ("\n XMM14: "); - ADD_MEM (xmmregs[0], 32); - ADD_STRING (" XMM15: "); - ADD_MEM (xmmregs[0], 32); - - } - - ADD_STRING ("\n"); - - /* Write the stuff out. */ - writev (fd, iov, nr); -} - - -#define REGISTER_DUMP register_dump (fd, ctx) |