]>
Commit | Line | Data |
---|---|---|
5f04ac3d | 1 | /* Native-dependent code for NetBSD/i386, for GDB. |
3549ab40 | 2 | Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001, 2002 |
b6ba6518 | 3 | Free Software Foundation, Inc. |
5f04ac3d C |
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 <sys/ptrace.h> | |
25 | #include <machine/reg.h> | |
26 | #include <machine/frame.h> | |
27 | #include "inferior.h" | |
7e89e357 | 28 | #include "gdbcore.h" |
4e052eda | 29 | #include "regcache.h" |
5f04ac3d | 30 | |
7e89e357 JT |
31 | #ifndef HAVE_GREGSET_T |
32 | typedef struct reg gregset_t; | |
33 | #endif | |
5f04ac3d | 34 | |
7e89e357 JT |
35 | #ifndef HAVE_FPREGSET_T |
36 | typedef struct fpreg fpregset_t; | |
37 | #endif | |
38 | ||
39 | #include "gregset.h" | |
40 | ||
41 | /* Prototypes for i387_supply_fsave etc. */ | |
e750d25e | 42 | #include "i387-tdep.h" |
5f04ac3d | 43 | |
5f04ac3d C |
44 | struct md_core |
45 | { | |
46 | struct reg intreg; | |
7e89e357 | 47 | char freg[108]; |
5f04ac3d C |
48 | }; |
49 | ||
eafd4536 | 50 | static void |
fba45db2 KB |
51 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, |
52 | CORE_ADDR ignore) | |
5f04ac3d C |
53 | { |
54 | struct md_core *core_reg = (struct md_core *) core_reg_sect; | |
55 | ||
7e89e357 JT |
56 | /* We get everything from one section. */ |
57 | if (which != 0) | |
58 | return; | |
59 | ||
60 | /* Integer registers. */ | |
61 | supply_gregset (&core_reg->intreg); | |
62 | ||
63 | /* Floating point registers. */ | |
64 | i387_supply_fsave (core_reg->freg); | |
65 | } | |
66 | ||
67 | static void | |
68 | fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, | |
69 | CORE_ADDR ignore) | |
70 | { | |
71 | gregset_t gregset; | |
72 | ||
73 | switch (which) | |
74 | { | |
75 | case 0: /* Integer registers. */ | |
76 | if (core_reg_size != sizeof (struct reg)) | |
77 | warning ("Wrong size register set in core file."); | |
78 | else | |
79 | { | |
80 | memcpy (&gregset, core_reg_sect, sizeof (gregset)); | |
81 | supply_gregset (&gregset); | |
82 | } | |
83 | break; | |
84 | ||
85 | case 2: /* Floating point registers. */ | |
86 | if (core_reg_size != 108) | |
87 | warning ("Wrong size FP register set in core file."); | |
88 | else | |
89 | i387_supply_fsave (core_reg_sect); | |
90 | break; | |
91 | ||
92 | case 3: /* "Extended" floating point registers. This is gdb-speak | |
93 | for SSE/SSE2. */ | |
94 | if (core_reg_size != 512) | |
95 | warning ("Wrong size XMM register set in core file."); | |
96 | else | |
97 | i387_supply_fxsave (core_reg_sect); | |
98 | break; | |
99 | ||
100 | default: | |
101 | /* Don't know what kind of register request this is; just ignore it. */ | |
102 | break; | |
103 | } | |
76a22209 C |
104 | } |
105 | ||
106 | /* Register that we are able to handle i386nbsd core file formats. | |
107 | FIXME: is this really bfd_target_unknown_flavour? */ | |
108 | ||
109 | static struct core_fns i386nbsd_core_fns = | |
110 | { | |
111 | bfd_target_unknown_flavour, /* core_flavour */ | |
112 | default_check_format, /* check_format */ | |
113 | default_core_sniffer, /* core_sniffer */ | |
114 | fetch_core_registers, /* core_read_registers */ | |
115 | NULL /* next */ | |
116 | }; | |
117 | ||
7e89e357 JT |
118 | static struct core_fns i386nbsd_elfcore_fns = |
119 | { | |
120 | bfd_target_elf_flavour, /* core_flavour */ | |
121 | default_check_format, /* check_format */ | |
122 | default_core_sniffer, /* core_sniffer */ | |
123 | fetch_elfcore_registers, /* core_read_registers */ | |
124 | NULL /* next */ | |
125 | }; | |
126 | ||
76a22209 | 127 | void |
fba45db2 | 128 | _initialize_i386nbsd_nat (void) |
76a22209 C |
129 | { |
130 | add_core_fns (&i386nbsd_core_fns); | |
7e89e357 | 131 | add_core_fns (&i386nbsd_elfcore_fns); |
5f04ac3d | 132 | } |