From patchwork Wed Dec 22 12:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49175 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A65953858402 for ; Wed, 22 Dec 2021 12:51:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A65953858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640177509; bh=yK1VfWyaZ81wRPI0DwdXRRR+LKSDKTTo6GjF1pZJJiA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gLUEPv4/7aJoErMHsYk+BFUw8dxbqVx9xfWwx2YETBz7EyR0OmnhbLu9oXqFbw8k8 bSl9I3i5K9kHMfR66tpibAJGLGQcDjdb9opS/yYuIRKgx+HuN1H/Mpy3z1eq1lJflM 7o3M1+YNTy32qWxCgOi1awhJ9MkKnJUgkiawyYsE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by sourceware.org (Postfix) with ESMTPS id 6D62A3858D35 for ; Wed, 22 Dec 2021 12:51:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D62A3858D35 Received: by mail-qk1-x72b.google.com with SMTP id r139so1259459qke.9 for ; Wed, 22 Dec 2021 04:51:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yK1VfWyaZ81wRPI0DwdXRRR+LKSDKTTo6GjF1pZJJiA=; b=k5N0y0cpniyv2JHK0wlKrFzuhbGg++gmnDadl/ACJhOAejWcTDBVfymjg0khMrdK5E zmyIhq6XrQGzR/NJmaKIObF9GHtCjBGVCLGFFKbcSd+Pa5M33p7sKDg5QJprf7U7m4Ug +mHrLtVTHSJaa9CzusRO3sDH2NWoz+v4vHIgaIP3J0KuKZ8qbRXIaS+woWpS2GH4LZcO FPUXo59YmpGs8KDfmEdTG0z/9BVCVOdRIcYUoToavSBD28U+jD2oZmZT/Mv1P06KQV56 pi5aUHnooxQDGkebr3colqO5Kvc6YVmt1F+uPe3kDsi/eAUbVW9EG1ppRNN7HqiBXsq7 nZEA== X-Gm-Message-State: AOAM5315Xux+WUjEXxRnLNoJrNtZltVefcNKoQErMt6Y+0dUJBBktb45 tQQMx4r50Ysvxbm8pGpmp1rMdAxMQxgx/w== X-Google-Smtp-Source: ABdhPJzrOSruHq00keqUEFGN+KId3zYbtxPDOy1j3Xo4MgqQ2AJEYUIaX55cuFcrZ8BTM8PMx8kaaQ== X-Received: by 2002:a05:620a:2486:: with SMTP id i6mr1805720qkn.331.1640177474566; Wed, 22 Dec 2021 04:51:14 -0800 (PST) Received: from birita.. ([2804:431:c7cb:3b1e:1ba8:c11f:6224:efe1]) by smtp.gmail.com with ESMTPSA id x62sm1608515qkb.70.2021.12.22.04.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Dec 2021 04:51:14 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2] debug: Remove catchsegv and libSegfault (BZ #14913) Date: Wed, 22 Dec 2021 09:51:10 -0300 Message-Id: <20211222125110.518305-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. --- v2: Rewrote NEWS, fixed typos in the commit message, and add BZ#14913 reference. --- NEWS | 4 + debug/Makefile | 19 +- debug/catchsegv.sh | 106 ------ debug/segfault.c | 215 ----------- 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 ---- .../sysv/linux/s390/s390-32/register-dump.h | 128 ------- .../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 ------------- .../sysv/linux/sparc/sparc32/register-dump.h | 342 ----------------- .../sysv/linux/sparc/sparc64/register-dump.h | 273 -------------- .../unix/sysv/linux/x86_64/register-dump.h | 345 ------------------ 22 files changed, 6 insertions(+), 3438 deletions(-) delete mode 100755 debug/catchsegv.sh delete mode 100644 debug/segfault.c 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 diff --git a/NEWS b/NEWS index c7200cd4e8..c142beab5f 100644 --- a/NEWS +++ b/NEWS @@ -119,6 +119,10 @@ Deprecated and removed features, and other changes affecting compatibility: configuration script now automatically detects static-pie support in the toolchain and architecture and enables it if available. +* The catchsegv script and associated libSegFault.so shared object have + been removed. There are widely-deployed out-of-process alternatives for + catching coredumps and backtraces. + Changes to build and runtime requirements: [Add changes to build and runtime requirements here] diff --git a/debug/Makefile b/debug/Makefile index bc37e466ee..5ca27414bf 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -167,12 +167,9 @@ tests-unsupported = tst-chk4 tst-chk5 tst-chk6 tst-chk8 \ tst-lfschk4 tst-lfschk5 tst-lfschk6 endif -extra-libs = libSegFault libpcprofile +extra-libs = libpcprofile extra-libs-others = $(extra-libs) -libSegFault-routines = segfault -libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes)) - libpcprofile-routines = pcprofile libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes)) @@ -180,10 +177,7 @@ others = pcprofiledump install-bin = pcprofiledump install-bin-script = xtrace -ifeq ($(build-shared),yes) -install-bin-script += catchsegv -endif -generated += catchsegv xtrace +generated += xtrace include ../Rules @@ -209,15 +203,6 @@ endif sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,') -$(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \ - $(common-objpfx)config.make - slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \ - sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" \ - -e 's|@PKGVERSION@|$(PKGVERSION)|' \ - -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $< > $@.new - chmod 555 $@.new - mv -f $@.new $@ - $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o $(objpfx)xtrace: xtrace.sh diff --git a/debug/catchsegv.sh b/debug/catchsegv.sh deleted file mode 100755 index e431d4417b..0000000000 --- a/debug/catchsegv.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# Copyright (C) 1998-2021 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 -# . - -if test $# -eq 0; then - echo "$0: missing program name" >&2 - echo "Try \`$0 --help' for more information." >&2 - exit 1 -fi - -prog="$1" -shift - -if test $# -eq 0; then - case "$prog" in - --h | --he | --hel | --help) - echo 'Usage: catchsegv PROGRAM ARGS...' - echo ' --help print this help, then exit' - echo ' --version print version number, then exit' - echo 'For bug reporting instructions, please see:' - cat <<\EOF -@REPORT_BUGS_TO@. -EOF - exit 0 - ;; - --v | --ve | --ver | --vers | --versi | --versio | --version) - echo 'catchsegv @PKGVERSION@@VERSION@' - echo 'Copyright (C) 2021 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Written by Ulrich Drepper.' - exit 0 - ;; - *) - ;; - esac -fi - -segv_output=`mktemp ${TMPDIR:-/tmp}/segv_output.XXXXXX` || exit - -# Redirect stderr to avoid termination message from shell. -(exec 3>&2 2>/dev/null -LD_PRELOAD=${LD_PRELOAD:+${LD_PRELOAD}:}@SLIB@/libSegFault.so \ -SEGFAULT_USE_ALTSTACK=1 \ -SEGFAULT_OUTPUT_NAME=$segv_output \ -"$prog" ${1+"$@"} 2>&3 3>&-) -exval=$? - -# Check for output. Even if the program terminated correctly it might -# be that a minor process (clone) failed. Therefore we do not check the -# exit code. -if test -s "$segv_output"; then - # The program caught a signal. The output is in the file with the - # name we have in SEGFAULT_OUTPUT_NAME. In the output the names of - # functions in shared objects are available, but names in the static - # part of the program are not. We use addr2line to get this information. - case $prog in - */*) ;; - *) - old_IFS=$IFS - IFS=: - for p in $PATH; do - test -n "$p" || p=. - if test -f "$p/$prog"; then - prog=$p/$prog - break - fi - done - IFS=$old_IFS - ;; - esac - sed '/Backtrace/q' "$segv_output" - sed '1,/Backtrace/d' "$segv_output" | - (while read line; do - line=`echo $line | sed "s@^$prog\\(\\[.*\\)@\1@"` - case "$line" in - \[*) addr=`echo "$line" | sed 's/^\[\(.*\)\]$/\1/'` - complete=`addr2line -f -e "$prog" $addr 2>/dev/null` - if test $? -eq 0; then - echo "`echo "$complete"|sed 'N;s/\(.*\)\n\(.*\)/\2(\1)/;'`$line" - else - echo "$line" - fi - ;; - *) echo "$line" - ;; - esac - done) -fi -rm -f "$segv_output" - -exit $exval diff --git a/debug/segfault.c b/debug/segfault.c deleted file mode 100644 index b6c0facd59..0000000000 --- a/debug/segfault.c +++ /dev/null @@ -1,215 +0,0 @@ -/* Catch segmentation faults and print backtrace. - Copyright (C) 1998-2021 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 -#include -#include -#include -#include -#include -#include -#include -#include <_itoa.h> -#include - -/* This file defines macros to access the content of the sigcontext element - passed up by the signal handler. */ -#include - -#ifdef SA_SIGINFO -# define SIGCONTEXT siginfo_t *info, void * -#endif - -/* Get code to possibly dump the content of all registers. */ -#include - -/* We'll use this a lot. */ -#define WRITE_STRING(s) write (fd, s, strlen (s)) - -/* Name of the output file. */ -static const char *fname; - - -/* Print the signal number SIGNAL. Either strerror or strsignal might - call local internal functions and these in turn call far too many - other functions and might even allocate memory which might fail. */ -static void -write_strsignal (int fd, int signal) -{ - char buf[30]; - char *ptr = _itoa_word (signal, &buf[sizeof (buf)], 10, 0); - WRITE_STRING ("signal "); - write (fd, ptr, &buf[sizeof (buf)] - ptr); -} - - -/* This function is called when a segmentation fault is caught. The system - is in an unstable state now. This means especially that malloc() might - not work anymore. */ -static void -catch_segfault (int signal, SIGCONTEXT ctx) -{ - int fd, cnt, i; - void **arr; - struct sigaction sa; - uintptr_t pc; - - /* This is the name of the file we are writing to. If none is given - or we cannot write to this file write to stderr. */ - fd = 2; - if (fname != NULL) - { - fd = open (fname, O_TRUNC | O_WRONLY | O_CREAT, 0666); - if (fd == -1) - fd = 2; - } - - WRITE_STRING ("*** "); - write_strsignal (fd, signal); - WRITE_STRING ("\n"); - -#ifdef REGISTER_DUMP - REGISTER_DUMP; -#endif - - WRITE_STRING ("\nBacktrace:\n"); - - /* Get the backtrace. */ - arr = alloca (256 * sizeof (void *)); - cnt = backtrace (arr, 256); - - /* Now try to locate the PC from signal context in the backtrace. - Normally it will be found at arr[2], but it might appear later - if there were some signal handler wrappers. Allow a few bytes - difference to cope with as many arches as possible. */ - pc = sigcontext_get_pc (ctx); - for (i = 0; i < cnt; ++i) - if ((uintptr_t) arr[i] >= pc - 16 && (uintptr_t) arr[i] <= pc + 16) - break; - - /* If we haven't found it, better dump full backtrace even including - the signal handler frames instead of not dumping anything. */ - if (i == cnt) - i = 0; - - /* Now generate nicely formatted output. */ - __backtrace_symbols_fd (arr + i, cnt - i, fd); - -#ifdef HAVE_PROC_SELF - /* Now the link map. */ - int mapfd = open ("/proc/self/maps", O_RDONLY); - if (mapfd != -1) - { - write (fd, "\nMemory map:\n\n", 14); - - char buf[256]; - ssize_t n; - - while ((n = TEMP_FAILURE_RETRY (read (mapfd, buf, sizeof (buf)))) > 0) - TEMP_FAILURE_RETRY (write (fd, buf, n)); - - close (mapfd); - } -#endif - - /* Pass on the signal (so that a core file is produced). */ - sa.sa_handler = SIG_DFL; - sigemptyset (&sa.sa_mask); - sa.sa_flags = 0; - sigaction (signal, &sa, NULL); - raise (signal); -} - - -static void -__attribute__ ((constructor)) -install_handler (void) -{ - struct sigaction sa; - const char *sigs = getenv ("SEGFAULT_SIGNALS"); - const char *name; - -#ifdef SA_SIGINFO - sa.sa_sigaction = catch_segfault; - sa.sa_flags = SA_SIGINFO; -#else - sa.sa_handler = (void*) catch_segfault; - sa.sa_flags = 0; -#endif - sigemptyset (&sa.sa_mask); - sa.sa_flags |= SA_RESTART; - - /* Maybe we are expected to use an alternative stack. */ - if (getenv ("SEGFAULT_USE_ALTSTACK") != 0) - { - void *stack_mem = malloc (2 * SIGSTKSZ); - stack_t ss; - - if (stack_mem != NULL) - { - ss.ss_sp = stack_mem; - ss.ss_flags = 0; - ss.ss_size = 2 * SIGSTKSZ; - - if (sigaltstack (&ss, NULL) == 0) - sa.sa_flags |= SA_ONSTACK; - } - } - - if (sigs == NULL) - sigaction (SIGSEGV, &sa, NULL); - else if (sigs[0] == '\0') - /* Do not do anything. */ - return; - else - { - const char *where; - int all = __strcasecmp (sigs, "all") == 0; - -#define INSTALL_FOR_SIG(sig, name) \ - where = __strcasestr (sigs, name); \ - if (all || (where != NULL \ - && (where == sigs || !isalnum (where[-1])) \ - && !isalnum (where[sizeof (name) - 1]))) \ - sigaction (sig, &sa, NULL); - - INSTALL_FOR_SIG (SIGSEGV, "segv"); - INSTALL_FOR_SIG (SIGILL, "ill"); -#ifdef SIGBUS - INSTALL_FOR_SIG (SIGBUS, "bus"); -#endif -#ifdef SIGSTKFLT - INSTALL_FOR_SIG (SIGSTKFLT, "stkflt"); -#endif - INSTALL_FOR_SIG (SIGABRT, "abrt"); - INSTALL_FOR_SIG (SIGFPE, "fpe"); - } - - /* Preserve the output file name if there is any given. */ - name = getenv ("SEGFAULT_OUTPUT_NAME"); - if (name != NULL && name[0] != '\0') - { - int ret = access (name, R_OK | W_OK); - - if (ret == 0 || (ret == -1 && errno == ENOENT)) - fname = __strdup (name); - } -} diff --git a/sysdeps/generic/register-dump.h b/sysdeps/generic/register-dump.h deleted file mode 100644 index 4554fb1ecd..0000000000 --- a/sysdeps/generic/register-dump.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 1e3531956d..0000000000 --- a/sysdeps/powerpc/powerpc32/register-dump.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 16bd8eaf13..0000000000 --- a/sysdeps/powerpc/powerpc64/register-dump.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 772944ab18..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/register-dump.h +++ /dev/null @@ -1,239 +0,0 @@ -/* Dump registers. - Copyright (C) 2004-2021 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 80efdcdbb0..0000000000 --- a/sysdeps/unix/sysv/linux/arm/register-dump.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 7089200613..0000000000 --- a/sysdeps/unix/sysv/linux/csky/register-dump.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Dump registers. - Copyright (C) 2018-2021 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 03a9acf65f..0000000000 --- a/sysdeps/unix/sysv/linux/i386/register-dump.h +++ /dev/null @@ -1,250 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 6a44f30eb5..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/register-dump.h +++ /dev/null @@ -1,180 +0,0 @@ -/* Dump registers. - Copyright (C) 2004-2021 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 9b4f2118f0..0000000000 --- a/sysdeps/unix/sysv/linux/m68k/register-dump.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Dump registers. - Copyright (C) 1998-2021 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 9346cb5f06..0000000000 --- a/sysdeps/unix/sysv/linux/mips/register-dump.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2021 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 3cfb2b1ac2..0000000000 --- a/sysdeps/unix/sysv/linux/riscv/register-dump.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2021 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 a4647fc9d0..0000000000 --- a/sysdeps/unix/sysv/linux/s390/s390-32/register-dump.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Dump registers. - Copyright (C) 2000-2021 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_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 1c9ca2e300..0000000000 --- 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-2021 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: 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 a417df9c41..0000000000 --- a/sysdeps/unix/sysv/linux/segfault.c +++ /dev/null @@ -1,2 +0,0 @@ -#define HAVE_PROC_SELF 1 -#include 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 0b93ee8b93..0000000000 --- a/sysdeps/unix/sysv/linux/sh/register-dump.h +++ /dev/null @@ -1,263 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2021 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: - - 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 23a2d50a95..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/register-dump.h +++ /dev/null @@ -1,342 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2021 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: - - 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 13dcdc33ed..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/register-dump.h +++ /dev/null @@ -1,273 +0,0 @@ -/* Dump registers. - Copyright (C) 1999-2021 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: - - 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 b3ec6275e9..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/register-dump.h +++ /dev/null @@ -1,345 +0,0 @@ -/* Dump registers. - Copyright (C) 2001-2021 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: - - 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)