Commit | Line | Data |
---|---|---|
da8ca43d JT |
1 | /* Native-dependent code for Alpha NetBSD. |
2 | Copyright 2002 Free Software Foundation, Inc. | |
3 | Contributed by Wasabi Systems, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "defs.h" | |
23 | #include <sys/types.h> | |
24 | #include <machine/reg.h> | |
25 | #include <machine/frame.h> | |
26 | #include <machine/pcb.h> | |
27 | #include "gdbcore.h" | |
28 | #include "regcache.h" | |
29 | ||
30 | #include "alpha-tdep.h" | |
31 | ||
32 | #ifndef HAVE_GREGSET_T | |
33 | typedef struct reg gregset_t; | |
34 | #endif | |
35 | ||
36 | #ifndef HAVE_FPREGSET_T | |
37 | typedef struct fpreg fpregset_t; | |
38 | #endif | |
39 | ||
40 | #include "gregset.h" | |
41 | ||
42 | static void | |
43 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, | |
44 | CORE_ADDR ignore) | |
45 | { | |
46 | struct md_coredump *core_reg; | |
47 | char *regs; | |
48 | int regno; | |
49 | ||
50 | /* Table to map a gdb register number to a trapframe register index. */ | |
51 | static const int regmap[] = | |
52 | { | |
53 | FRAME_V0, FRAME_T0, FRAME_T1, FRAME_T2, | |
54 | FRAME_T3, FRAME_T4, FRAME_T5, FRAME_T6, | |
55 | FRAME_T7, FRAME_S0, FRAME_S1, FRAME_S2, | |
56 | FRAME_S3, FRAME_S4, FRAME_S5, FRAME_S6, | |
57 | FRAME_A0, FRAME_A1, FRAME_A2, FRAME_A3, | |
58 | FRAME_A4, FRAME_A5, FRAME_T8, FRAME_T9, | |
59 | FRAME_T10, FRAME_T11, FRAME_RA, FRAME_T12, | |
60 | FRAME_AT, FRAME_GP, FRAME_SP | |
61 | }; | |
62 | ||
63 | /* We get everything from one section. */ | |
64 | if (which != 0) | |
65 | return; | |
66 | ||
67 | core_reg = (struct md_coredump *) core_reg_sect; | |
68 | regs = (char *) &core_reg->md_tf; | |
69 | ||
70 | if (core_reg_size < sizeof (*core_reg)) | |
71 | { | |
72 | warning ("Wrong size register set in core file."); | |
73 | return; | |
74 | } | |
75 | ||
76 | /* Integer registers. */ | |
77 | for (regno = 0; regno < ALPHA_ZERO_REGNUM; regno++) | |
78 | supply_register (regno, regs + (regmap[regno] * 8)); | |
79 | supply_register (ALPHA_ZERO_REGNUM, NULL); | |
80 | supply_register (FP_REGNUM, NULL); | |
81 | supply_register (PC_REGNUM, regs + (FRAME_PC * 8)); | |
82 | ||
83 | /* Floating point registers. */ | |
84 | supply_fpregset (&core_reg->md_fpstate); | |
85 | } | |
86 | ||
87 | static void | |
88 | fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, | |
89 | CORE_ADDR ignore) | |
90 | { | |
91 | switch (which) | |
92 | { | |
93 | case 0: /* Integer registers. */ | |
94 | if (core_reg_size != sizeof (struct reg)) | |
95 | warning ("Wrong size register set in core file."); | |
96 | else | |
97 | supply_gregset ((gregset_t *) core_reg_sect); | |
98 | break; | |
99 | ||
100 | case 2: /* Floating point registers. */ | |
101 | if (core_reg_size != sizeof (struct fpreg)) | |
102 | warning ("Wrong size FP register set in core file."); | |
103 | else | |
104 | supply_fpregset ((fpregset_t *) core_reg_sect); | |
105 | break; | |
106 | ||
107 | default: | |
108 | /* Don't know what kind of register request this is; just ignore it. */ | |
109 | break; | |
110 | } | |
111 | } | |
112 | ||
113 | static struct core_fns alphanbsd_core_fns = | |
114 | { | |
115 | bfd_target_unknown_flavour, /* core_flavour */ | |
116 | default_check_format, /* check_format */ | |
117 | default_core_sniffer, /* core_sniffer */ | |
118 | fetch_core_registers, /* core_read_registers */ | |
119 | NULL /* next */ | |
120 | }; | |
121 | ||
122 | static struct core_fns alphanbsd_elfcore_fns = | |
123 | { | |
124 | bfd_target_elf_flavour, /* core_flavour */ | |
125 | default_check_format, /* check_format */ | |
126 | default_core_sniffer, /* core_sniffer */ | |
127 | fetch_elfcore_registers, /* core_read_registers */ | |
128 | NULL /* next */ | |
129 | }; | |
130 | ||
131 | void | |
132 | _initialize_alphanbsd_nat (void) | |
133 | { | |
134 | add_core_fns (&alphanbsd_core_fns); | |
135 | add_core_fns (&alphanbsd_elfcore_fns); | |
136 | } |