2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-32 / register-dump.h
blob2030bfef30fcf47c3e1b9fcdce3feea90bb9a6a2
1 /* Dump registers.
2 Copyright (C) 2000, 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: XXXXXXXX GPR1: XXXXXXXX GPR2: XXXXXXXX GPR3: XXXXXXXX
27 GPR4: XXXXXXXX GPR5: XXXXXXXX GPR6: XXXXXXXX GPR7: XXXXXXXX
28 GPR8: XXXXXXXX GPR9: XXXXXXXX GPRA: XXXXXXXX GPRB: XXXXXXXX
29 GPRC: XXXXXXXX GPRD: XXXXXXXX GPRE: XXXXXXXX GPRF: XXXXXXXX
31 PSW.MASK: XXXXXXXX PSW.ADDR: XXXXXXXX
33 ST(0) XXXX XXXXXXXXXXXXXXXX ST(1) XXXX XXXXXXXXXXXXXXXX
34 ST(2) XXXX XXXXXXXXXXXXXXXX ST(3) XXXX XXXXXXXXXXXXXXXX
35 ST(4) XXXX XXXXXXXXXXXXXXXX ST(5) XXXX XXXXXXXXXXXXXXXX
36 ST(6) XXXX XXXXXXXXXXXXXXXX ST(7) XXXX XXXXXXXXXXXXXXXX
40 static void
41 hexvalue (unsigned long int value, char *buf, size_t len)
43 char *cp = _itoa_word (value, buf + len, 16, 0);
44 while (cp > buf)
45 *--cp = '0';
48 static void
49 register_dump (int fd, struct sigcontext *ctx)
51 char regs[19][8];
52 struct iovec iov[40];
53 size_t nr = 0;
55 #define ADD_STRING(str) \
56 iov[nr].iov_base = (char *) str; \
57 iov[nr].iov_len = strlen (str); \
58 ++nr
59 #define ADD_MEM(str, len) \
60 iov[nr].iov_base = str; \
61 iov[nr].iov_len = len; \
62 ++nr
64 /* Generate strings of register contents. */
65 hexvalue (ctx->sregs->regs.gprs[0], regs[0], 8);
66 hexvalue (ctx->sregs->regs.gprs[1], regs[1], 8);
67 hexvalue (ctx->sregs->regs.gprs[2], regs[2], 8);
68 hexvalue (ctx->sregs->regs.gprs[3], regs[3], 8);
69 hexvalue (ctx->sregs->regs.gprs[4], regs[4], 8);
70 hexvalue (ctx->sregs->regs.gprs[5], regs[5], 8);
71 hexvalue (ctx->sregs->regs.gprs[6], regs[6], 8);
72 hexvalue (ctx->sregs->regs.gprs[7], regs[7], 8);
73 hexvalue (ctx->sregs->regs.gprs[8], regs[8], 8);
74 hexvalue (ctx->sregs->regs.gprs[9], regs[9], 8);
75 hexvalue (ctx->sregs->regs.gprs[10], regs[10], 8);
76 hexvalue (ctx->sregs->regs.gprs[11], regs[11], 8);
77 hexvalue (ctx->sregs->regs.gprs[12], regs[12], 8);
78 hexvalue (ctx->sregs->regs.gprs[13], regs[13], 8);
79 hexvalue (ctx->sregs->regs.gprs[14], regs[14], 8);
80 hexvalue (ctx->sregs->regs.gprs[15], regs[15], 8);
81 hexvalue (ctx->sregs->regs.psw.mask, regs[16], 8);
82 hexvalue (ctx->sregs->regs.psw.addr, regs[17], 8);
84 /* Generate the output. */
85 ADD_STRING ("Register dump:\n\n GPR0: ");
86 ADD_MEM (regs[0], 8);
87 ADD_STRING (" GPR1: ");
88 ADD_MEM (regs[1], 8);
89 ADD_STRING (" GPR2: ");
90 ADD_MEM (regs[2], 8);
91 ADD_STRING (" GPR3: ");
92 ADD_MEM (regs[3], 8);
93 ADD_STRING ("\n GPR4: ");
94 ADD_MEM (regs[4], 8);
95 ADD_STRING (" GPR5: ");
96 ADD_MEM (regs[5], 8);
97 ADD_STRING (" GPR6: ");
98 ADD_MEM (regs[6], 8);
99 ADD_STRING (" GPR7: ");
100 ADD_MEM (regs[7], 8);
101 ADD_STRING ("\n GPR8: ");
102 ADD_MEM (regs[8], 8);
103 ADD_STRING (" GPR9: ");
104 ADD_MEM (regs[9], 8);
105 ADD_STRING (" GPRA: ");
106 ADD_MEM (regs[10], 8);
107 ADD_STRING (" GPRB: ");
108 ADD_MEM (regs[11], 8);
109 ADD_STRING ("\n GPRC: ");
110 ADD_MEM (regs[12], 8);
111 ADD_STRING (" GPRD: ");
112 ADD_MEM (regs[13], 8);
113 ADD_STRING (" GPRE: ");
114 ADD_MEM (regs[14], 8);
115 ADD_STRING (" GPRF: ");
116 ADD_MEM (regs[15], 8);
117 ADD_STRING ("\n\n PSW.MASK: ");
118 ADD_MEM (regs[16], 8);
119 ADD_STRING (" PSW.ADDR: ");
120 ADD_MEM (regs[17], 8);
121 ADD_STRING (" TRAP: ");
122 ADD_MEM (regs[18], 4);
123 ADD_STRING ("\n");
125 /* Write the stuff out. */
126 writev (fd, iov, nr);
130 #define REGISTER_DUMP register_dump (fd, ctx)