]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/m68k/register-dump.h
2 Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Schwab <schwab@gnu.org>.
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
23 #include <stdio-common/_itoa.h>
25 /* We will print the register dump in this format:
27 D0: XXXXXXXX D1: XXXXXXXX D2: XXXXXXXX D3: XXXXXXXX
28 D4: XXXXXXXX D5: XXXXXXXX D6: XXXXXXXX D7: XXXXXXXX
29 A0: XXXXXXXX A1: XXXXXXXX A2: XXXXXXXX A3: XXXXXXXX
30 A4: XXXXXXXX A5: XXXXXXXX A6: XXXXXXXX A7: XXXXXXXX
33 OldMask: XXXXXXXX Vector: XXXX
35 FP0: XXXXXXXXXXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXXXXXXXXXX
36 FP2: XXXXXXXXXXXXXXXXXXXXXXXX FP3: XXXXXXXXXXXXXXXXXXXXXXXX
37 FP4: XXXXXXXXXXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXXXXXXXXXX
38 FP6: XXXXXXXXXXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXXXXXXXXXX
39 FPCR: XXXXXXXX FPSR: XXXXXXXX FPIAR: XXXXXXXX
43 /* Linux saves only the call-clobbered registers in the sigcontext. We
44 need to use a trampoline that saves the rest so that the C code can
45 access them. We use the sc_fpstate field, since the handler is not
46 supposed to return anyway, thus it doesn't matter that it's clobbered. */
48 /* static */ void catch_segfault (int, int, struct sigcontext
*);
50 /* Dummy function so that we can use asm with arguments. */
51 static void __attribute_used__
56 move.l 12(%%sp),%%a0\n\
58 /* Clear the first 4 bytes to make it a null fp state, just\n\
59 in case the handler does return. */\n\
61 movem.l %%d2-%%d7/%%a2-%%a6,(%%a0)\n\
62 fmovem.x %%fp2-%%fp7,11*4(%%a0)\n\
63 jra real_catch_segfault"
64 : : "n" (offsetof (struct sigcontext
, sc_fpstate
)));
66 #define catch_segfault(a,b) \
67 __attribute_used__ real_catch_segfault(a,b)
70 hexvalue (unsigned long int value
, char *buf
, size_t len
)
72 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
78 register_dump (int fd
, struct sigcontext
*ctx
)
82 struct iovec iov
[63], *next_iov
= iov
;
83 unsigned long *p
= (unsigned long *) ctx
->sc_fpstate
+ 1;
85 #define ADD_STRING(str) \
86 next_iov->iov_base = (char *) (str); \
87 next_iov->iov_len = strlen (str); \
89 #define ADD_MEM(str, len) \
90 next_iov->iov_base = (str); \
91 next_iov->iov_len = (len); \
94 /* Generate strings of register contents. */
95 hexvalue (ctx
->sc_d0
, regs
[0], 8);
96 hexvalue (ctx
->sc_d1
, regs
[1], 8);
97 hexvalue (*p
++, regs
[2], 8);
98 hexvalue (*p
++, regs
[3], 8);
99 hexvalue (*p
++, regs
[4], 8);
100 hexvalue (*p
++, regs
[5], 8);
101 hexvalue (*p
++, regs
[6], 8);
102 hexvalue (*p
++, regs
[7], 8);
103 hexvalue (ctx
->sc_a0
, regs
[8], 8);
104 hexvalue (ctx
->sc_a1
, regs
[9], 8);
105 hexvalue (*p
++, regs
[10], 8);
106 hexvalue (*p
++, regs
[11], 8);
107 hexvalue (*p
++, regs
[12], 8);
108 hexvalue (*p
++, regs
[13], 8);
109 hexvalue (*p
++, regs
[14], 8);
110 hexvalue (ctx
->sc_usp
, regs
[15], 8);
111 hexvalue (ctx
->sc_pc
, regs
[16], 8);
112 hexvalue (ctx
->sc_sr
, regs
[17], 4);
113 hexvalue (ctx
->sc_mask
, regs
[18], 8);
114 hexvalue (ctx
->sc_formatvec
& 0xfff, regs
[19], 4);
115 hexvalue (ctx
->sc_fpregs
[0], fpregs
[0], 8);
116 hexvalue (ctx
->sc_fpregs
[1], fpregs
[0] + 8, 8);
117 hexvalue (ctx
->sc_fpregs
[2], fpregs
[0] + 16, 8);
118 hexvalue (ctx
->sc_fpregs
[3], fpregs
[1], 8);
119 hexvalue (ctx
->sc_fpregs
[4], fpregs
[1] + 8, 8);
120 hexvalue (ctx
->sc_fpregs
[5], fpregs
[1] + 16, 8);
121 hexvalue (*p
++, fpregs
[2], 8);
122 hexvalue (*p
++, fpregs
[2] + 8, 8);
123 hexvalue (*p
++, fpregs
[2] + 16, 8);
124 hexvalue (*p
++, fpregs
[3], 8);
125 hexvalue (*p
++, fpregs
[3] + 8, 8);
126 hexvalue (*p
++, fpregs
[3] + 16, 8);
127 hexvalue (*p
++, fpregs
[4], 8);
128 hexvalue (*p
++, fpregs
[4] + 8, 8);
129 hexvalue (*p
++, fpregs
[4] + 16, 8);
130 hexvalue (*p
++, fpregs
[5], 8);
131 hexvalue (*p
++, fpregs
[5] + 8, 8);
132 hexvalue (*p
++, fpregs
[5] + 16, 8);
133 hexvalue (*p
++, fpregs
[6], 8);
134 hexvalue (*p
++, fpregs
[6] + 8, 8);
135 hexvalue (*p
++, fpregs
[6] + 16, 8);
136 hexvalue (*p
++, fpregs
[7], 8);
137 hexvalue (*p
++, fpregs
[7] + 8, 8);
138 hexvalue (*p
++, fpregs
[7] + 16, 8);
139 hexvalue (ctx
->sc_fpcntl
[0], fpregs
[8], 8);
140 hexvalue (ctx
->sc_fpcntl
[1], fpregs
[9], 8);
141 hexvalue (ctx
->sc_fpcntl
[2], fpregs
[10], 8);
143 /* Generate the output. */
144 ADD_STRING ("Register dump:\n\n D0: ");
145 ADD_MEM (regs
[0], 8);
146 ADD_STRING (" D1: ");
147 ADD_MEM (regs
[1], 8);
148 ADD_STRING (" D2: ");
149 ADD_MEM (regs
[2], 8);
150 ADD_STRING (" D3: ");
151 ADD_MEM (regs
[3], 8);
152 ADD_STRING ("\n D4: ");
153 ADD_MEM (regs
[4], 8);
154 ADD_STRING (" D5: ");
155 ADD_MEM (regs
[5], 8);
156 ADD_STRING (" D6: ");
157 ADD_MEM (regs
[6], 8);
158 ADD_STRING (" D7: ");
159 ADD_MEM (regs
[7], 8);
160 ADD_STRING ("\n A0: ");
161 ADD_MEM (regs
[8], 8);
162 ADD_STRING (" A1: ");
163 ADD_MEM (regs
[9], 8);
164 ADD_STRING (" A2: ");
165 ADD_MEM (regs
[10], 8);
166 ADD_STRING (" A3: ");
167 ADD_MEM (regs
[11], 8);
168 ADD_STRING ("\n A4: ");
169 ADD_MEM (regs
[12], 8);
170 ADD_STRING (" A5: ");
171 ADD_MEM (regs
[13], 8);
172 ADD_STRING (" A6: ");
173 ADD_MEM (regs
[14], 8);
174 ADD_STRING (" A7: ");
175 ADD_MEM (regs
[15], 8);
176 ADD_STRING ("\n PC: ");
177 ADD_MEM (regs
[16], 8);
178 ADD_STRING (" SR: ");
179 ADD_MEM (regs
[17], 4);
181 ADD_STRING ("\n\n OldMask: ");
182 ADD_MEM (regs
[18], 8);
183 ADD_STRING (" Vector: ");
184 ADD_MEM (regs
[19], 4);
186 ADD_STRING ("\n\n FP0: ");
187 ADD_MEM (fpregs
[0], 24);
188 ADD_STRING (" FP1: ");
189 ADD_MEM (fpregs
[1], 24);
190 ADD_STRING ("\n FP2: ");
191 ADD_MEM (fpregs
[2], 24);
192 ADD_STRING (" FP3: ");
193 ADD_MEM (fpregs
[3], 24);
194 ADD_STRING ("\n FP4: ");
195 ADD_MEM (fpregs
[4], 24);
196 ADD_STRING (" FP5: ");
197 ADD_MEM (fpregs
[5], 24);
198 ADD_STRING ("\n FP6: ");
199 ADD_MEM (fpregs
[6], 24);
200 ADD_STRING (" FP7: ");
201 ADD_MEM (fpregs
[7], 24);
202 ADD_STRING ("\n FPCR: ");
203 ADD_MEM (fpregs
[8], 8);
204 ADD_STRING (" FPSR: ");
205 ADD_MEM (fpregs
[9], 8);
206 ADD_STRING (" FPIAR: ");
207 ADD_MEM (fpregs
[10], 8);
210 /* Write the stuff out. */
211 writev (fd
, iov
, next_iov
- iov
);
214 #define REGISTER_DUMP register_dump (fd, ctx)