]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/s390/s390-64/register-dump.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-64 / register-dump.h
CommitLineData
ffeac417 1/* Dump registers. 64 bit S/390 version.
b168057a 2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
847b055c
AJ
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
847b055c
AJ
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
847b055c 15
41bdb6e2 16 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
847b055c
AJ
19
20#include <sys/uio.h>
eb96ffb0 21#include <_itoa.h>
847b055c
AJ
22
23/* We will print the register dump in this format:
24
ffeac417
UD
25 GPR0: XXXXXXXXXXXXXXXX GPR1: XXXXXXXXXXXXXXXX
26 GPR2: XXXXXXXXXXXXXXXX GPR3: XXXXXXXXXXXXXXXX
27 GPR4: XXXXXXXXXXXXXXXX GPR5: XXXXXXXXXXXXXXXX
28 GPR6: XXXXXXXXXXXXXXXX GPR7: XXXXXXXXXXXXXXXX
29 GPR8: XXXXXXXXXXXXXXXX GPR9: XXXXXXXXXXXXXXXX
30 GPRA: XXXXXXXXXXXXXXXX GPRB: XXXXXXXXXXXXXXXX
31 GPRC: XXXXXXXXXXXXXXXX GPRD: XXXXXXXXXXXXXXXX
32 GPRE: XXXXXXXXXXXXXXXX GPRF: XXXXXXXXXXXXXXXX
847b055c 33
ffeac417 34 PSW.MASK: XXXXXXXXXXXXXXXX PSW.ADDR: XXXXXXXXXXXXXXXX
847b055c
AJ
35
36 ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX
37 ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX
38 ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX
39 ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX
847b055c
AJ
40 */
41
42static void
43hexvalue (unsigned long int value, char *buf, size_t len)
44{
45 char *cp = _itoa_word (value, buf + len, 16, 0);
46 while (cp > buf)
47 *--cp = '0';
48}
49
50static void
51register_dump (int fd, struct sigcontext *ctx)
52{
ffeac417 53 char regs[19][16];
847b055c
AJ
54 struct iovec iov[40];
55 size_t nr = 0;
56
57#define ADD_STRING(str) \
58 iov[nr].iov_base = (char *) str; \
59 iov[nr].iov_len = strlen (str); \
60 ++nr
61#define ADD_MEM(str, len) \
62 iov[nr].iov_base = str; \
63 iov[nr].iov_len = len; \
64 ++nr
65
66 /* Generate strings of register contents. */
ffeac417
UD
67 hexvalue (ctx->sregs->regs.gprs[0], regs[0], 16);
68 hexvalue (ctx->sregs->regs.gprs[1], regs[1], 16);
69 hexvalue (ctx->sregs->regs.gprs[2], regs[2], 16);
70 hexvalue (ctx->sregs->regs.gprs[3], regs[3], 16);
71 hexvalue (ctx->sregs->regs.gprs[4], regs[4], 16);
72 hexvalue (ctx->sregs->regs.gprs[5], regs[5], 16);
73 hexvalue (ctx->sregs->regs.gprs[6], regs[6], 16);
74 hexvalue (ctx->sregs->regs.gprs[7], regs[7], 16);
75 hexvalue (ctx->sregs->regs.gprs[8], regs[8], 16);
76 hexvalue (ctx->sregs->regs.gprs[9], regs[9], 16);
77 hexvalue (ctx->sregs->regs.gprs[10], regs[10], 16);
78 hexvalue (ctx->sregs->regs.gprs[11], regs[11], 16);
79 hexvalue (ctx->sregs->regs.gprs[12], regs[12], 16);
80 hexvalue (ctx->sregs->regs.gprs[13], regs[13], 16);
81 hexvalue (ctx->sregs->regs.gprs[14], regs[14], 16);
82 hexvalue (ctx->sregs->regs.gprs[15], regs[15], 16);
83 hexvalue (ctx->sregs->regs.psw.mask, regs[16], 16);
84 hexvalue (ctx->sregs->regs.psw.addr, regs[17], 16);
9c84384c 85
847b055c
AJ
86 /* Generate the output. */
87 ADD_STRING ("Register dump:\n\n GPR0: ");
ffeac417 88 ADD_MEM (regs[0], 16);
847b055c 89 ADD_STRING (" GPR1: ");
ffeac417 90 ADD_MEM (regs[1], 16);
847b055c 91 ADD_STRING (" GPR2: ");
ffeac417 92 ADD_MEM (regs[2], 16);
847b055c 93 ADD_STRING (" GPR3: ");
ffeac417 94 ADD_MEM (regs[3], 16);
847b055c 95 ADD_STRING ("\n GPR4: ");
ffeac417 96 ADD_MEM (regs[4], 16);
847b055c 97 ADD_STRING (" GPR5: ");
ffeac417 98 ADD_MEM (regs[5], 16);
847b055c 99 ADD_STRING (" GPR6: ");
ffeac417 100 ADD_MEM (regs[6], 16);
847b055c 101 ADD_STRING (" GPR7: ");
ffeac417 102 ADD_MEM (regs[7], 16);
847b055c 103 ADD_STRING ("\n GPR8: ");
ffeac417 104 ADD_MEM (regs[8], 16);
847b055c 105 ADD_STRING (" GPR9: ");
ffeac417 106 ADD_MEM (regs[9], 16);
847b055c 107 ADD_STRING (" GPRA: ");
ffeac417 108 ADD_MEM (regs[10], 16);
847b055c 109 ADD_STRING (" GPRB: ");
ffeac417 110 ADD_MEM (regs[11], 16);
847b055c 111 ADD_STRING ("\n GPRC: ");
ffeac417 112 ADD_MEM (regs[12], 16);
847b055c 113 ADD_STRING (" GPRD: ");
ffeac417 114 ADD_MEM (regs[13], 16);
847b055c 115 ADD_STRING (" GPRE: ");
ffeac417 116 ADD_MEM (regs[14], 16);
847b055c 117 ADD_STRING (" GPRF: ");
ffeac417 118 ADD_MEM (regs[15], 16);
847b055c 119 ADD_STRING ("\n\n PSW.MASK: ");
ffeac417 120 ADD_MEM (regs[16], 16);
847b055c 121 ADD_STRING (" PSW.ADDR: ");
ffeac417 122 ADD_MEM (regs[17], 16);
847b055c
AJ
123 ADD_STRING (" TRAP: ");
124 ADD_MEM (regs[18], 4);
125 ADD_STRING ("\n");
126
127 /* Write the stuff out. */
128 writev (fd, iov, nr);
129}
130
131
6d763b87 132#define REGISTER_DUMP register_dump (fd, ctx)