2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Jaeger <aj@suse.de>, 2000.
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
22 #include <stdio-common/_itoa.h>
24 /* We will print the register dump in this format:
26 R0 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
27 R8 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
28 R16 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
29 R24 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
30 pc cause status badvaddr lo hi
31 XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
32 The FPU registers will not be printed.
36 hexvalue (unsigned long int value
, char *buf
, size_t len
)
38 char *cp
= _itoa_word (value
, buf
+ len
, 16, 0);
44 register_dump (int fd
, struct sigcontext
*ctx
)
47 struct iovec iov
[38 * 2 + 10];
51 #define ADD_STRING(str) \
52 iov[nr].iov_base = (char *) str; \
53 iov[nr].iov_len = strlen (str); \
55 #define ADD_MEM(str, len) \
56 iov[nr].iov_base = str; \
57 iov[nr].iov_len = len; \
60 /* Generate strings of register contents. */
61 for (i
= 0; i
< 32; i
++)
62 hexvalue (ctx
->sc_regs
[i
], regs
[i
], 8);
63 hexvalue (ctx
->sc_pc
, regs
[32], 8);
64 hexvalue (ctx
->sc_cause
, regs
[33], 8);
65 hexvalue (ctx
->sc_status
, regs
[34], 8);
66 hexvalue (ctx
->sc_badvaddr
, regs
[35], 8);
67 hexvalue (ctx
->sc_mdhi
, regs
[36], 8);
68 hexvalue (ctx
->sc_mdlo
, regs
[37], 8);
70 /* Generate the output. */
71 ADD_STRING ("Register dump:\n\n R0 ");
72 for (i
= 0; i
< 8; i
++)
77 ADD_STRING ("\n R8 ");
78 for (i
= 8; i
< 16; i
++)
83 ADD_STRING ("\n R16 ");
84 for (i
= 16; i
< 24; i
++)
89 ADD_STRING ("\n R24 ");
90 for (i
= 24; i
< 32; i
++)
95 ADD_STRING ("\n pc cause status badvaddr lo hi\n ");
96 for (i
= 32; i
< 38; i
++)
103 /* Write the stuff out. */
104 writev (fd
, iov
, nr
);
108 #define REGISTER_DUMP register_dump (fd, ctx)