]>
Commit | Line | Data |
---|---|---|
3846ef75 | 1 | /* Dump registers. |
d4697bc9 | 2 | Copyright (C) 1999-2014 Free Software Foundation, Inc. |
3846ef75 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
3846ef75 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
3846ef75 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
3846ef75 UD |
18 | |
19 | #include <sys/uio.h> | |
eb96ffb0 | 20 | #include <_itoa.h> |
3846ef75 UD |
21 | |
22 | /* We will print the register dump in this format: | |
23 | ||
24 | R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX | |
25 | R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX | |
26 | R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX | |
27 | R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX | |
28 | ||
29 | MACL: XXXXXXXX MACH: XXXXXXXX | |
30 | ||
31 | PC: XXXXXXXX PR: XXXXXXXX GBR: XXXXXXXX SR: XXXXXXXX | |
32 | ||
0899b889 UD |
33 | FR0: XXXXXXXX FR1: XXXXXXXX FR2: XXXXXXXX FR3: XXXXXXXX |
34 | FR4: XXXXXXXX FR5: XXXXXXXX FR6: XXXXXXXX FR7: XXXXXXXX | |
35 | FR8: XXXXXXXX FR9: XXXXXXXX FR10: XXXXXXXX FR11: XXXXXXXX | |
36 | FR12: XXXXXXXX FR13: XXXXXXXX FR14: XXXXXXXX FR15: XXXXXXXX | |
3846ef75 | 37 | |
0899b889 UD |
38 | XR0: XXXXXXXX XR1: XXXXXXXX XR2: XXXXXXXX XR3: XXXXXXXX |
39 | XR4: XXXXXXXX XR5: XXXXXXXX XR6: XXXXXXXX XR7: XXXXXXXX | |
40 | XR8: XXXXXXXX XR9: XXXXXXXX XR10: XXXXXXXX XR11: XXXXXXXX | |
41 | XR12: XXXXXXXX XR13: XXXXXXXX XR14: XXXXXXXX XR15: XXXXXXXX | |
3846ef75 UD |
42 | |
43 | FPSCR: XXXXXXXX FPUL: XXXXXXXX | |
44 | ||
45 | */ | |
46 | ||
47 | static void | |
48 | hexvalue (unsigned long int value, char *buf, size_t len) | |
49 | { | |
50 | char *cp = _itoa_word (value, buf + len, 16, 0); | |
51 | while (cp > buf) | |
52 | *--cp = '0'; | |
53 | } | |
54 | ||
55 | static void | |
56 | register_dump (int fd, struct sigcontext *ctx) | |
57 | { | |
58 | char regs[22][8]; | |
59 | char fpregs[34][8]; | |
d2f73151 | 60 | struct iovec iov[22 * 2 + 34 * 2 + 2]; |
3846ef75 UD |
61 | size_t nr = 0; |
62 | ||
63 | #define ADD_STRING(str) \ | |
64 | iov[nr].iov_base = (char *) str; \ | |
65 | iov[nr].iov_len = strlen (str); \ | |
66 | ++nr | |
67 | #define ADD_MEM(str, len) \ | |
68 | iov[nr].iov_base = str; \ | |
69 | iov[nr].iov_len = len; \ | |
70 | ++nr | |
71 | ||
72 | /* Generate strings of register contents. */ | |
73 | hexvalue (ctx->sc_regs[0], regs[0], 8); | |
74 | hexvalue (ctx->sc_regs[1], regs[1], 8); | |
75 | hexvalue (ctx->sc_regs[2], regs[2], 8); | |
76 | hexvalue (ctx->sc_regs[3], regs[3], 8); | |
77 | hexvalue (ctx->sc_regs[4], regs[4], 8); | |
78 | hexvalue (ctx->sc_regs[5], regs[5], 8); | |
79 | hexvalue (ctx->sc_regs[6], regs[6], 8); | |
80 | hexvalue (ctx->sc_regs[7], regs[7], 8); | |
81 | hexvalue (ctx->sc_regs[8], regs[8], 8); | |
82 | hexvalue (ctx->sc_regs[9], regs[9], 8); | |
83 | hexvalue (ctx->sc_regs[10], regs[10], 8); | |
84 | hexvalue (ctx->sc_regs[11], regs[11], 8); | |
85 | hexvalue (ctx->sc_regs[12], regs[12], 8); | |
86 | hexvalue (ctx->sc_regs[13], regs[13], 8); | |
87 | hexvalue (ctx->sc_regs[14], regs[14], 8); | |
88 | hexvalue (ctx->sc_regs[15], regs[15], 8); | |
89 | hexvalue (ctx->sc_macl, regs[16], 8); | |
90 | hexvalue (ctx->sc_mach, regs[17], 8); | |
91 | hexvalue (ctx->sc_pc, regs[18], 8); | |
92 | hexvalue (ctx->sc_pr, regs[19], 8); | |
93 | hexvalue (ctx->sc_gbr, regs[20], 8); | |
94 | hexvalue (ctx->sc_sr, regs[21], 8); | |
95 | ||
96 | /* Generate the output. */ | |
97 | ADD_STRING ("Register dump:\n\n R0: "); | |
98 | ADD_MEM (regs[0], 8); | |
99 | ADD_STRING (" R1: "); | |
100 | ADD_MEM (regs[1], 8); | |
101 | ADD_STRING (" R2: "); | |
102 | ADD_MEM (regs[2], 8); | |
103 | ADD_STRING (" R3: "); | |
104 | ADD_MEM (regs[3], 8); | |
105 | ADD_STRING ("\n R4: "); | |
106 | ADD_MEM (regs[4], 8); | |
107 | ADD_STRING (" R5: "); | |
108 | ADD_MEM (regs[5], 8); | |
109 | ADD_STRING (" R6: "); | |
110 | ADD_MEM (regs[6], 8); | |
111 | ADD_STRING (" R7: "); | |
112 | ADD_MEM (regs[7], 8); | |
113 | ADD_STRING ("\n R8: "); | |
114 | ADD_MEM (regs[8], 8); | |
115 | ADD_STRING (" R9: "); | |
116 | ADD_MEM (regs[9], 8); | |
117 | ADD_STRING (" R10: "); | |
118 | ADD_MEM (regs[10], 8); | |
119 | ADD_STRING (" R11: "); | |
120 | ADD_MEM (regs[11], 8); | |
121 | ADD_STRING ("\n R12: "); | |
122 | ADD_MEM (regs[12], 8); | |
123 | ADD_STRING (" R13: "); | |
124 | ADD_MEM (regs[13], 8); | |
125 | ADD_STRING (" R14: "); | |
126 | ADD_MEM (regs[14], 8); | |
127 | ADD_STRING (" R15: "); | |
128 | ADD_MEM (regs[15], 8); | |
129 | ||
130 | ADD_STRING ("\n\nMACL: "); | |
131 | ADD_MEM (regs[16], 8); | |
132 | ADD_STRING (" MACH: "); | |
133 | ADD_MEM (regs[17], 8); | |
134 | ||
135 | ADD_STRING ("\n\n PC: "); | |
136 | ADD_MEM (regs[18], 8); | |
137 | ADD_STRING (" PR: "); | |
138 | ADD_MEM (regs[19], 8); | |
139 | ADD_STRING (" GBR: "); | |
140 | ADD_MEM (regs[20], 8); | |
141 | ADD_STRING (" SR: "); | |
142 | ADD_MEM (regs[21], 8); | |
143 | ||
144 | ADD_STRING ("\n"); | |
145 | ||
0899b889 | 146 | #ifdef __SH_FPU_ANY__ |
3846ef75 UD |
147 | if (ctx->sc_ownedfp != NULL) |
148 | { | |
149 | hexvalue (ctx->sc_fpregs[0], fpregs[0], 8); | |
150 | hexvalue (ctx->sc_fpregs[1], fpregs[1], 8); | |
151 | hexvalue (ctx->sc_fpregs[2], fpregs[2], 8); | |
152 | hexvalue (ctx->sc_fpregs[3], fpregs[3], 8); | |
153 | hexvalue (ctx->sc_fpregs[4], fpregs[4], 8); | |
154 | hexvalue (ctx->sc_fpregs[5], fpregs[5], 8); | |
155 | hexvalue (ctx->sc_fpregs[6], fpregs[6], 8); | |
156 | hexvalue (ctx->sc_fpregs[7], fpregs[7], 8); | |
157 | hexvalue (ctx->sc_fpregs[8], fpregs[8], 8); | |
158 | hexvalue (ctx->sc_fpregs[9], fpregs[9], 8); | |
159 | hexvalue (ctx->sc_fpregs[10], fpregs[10], 8); | |
160 | hexvalue (ctx->sc_fpregs[11], fpregs[11], 8); | |
161 | hexvalue (ctx->sc_fpregs[12], fpregs[12], 8); | |
162 | hexvalue (ctx->sc_fpregs[13], fpregs[13], 8); | |
163 | hexvalue (ctx->sc_fpregs[14], fpregs[14], 8); | |
164 | hexvalue (ctx->sc_fpregs[15], fpregs[15], 8); | |
165 | hexvalue (ctx->sc_xfpregs[0], fpregs[16], 8); | |
166 | hexvalue (ctx->sc_xfpregs[1], fpregs[17], 8); | |
167 | hexvalue (ctx->sc_xfpregs[2], fpregs[18], 8); | |
168 | hexvalue (ctx->sc_xfpregs[3], fpregs[19], 8); | |
169 | hexvalue (ctx->sc_xfpregs[4], fpregs[20], 8); | |
170 | hexvalue (ctx->sc_xfpregs[5], fpregs[21], 8); | |
171 | hexvalue (ctx->sc_xfpregs[6], fpregs[22], 8); | |
172 | hexvalue (ctx->sc_xfpregs[7], fpregs[23], 8); | |
173 | hexvalue (ctx->sc_xfpregs[8], fpregs[24], 8); | |
174 | hexvalue (ctx->sc_xfpregs[9], fpregs[25], 8); | |
175 | hexvalue (ctx->sc_xfpregs[10], fpregs[26], 8); | |
176 | hexvalue (ctx->sc_xfpregs[11], fpregs[27], 8); | |
177 | hexvalue (ctx->sc_xfpregs[12], fpregs[28], 8); | |
178 | hexvalue (ctx->sc_xfpregs[13], fpregs[29], 8); | |
179 | hexvalue (ctx->sc_xfpregs[14], fpregs[30], 8); | |
180 | hexvalue (ctx->sc_xfpregs[15], fpregs[31], 8); | |
181 | hexvalue (ctx->sc_fpscr, fpregs[32], 8); | |
182 | hexvalue (ctx->sc_fpul, fpregs[33], 8); | |
183 | ||
184 | ADD_STRING ("\n\n FR0: "); | |
185 | ADD_MEM (fpregs[0], 8); | |
186 | ADD_STRING (" FR1: "); | |
187 | ADD_MEM (fpregs[1], 8); | |
188 | ADD_STRING (" FR2: "); | |
189 | ADD_MEM (fpregs[2], 8); | |
190 | ADD_STRING (" FR3: "); | |
191 | ADD_MEM (fpregs[3], 8); | |
192 | ADD_STRING ("\n FR4: "); | |
193 | ADD_MEM (fpregs[4], 8); | |
194 | ADD_STRING (" FR5: "); | |
195 | ADD_MEM (fpregs[5], 8); | |
196 | ADD_STRING (" FR6: "); | |
197 | ADD_MEM (fpregs[6], 8); | |
198 | ADD_STRING (" FR7: "); | |
199 | ADD_MEM (fpregs[7], 8); | |
200 | ADD_STRING ("\n FR8: "); | |
201 | ADD_MEM (fpregs[8], 8); | |
202 | ADD_STRING (" FR9: "); | |
203 | ADD_MEM (fpregs[9], 8); | |
204 | ADD_STRING (" FR10: "); | |
205 | ADD_MEM (fpregs[10], 8); | |
206 | ADD_STRING (" FR11: "); | |
207 | ADD_MEM (fpregs[11], 8); | |
208 | ADD_STRING ("\nFR12: "); | |
209 | ADD_MEM (fpregs[12], 8); | |
210 | ADD_STRING (" FR13: "); | |
211 | ADD_MEM (fpregs[13], 8); | |
212 | ADD_STRING (" FR14: "); | |
213 | ADD_MEM (fpregs[14], 8); | |
214 | ADD_STRING (" FR15: "); | |
215 | ADD_MEM (fpregs[15], 8); | |
216 | ADD_STRING ("\n\n XR0: "); | |
217 | ADD_MEM (fpregs[16], 8); | |
218 | ADD_STRING (" XR1: "); | |
219 | ADD_MEM (fpregs[17], 8); | |
220 | ADD_STRING (" XR2: "); | |
221 | ADD_MEM (fpregs[18], 8); | |
222 | ADD_STRING (" XR3: "); | |
223 | ADD_MEM (fpregs[19], 8); | |
224 | ADD_STRING ("\n XR4: "); | |
225 | ADD_MEM (fpregs[20], 8); | |
226 | ADD_STRING (" XR5: "); | |
227 | ADD_MEM (fpregs[21], 8); | |
228 | ADD_STRING (" XR6: "); | |
229 | ADD_MEM (fpregs[22], 8); | |
230 | ADD_STRING (" XR7: "); | |
231 | ADD_MEM (fpregs[23], 8); | |
232 | ADD_STRING ("\n XR8: "); | |
233 | ADD_MEM (fpregs[24], 8); | |
234 | ADD_STRING (" XR9: "); | |
235 | ADD_MEM (fpregs[25], 8); | |
236 | ADD_STRING (" XR10: "); | |
237 | ADD_MEM (fpregs[26], 8); | |
238 | ADD_STRING (" XR11: "); | |
239 | ADD_MEM (fpregs[27], 8); | |
240 | ADD_STRING ("\nXR12: "); | |
241 | ADD_MEM (fpregs[28], 8); | |
242 | ADD_STRING (" XR13: "); | |
243 | ADD_MEM (fpregs[29], 8); | |
244 | ADD_STRING (" XR14: "); | |
245 | ADD_MEM (fpregs[30], 8); | |
246 | ADD_STRING (" XR15: "); | |
247 | ADD_MEM (fpregs[31], 8); | |
248 | ||
249 | ADD_STRING ("\n\nFPSCR: "); | |
250 | ADD_MEM (fpregs[32], 8); | |
251 | ADD_STRING (" FPUL: "); | |
252 | ADD_MEM (fpregs[33], 8); | |
253 | ||
254 | ADD_STRING ("\n"); | |
255 | } | |
0899b889 | 256 | #endif /* __SH_FPU_ANY__ */ |
3846ef75 UD |
257 | |
258 | /* Write the stuff out. */ | |
259 | writev (fd, iov, nr); | |
260 | } | |
261 | ||
262 | ||
263 | #define REGISTER_DUMP register_dump (fd, &ctx) |