]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Machine independent GDB support for core files on systems using "regsets". |
b6ba6518 KB |
2 | Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000 |
3 | Free Software Foundation, Inc. | |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
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. | |
c906108c | 11 | |
c5aa993b JM |
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. | |
c906108c | 16 | |
c5aa993b JM |
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. */ | |
c906108c SS |
21 | |
22 | ||
c5aa993b | 23 | /* N O T E S |
c906108c | 24 | |
c5aa993b JM |
25 | This file is used by most systems that implement /proc. For these systems, |
26 | the general registers are laid out the same way in both the core file and | |
27 | the gregset_p structure. The current exception to this is Irix-4.*, where | |
28 | the gregset_p structure is split up into two pieces in the core file. | |
c906108c | 29 | |
c5aa993b JM |
30 | The general register and floating point register sets are manipulated by |
31 | separate ioctl's. This file makes the assumption that if FP0_REGNUM is | |
32 | defined, then support for the floating point register set is desired, | |
33 | regardless of whether or not the actual target has floating point hardware. | |
c906108c SS |
34 | |
35 | */ | |
36 | ||
37 | #include "defs.h" | |
38 | ||
39 | #include <time.h> | |
40 | #ifdef HAVE_SYS_PROCFS_H | |
41 | #include <sys/procfs.h> | |
42 | #endif | |
43 | #include <fcntl.h> | |
44 | #include <errno.h> | |
45 | #include "gdb_string.h" | |
46 | ||
47 | #include "inferior.h" | |
48 | #include "target.h" | |
49 | #include "command.h" | |
50 | #include "gdbcore.h" | |
51 | ||
c60c0f5f MS |
52 | /* Prototypes for supply_gregset etc. */ |
53 | #include "gregset.h" | |
54 | ||
a14ed312 | 55 | static void fetch_core_registers (char *, unsigned, int, CORE_ADDR); |
c906108c | 56 | |
a14ed312 | 57 | void _initialize_core_regset (void); |
c906108c SS |
58 | |
59 | /* | |
60 | ||
c5aa993b | 61 | GLOBAL FUNCTION |
c906108c | 62 | |
c5aa993b | 63 | fetch_core_registers -- fetch current registers from core file |
c906108c | 64 | |
c5aa993b | 65 | SYNOPSIS |
c906108c | 66 | |
c5aa993b JM |
67 | void fetch_core_registers (char *core_reg_sect, |
68 | unsigned core_reg_size, | |
69 | int which, CORE_ADDR reg_addr) | |
c906108c | 70 | |
c5aa993b | 71 | DESCRIPTION |
c906108c | 72 | |
c5aa993b JM |
73 | Read the values of either the general register set (WHICH equals 0) |
74 | or the floating point register set (WHICH equals 2) from the core | |
75 | file data (pointed to by CORE_REG_SECT), and update gdb's idea of | |
89727b6f KB |
76 | their current values. The CORE_REG_SIZE parameter is compared to |
77 | the size of the gregset or fpgregset structures (as appropriate) to | |
78 | validate the size of the structure from the core file. The | |
79 | REG_ADDR parameter is ignored. | |
c906108c | 80 | |
c5aa993b | 81 | */ |
c906108c SS |
82 | |
83 | static void | |
89727b6f KB |
84 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, |
85 | CORE_ADDR reg_addr) | |
c906108c | 86 | { |
455ecc72 DJ |
87 | gdb_gregset_t gregset; |
88 | gdb_fpregset_t fpregset; | |
c906108c SS |
89 | |
90 | if (which == 0) | |
91 | { | |
92 | if (core_reg_size != sizeof (gregset)) | |
93 | { | |
94 | warning ("wrong size gregset struct in core file"); | |
95 | } | |
96 | else | |
97 | { | |
98 | memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset)); | |
99 | supply_gregset (&gregset); | |
100 | } | |
101 | } | |
102 | else if (which == 2) | |
103 | { | |
104 | if (core_reg_size != sizeof (fpregset)) | |
105 | { | |
106 | warning ("wrong size fpregset struct in core file"); | |
107 | } | |
108 | else | |
109 | { | |
110 | memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset)); | |
60054393 MS |
111 | if (FP0_REGNUM >= 0) |
112 | supply_fpregset (&fpregset); | |
c906108c SS |
113 | } |
114 | } | |
c906108c | 115 | } |
c906108c | 116 | \f |
c5aa993b | 117 | |
c906108c SS |
118 | /* Register that we are able to handle ELF file formats using standard |
119 | procfs "regset" structures. */ | |
120 | ||
121 | static struct core_fns regset_core_fns = | |
122 | { | |
2acceee2 JM |
123 | bfd_target_elf_flavour, /* core_flavour */ |
124 | default_check_format, /* check_format */ | |
125 | default_core_sniffer, /* core_sniffer */ | |
126 | fetch_core_registers, /* core_read_registers */ | |
127 | NULL /* next */ | |
c906108c SS |
128 | }; |
129 | ||
130 | void | |
fba45db2 | 131 | _initialize_core_regset (void) |
c906108c SS |
132 | { |
133 | add_core_fns (®set_core_fns); | |
134 | } |