* command.c (shell_escape, make_command, _initialze_command):
[deliverable/binutils-gdb.git] / gdb / irix4-nat.c
CommitLineData
2268d619 1/* Native support for the SGI Iris running IRIX version 4, for GDB.
a70dc898
RP
2 Copyright 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
4 and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
2268d619 5 Implemented for Irix 4.x by Garrett A. Wollman.
a70dc898
RP
6
7This file is part of GDB.
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22
23#include "defs.h"
3496b745 24#include "inferior.h"
a70dc898 25
a70dc898
RP
26#include <sys/time.h>
27#include <sys/procfs.h>
2268d619
JG
28#include <setjmp.h> /* For JB_XXX. */
29
30/* Size of elements in jmpbuf */
31
32#define JB_ELEMENT_SIZE 4
a70dc898
RP
33
34typedef unsigned int greg_t; /* why isn't this defined? */
35
36/*
37 * See the comment in m68k-tdep.c regarding the utility of these functions.
38 */
39
40void
41supply_gregset (gregsetp)
42 gregset_t *gregsetp;
43{
44 register int regi;
45 register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
46
47 /* FIXME: somewhere, there should be a #define for the meaning
48 of this magic number 32; we should use that. */
49 for(regi = 0; regi < 32; regi++)
50 supply_register (regi, (char *)(regp + regi));
51
52 supply_register (PC_REGNUM, (char *)&(gregsetp->gp_pc));
53 supply_register (HI_REGNUM, (char *)&(gregsetp->gp_mdhi));
54 supply_register (LO_REGNUM, (char *)&(gregsetp->gp_mdlo));
55 supply_register (PS_REGNUM, (char *)&(gregsetp->gp_cause));
56}
57
58void
59fill_gregset (gregsetp, regno)
60 gregset_t *gregsetp;
61 int regno;
62{
63 int regi;
64 register greg_t *regp = (greg_t *)(gregsetp->gp_regs);
a70dc898
RP
65
66 /* same FIXME as above wrt 32*/
67 for (regi = 0; regi < 32; regi++)
68 if ((regno == -1) || (regno == regi))
69 *(regp + regi) = *(greg_t *) &registers[REGISTER_BYTE (regi)];
70
71 if ((regno == -1) || (regno == PC_REGNUM))
72 gregsetp->gp_pc = *(greg_t *) &registers[REGISTER_BYTE (PC_REGNUM)];
73
74 if ((regno == -1) || (regno == PS_REGNUM))
75 gregsetp->gp_cause = *(greg_t *) &registers[REGISTER_BYTE (PS_REGNUM)];
76
77 if ((regno == -1) || (regno == HI_REGNUM))
78 gregsetp->gp_mdhi = *(greg_t *) &registers[REGISTER_BYTE (HI_REGNUM)];
79
80 if ((regno == -1) || (regno == LO_REGNUM))
81 gregsetp->gp_mdlo = *(greg_t *) &registers[REGISTER_BYTE (LO_REGNUM)];
82}
83
84/*
85 * Now we do the same thing for floating-point registers.
86 * We don't bother to condition on FP0_REGNUM since any
87 * reasonable MIPS configuration has an R3010 in it.
88 *
89 * Again, see the comments in m68k-tdep.c.
90 */
91
92void
93supply_fpregset (fpregsetp)
94 fpregset_t *fpregsetp;
95{
96 register int regi;
97
98 for (regi = 0; regi < 32; regi++)
99 supply_register (FP0_REGNUM + regi,
100 (char *)&fpregsetp->fp_r.fp_regs[regi]);
101
102 supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr);
103
104 /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */
105}
106
107void
108fill_fpregset (fpregsetp, regno)
109 fpregset_t *fpregsetp;
110 int regno;
111{
112 int regi;
113 char *from, *to;
a70dc898
RP
114
115 for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++)
116 {
117 if ((regno == -1) || (regno == regi))
118 {
119 from = (char *) &registers[REGISTER_BYTE (regi)];
120 to = (char *) &(fpregsetp->fp_r.fp_regs[regi]);
121 bcopy(from, to, REGISTER_RAW_SIZE (regi));
122 }
123 }
124
125 if ((regno == -1) || (regno == FCRCS_REGNUM))
126 fpregsetp->fp_csr = *(unsigned *) &registers[REGISTER_BYTE(FCRCS_REGNUM)];
127}
2268d619
JG
128
129
130/* Figure out where the longjmp will land.
131 We expect the first arg to be a pointer to the jmp_buf structure from which
132 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
133 This routine returns true on success. */
134
135int
136get_longjmp_target(pc)
137 CORE_ADDR *pc;
138{
139 CORE_ADDR jb_addr;
140
141 jb_addr = read_register(A0_REGNUM);
142
143 if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, pc,
144 sizeof(CORE_ADDR)))
145 return 0;
146
147 SWAP_TARGET_AND_HOST(pc, sizeof(CORE_ADDR));
148
149 return 1;
150}
This page took 0.035046 seconds and 4 git commands to generate.