Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / register-dump.h
blob03a1131be91a972ce8ad49e01cbf43f2a613e482
1 /* Dump registers.
2 Copyright (C) 2000-2015 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
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.
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
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <sys/uio.h>
21 #include <_itoa.h>
23 /* We will print the register dump in this format:
25 GPR0: XXXXXXXX GPR1: XXXXXXXX GPR2: XXXXXXXX GPR3: XXXXXXXX
26 GPR4: XXXXXXXX GPR5: XXXXXXXX GPR6: XXXXXXXX GPR7: XXXXXXXX
27 GPR8: XXXXXXXX GPR9: XXXXXXXX GPRA: XXXXXXXX GPRB: XXXXXXXX
28 GPRC: XXXXXXXX GPRD: XXXXXXXX GPRE: XXXXXXXX GPRF: XXXXXXXX
30 PSW.MASK: XXXXXXXX PSW.ADDR: XXXXXXXX
32 ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX
33 ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX
34 ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX
35 ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX
39 static void
40 hexvalue (unsigned long int value, char *buf, size_t len)
42 char *cp = _itoa_word (value, buf + len, 16, 0);
43 while (cp > buf)
44 *--cp = '0';
47 static void
48 register_dump (int fd, struct sigcontext *ctx)
50 char regs[19][8];
51 struct iovec iov[40];
52 size_t nr = 0;
54 #define ADD_STRING(str) \
55 iov[nr].iov_base = (char *) str; \
56 iov[nr].iov_len = strlen (str); \
57 ++nr
58 #define ADD_MEM(str, len) \
59 iov[nr].iov_base = str; \
60 iov[nr].iov_len = len; \
61 ++nr
63 /* Generate strings of register contents. */
64 hexvalue (ctx->sregs->regs.gprs[0], regs[0], 8);
65 hexvalue (ctx->sregs->regs.gprs[1], regs[1], 8);
66 hexvalue (ctx->sregs->regs.gprs[2], regs[2], 8);
67 hexvalue (ctx->sregs->regs.gprs[3], regs[3], 8);
68 hexvalue (ctx->sregs->regs.gprs[4], regs[4], 8);
69 hexvalue (ctx->sregs->regs.gprs[5], regs[5], 8);
70 hexvalue (ctx->sregs->regs.gprs[6], regs[6], 8);
71 hexvalue (ctx->sregs->regs.gprs[7], regs[7], 8);
72 hexvalue (ctx->sregs->regs.gprs[8], regs[8], 8);
73 hexvalue (ctx->sregs->regs.gprs[9], regs[9], 8);
74 hexvalue (ctx->sregs->regs.gprs[10], regs[10], 8);
75 hexvalue (ctx->sregs->regs.gprs[11], regs[11], 8);
76 hexvalue (ctx->sregs->regs.gprs[12], regs[12], 8);
77 hexvalue (ctx->sregs->regs.gprs[13], regs[13], 8);
78 hexvalue (ctx->sregs->regs.gprs[14], regs[14], 8);
79 hexvalue (ctx->sregs->regs.gprs[15], regs[15], 8);
80 hexvalue (ctx->sregs->regs.psw.mask, regs[16], 8);
81 hexvalue (ctx->sregs->regs.psw.addr, regs[17], 8);
83 /* Generate the output. */
84 ADD_STRING ("Register dump:\n\n GPR0: ");
85 ADD_MEM (regs[0], 8);
86 ADD_STRING (" GPR1: ");
87 ADD_MEM (regs[1], 8);
88 ADD_STRING (" GPR2: ");
89 ADD_MEM (regs[2], 8);
90 ADD_STRING (" GPR3: ");
91 ADD_MEM (regs[3], 8);
92 ADD_STRING ("\n GPR4: ");
93 ADD_MEM (regs[4], 8);
94 ADD_STRING (" GPR5: ");
95 ADD_MEM (regs[5], 8);
96 ADD_STRING (" GPR6: ");
97 ADD_MEM (regs[6], 8);
98 ADD_STRING (" GPR7: ");
99 ADD_MEM (regs[7], 8);
100 ADD_STRING ("\n GPR8: ");
101 ADD_MEM (regs[8], 8);
102 ADD_STRING (" GPR9: ");
103 ADD_MEM (regs[9], 8);
104 ADD_STRING (" GPRA: ");
105 ADD_MEM (regs[10], 8);
106 ADD_STRING (" GPRB: ");
107 ADD_MEM (regs[11], 8);
108 ADD_STRING ("\n GPRC: ");
109 ADD_MEM (regs[12], 8);
110 ADD_STRING (" GPRD: ");
111 ADD_MEM (regs[13], 8);
112 ADD_STRING (" GPRE: ");
113 ADD_MEM (regs[14], 8);
114 ADD_STRING (" GPRF: ");
115 ADD_MEM (regs[15], 8);
116 ADD_STRING ("\n\n PSW.MASK: ");
117 ADD_MEM (regs[16], 8);
118 ADD_STRING (" PSW.ADDR: ");
119 ADD_MEM (regs[17], 8);
120 ADD_STRING (" TRAP: ");
121 ADD_MEM (regs[18], 4);
122 ADD_STRING ("\n");
124 /* Write the stuff out. */
125 writev (fd, iov, nr);
129 #define REGISTER_DUMP register_dump (fd, ctx)