2 Copyright (C) 1999, 2000 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>
23 /* We will print the register dump in this format:
25 R0: XXXXXXXX R1: XXXXXXXX R2: XXXXXXXX R3: XXXXXXXX
26 R4: XXXXXXXX R5: XXXXXXXX R6: XXXXXXXX R7: XXXXXXXX
27 R8: XXXXXXXX R9: XXXXXXXX R10: XXXXXXXX R11: XXXXXXXX
28 R12: XXXXXXXX R13: XXXXXXXX R14: XXXXXXXX R15: XXXXXXXX
30 MACL: XXXXXXXX MACH: XXXXXXXX
32 PC: XXXXXXXX PR: XXXXXXXX GBR: XXXXXXXX SR: XXXXXXXX
34 FR0: XXXXXXXX FR1: XXXXXXXX FR2: XXXXXXXX FR3: XXXXXXXX
35 FR4: XXXXXXXX FR5: XXXXXXXX FR6: XXXXXXXX FR7: XXXXXXXX
36 FR8: XXXXXXXX FR9: XXXXXXXX FR10: XXXXXXXX FR11: XXXXXXXX
37 FR12: XXXXXXXX FR13: XXXXXXXX FR14: XXXXXXXX FR15: XXXXXXXX
39 XR0: XXXXXXXX XR1: XXXXXXXX XR2: XXXXXXXX XR3: XXXXXXXX
40 XR4: XXXXXXXX XR5: XXXXXXXX XR6: XXXXXXXX XR7: XXXXXXXX
41 XR8: XXXXXXXX XR9: XXXXXXXX XR10: XXXXXXXX XR11: XXXXXXXX
42 XR12: XXXXXXXX XR13: XXXXXXXX XR14: XXXXXXXX XR15: XXXXXXXX
44 FPSCR: XXXXXXXX FPUL: XXXXXXXX
49 hexvalue (unsigned long int value
, char *buf
, size_t len
)
51 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
57 register_dump (int fd
, struct sigcontext
*ctx
)
60 struct iovec iov
[112];
63 #define ADD_STRING(str) \
64 iov[nr].iov_base = (char *) str; \
65 iov[nr].iov_len = strlen (str); \
67 #define ADD_MEM(str, len) \
68 iov[nr].iov_base = str; \
69 iov[nr].iov_len = len; \
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);
96 /* Generate the output. */
97 ADD_STRING ("Register dump:\n\n R0: ");
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);
130 ADD_STRING ("\n\nMACL: ");
131 ADD_MEM (regs
[16], 8);
132 ADD_STRING (" MACH: ");
133 ADD_MEM (regs
[17], 8);
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);
146 /* Write the stuff out. */
147 writev (fd
, iov
, nr
);
151 #define REGISTER_DUMP register_dump (fd, &ctx)