2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-64 / register-dump.h
blobd705dd76d3988a67ad67249d385379d8ed3c6170
1 /* Dump registers. 64 bit S/390 version.
2 Copyright (C) 2001 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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <sys/uio.h>
22 #include <stdio-common/_itoa.h>
24 /* We will print the register dump in this format:
26 GPR0: XXXXXXXXXXXXXXXX GPR1: XXXXXXXXXXXXXXXX
27 GPR2: XXXXXXXXXXXXXXXX GPR3: XXXXXXXXXXXXXXXX
28 GPR4: XXXXXXXXXXXXXXXX GPR5: XXXXXXXXXXXXXXXX
29 GPR6: XXXXXXXXXXXXXXXX GPR7: XXXXXXXXXXXXXXXX
30 GPR8: XXXXXXXXXXXXXXXX GPR9: XXXXXXXXXXXXXXXX
31 GPRA: XXXXXXXXXXXXXXXX GPRB: XXXXXXXXXXXXXXXX
32 GPRC: XXXXXXXXXXXXXXXX GPRD: XXXXXXXXXXXXXXXX
33 GPRE: XXXXXXXXXXXXXXXX GPRF: XXXXXXXXXXXXXXXX
35 PSW.MASK: XXXXXXXXXXXXXXXX PSW.ADDR: XXXXXXXXXXXXXXXX
37 ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX
38 ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX
39 ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX
40 ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX
43 static void
44 hexvalue (unsigned long int value, char *buf, size_t len)
46 char *cp = _itoa_word (value, buf + len, 16, 0);
47 while (cp > buf)
48 *--cp = '0';
51 static void
52 register_dump (int fd, struct sigcontext *ctx)
54 char regs[19][16];
55 struct iovec iov[40];
56 size_t nr = 0;
58 #define ADD_STRING(str) \
59 iov[nr].iov_base = (char *) str; \
60 iov[nr].iov_len = strlen (str); \
61 ++nr
62 #define ADD_MEM(str, len) \
63 iov[nr].iov_base = str; \
64 iov[nr].iov_len = len; \
65 ++nr
67 /* Generate strings of register contents. */
68 hexvalue (ctx->sregs->regs.gprs[0], regs[0], 16);
69 hexvalue (ctx->sregs->regs.gprs[1], regs[1], 16);
70 hexvalue (ctx->sregs->regs.gprs[2], regs[2], 16);
71 hexvalue (ctx->sregs->regs.gprs[3], regs[3], 16);
72 hexvalue (ctx->sregs->regs.gprs[4], regs[4], 16);
73 hexvalue (ctx->sregs->regs.gprs[5], regs[5], 16);
74 hexvalue (ctx->sregs->regs.gprs[6], regs[6], 16);
75 hexvalue (ctx->sregs->regs.gprs[7], regs[7], 16);
76 hexvalue (ctx->sregs->regs.gprs[8], regs[8], 16);
77 hexvalue (ctx->sregs->regs.gprs[9], regs[9], 16);
78 hexvalue (ctx->sregs->regs.gprs[10], regs[10], 16);
79 hexvalue (ctx->sregs->regs.gprs[11], regs[11], 16);
80 hexvalue (ctx->sregs->regs.gprs[12], regs[12], 16);
81 hexvalue (ctx->sregs->regs.gprs[13], regs[13], 16);
82 hexvalue (ctx->sregs->regs.gprs[14], regs[14], 16);
83 hexvalue (ctx->sregs->regs.gprs[15], regs[15], 16);
84 hexvalue (ctx->sregs->regs.psw.mask, regs[16], 16);
85 hexvalue (ctx->sregs->regs.psw.addr, regs[17], 16);
87 /* Generate the output. */
88 ADD_STRING ("Register dump:\n\n GPR0: ");
89 ADD_MEM (regs[0], 16);
90 ADD_STRING (" GPR1: ");
91 ADD_MEM (regs[1], 16);
92 ADD_STRING (" GPR2: ");
93 ADD_MEM (regs[2], 16);
94 ADD_STRING (" GPR3: ");
95 ADD_MEM (regs[3], 16);
96 ADD_STRING ("\n GPR4: ");
97 ADD_MEM (regs[4], 16);
98 ADD_STRING (" GPR5: ");
99 ADD_MEM (regs[5], 16);
100 ADD_STRING (" GPR6: ");
101 ADD_MEM (regs[6], 16);
102 ADD_STRING (" GPR7: ");
103 ADD_MEM (regs[7], 16);
104 ADD_STRING ("\n GPR8: ");
105 ADD_MEM (regs[8], 16);
106 ADD_STRING (" GPR9: ");
107 ADD_MEM (regs[9], 16);
108 ADD_STRING (" GPRA: ");
109 ADD_MEM (regs[10], 16);
110 ADD_STRING (" GPRB: ");
111 ADD_MEM (regs[11], 16);
112 ADD_STRING ("\n GPRC: ");
113 ADD_MEM (regs[12], 16);
114 ADD_STRING (" GPRD: ");
115 ADD_MEM (regs[13], 16);
116 ADD_STRING (" GPRE: ");
117 ADD_MEM (regs[14], 16);
118 ADD_STRING (" GPRF: ");
119 ADD_MEM (regs[15], 16);
120 ADD_STRING ("\n\n PSW.MASK: ");
121 ADD_MEM (regs[16], 16);
122 ADD_STRING (" PSW.ADDR: ");
123 ADD_MEM (regs[17], 16);
124 ADD_STRING (" TRAP: ");
125 ADD_MEM (regs[18], 4);
126 ADD_STRING ("\n");
128 /* Write the stuff out. */
129 writev (fd, iov, nr);
133 #define REGISTER_DUMP register_dump (fd, ctx)