linux ttyname: Update a reference to kernel docs for kernel 4.10
[glibc.git] / sysdeps / unix / sysv / linux / alpha / register-dump.h
blobb9d277ce3edbca70ab60da572f003f0c121439dc
1 /* Dump registers.
2 Copyright (C) 2004-2017 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, see
17 <http://www.gnu.org/licenses/>. */
19 #include <stddef.h>
20 #include <string.h>
22 /* We will print the register dump in this format:
24 V0: XXXXXXXXXXXXXXXX T0: XXXXXXXXXXXXXXXX T1: XXXXXXXXXXXXXXXX
25 T2: XXXXXXXXXXXXXXXX T3: XXXXXXXXXXXXXXXX T4: XXXXXXXXXXXXXXXX
26 T5: XXXXXXXXXXXXXXXX T6: XXXXXXXXXXXXXXXX T7: XXXXXXXXXXXXXXXX
27 S0: XXXXXXXXXXXXXXXX S1: XXXXXXXXXXXXXXXX S2: XXXXXXXXXXXXXXXX
28 S3: XXXXXXXXXXXXXXXX S4: XXXXXXXXXXXXXXXX S5: XXXXXXXXXXXXXXXX
29 S6: XXXXXXXXXXXXXXXX A0: XXXXXXXXXXXXXXXX A1: XXXXXXXXXXXXXXXX
30 A2: XXXXXXXXXXXXXXXX A3: XXXXXXXXXXXXXXXX A4: XXXXXXXXXXXXXXXX
31 A5: XXXXXXXXXXXXXXXX T8: XXXXXXXXXXXXXXXX T9: XXXXXXXXXXXXXXXX
32 T10: XXXXXXXXXXXXXXXX T11: XXXXXXXXXXXXXXXX RA: XXXXXXXXXXXXXXXX
33 T12: XXXXXXXXXXXXXXXX AT: XXXXXXXXXXXXXXXX GP: XXXXXXXXXXXXXXXX
34 SP: XXXXXXXXXXXXXXXX PC: XXXXXXXXXXXXXXXX
36 FP0: XXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXX FP2: XXXXXXXXXXXXXXXX
37 FP3: XXXXXXXXXXXXXXXX FP4: XXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXX
38 FP6: XXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXX FP8: XXXXXXXXXXXXXXXX
39 FP9: XXXXXXXXXXXXXXXX FP10: XXXXXXXXXXXXXXXX FP11: XXXXXXXXXXXXXXXX
40 FP12: XXXXXXXXXXXXXXXX FP13: XXXXXXXXXXXXXXXX FP14: XXXXXXXXXXXXXXXX
41 FP15: XXXXXXXXXXXXXXXX FP16: XXXXXXXXXXXXXXXX FP17: XXXXXXXXXXXXXXXX
42 FP18: XXXXXXXXXXXXXXXX FP19: XXXXXXXXXXXXXXXX FP20: XXXXXXXXXXXXXXXX
43 FP21: XXXXXXXXXXXXXXXX FP22: XXXXXXXXXXXXXXXX FP23: XXXXXXXXXXXXXXXX
44 FP24: XXXXXXXXXXXXXXXX FP25: XXXXXXXXXXXXXXXX FP26: XXXXXXXXXXXXXXXX
45 FP27: XXXXXXXXXXXXXXXX FP28: XXXXXXXXXXXXXXXX FP29: XXXXXXXXXXXXXXXX
46 FP30: XXXXXXXXXXXXXXXX FPCR: XXXXXXXXXXXXXXXX
48 TA0: XXXXXXXXXXXXXXXX TA1: XXXXXXXXXXXXXXXX TA2: XXXXXXXXXXXXXXXX
51 #define NREGS (32+32+3)
53 static const char __attribute__((aligned(8))) regnames[NREGS][8] =
55 " V0: ", " T0: ", " T1: ",
56 " T2: ", " T3: ", " T4: ",
57 " T5: ", " T6: ", " T7: ",
58 " S0: ", " S1: ", " S2: ",
59 " S3: ", " S4: ", " S5: ",
60 " S6: ", " A0: ", " A1: ",
61 " A2: ", " A3: ", " A4: ",
62 " A5: ", " T8: ", " T9: ",
63 " T10: ", " T11: ", " RA: ",
64 " T12: ", " AT: ", " GP: ",
65 " SP: ", " PC: ",
67 " FP0: ", " FP1: ", " FP2: ",
68 " FP3: ", " FP4: ", " FP5: ",
69 " FP6: ", " FP7: ", " FP8: ",
70 " FP9: ", " FP10: ", " FP11: ",
71 " FP12: ", " FP13: ", " FP14: ",
72 " FP15: ", " FP16: ", " FP17: ",
73 " FP18: ", " FP19: ", " FP20: ",
74 " FP21: ", " FP22: ", " FP23: ",
75 " FP24: ", " FP25: ", " FP26: ",
76 " FP27: ", " FP28: ", " FP29: ",
77 " FP30: ", " FPCR: ",
79 " TA0: ", " TA1: ", " TA2: "
82 #define O(FIELD, LF) offsetof(struct sigcontext, FIELD) + LF
84 static const int offsets[NREGS] =
86 O(sc_regs[0], 0), O(sc_regs[1], 0), O(sc_regs[2], 1),
87 O(sc_regs[3], 0), O(sc_regs[4], 0), O(sc_regs[5], 1),
88 O(sc_regs[6], 0), O(sc_regs[7], 0), O(sc_regs[8], 1),
89 O(sc_regs[9], 0), O(sc_regs[10], 0), O(sc_regs[11], 1),
90 O(sc_regs[12], 0), O(sc_regs[13], 0), O(sc_regs[14], 1),
91 O(sc_regs[15], 0), O(sc_regs[16], 0), O(sc_regs[17], 1),
92 O(sc_regs[18], 0), O(sc_regs[19], 0), O(sc_regs[20], 1),
93 O(sc_regs[21], 0), O(sc_regs[22], 0), O(sc_regs[23], 1),
94 O(sc_regs[24], 0), O(sc_regs[25], 0), O(sc_regs[26], 1),
95 O(sc_regs[27], 0), O(sc_regs[28], 0), O(sc_regs[29], 1),
96 O(sc_regs[30], 0), O(sc_pc, 2),
98 O(sc_fpregs[0], 0), O(sc_fpregs[1], 0), O(sc_fpregs[2], 1),
99 O(sc_fpregs[3], 0), O(sc_fpregs[4], 0), O(sc_fpregs[5], 1),
100 O(sc_fpregs[6], 0), O(sc_fpregs[7], 0), O(sc_fpregs[8], 1),
101 O(sc_fpregs[9], 0), O(sc_fpregs[10], 0), O(sc_fpregs[11], 1),
102 O(sc_fpregs[12], 0), O(sc_fpregs[13], 0), O(sc_fpregs[14], 1),
103 O(sc_fpregs[15], 0), O(sc_fpregs[16], 0), O(sc_fpregs[17], 1),
104 O(sc_fpregs[18], 0), O(sc_fpregs[19], 0), O(sc_fpregs[20], 1),
105 O(sc_fpregs[21], 0), O(sc_fpregs[22], 0), O(sc_fpregs[23], 1),
106 O(sc_fpregs[24], 0), O(sc_fpregs[25], 0), O(sc_fpregs[26], 1),
107 O(sc_fpregs[27], 0), O(sc_fpregs[28], 0), O(sc_fpregs[29], 1),
108 O(sc_fpregs[30], 0), O(sc_fpcr, 2),
110 O(sc_traparg_a0, 0), O(sc_traparg_a1, 0), O(sc_traparg_a2, 1)
113 #undef O
115 static void
116 register_dump (int fd, struct sigcontext *ctx)
118 char buf[NREGS*(8+16) + 25 + 80];
119 char *p = buf;
120 size_t i;
122 p = stpcpy (p, "Register dump:\n\n");
124 for (i = 0; i < NREGS; ++i)
126 int this_offset, this_lf;
127 unsigned long val;
128 signed long j;
130 this_offset = offsets[i];
131 this_lf = this_offset & 7;
133 val = *(unsigned long *)(((size_t)ctx + this_offset) & -8);
135 memcpy (p, regnames[i], 8);
136 p += 8;
138 for (j = 60; j >= 0; j -= 4)
140 unsigned long x = (val >> j) & 15;
141 x += x < 10 ? '0' : 'a' - 10;
142 *p++ = x;
145 if (this_lf > 0)
147 if (this_lf > 1)
148 *p++ = '\n';
149 *p++ = '\n';
153 write (fd, buf, p - buf);
156 #define REGISTER_DUMP register_dump (fd, ctx)