* Makefile.in (ALLDEPFILES): Add alphabsd-tdep.c.
[deliverable/binutils-gdb.git] / gdb / alphanbsd-nat.c
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 #include "alphabsd-tdep.h"
32
33 static void
34 fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
35 CORE_ADDR ignore)
36 {
37 struct md_coredump *core_reg;
38 char *regs;
39 int regno;
40
41 /* Table to map a gdb register number to a trapframe register index. */
42 static const int regmap[] =
43 {
44 FRAME_V0, FRAME_T0, FRAME_T1, FRAME_T2,
45 FRAME_T3, FRAME_T4, FRAME_T5, FRAME_T6,
46 FRAME_T7, FRAME_S0, FRAME_S1, FRAME_S2,
47 FRAME_S3, FRAME_S4, FRAME_S5, FRAME_S6,
48 FRAME_A0, FRAME_A1, FRAME_A2, FRAME_A3,
49 FRAME_A4, FRAME_A5, FRAME_T8, FRAME_T9,
50 FRAME_T10, FRAME_T11, FRAME_RA, FRAME_T12,
51 FRAME_AT, FRAME_GP, FRAME_SP
52 };
53
54 /* We get everything from one section. */
55 if (which != 0)
56 return;
57
58 core_reg = (struct md_coredump *) core_reg_sect;
59 regs = (char *) &core_reg->md_tf;
60
61 if (core_reg_size < sizeof (*core_reg))
62 {
63 warning ("Wrong size register set in core file.");
64 return;
65 }
66
67 /* Integer registers. */
68 for (regno = 0; regno < ALPHA_ZERO_REGNUM; regno++)
69 supply_register (regno, regs + (regmap[regno] * 8));
70 supply_register (ALPHA_ZERO_REGNUM, NULL);
71 supply_register (FP_REGNUM, NULL);
72 supply_register (PC_REGNUM, regs + (FRAME_PC * 8));
73
74 /* Floating point registers. */
75 alphabsd_supply_fpreg ((char *) &core_reg->md_fpstate, -1);
76 }
77
78 static void
79 fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which,
80 CORE_ADDR ignore)
81 {
82 switch (which)
83 {
84 case 0: /* Integer registers. */
85 if (core_reg_size != SIZEOF_STRUCT_REG)
86 warning ("Wrong size register set in core file.");
87 else
88 alphabsd_supply_reg (core_reg_sect, -1);
89 break;
90
91 case 2: /* Floating point registers. */
92 if (core_reg_size != SIZEOF_STRUCT_FPREG)
93 warning ("Wrong size FP register set in core file.");
94 else
95 alphabsd_supply_fpreg (core_reg_sect, -1);
96 break;
97
98 default:
99 /* Don't know what kind of register request this is; just ignore it. */
100 break;
101 }
102 }
103
104 static struct core_fns alphanbsd_core_fns =
105 {
106 bfd_target_unknown_flavour, /* core_flavour */
107 default_check_format, /* check_format */
108 default_core_sniffer, /* core_sniffer */
109 fetch_core_registers, /* core_read_registers */
110 NULL /* next */
111 };
112
113 static struct core_fns alphanbsd_elfcore_fns =
114 {
115 bfd_target_elf_flavour, /* core_flavour */
116 default_check_format, /* check_format */
117 default_core_sniffer, /* core_sniffer */
118 fetch_elfcore_registers, /* core_read_registers */
119 NULL /* next */
120 };
121
122 void
123 _initialize_alphanbsd_nat (void)
124 {
125 add_core_fns (&alphanbsd_core_fns);
126 add_core_fns (&alphanbsd_elfcore_fns);
127 }
This page took 0.034136 seconds and 5 git commands to generate.