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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [irix4-nat.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* Native support for the SGI Iris running IRIX version 4, for GDB.
2
   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1995
3
   Free Software Foundation, Inc.
4
   Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
5
   and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
6
   Implemented for Irix 4.x by Garrett A. Wollman.
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 2 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, write to the Free Software
22
   Foundation, Inc., 59 Temple Place - Suite 330,
23
   Boston, MA 02111-1307, USA.  */
24
 
25
#include "defs.h"
26
#include "inferior.h"
27
#include "gdbcore.h"
28
 
29
#include <sys/time.h>
30
#include <sys/procfs.h>
31
#include <setjmp.h>             /* For JB_XXX.  */
32
 
33
/* Size of elements in jmpbuf */
34
 
35
#define JB_ELEMENT_SIZE 4
36
 
37
typedef unsigned int greg_t;    /* why isn't this defined? */
38
 
39
static void
40
fetch_core_registers PARAMS ((char *, unsigned int, int, CORE_ADDR));
41
 
42
/*
43
 * See the comment in m68k-tdep.c regarding the utility of these functions.
44
 */
45
 
46
void
47
supply_gregset (gregsetp)
48
     gregset_t *gregsetp;
49
{
50
  register int regi;
51
  register greg_t *regp = (greg_t *) (gregsetp->gp_regs);
52
  static char zerobuf[MAX_REGISTER_RAW_SIZE] =
53
  {0};
54
 
55
  /* FIXME: somewhere, there should be a #define for the meaning
56
     of this magic number 32; we should use that. */
57
  for (regi = 0; regi < 32; regi++)
58
    supply_register (regi, (char *) (regp + regi));
59
 
60
  supply_register (PC_REGNUM, (char *) &(gregsetp->gp_pc));
61
  supply_register (HI_REGNUM, (char *) &(gregsetp->gp_mdhi));
62
  supply_register (LO_REGNUM, (char *) &(gregsetp->gp_mdlo));
63
  supply_register (CAUSE_REGNUM, (char *) &(gregsetp->gp_cause));
64
 
65
  /* Fill inaccessible registers with zero.  */
66
  supply_register (BADVADDR_REGNUM, zerobuf);
67
}
68
 
69
void
70
fill_gregset (gregsetp, regno)
71
     gregset_t *gregsetp;
72
     int regno;
73
{
74
  int regi;
75
  register greg_t *regp = (greg_t *) (gregsetp->gp_regs);
76
 
77
  /* same FIXME as above wrt 32 */
78
  for (regi = 0; regi < 32; regi++)
79
    if ((regno == -1) || (regno == regi))
80
      *(regp + regi) = *(greg_t *) & registers[REGISTER_BYTE (regi)];
81
 
82
  if ((regno == -1) || (regno == PC_REGNUM))
83
    gregsetp->gp_pc = *(greg_t *) & registers[REGISTER_BYTE (PC_REGNUM)];
84
 
85
  if ((regno == -1) || (regno == CAUSE_REGNUM))
86
    gregsetp->gp_cause = *(greg_t *) & registers[REGISTER_BYTE (CAUSE_REGNUM)];
87
 
88
  if ((regno == -1) || (regno == HI_REGNUM))
89
    gregsetp->gp_mdhi = *(greg_t *) & registers[REGISTER_BYTE (HI_REGNUM)];
90
 
91
  if ((regno == -1) || (regno == LO_REGNUM))
92
    gregsetp->gp_mdlo = *(greg_t *) & registers[REGISTER_BYTE (LO_REGNUM)];
93
}
94
 
95
/*
96
 * Now we do the same thing for floating-point registers.
97
 * We don't bother to condition on FP0_REGNUM since any
98
 * reasonable MIPS configuration has an R3010 in it.
99
 *
100
 * Again, see the comments in m68k-tdep.c.
101
 */
102
 
103
void
104
supply_fpregset (fpregsetp)
105
     fpregset_t *fpregsetp;
106
{
107
  register int regi;
108
  static char zerobuf[MAX_REGISTER_RAW_SIZE] =
109
  {0};
110
 
111
  for (regi = 0; regi < 32; regi++)
112
    supply_register (FP0_REGNUM + regi,
113
                     (char *) &fpregsetp->fp_r.fp_regs[regi]);
114
 
115
  supply_register (FCRCS_REGNUM, (char *) &fpregsetp->fp_csr);
116
 
117
  /* FIXME: how can we supply FCRIR_REGNUM?  SGI doesn't tell us. */
118
  supply_register (FCRIR_REGNUM, zerobuf);
119
}
120
 
121
void
122
fill_fpregset (fpregsetp, regno)
123
     fpregset_t *fpregsetp;
124
     int regno;
125
{
126
  int regi;
127
  char *from, *to;
128
 
129
  for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
130
    {
131
      if ((regno == -1) || (regno == regi))
132
        {
133
          from = (char *) &registers[REGISTER_BYTE (regi)];
134
          to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]);
135
          memcpy (to, from, REGISTER_RAW_SIZE (regi));
136
        }
137
    }
138
 
139
  if ((regno == -1) || (regno == FCRCS_REGNUM))
140
    fpregsetp->fp_csr = *(unsigned *) &registers[REGISTER_BYTE (FCRCS_REGNUM)];
141
}
142
 
143
 
144
/* Figure out where the longjmp will land.
145
   We expect the first arg to be a pointer to the jmp_buf structure from which
146
   we extract the pc (JB_PC) that we will land at.  The pc is copied into PC.
147
   This routine returns true on success. */
148
 
149
int
150
get_longjmp_target (pc)
151
     CORE_ADDR *pc;
152
{
153
  char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
154
  CORE_ADDR jb_addr;
155
 
156
  jb_addr = read_register (A0_REGNUM);
157
 
158
  if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
159
                          TARGET_PTR_BIT / TARGET_CHAR_BIT))
160
    return 0;
161
 
162
  *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
163
 
164
  return 1;
165
}
166
 
167
static void
168
fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
169
     char *core_reg_sect;
170
     unsigned core_reg_size;
171
     int which;                 /* Unused */
172
     CORE_ADDR reg_addr;        /* Unused */
173
{
174
  if (core_reg_size != REGISTER_BYTES)
175
    {
176
      warning ("wrong size gregset struct in core file");
177
      return;
178
    }
179
 
180
  memcpy ((char *) registers, core_reg_sect, core_reg_size);
181
}
182
 
183
 
184
/* Register that we are able to handle irix4 core file formats.
185
   FIXME: is this really bfd_target_unknown_flavour? */
186
 
187
static struct core_fns irix4_core_fns =
188
{
189
  bfd_target_unknown_flavour,           /* core_flavour */
190
  default_check_format,                 /* check_format */
191
  default_core_sniffer,                 /* core_sniffer */
192
  fetch_core_registers,                 /* core_read_registers */
193
  NULL                                  /* next */
194
};
195
 
196
void
197
_initialize_core_irix4 ()
198
{
199
  add_core_fns (&irix4_core_fns);
200
}

powered by: WebSVN 2.1.0

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