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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [core-regset.c] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Machine independent GDB support for core files on systems using "regsets".
2
 
3
   Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2007, 2008
4
   Free Software Foundation, Inc.
5
 
6
   This file is part of GDB.
7
 
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 3 of the License, or
11
   (at your option) any later version.
12
 
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.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
/* This file is used by most systems that use ELF for their core
22
   dumps.  This includes most systems that have SVR4-ish variant of
23
   /proc.  For these systems, the registers are laid out the same way
24
   in core files as in the gregset_t and fpregset_t structures that
25
   are used in the interaction with /proc (Irix 4 is an exception and
26
   therefore doesn't use this file).  Quite a few systems without a
27
   SVR4-ish /proc define these structures too, and can make use of
28
   this code too.  */
29
 
30
#include "defs.h"
31
#include "command.h"
32
#include "gdbcore.h"
33
#include "inferior.h"
34
#include "target.h"
35
#include "regcache.h"
36
 
37
#include <fcntl.h>
38
#include <errno.h>
39
#include "gdb_string.h"
40
#include <time.h>
41
#ifdef HAVE_SYS_PROCFS_H
42
#include <sys/procfs.h>
43
#endif
44
 
45
/* Prototypes for supply_gregset etc.  */
46
#include "gregset.h"
47
 
48
/* Provide registers to GDB from a core file.
49
 
50
   CORE_REG_SECT points to an array of bytes, which are the contents
51
   of a `note' from a core file which BFD thinks might contain
52
   register contents.  CORE_REG_SIZE is its size.
53
 
54
   WHICH says which register set corelow suspects this is:
55
 
56
     2 --- the floating-point register set, in fpregset_t format
57
 
58
   REG_ADDR is ignored.  */
59
 
60
static void
61
fetch_core_registers (struct regcache *regcache,
62
                      char *core_reg_sect, unsigned core_reg_size, int which,
63
                      CORE_ADDR reg_addr)
64
{
65
  gdb_gregset_t gregset;
66
  gdb_fpregset_t fpregset;
67
  gdb_gregset_t *gregset_p = &gregset;
68
  gdb_fpregset_t *fpregset_p = &fpregset;
69
 
70
  switch (which)
71
    {
72
    case 0:
73
      if (core_reg_size != sizeof (gregset))
74
        warning (_("Wrong size gregset in core file."));
75
      else
76
        {
77
          memcpy (&gregset, core_reg_sect, sizeof (gregset));
78
          supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
79
        }
80
      break;
81
 
82
    case 2:
83
      if (core_reg_size != sizeof (fpregset))
84
        warning (_("Wrong size fpregset in core file."));
85
      else
86
        {
87
          memcpy (&fpregset, core_reg_sect, sizeof (fpregset));
88
          if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) >= 0)
89
            supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset_p);
90
        }
91
      break;
92
 
93
    default:
94
      /* We've covered all the kinds of registers we know about here,
95
         so this must be something we wouldn't know what to do with
96
         anyway.  Just ignore it.  */
97
      break;
98
    }
99
}
100
 
101
 
102
/* Register that we are able to handle ELF core file formats using
103
   standard procfs "regset" structures.  */
104
 
105
static struct core_fns regset_core_fns =
106
{
107
  bfd_target_elf_flavour,               /* core_flavour */
108
  default_check_format,                 /* check_format */
109
  default_core_sniffer,                 /* core_sniffer */
110
  fetch_core_registers,                 /* core_read_registers */
111
  NULL                                  /* next */
112
};
113
 
114
/* Provide a prototype to silence -Wmissing-prototypes.  */
115
extern void _initialize_core_regset (void);
116
 
117
void
118
_initialize_core_regset (void)
119
{
120
  deprecated_add_core_fns (&regset_core_fns);
121
}

powered by: WebSVN 2.1.0

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