From 65ccd641bacea33be23d51da737c2de7543d0f5e Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 20 Dec 2021 08:41:55 -0300 Subject: 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. --- sysdeps/generic/register-dump.h | 19 -- sysdeps/powerpc/powerpc32/register-dump.h | 120 ------- sysdeps/powerpc/powerpc64/register-dump.h | 124 -------- sysdeps/unix/sysv/linux/alpha/register-dump.h | 239 -------------- sysdeps/unix/sysv/linux/arm/register-dump.h | 135 -------- sysdeps/unix/sysv/linux/csky/register-dump.h | 190 ------------ sysdeps/unix/sysv/linux/i386/register-dump.h | 250 --------------- sysdeps/unix/sysv/linux/ia64/register-dump.h | 180 ----------- sysdeps/unix/sysv/linux/m68k/register-dump.h | 176 ----------- sysdeps/unix/sysv/linux/mips/register-dump.h | 120 ------- sysdeps/unix/sysv/linux/riscv/register-dump.h | 63 ---- .../unix/sysv/linux/s390/s390-32/register-dump.h | 128 -------- .../unix/sysv/linux/s390/s390-64/register-dump.h | 131 -------- sysdeps/unix/sysv/linux/segfault.c | 2 - sysdeps/unix/sysv/linux/sh/register-dump.h | 263 ---------------- .../unix/sysv/linux/sparc/sparc32/register-dump.h | 342 -------------------- .../unix/sysv/linux/sparc/sparc64/register-dump.h | 273 ---------------- sysdeps/unix/sysv/linux/x86_64/register-dump.h | 345 --------------------- 18 files changed, 3100 deletions(-) delete mode 100644 sysdeps/generic/register-dump.h delete mode 100644 sysdeps/powerpc/powerpc32/register-dump.h delete mode 100644 sysdeps/powerpc/powerpc64/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/alpha/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/arm/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/csky/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/i386/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/ia64/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/m68k/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/mips/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/riscv/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/segfault.c delete mode 100644 sysdeps/unix/sysv/linux/sh/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h delete mode 100644 sysdeps/unix/sysv/linux/x86_64/register-dump.h (limited to 'sysdeps') diff --git a/sysdeps/generic/register-dump.h b/sysdeps/generic/register-dump.h deleted file mode 100644 index 9d6b2a3b0b..0000000000 --- a/sysdeps/generic/register-dump.h +++ /dev/null @@ -1,19 +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 - . */ - -/* In general we cannot do anything. */ diff --git a/sysdeps/powerpc/powerpc32/register-dump.h b/sysdeps/powerpc/powerpc32/register-dump.h deleted file mode 100644 index ea1335fd02..0000000000 --- a/sysdeps/powerpc/powerpc32/register-dump.h +++ /dev/null @@ -1,120 +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 - . */ - -#include -#include <_itoa.h> - -/* This prints out the information in the following form: */ -static const char dumpform[] = "\ -Register dump:\n\ -fp0-3: 0000030%0000031% 0000032%0000033% 0000034%0000035% 0000036%0000037%\n\ -fp4-7: 0000038%0000039% 000003a%000003b% 000003c%000003d% 000003e%000003f%\n\ -fp8-11: 0000040%0000041% 0000042%0000043% 0000044%0000045% 0000046%0000047%\n\ -fp12-15: 0000048%0000049% 000004a%000004b% 000004c%000004d% 000004e%000004f%\n\ -fp16-19: 0000050%0000051% 0000052%0000053% 0000054%0000055% 0000056%0000057%\n\ -fp20-23: 0000058%0000059% 000005a%000005b% 000005c%000005d% 000005e%000005f%\n\ -fp24-27: 0000060%0000061% 0000062%0000063% 0000064%0000065% 0000066%0000067%\n\ -fp28-31: 0000068%0000069% 000006a%000006b% 000006c%000006d% 000006e%000006f%\n\ -r0 =0000000% sp =0000001% r2 =0000002% r3 =0000003% trap=0000028%\n\ -r4 =0000004% r5 =0000005% r6 =0000006% r7 =0000007% sr0=0000020% sr1=0000021%\n\ -r8 =0000008% r9 =0000009% r10=000000a% r11=000000b% dar=0000029% dsi=000002a%\n\ -r12=000000c% r13=000000d% r14=000000e% r15=000000f% r3*=0000022%\n\ -r16=0000010% r17=0000011% r18=0000012% r19=0000013%\n\ -r20=0000014% r21=0000015% r22=0000016% r23=0000017% lr=0000024% xer=0000025%\n\ -r24=0000018% r25=0000019% r26=000001a% r27=000001b% mq=0000027% ctr=0000023%\n\ -r28=000001c% r29=000001d% r30=000001e% r31=000001f% fscr=0000071% ccr=0000026%\n\ -"; - -/* Most of the fields are self-explanatory. 'sr0' is the next - instruction to execute, from SRR0, which may have some relationship - with the instruction that caused the exception. 'r3*' is the value - that will be returned in register 3 when the current system call - returns. 'sr1' is SRR1, bits 16-31 of which are copied from the MSR: - - 16 - External interrupt enable - 17 - Privilege level (1=user, 0=supervisor) - 18 - FP available - 19 - Machine check enable (if clear, processor locks up on machine check) - 20 - FP exception mode bit 0 (FP exceptions recoverable) - 21 - Single-step trace enable - 22 - Branch trace enable - 23 - FP exception mode bit 1 - 25 - exception prefix (if set, exceptions are taken from 0xFFFnnnnn, - otherwise from 0x000nnnnn). - 26 - Instruction address translation enabled. - 27 - Data address translation enabled. - 30 - Exception is recoverable (otherwise, don't try to return). - 31 - Little-endian mode enable. - - 'Trap' is the address of the exception: - - 00200 - Machine check exception (memory parity error, for instance) - 00300 - Data access exception (memory not mapped, see dsisr for why) - 00400 - Instruction access exception (memory not mapped) - 00500 - External interrupt - 00600 - Alignment exception (see dsisr for more information) - 00700 - Program exception (illegal/trap instruction, FP exception) - 00800 - FP unavailable (should not be seen by user code) - 00900 - Decrementer exception (for instance, SIGALRM) - 00A00 - I/O controller interface exception - 00C00 - System call exception (for instance, kill(3)). - 00E00 - FP assist exception (optional FP instructions, etc.) - - 'dar' is the memory location, for traps 00300, 00400, 00600, 00A00. - 'dsisr' has the following bits under trap 00300: - 0 - direct-store error exception - 1 - no page table entry for page - 4 - memory access not permitted - 5 - trying to access I/O controller space or using lwarx/stwcx on - non-write-cached memory - 6 - access was store - 9 - data access breakpoint hit - 10 - segment table search failed to find translation (64-bit ppcs only) - 11 - I/O controller instruction not permitted - For trap 00400, the same bits are set in SRR1 instead. - For trap 00600, bits 12-31 of the DSISR set to allow emulation of - the instruction without actually having to read it from memory. -*/ - -#define xtoi(x) (x >= 'a' ? x + 10 - 'a' : x - '0') - -static void -register_dump (int fd, struct sigcontext *ctx) -{ - char buffer[sizeof (dumpform)]; - char *bufferpos; - unsigned regno; - unsigned *regs = (unsigned *)(ctx->regs); - - memcpy(buffer, dumpform, sizeof (dumpform)); - - /* Generate the output. */ - while ((bufferpos = memchr (buffer, '%', sizeof (dumpform)))) - { - regno = xtoi (bufferpos[-1]) | xtoi (bufferpos[-2]) << 4; - memset (bufferpos-2, '0', 3); - _itoa_word (regs[regno], bufferpos+1, 16, 0); - } - - /* Write the output. */ - write (fd, buffer, sizeof (buffer) - 1); -} - - -#define REGISTER_DUMP \ - register_dump (fd, ctx) diff --git a/sysdeps/powerpc/powerpc64/register-dump.h b/sysdeps/powerpc/powerpc64/register-dump.h deleted file mode 100644 index 73454e5d34..0000000000 --- a/sysdeps/powerpc/powerpc64/register-dump.h +++ /dev/null @@ -1,124 +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 - . */ - -#include -#include <_itoa.h> - -/* This prints out the information in the following form: */ -static const char dumpform[] = "\ -Register dump:\n\ -sr0=000000000000020% sr1=000000000000021% dar=000000000000029% dsi=000002a%\n\ -lr=000000000000024% ctr=000000000000023% gr3*=000000000000022% trap=0000028%\n\ -ccr=0000026% xer=0000025%\n\ -gr0-3: 000000000000000% 000000000000001% 000000000000002% 000000000000003%\n\ -gr4-7: 000000000000004% 000000000000005% 000000000000006% 000000000000007%\n\ -gr8-11: 000000000000008% 000000000000009% 00000000000000a% 00000000000000b%\n\ -gr12-15: 00000000000000c% 00000000000000d% 00000000000000e% 00000000000000f%\n\ -gr16-19: 000000000000010% 000000000000011% 000000000000012% 000000000000013%\n\ -gr20-23: 000000000000014% 000000000000015% 000000000000016% 000000000000017%\n\ -gr24-27: 000000000000018% 000000000000019% 00000000000001a% 00000000000001b%\n\ -gr28-31: 00000000000001c% 00000000000001d% 00000000000001e% 00000000000001f%\n\ -fscr=000000000000050%\n\ -fp0-3: 000000000000030% 000000000000031% 000000000000032% 000000000000033%\n\ -fp4-7: 000000000000034% 000000000000035% 000000000000036% 000000000000037%\n\ -fp8-11: 000000000000038% 000000000000038% 00000000000003a% 00000000000003b%\n\ -fp12-15: 00000000000003c% 00000000000003d% 00000000000003e% 00000000000003f%\n\ -fp16-19: 000000000000040% 000000000000041% 000000000000042% 000000000000043%\n\ -fp20-23: 000000000000044% 000000000000045% 000000000000046% 000000000000047%\n\ -fp24-27: 000000000000048% 000000000000049% 00000000000004a% 00000000000004b%\n\ -fp28-31: 00000000000004c% 00000000000004d% 00000000000004e% 00000000000004f%\n\ -"; - -/* Most of the fields are self-explanatory. 'sr0' is the next - instruction to execute, from SRR0, which may have some relationship - with the instruction that caused the exception. 'r3*' is the value - that will be returned in register 3 when the current system call - returns. 'sr1' is SRR1, bits 16-31 of which are copied from the MSR: - - 16 - External interrupt enable - 17 - Privilege level (1=user, 0=supervisor) - 18 - FP available - 19 - Machine check enable (if clear, processor locks up on machine check) - 20 - FP exception mode bit 0 (FP exceptions recoverable) - 21 - Single-step trace enable - 22 - Branch trace enable - 23 - FP exception mode bit 1 - 25 - exception prefix (if set, exceptions are taken from 0xFFFnnnnn, - otherwise from 0x000nnnnn). - 26 - Instruction address translation enabled. - 27 - Data address translation enabled. - 30 - Exception is recoverable (otherwise, don't try to return). - 31 - Little-endian mode enable. - - 'Trap' is the address of the exception: - - 00200 - Machine check exception (memory parity error, for instance) - 00300 - Data access exception (memory not mapped, see dsisr for why) - 00400 - Instruction access exception (memory not mapped) - 00500 - External interrupt - 00600 - Alignment exception (see dsisr for more information) - 00700 - Program exception (illegal/trap instruction, FP exception) - 00800 - FP unavailable (should not be seen by user code) - 00900 - Decrementer exception (for instance, SIGALRM) - 00A00 - I/O controller interface exception - 00C00 - System call exception (for instance, kill(3)). - 00E00 - FP assist exception (optional FP instructions, etc.) - - 'dar' is the memory location, for traps 00300, 00400, 00600, 00A00. - 'dsisr' has the following bits under trap 00300: - 0 - direct-store error exception - 1 - no page table entry for page - 4 - memory access not permitted - 5 - trying to access I/O controller space or using lwarx/stwcx on - non-write-cached memory - 6 - access was store - 9 - data access breakpoint hit - 10 - segment table search failed to find translation (64-bit ppcs only) - 11 - I/O controller instruction not permitted - For trap 00400, the same bits are set in SRR1 instead. - For trap 00600, bits 12-31 of the DSISR set to allow emulation of - the instruction without actually having to read it from memory. -*/ - -#define xtoi(x) (x >= 'a' ? x + 10 - 'a' : x - '0') - -static void -register_dump (int fd, struct sigcontext *ctx) -{ - char buffer[sizeof (dumpform)]; - char *bufferpos; - unsigned regno; - unsigned long *regs = (unsigned long *)(ctx->regs); - - memcpy(buffer, dumpform, sizeof (dumpform)); - - /* Generate the output. */ - while ((bufferpos = memchr (buffer, '%', sizeof (dumpform)))) - { - regno = xtoi (bufferpos[-1]) | xtoi (bufferpos[-2]) << 4; - memset (bufferpos-2, '0', 3); - _itoa_word (regs[regno], bufferpos+1, 16, 0); - } - - /* Write the output. */ - write (fd, buffer, sizeof (buffer) - 1); -} - - -#define REGISTER_DUMP \ - register_dump (fd, ctx) 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 5ecdd0c2ac..0000000000 --- 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 - . */ - -#include -#include -#include -#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 1cbdbe38e1..0000000000 --- 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 - . */ - -#include -#include <_itoa.h> -#include - -/* 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 f313a6979a..0000000000 --- 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 - . */ - -#include -#include <_itoa.h> -#include -#include - -/* 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 612424b2c5..0000000000 --- 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 - . */ - -#include -#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 4c7c4002cb..0000000000 --- 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 - . */ - -#include -#include -#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 38cc401145..0000000000 --- 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 - . */ - -#include -#include -#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 b3ada7b7bf..0000000000 --- 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 - . */ - -#include -#include -#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 177636f18f..0000000000 --- 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 - . */ - -#include -#include -#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 51aa1e4cc0..0000000000 --- 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 - . */ - -#include -#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_