2 Copyright (C) 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
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 GP: XXXXXXXXXXXXXXXX R2: XXXXXXXXXXXXXXXX R3: XXXXXXXXXXXXXXXX
28 R8: XXXXXXXXXXXXXXXX R9: XXXXXXXXXXXXXXXX R10: XXXXXXXXXXXXXXXX
29 R11: XXXXXXXXXXXXXXXX SP: XXXXXXXXXXXXXXXX TP: XXXXXXXXXXXXXXXX
30 R14: XXXXXXXXXXXXXXXX R15: XXXXXXXXXXXXXXXX R16: XXXXXXXXXXXXXXXX
31 R17: XXXXXXXXXXXXXXXX R18: XXXXXXXXXXXXXXXX R19: XXXXXXXXXXXXXXXX
32 R20: XXXXXXXXXXXXXXXX R21: XXXXXXXXXXXXXXXX R22: XXXXXXXXXXXXXXXX
33 R23: XXXXXXXXXXXXXXXX R24: XXXXXXXXXXXXXXXX R25: XXXXXXXXXXXXXXXX
34 R26: XXXXXXXXXXXXXXXX R27: XXXXXXXXXXXXXXXX R28: XXXXXXXXXXXXXXXX
35 R29: XXXXXXXXXXXXXXXX R30: XXXXXXXXXXXXXXXX R31: XXXXXXXXXXXXXXXX
37 RP: XXXXXXXXXXXXXXXX B6: XXXXXXXXXXXXXXXX B7: XXXXXXXXXXXXXXXX
39 IP: XXXXXXXXXXXXXXXX RSC: XXXXXXXXXXXXXXXX PR: XXXXXXXXXXXXXXXX
40 PFS: XXXXXXXXXXXXXXXX UNAT: XXXXXXXXXXXXXXXX CFM: XXXXXXXXXXXXXXXX
41 CCV: XXXXXXXXXXXXXXXX FPSR: XXXXXXXXXXXXXXXX
43 F32: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F33: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
44 F34: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F35: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
46 F124: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F125: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
47 F126: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX F127: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
51 hexvalue (unsigned long int value
, char *buf
, size_t len
)
53 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
59 regvalue (unsigned long int *value
, char letter
, int regno
, char *buf
)
61 int n
= regno
>= 100 ? 3 : regno
>= 10 ? 2 : 1;
64 _itoa_word (regno
, buf
+ 2 + n
, 10, 0);
66 for (++n
; n
<= 4; ++n
)
68 hexvalue (value
[0], buf
+ 7, 16);
71 hexvalue (value
[1], buf
+ 7 + 16, 16);
79 register_dump (int fd
, struct sigcontext
*ctx
)
81 char gpregs
[32 - 5][8 + 16];
82 char fpregs
[128 - 32][8 + 32];
83 char bpregs
[3][8 + 16];
85 struct iovec iov
[146];
89 #define ADD_STRING(str) \
92 iov[nr].iov_base = (char *) str; \
93 iov[nr].iov_len = strlen (str); \
97 #define ADD_MEM(str, len) \
100 iov[nr].iov_base = str; \
101 iov[nr].iov_len = len; \
106 /* Generate strings of register contents. */
107 for (i
= 1; i
< 4; ++i
)
109 regvalue (&ctx
->sc_gr
[i
], 'R', i
, gpregs
[i
- 1]);
110 if (ctx
->sc_nat
& (1L << i
))
111 memcpy (gpregs
[i
- 1] + 7, "NaT ", 16);
113 for (i
= 8; i
< 32; ++i
)
115 regvalue (&ctx
->sc_gr
[i
], 'R', i
, gpregs
[i
- 5]);
116 if (ctx
->sc_nat
& (1L << i
))
117 memcpy (gpregs
[i
- 1] + 7, "NaT ", 16);
119 memcpy (gpregs
[0] + 1, "GP:", 3);
120 memcpy (gpregs
[7] + 1, "SP: ", 4);
121 memcpy (gpregs
[8] + 1, "TP: ", 4);
123 regvalue (&ctx
->sc_br
[0], 'B', 0, bpregs
[0]);
124 regvalue (&ctx
->sc_br
[6], 'B', 6, bpregs
[1]);
125 regvalue (&ctx
->sc_br
[7], 'B', 7, bpregs
[2]);
126 memcpy (bpregs
[0] + 1, "RP:", 3);
128 if (ctx
->sc_flags
& IA64_SC_FLAG_FPH_VALID
)
129 for (i
= 32; i
< 128; ++i
)
130 regvalue (&ctx
->sc_fr
[i
].u
.bits
[0], 'F', i
, fpregs
[i
- 32]);
132 hexvalue (ctx
->sc_ip
, spregs
[0], sizeof (spregs
[0]));
133 hexvalue (ctx
->sc_ar_rsc
, spregs
[1], sizeof (spregs
[1]));
134 hexvalue (ctx
->sc_pr
, spregs
[2], sizeof (spregs
[2]));
135 hexvalue (ctx
->sc_ar_pfs
, spregs
[3], sizeof (spregs
[3]));
136 hexvalue (ctx
->sc_ar_unat
, spregs
[4], sizeof (spregs
[4]));
137 hexvalue (ctx
->sc_cfm
, spregs
[5], sizeof (spregs
[5]));
138 hexvalue (ctx
->sc_ar_ccv
, spregs
[6], sizeof (spregs
[6]));
139 hexvalue (ctx
->sc_ar_fpsr
, spregs
[7], sizeof (spregs
[7]));
141 /* Generate the output. */
142 ADD_STRING ("Register dump:\n\n");
144 for (i
= 0; i
< 32 - 5; ++i
)
145 ADD_MEM (gpregs
[i
], sizeof (gpregs
[0]) - 1 + ((i
% 3) == 2));
148 for (i
= 0; i
< 3; ++i
)
149 ADD_MEM (bpregs
[i
], sizeof (bpregs
[0]) - 1);
151 ADD_STRING ("\n\n IP: ");
152 ADD_MEM (spregs
[0], sizeof (spregs
[0]));
153 ADD_STRING (" RSC: ");
154 ADD_MEM (spregs
[1], sizeof (spregs
[0]));
155 ADD_STRING (" PR: ");
156 ADD_MEM (spregs
[2], sizeof (spregs
[0]));
157 ADD_STRING ("\n PFS: ");
158 ADD_MEM (spregs
[3], sizeof (spregs
[0]));
159 ADD_STRING (" UNAT: ");
160 ADD_MEM (spregs
[4], sizeof (spregs
[0]));
161 ADD_STRING (" CFM: ");
162 ADD_MEM (spregs
[5], sizeof (spregs
[0]));
163 ADD_STRING ("\n CCV: ");
164 ADD_MEM (spregs
[6], sizeof (spregs
[0]));
165 ADD_STRING (" FPSR: ");
166 ADD_MEM (spregs
[7], sizeof (spregs
[0]));
169 if (ctx
->sc_flags
& IA64_SC_FLAG_FPH_VALID
)
173 for (i
= 0; i
< 128 - 32; ++i
)
174 ADD_MEM (fpregs
[i
], sizeof (fpregs
[0]) - 1 + (i
& 1));
177 /* Write the stuff out. */
178 writev (fd
, iov
, nr
);
182 #define REGISTER_DUMP register_dump (fd, ctx)