OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [core-regset.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Machine independent GDB support for core files on systems using "regsets".
2
   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000
3
   Free Software Foundation, Inc.
4
 
5
   This file is part of GDB.
6
 
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.
11
 
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.
16
 
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.  */
21
 
22
 
23
/*                      N  O  T  E  S
24
 
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.
29
 
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.
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
 
52
/* Prototypes for supply_gregset etc. */
53
#include "gregset.h"
54
 
55
static void fetch_core_registers (char *, unsigned, int, CORE_ADDR);
56
 
57
void _initialize_core_regset (void);
58
 
59
/*
60
 
61
   GLOBAL FUNCTION
62
 
63
   fetch_core_registers -- fetch current registers from core file
64
 
65
   SYNOPSIS
66
 
67
   void fetch_core_registers (char *core_reg_sect,
68
   unsigned core_reg_size,
69
   int which, CORE_ADDR reg_addr)
70
 
71
   DESCRIPTION
72
 
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
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.
80
 
81
 */
82
 
83
static void
84
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
85
                      CORE_ADDR reg_addr)
86
{
87
#if defined (HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T)
88
  gregset_t gregset;
89
  fpregset_t fpregset;
90
 
91
  if (which == 0)
92
    {
93
      if (core_reg_size != sizeof (gregset))
94
        {
95
          warning ("wrong size gregset struct in core file");
96
        }
97
      else
98
        {
99
          memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset));
100
          supply_gregset (&gregset);
101
        }
102
    }
103
  else if (which == 2)
104
    {
105
      if (core_reg_size != sizeof (fpregset))
106
        {
107
          warning ("wrong size fpregset struct in core file");
108
        }
109
      else
110
        {
111
          memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
112
          if (FP0_REGNUM >= 0)
113
            supply_fpregset (&fpregset);
114
        }
115
    }
116
#endif /* defined(HAVE_GREGSET_T) && defined (HAVE_FPREGSET_T) */
117
}
118
 
119
 
120
/* Register that we are able to handle ELF file formats using standard
121
   procfs "regset" structures.  */
122
 
123
static struct core_fns regset_core_fns =
124
{
125
  bfd_target_elf_flavour,               /* core_flavour */
126
  default_check_format,                 /* check_format */
127
  default_core_sniffer,                 /* core_sniffer */
128
  fetch_core_registers,                 /* core_read_registers */
129
  NULL                                  /* next */
130
};
131
 
132
void
133
_initialize_core_regset (void)
134
{
135
  add_core_fns (&regset_core_fns);
136
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.