(ELF_MACHINE_NO_RELA): Define unconditionally to defined RTLD_BOOTSTRAP.
[glibc-ports.git] / sysdeps / unix / sysv / aix / powerpc / register-dump.h
blobf0d8b998376b22c7d1a46cab5d5053845521b2a2
1 /* Dump registers.
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
18 02111-1307 USA. */
20 #include <sys/uio.h>
21 #include <stdio-common/_itoa.h>
22 #include <sys/ucontext.h>
24 /* We will print the register dump in this format:
26 Register dump:
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
48 static void
49 hexvalue (unsigned long int value, char *buf, size_t len)
51 char *cp = _itoa_word (value, buf + len, 16, 0);
52 while (cp > buf)
53 *--cp = '0';
57 static void
58 register_dump (int fd, struct sigcontext *ctx)
60 char regs[108][8];
61 struct iovec iov[38];
62 struct __mstsafe *reg_state;
63 int i;
64 int ii;
65 size_t nr = 0;
67 #define ADD_STRING(str) \
68 iov[nr].iov_base = (char *) str; \
69 iov[nr].iov_len = strlen (str); \
70 ++nr
71 #define ADD_MEM(str, len) \
72 iov[nr].iov_base = str; \
73 iov[nr].iov_len = len; \
74 ++nr
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);
89 ii=10;
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);
97 ADD_STRING (" ");
98 ADD_MEM (regs[44], 8);
99 ADD_MEM (regs[45], 8);
100 ADD_STRING (" ");
101 ADD_MEM (regs[46], 8);
102 ADD_MEM (regs[47], 8);
103 ADD_STRING (" ");
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);
109 ADD_STRING (" ");
110 ADD_MEM (regs[52], 8);
111 ADD_MEM (regs[53], 8);
112 ADD_STRING (" ");
113 ADD_MEM (regs[54], 8);
114 ADD_MEM (regs[55], 8);
115 ADD_STRING (" ");
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);
121 ADD_STRING (" ");
122 ADD_MEM (regs[60], 8);
123 ADD_MEM (regs[61], 8);
124 ADD_STRING (" ");
125 ADD_MEM (regs[62], 8);
126 ADD_MEM (regs[63], 8);
127 ADD_STRING (" ");
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);
133 ADD_STRING (" ");
134 ADD_MEM (regs[68], 8);
135 ADD_MEM (regs[69], 8);
136 ADD_STRING (" ");
137 ADD_MEM (regs[70], 8);
138 ADD_MEM (regs[71], 8);
139 ADD_STRING (" ");
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);
145 ADD_STRING (" ");
146 ADD_MEM (regs[76], 8);
147 ADD_MEM (regs[78], 8);
148 ADD_STRING (" ");
149 ADD_MEM (regs[79], 8);
150 ADD_MEM (regs[80], 8);
151 ADD_STRING (" ");
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);
157 ADD_STRING (" ");
158 ADD_MEM (regs[85], 8);
159 ADD_MEM (regs[86], 8);
160 ADD_STRING (" ");
161 ADD_MEM (regs[87], 8);
162 ADD_MEM (regs[88], 8);
163 ADD_STRING (" ");
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);
169 ADD_STRING (" ");
170 ADD_MEM (regs[93], 8);
171 ADD_MEM (regs[94], 8);
172 ADD_STRING (" ");
173 ADD_MEM (regs[95], 8);
174 ADD_MEM (regs[96], 8);
175 ADD_STRING (" ");
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);
181 ADD_STRING (" ");
182 ADD_MEM (regs[101], 8);
183 ADD_MEM (regs[102], 8);
184 ADD_STRING (" ");
185 ADD_MEM (regs[103], 8);
186 ADD_MEM (regs[104], 8);
187 ADD_STRING (" ");
188 ADD_MEM (regs[105], 8);
189 ADD_MEM (regs[106], 8);
190 ADD_STRING ("\n\nr00-07 ");
191 ADD_MEM (regs[10], 8);
192 ADD_STRING (" ");
193 ADD_MEM (regs[11], 8);
194 ADD_STRING (" ");
195 ADD_MEM (regs[12], 8);
196 ADD_STRING (" ");
197 ADD_MEM (regs[13], 8);
198 ADD_STRING (" ");
199 ADD_MEM (regs[14], 8);
200 ADD_STRING (" ");
201 ADD_MEM (regs[15], 8);
202 ADD_STRING (" ");
203 ADD_MEM (regs[16], 8);
204 ADD_STRING (" ");
205 ADD_MEM (regs[17], 8);
206 ADD_STRING ("\nr08-15 ");
207 ADD_MEM (regs[18], 8);
208 ADD_STRING (" ");
209 ADD_MEM (regs[19], 8);
210 ADD_STRING (" ");
211 ADD_MEM (regs[20], 8);
212 ADD_STRING (" ");
213 ADD_MEM (regs[21], 8);
214 ADD_STRING (" ");
215 ADD_MEM (regs[22], 8);
216 ADD_STRING (" ");
217 ADD_MEM (regs[23], 8);
218 ADD_STRING (" ");
219 ADD_MEM (regs[24], 8);
220 ADD_STRING (" ");
221 ADD_MEM (regs[25], 8);
222 ADD_STRING ("\nr16-23 ");
223 ADD_MEM (regs[26], 8);
224 ADD_STRING (" ");
225 ADD_MEM (regs[27], 8);
226 ADD_STRING (" ");
227 ADD_MEM (regs[28], 8);
228 ADD_STRING (" ");
229 ADD_MEM (regs[29], 8);
230 ADD_STRING (" ");
231 ADD_MEM (regs[30], 8);
232 ADD_STRING (" ");
233 ADD_MEM (regs[31], 8);
234 ADD_STRING (" ");
235 ADD_MEM (regs[32], 8);
236 ADD_STRING (" ");
237 ADD_MEM (regs[33], 8);
238 ADD_STRING ("\nr24-31 ");
239 ADD_MEM (regs[34], 8);
240 ADD_STRING (" ");
241 ADD_MEM (regs[35], 8);
242 ADD_STRING (" ");
243 ADD_MEM (regs[36], 8);
244 ADD_STRING (" ");
245 ADD_MEM (regs[37], 8);
246 ADD_STRING (" ");
247 ADD_MEM (regs[38], 8);
248 ADD_STRING (" ");
249 ADD_MEM (regs[39], 8);
250 ADD_STRING (" ");
251 ADD_MEM (regs[40], 8);
252 ADD_STRING (" ");
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);
260 ADD_STRING (" cr ");
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);
268 ADD_STRING (" mq ");
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);
274 ADD_STRING ("\n");
276 /* Write the stuff out. */
277 writev (fd, iov, nr);
280 #define REGISTER_DUMP register_dump (fd, ctx)