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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [shnbsd-nat.c] - Blame information for rev 280

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

Line No. Rev Author Line
1 227 jeremybenn
/* Native-dependent code for NetBSD/sh.
2
 
3
   Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   Contributed by Wasabi Systems, Inc.
7
 
8
   This file is part of GDB.
9
 
10
   This program is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3 of the License, or
13
   (at your option) any later version.
14
 
15
   This program is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
22
 
23
#include "defs.h"
24
#include "inferior.h"
25
 
26
#include <sys/types.h>
27
#include <sys/ptrace.h>
28
#include <machine/reg.h>
29
 
30
#include "sh-tdep.h"
31
#include "inf-ptrace.h"
32
#include "regcache.h"
33
 
34
 
35
/* Determine if PT_GETREGS fetches this register. */
36
#define GETREGS_SUPPLIES(gdbarch, regno) \
37
  (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \
38
|| (regno) == gdbarch_pc_regnum (gdbarch) || (regno) == PR_REGNUM \
39
|| (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
40
|| (regno) == SR_REGNUM)
41
 
42
/* Sizeof `struct reg' in <machine/reg.h>.  */
43
#define SHNBSD_SIZEOF_GREGS     (21 * 4)
44
 
45
static void
46
shnbsd_fetch_inferior_registers (struct target_ops *ops,
47
                                 struct regcache *regcache, int regno)
48
{
49
  if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
50
    {
51
      struct reg inferior_registers;
52
 
53
      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
54
                  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
55
        perror_with_name (_("Couldn't get registers"));
56
 
57
      sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno,
58
                                 (char *) &inferior_registers,
59
                                 SHNBSD_SIZEOF_GREGS);
60
 
61
      if (regno != -1)
62
        return;
63
    }
64
}
65
 
66
static void
67
shnbsd_store_inferior_registers (struct target_ops *ops,
68
                                 struct regcache *regcache, int regno)
69
{
70
  if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
71
    {
72
      struct reg inferior_registers;
73
 
74
      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
75
                  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
76
        perror_with_name (_("Couldn't get registers"));
77
 
78
      sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno,
79
                                  (char *) &inferior_registers,
80
                                  SHNBSD_SIZEOF_GREGS);
81
 
82
      if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
83
                  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
84
        perror_with_name (_("Couldn't set registers"));
85
 
86
      if (regno != -1)
87
        return;
88
    }
89
}
90
 
91
/* Provide a prototype to silence -Wmissing-prototypes.  */
92
void _initialize_shnbsd_nat (void);
93
 
94
void
95
_initialize_shnbsd_nat (void)
96
{
97
  struct target_ops *t;
98
 
99
  t = inf_ptrace_target ();
100
  t->to_fetch_registers = shnbsd_fetch_inferior_registers;
101
  t->to_store_registers = shnbsd_store_inferior_registers;
102
  add_target (t);
103
}

powered by: WebSVN 2.1.0

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