* lib/gdb.exp: Close connection to remote host if gdb doesn't
[deliverable/binutils-gdb.git] / gdb / core-regset.c
CommitLineData
a1df8e78
FF
1/* Machine independent GDB support for core files on systems using "regsets".
2 Copyright 1993-1996 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20
21/* N O T E S
22
23This file is used by most systems that implement /proc. For these systems,
24the general registers are laid out the same way in both the core file and
25the gregset_p structure. The current exception to this is Irix-4.*, where
26the gregset_p structure is split up into two pieces in the core file.
27
28The general register and floating point register sets are manipulated by
29separate ioctl's. This file makes the assumption that if FP0_REGNUM is
30defined, then support for the floating point register set is desired,
31regardless of whether or not the actual target has floating point hardware.
32
33 */
34
35#include "defs.h"
36
37#include <time.h>
4708ac65 38#ifdef HAVE_SYS_PROCFS_H
a1df8e78 39#include <sys/procfs.h>
4708ac65 40#endif
a1df8e78
FF
41#include <fcntl.h>
42#include <errno.h>
43#include "gdb_string.h"
44
45#include "inferior.h"
46#include "target.h"
47#include "command.h"
48#include "gdbcore.h"
49
948a9d92
FF
50static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
51
a1df8e78
FF
52/*
53
54GLOBAL FUNCTION
55
56 fetch_core_registers -- fetch current registers from core file
57
58SYNOPSIS
59
60 void fetch_core_registers (char *core_reg_sect,
61 unsigned core_reg_size,
948a9d92 62 int which, CORE_ADDR reg_addr)
a1df8e78
FF
63
64DESCRIPTION
65
66 Read the values of either the general register set (WHICH equals 0)
67 or the floating point register set (WHICH equals 2) from the core
68 file data (pointed to by CORE_REG_SECT), and update gdb's idea of
69 their current values. The CORE_REG_SIZE parameter is ignored.
70
71NOTES
72
73 Use the indicated sizes to validate the gregset and fpregset
74 structures.
75*/
76
77static void
78fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
79 char *core_reg_sect;
80 unsigned core_reg_size;
81 int which;
948a9d92 82 CORE_ADDR reg_addr; /* Unused in this version */
a1df8e78 83{
4708ac65 84#if defined (HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T)
a1df8e78
FF
85 gregset_t gregset;
86 fpregset_t fpregset;
87
88 if (which == 0)
89 {
90 if (core_reg_size != sizeof (gregset))
91 {
92 warning ("wrong size gregset struct in core file");
93 }
94 else
95 {
96 memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset));
97 supply_gregset (&gregset);
98 }
99 }
100 else if (which == 2)
101 {
102 if (core_reg_size != sizeof (fpregset))
103 {
104 warning ("wrong size fpregset struct in core file");
105 }
106 else
107 {
108 memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
109#if defined (FP0_REGNUM)
110 supply_fpregset (&fpregset);
111#endif
112 }
113 }
4708ac65 114#endif /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
a1df8e78
FF
115}
116
117\f
118/* Register that we are able to handle ELF file formats using standard
119 procfs "regset" structures. */
120
121static struct core_fns regset_core_fns =
122{
123 bfd_target_elf_flavour,
124 fetch_core_registers,
125 NULL
126};
127
128void
129_initialize_core_regset ()
130{
131 add_core_fns (&regset_core_fns);
132}
This page took 0.076495 seconds and 4 git commands to generate.