1 /* Copyright (C) 2011 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
4 Based on work contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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, see
18 <http://www.gnu.org/licenses/>. */
23 /* We will print the register dump in this format:
25 R0: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
26 R8: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
27 R16: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
28 R24: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
29 R32: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
30 R40: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
31 R48: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
32 R52: XXXXXXXX TP: XXXXXXXX SP: XXXXXXXX LR: XXXXXXXX
34 PC: XXXXXXXX ICS: X FAULTNUM: XX
39 hexvalue (unsigned long int value
, char *buf
, size_t len
)
41 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
47 register_dump (int fd
, mcontext_t
*ctx
)
50 struct iovec iov
[143];
54 #define ADD_STRING(str) \
55 iov[nr].iov_base = (char *) str; \
56 iov[nr].iov_len = strlen (str); \
58 #define ADD_MEM(str, len) \
59 iov[nr].iov_base = str; \
60 iov[nr].iov_len = len; \
63 /* Generate strings of register contents. */
64 for (i
= 0; i
< 56; ++i
)
65 hexvalue (ctx
->gregs
[i
], regs
[i
], 8);
66 hexvalue (ctx
->pc
, regs
[56], 8);
67 hexvalue (ctx
->ics
, regs
[57], 1);
68 hexvalue (ctx
->faultnum
, regs
[58], 2);
70 /* Generate the output. */
73 const char *prefixes
[] = {
74 "Register dump:\n\n R0: ",
82 ADD_STRING (prefixes
[i
/ 8]);
88 while (++i
% 8 && i
< 52);
90 ADD_STRING ("\n R52: ");
91 ADD_MEM (regs
[52], 8);
93 ADD_MEM (regs
[53], 8);
95 ADD_MEM (regs
[54], 8);
97 ADD_MEM (regs
[55], 8);
98 ADD_STRING ("\n\n PC: ");
99 ADD_MEM (regs
[56], 8);
100 ADD_STRING (" ICS: ");
101 ADD_MEM (regs
[57], 1);
102 ADD_STRING (" FAULTNUM: ");
103 ADD_MEM (regs
[58], 2);
106 /* Write the stuff out. */
107 writev (fd
, iov
, nr
);
111 #define REGISTER_DUMP register_dump (fd, &ctx->uc_mcontext)