]>
Commit | Line | Data |
---|---|---|
847b055c | 1 | /* Dump registers. |
d4697bc9 | 2 | Copyright (C) 2000-2014 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 | ||
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 | |
29 | ||
30 | PSW.MASK: XXXXXXXX PSW.ADDR: XXXXXXXX | |
31 | ||
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 | |
36 | ||
37 | */ | |
38 | ||
39 | static void | |
40 | hexvalue (unsigned long int value, char *buf, size_t len) | |
41 | { | |
42 | char *cp = _itoa_word (value, buf + len, 16, 0); | |
43 | while (cp > buf) | |
44 | *--cp = '0'; | |
45 | } | |
46 | ||
47 | static void | |
48 | register_dump (int fd, struct sigcontext *ctx) | |
49 | { | |
50 | char regs[19][8]; | |
51 | struct iovec iov[40]; | |
52 | size_t nr = 0; | |
53 | ||
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 | |
62 | ||
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); | |
82 | ||
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"); | |
123 | ||
124 | /* Write the stuff out. */ | |
125 | writev (fd, iov, nr); | |
126 | } | |
127 | ||
128 | ||
6d763b87 | 129 | #define REGISTER_DUMP register_dump (fd, ctx) |