2000-12-19 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / core-regset.c
CommitLineData
c906108c
SS
1/* Machine independent GDB support for core files on systems using "regsets".
2 Copyright 1993-1998 Free Software Foundation, Inc.
3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
c906108c 15
c5aa993b
JM
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
c906108c
SS
20
21
c5aa993b 22/* N O T E S
c906108c 23
c5aa993b
JM
24 This file is used by most systems that implement /proc. For these systems,
25 the general registers are laid out the same way in both the core file and
26 the gregset_p structure. The current exception to this is Irix-4.*, where
27 the gregset_p structure is split up into two pieces in the core file.
c906108c 28
c5aa993b
JM
29 The general register and floating point register sets are manipulated by
30 separate ioctl's. This file makes the assumption that if FP0_REGNUM is
31 defined, then support for the floating point register set is desired,
32 regardless of whether or not the actual target has floating point hardware.
c906108c
SS
33
34 */
35
36#include "defs.h"
37
38#include <time.h>
39#ifdef HAVE_SYS_PROCFS_H
40#include <sys/procfs.h>
41#endif
42#include <fcntl.h>
43#include <errno.h>
44#include "gdb_string.h"
45
46#include "inferior.h"
47#include "target.h"
48#include "command.h"
49#include "gdbcore.h"
50
c60c0f5f
MS
51/* Prototypes for supply_gregset etc. */
52#include "gregset.h"
53
a14ed312 54static void fetch_core_registers (char *, unsigned, int, CORE_ADDR);
c906108c 55
a14ed312 56void _initialize_core_regset (void);
c906108c
SS
57
58/*
59
c5aa993b 60 GLOBAL FUNCTION
c906108c 61
c5aa993b 62 fetch_core_registers -- fetch current registers from core file
c906108c 63
c5aa993b 64 SYNOPSIS
c906108c 65
c5aa993b
JM
66 void fetch_core_registers (char *core_reg_sect,
67 unsigned core_reg_size,
68 int which, CORE_ADDR reg_addr)
c906108c 69
c5aa993b 70 DESCRIPTION
c906108c 71
c5aa993b
JM
72 Read the values of either the general register set (WHICH equals 0)
73 or the floating point register set (WHICH equals 2) from the core
74 file data (pointed to by CORE_REG_SECT), and update gdb's idea of
89727b6f
KB
75 their current values. The CORE_REG_SIZE parameter is compared to
76 the size of the gregset or fpgregset structures (as appropriate) to
77 validate the size of the structure from the core file. The
78 REG_ADDR parameter is ignored.
c906108c 79
c5aa993b 80 */
c906108c
SS
81
82static void
89727b6f
KB
83fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
84 CORE_ADDR reg_addr)
c906108c
SS
85{
86#if defined (HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T)
87 gregset_t gregset;
88 fpregset_t fpregset;
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 }
c5aa993b 115#endif /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
c906108c 116}
c906108c 117\f
c5aa993b 118
c906108c
SS
119/* Register that we are able to handle ELF file formats using standard
120 procfs "regset" structures. */
121
122static struct core_fns regset_core_fns =
123{
2acceee2
JM
124 bfd_target_elf_flavour, /* core_flavour */
125 default_check_format, /* check_format */
126 default_core_sniffer, /* core_sniffer */
127 fetch_core_registers, /* core_read_registers */
128 NULL /* next */
c906108c
SS
129};
130
131void
fba45db2 132_initialize_core_regset (void)
c906108c
SS
133{
134 add_core_fns (&regset_core_fns);
135}
This page took 0.075171 seconds and 4 git commands to generate.