]>
Commit | Line | Data |
---|---|---|
3846ef75 UD |
1 | /* Dump registers. |
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | |
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> | |
20 | #include <stdio-common/_itoa.h> | |
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 | ||
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 | |
37 | ||
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 | |
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 | struct iovec iov[112]; | |
60 | size_t nr = 0; | |
61 | ||
62 | #define ADD_STRING(str) \ | |
63 | iov[nr].iov_base = (char *) str; \ | |
64 | iov[nr].iov_len = strlen (str); \ | |
65 | ++nr | |
66 | #define ADD_MEM(str, len) \ | |
67 | iov[nr].iov_base = str; \ | |
68 | iov[nr].iov_len = len; \ | |
69 | ++nr | |
70 | ||
71 | /* Generate strings of register contents. */ | |
72 | hexvalue (ctx->sc_regs[0], regs[0], 8); | |
73 | hexvalue (ctx->sc_regs[1], regs[1], 8); | |
74 | hexvalue (ctx->sc_regs[2], regs[2], 8); | |
75 | hexvalue (ctx->sc_regs[3], regs[3], 8); | |
76 | hexvalue (ctx->sc_regs[4], regs[4], 8); | |
77 | hexvalue (ctx->sc_regs[5], regs[5], 8); | |
78 | hexvalue (ctx->sc_regs[6], regs[6], 8); | |
79 | hexvalue (ctx->sc_regs[7], regs[7], 8); | |
80 | hexvalue (ctx->sc_regs[8], regs[8], 8); | |
81 | hexvalue (ctx->sc_regs[9], regs[9], 8); | |
82 | hexvalue (ctx->sc_regs[10], regs[10], 8); | |
83 | hexvalue (ctx->sc_regs[11], regs[11], 8); | |
84 | hexvalue (ctx->sc_regs[12], regs[12], 8); | |
85 | hexvalue (ctx->sc_regs[13], regs[13], 8); | |
86 | hexvalue (ctx->sc_regs[14], regs[14], 8); | |
87 | hexvalue (ctx->sc_regs[15], regs[15], 8); | |
88 | hexvalue (ctx->sc_macl, regs[16], 8); | |
89 | hexvalue (ctx->sc_mach, regs[17], 8); | |
90 | hexvalue (ctx->sc_pc, regs[18], 8); | |
91 | hexvalue (ctx->sc_pr, regs[19], 8); | |
92 | hexvalue (ctx->sc_gbr, regs[20], 8); | |
93 | hexvalue (ctx->sc_sr, regs[21], 8); | |
94 | ||
95 | /* Generate the output. */ | |
96 | ADD_STRING ("Register dump:\n\n R0: "); | |
97 | ADD_MEM (regs[0], 8); | |
98 | ADD_STRING (" R1: "); | |
99 | ADD_MEM (regs[1], 8); | |
100 | ADD_STRING (" R2: "); | |
101 | ADD_MEM (regs[2], 8); | |
102 | ADD_STRING (" R3: "); | |
103 | ADD_MEM (regs[3], 8); | |
104 | ADD_STRING ("\n R4: "); | |
105 | ADD_MEM (regs[4], 8); | |
106 | ADD_STRING (" R5: "); | |
107 | ADD_MEM (regs[5], 8); | |
108 | ADD_STRING (" R6: "); | |
109 | ADD_MEM (regs[6], 8); | |
110 | ADD_STRING (" R7: "); | |
111 | ADD_MEM (regs[7], 8); | |
112 | ADD_STRING ("\n R8: "); | |
113 | ADD_MEM (regs[8], 8); | |
114 | ADD_STRING (" R9: "); | |
115 | ADD_MEM (regs[9], 8); | |
116 | ADD_STRING (" R10: "); | |
117 | ADD_MEM (regs[10], 8); | |
118 | ADD_STRING (" R11: "); | |
119 | ADD_MEM (regs[11], 8); | |
120 | ADD_STRING ("\n R12: "); | |
121 | ADD_MEM (regs[12], 8); | |
122 | ADD_STRING (" R13: "); | |
123 | ADD_MEM (regs[13], 8); | |
124 | ADD_STRING (" R14: "); | |
125 | ADD_MEM (regs[14], 8); | |
126 | ADD_STRING (" R15: "); | |
127 | ADD_MEM (regs[15], 8); | |
128 | ||
129 | ADD_STRING ("\n\nMACL: "); | |
130 | ADD_MEM (regs[16], 8); | |
131 | ADD_STRING (" MACH: "); | |
132 | ADD_MEM (regs[17], 8); | |
133 | ||
134 | ADD_STRING ("\n\n PC: "); | |
135 | ADD_MEM (regs[18], 8); | |
136 | ADD_STRING (" PR: "); | |
137 | ADD_MEM (regs[19], 8); | |
138 | ADD_STRING (" GBR: "); | |
139 | ADD_MEM (regs[20], 8); | |
140 | ADD_STRING (" SR: "); | |
141 | ADD_MEM (regs[21], 8); | |
142 | ||
143 | ADD_STRING ("\n"); | |
144 | ||
145 | /* Write the stuff out. */ | |
146 | writev (fd, iov, nr); | |
147 | } | |
148 | ||
149 | ||
150 | #define REGISTER_DUMP register_dump (fd, &ctx) |