2 Copyright (C) 1998 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include <stdio-common/_itoa.h>
22 #include <sys/ucontext.h>
24 /* We will print the register dump in this format:
27 fp0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
28 fp4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
29 fp8-11: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
30 fp12-15: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
31 fp16-19: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
32 fp20-23: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
33 fp24-27: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
34 fp28-31: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
36 r00-07 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
37 r08-15 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
38 r16-23 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
39 r24-31 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
41 trap 00000000 iar 00000000 msr 00000000 cr 00000000
42 lr 00000000 ctr 00000000 xer 00000000 mq 00000000
43 tid 00000000 fpscr 00000000
49 hexvalue (unsigned long int value
, char *buf
, size_t len
)
51 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
58 register_dump (int fd
, struct sigcontext
*ctx
)
62 struct __mstsafe
*reg_state
;
67 #define ADD_STRING(str) \
68 iov[nr].iov_base = (char *) str; \
69 iov[nr].iov_len = strlen (str); \
71 #define ADD_MEM(str, len) \
72 iov[nr].iov_base = str; \
73 iov[nr].iov_len = len; \
76 reg_state
= (struct __mstsafe
*)&ctx
->sc_jmpbuf
.__jmp_context
;
78 hexvalue (reg_state
->__excp_type
, regs
[0], 8);
79 hexvalue (reg_state
->__iar
, regs
[1], 8);
80 hexvalue (reg_state
->__msr
, regs
[2], 8);
81 hexvalue (reg_state
->__cr
, regs
[3], 8);
82 hexvalue (reg_state
->__lr
, regs
[4], 8);
83 hexvalue (reg_state
->__ctr
, regs
[5], 8);
84 hexvalue (reg_state
->__xer
, regs
[6], 8);
85 hexvalue (reg_state
->__mq
, regs
[7], 8);
86 hexvalue (reg_state
->__tid
, regs
[8], 8);
87 hexvalue (reg_state
->__fpscr
, regs
[9], 8);
90 for (i
= 0; i
<= 96; i
++,ii
++)
91 hexvalue (reg_state
->__gpr
[i
], regs
[ii
], 8);
93 /* Generate the output. */
94 ADD_STRING ("Register dump:\n\nfp0-3: ");
95 ADD_MEM (regs
[42], 8);
96 ADD_MEM (regs
[43], 8);
98 ADD_MEM (regs
[44], 8);
99 ADD_MEM (regs
[45], 8);
101 ADD_MEM (regs
[46], 8);
102 ADD_MEM (regs
[47], 8);
104 ADD_MEM (regs
[48], 8);
105 ADD_MEM (regs
[49], 8);
106 ADD_STRING ("\nfp4-7: ");
107 ADD_MEM (regs
[50], 8);
108 ADD_MEM (regs
[51], 8);
110 ADD_MEM (regs
[52], 8);
111 ADD_MEM (regs
[53], 8);
113 ADD_MEM (regs
[54], 8);
114 ADD_MEM (regs
[55], 8);
116 ADD_MEM (regs
[56], 8);
117 ADD_MEM (regs
[57], 8);
118 ADD_STRING ("\nfp8-11: ");
119 ADD_MEM (regs
[58], 8);
120 ADD_MEM (regs
[59], 8);
122 ADD_MEM (regs
[60], 8);
123 ADD_MEM (regs
[61], 8);
125 ADD_MEM (regs
[62], 8);
126 ADD_MEM (regs
[63], 8);
128 ADD_MEM (regs
[64], 8);
129 ADD_MEM (regs
[65], 8);
130 ADD_STRING ("\nfp12-15: ");
131 ADD_MEM (regs
[66], 8);
132 ADD_MEM (regs
[67], 8);
134 ADD_MEM (regs
[68], 8);
135 ADD_MEM (regs
[69], 8);
137 ADD_MEM (regs
[70], 8);
138 ADD_MEM (regs
[71], 8);
140 ADD_MEM (regs
[72], 8);
141 ADD_MEM (regs
[73], 8);
142 ADD_STRING ("\nfp16-19: ");
143 ADD_MEM (regs
[74], 8);
144 ADD_MEM (regs
[75], 8);
146 ADD_MEM (regs
[76], 8);
147 ADD_MEM (regs
[78], 8);
149 ADD_MEM (regs
[79], 8);
150 ADD_MEM (regs
[80], 8);
152 ADD_MEM (regs
[81], 8);
153 ADD_MEM (regs
[82], 8);
154 ADD_STRING ("\nfp20-23: ");
155 ADD_MEM (regs
[83], 8);
156 ADD_MEM (regs
[84], 8);
158 ADD_MEM (regs
[85], 8);
159 ADD_MEM (regs
[86], 8);
161 ADD_MEM (regs
[87], 8);
162 ADD_MEM (regs
[88], 8);
164 ADD_MEM (regs
[89], 8);
165 ADD_MEM (regs
[90], 8);
166 ADD_STRING ("\nfp24-27: ");
167 ADD_MEM (regs
[91], 8);
168 ADD_MEM (regs
[92], 8);
170 ADD_MEM (regs
[93], 8);
171 ADD_MEM (regs
[94], 8);
173 ADD_MEM (regs
[95], 8);
174 ADD_MEM (regs
[96], 8);
176 ADD_MEM (regs
[97], 8);
177 ADD_MEM (regs
[98], 8);
178 ADD_STRING ("\nfp28-31: ");
179 ADD_MEM (regs
[99], 8);
180 ADD_MEM (regs
[100], 8);
182 ADD_MEM (regs
[101], 8);
183 ADD_MEM (regs
[102], 8);
185 ADD_MEM (regs
[103], 8);
186 ADD_MEM (regs
[104], 8);
188 ADD_MEM (regs
[105], 8);
189 ADD_MEM (regs
[106], 8);
190 ADD_STRING ("\n\nr00-07 ");
191 ADD_MEM (regs
[10], 8);
193 ADD_MEM (regs
[11], 8);
195 ADD_MEM (regs
[12], 8);
197 ADD_MEM (regs
[13], 8);
199 ADD_MEM (regs
[14], 8);
201 ADD_MEM (regs
[15], 8);
203 ADD_MEM (regs
[16], 8);
205 ADD_MEM (regs
[17], 8);
206 ADD_STRING ("\nr08-15 ");
207 ADD_MEM (regs
[18], 8);
209 ADD_MEM (regs
[19], 8);
211 ADD_MEM (regs
[20], 8);
213 ADD_MEM (regs
[21], 8);
215 ADD_MEM (regs
[22], 8);
217 ADD_MEM (regs
[23], 8);
219 ADD_MEM (regs
[24], 8);
221 ADD_MEM (regs
[25], 8);
222 ADD_STRING ("\nr16-23 ");
223 ADD_MEM (regs
[26], 8);
225 ADD_MEM (regs
[27], 8);
227 ADD_MEM (regs
[28], 8);
229 ADD_MEM (regs
[29], 8);
231 ADD_MEM (regs
[30], 8);
233 ADD_MEM (regs
[31], 8);
235 ADD_MEM (regs
[32], 8);
237 ADD_MEM (regs
[33], 8);
238 ADD_STRING ("\nr24-31 ");
239 ADD_MEM (regs
[34], 8);
241 ADD_MEM (regs
[35], 8);
243 ADD_MEM (regs
[36], 8);
245 ADD_MEM (regs
[37], 8);
247 ADD_MEM (regs
[38], 8);
249 ADD_MEM (regs
[39], 8);
251 ADD_MEM (regs
[40], 8);
253 ADD_MEM (regs
[41], 8);
254 ADD_STRING ("\n\n trap ");
255 ADD_MEM (regs
[0], 8);
256 ADD_STRING (" iar ");
257 ADD_MEM (regs
[1], 8);
258 ADD_STRING (" msr ");
259 ADD_MEM (regs
[2], 8);
261 ADD_MEM (regs
[3], 8);
262 ADD_STRING ("\n lr ");
263 ADD_MEM (regs
[4], 8);
264 ADD_STRING (" ctr ");
265 ADD_MEM (regs
[5], 8);
266 ADD_STRING (" xer ");
267 ADD_MEM (regs
[6], 8);
269 ADD_MEM (regs
[7], 8);
270 ADD_STRING ("\n tid ");
271 ADD_MEM (regs
[8], 8);
272 ADD_STRING (" fpscr ");
273 ADD_MEM (regs
[9], 8);
276 /* Write the stuff out. */
277 writev (fd
, iov
, nr
);
280 #define REGISTER_DUMP register_dump (fd, ctx)