]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Machine independent GDB support for core files on systems using "regsets". |
94ba74a9 MK |
2 | |
3 | Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003 | |
b6ba6518 | 4 | Free Software Foundation, Inc. |
c906108c | 5 | |
c5aa993b | 6 | This file is part of GDB. |
c906108c | 7 | |
c5aa993b JM |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
c906108c | 12 | |
c5aa993b JM |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
c906108c | 17 | |
c5aa993b JM |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
c906108c | 22 | |
94ba74a9 MK |
23 | /* This file is used by most systems that use ELF for their core |
24 | dumps. This includes most systems that have SVR4-ish variant of | |
25 | /proc. For these systems, the registers are laid out the same way | |
26 | in core files as in the gregset_t and fpregset_t structures that | |
27 | are used in the interaction with /proc (Irix 4 is an exception and | |
28 | therefore doesn't use this file). Quite a few systems without a | |
29 | SVR4-ish /proc define these structures too, and can make use of | |
30 | this code too. */ | |
c906108c SS |
31 | |
32 | #include "defs.h" | |
94ba74a9 MK |
33 | #include "command.h" |
34 | #include "gdbcore.h" | |
35 | #include "inferior.h" | |
36 | #include "target.h" | |
c906108c | 37 | |
94ba74a9 MK |
38 | #include <fcntl.h> |
39 | #include <errno.h> | |
40 | #include "gdb_string.h" | |
c906108c SS |
41 | #include <time.h> |
42 | #ifdef HAVE_SYS_PROCFS_H | |
43 | #include <sys/procfs.h> | |
44 | #endif | |
c906108c | 45 | |
94ba74a9 | 46 | /* Prototypes for supply_gregset etc. */ |
c60c0f5f MS |
47 | #include "gregset.h" |
48 | ||
94ba74a9 | 49 | /* Provide registers to GDB from a core file. |
c906108c | 50 | |
94ba74a9 MK |
51 | CORE_REG_SECT points to an array of bytes, which are the contents |
52 | of a `note' from a core file which BFD thinks might contain | |
53 | register contents. CORE_REG_SIZE is its size. | |
c906108c | 54 | |
94ba74a9 MK |
55 | WHICH says which register set corelow suspects this is: |
56 | 0 --- the general-purpose register set, in gregset_t format | |
57 | 2 --- the floating-point register set, in fpregset_t format | |
c906108c | 58 | |
94ba74a9 | 59 | REG_ADDR is ignored. */ |
c906108c SS |
60 | |
61 | static void | |
89727b6f KB |
62 | fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, |
63 | CORE_ADDR reg_addr) | |
c906108c | 64 | { |
455ecc72 DJ |
65 | gdb_gregset_t gregset; |
66 | gdb_fpregset_t fpregset; | |
c906108c | 67 | |
94ba74a9 | 68 | switch (which) |
c906108c | 69 | { |
94ba74a9 | 70 | case 0: |
c906108c | 71 | if (core_reg_size != sizeof (gregset)) |
94ba74a9 | 72 | warning ("Wrong size gregset in core file."); |
c906108c SS |
73 | else |
74 | { | |
94ba74a9 | 75 | memcpy (&gregset, core_reg_sect, sizeof (gregset)); |
c906108c SS |
76 | supply_gregset (&gregset); |
77 | } | |
94ba74a9 MK |
78 | break; |
79 | ||
80 | case 2: | |
c906108c | 81 | if (core_reg_size != sizeof (fpregset)) |
94ba74a9 | 82 | warning ("Wrong size fpregset in core file."); |
c906108c SS |
83 | else |
84 | { | |
94ba74a9 | 85 | memcpy (&fpregset, core_reg_sect, sizeof (fpregset)); |
60054393 MS |
86 | if (FP0_REGNUM >= 0) |
87 | supply_fpregset (&fpregset); | |
c906108c | 88 | } |
94ba74a9 MK |
89 | break; |
90 | ||
91 | default: | |
92 | /* We've covered all the kinds of registers we know about here, | |
93 | so this must be something we wouldn't know what to do with | |
94 | anyway. Just ignore it. */ | |
95 | break; | |
c906108c | 96 | } |
c906108c | 97 | } |
c906108c | 98 | \f |
c5aa993b | 99 | |
94ba74a9 MK |
100 | /* Register that we are able to handle ELF core file formats using |
101 | standard procfs "regset" structures. */ | |
c906108c SS |
102 | |
103 | static struct core_fns regset_core_fns = | |
104 | { | |
2acceee2 JM |
105 | bfd_target_elf_flavour, /* core_flavour */ |
106 | default_check_format, /* check_format */ | |
107 | default_core_sniffer, /* core_sniffer */ | |
108 | fetch_core_registers, /* core_read_registers */ | |
109 | NULL /* next */ | |
c906108c SS |
110 | }; |
111 | ||
94ba74a9 MK |
112 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
113 | extern void _initialize_core_regset (void); | |
114 | ||
c906108c | 115 | void |
fba45db2 | 116 | _initialize_core_regset (void) |
c906108c SS |
117 | { |
118 | add_core_fns (®set_core_fns); | |
119 | } |