]> Git Repo - binutils.git/blob - gdb/core-regset.c
* main.c (main): Make sure command loop is used with cygwin32.
[binutils.git] / gdb / core-regset.c
1 /* Machine independent GDB support for core files on systems using "regsets".
2    Copyright 1993-1996 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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, Boston, MA 02111-1307, USA.  */
19
20
21 /*                      N  O  T  E  S
22
23 This file is used by most systems that implement /proc.  For these systems,
24 the general registers are laid out the same way in both the core file and
25 the gregset_p structure.  The current exception to this is Irix-4.*, where
26 the gregset_p structure is split up into two pieces in the core file.
27
28 The general register and floating point register sets are manipulated by
29 separate ioctl's.  This file makes the assumption that if FP0_REGNUM is
30 defined, then support for the floating point register set is desired,
31 regardless of whether or not the actual target has floating point hardware.
32
33  */
34
35 #include "defs.h"
36
37 #include <time.h>
38 #ifdef HAVE_SYS_PROCFS_H
39 #include <sys/procfs.h>
40 #endif
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
50 /*
51
52 GLOBAL FUNCTION
53
54         fetch_core_registers -- fetch current registers from core file
55
56 SYNOPSIS
57
58         void fetch_core_registers (char *core_reg_sect,
59                                           unsigned core_reg_size,
60                                           int which, unsigned in reg_addr)
61
62 DESCRIPTION
63
64         Read the values of either the general register set (WHICH equals 0)
65         or the floating point register set (WHICH equals 2) from the core
66         file data (pointed to by CORE_REG_SECT), and update gdb's idea of
67         their current values.  The CORE_REG_SIZE parameter is ignored.
68
69 NOTES
70
71         Use the indicated sizes to validate the gregset and fpregset
72         structures.
73 */
74
75 static void
76 fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
77      char *core_reg_sect;
78      unsigned core_reg_size;
79      int which;
80      unsigned int reg_addr;     /* Unused in this version */
81 {
82 #if defined (HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T)
83   gregset_t gregset;
84   fpregset_t fpregset;
85
86   if (which == 0)
87     {
88       if (core_reg_size != sizeof (gregset))
89         {
90           warning ("wrong size gregset struct in core file");
91         }
92       else
93         {
94           memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset));
95           supply_gregset (&gregset);
96         }
97     }
98   else if (which == 2)
99     {
100       if (core_reg_size != sizeof (fpregset))
101         {
102           warning ("wrong size fpregset struct in core file");
103         }
104       else
105         {
106           memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
107 #if defined (FP0_REGNUM)
108           supply_fpregset (&fpregset);
109 #endif
110         }
111     }
112 #endif  /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
113 }
114
115 \f
116 /* Register that we are able to handle ELF file formats using standard
117    procfs "regset" structures.  */
118
119 static struct core_fns regset_core_fns =
120 {
121   bfd_target_elf_flavour,
122   fetch_core_registers,
123   NULL
124 };
125
126 void
127 _initialize_core_regset ()
128 {
129   add_core_fns (&regset_core_fns);
130 }
This page took 0.053986 seconds and 4 git commands to generate.