1 /* Low level MIPS interface to ptrace, for GDB when running under Unix.
2 Copyright (C) 1988, 1989, 1991 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.
6 This file is part of GDB.
8 GDB 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 1, or (at your option)
13 GDB 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.
18 You should have received a copy of the GNU General Public License
19 along with GDB; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #include <mips/inst.h>
32 #include <sys/types.h>
35 #include <sys/param.h>
38 #include <sys/ioctl.h>
39 /* #include <fcntl.h> Can we live without this? */
43 #include <sys/user.h> /* After a.out.h */
47 /* Get all registers from the inferior */
50 fetch_inferior_registers ()
53 register unsigned int regaddr
;
54 char buf
[MAX_REGISTER_RAW_SIZE
];
59 for (regno
= 1; regno
< NUM_REGS
; regno
++)
61 regaddr
= register_addr (regno
, 1);
62 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
64 *(int *) &buf
[i
] = ptrace (3, inferior_pid
, regaddr
, 0);
65 regaddr
+= sizeof (int);
67 supply_register (regno
, buf
);
71 /* Store our register values back into the inferior.
72 If REGNO is -1, do this for all registers.
73 Otherwise, REGNO specifies which register (so we can save time). */
75 store_inferior_registers (regno
)
78 register unsigned int regaddr
;
86 regaddr
= register_addr (regno
, 1);
88 ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
91 sprintf (buf
, "writing register number %d", regno
);
92 perror_with_name (buf
);
97 for (regno
= 1; regno
< NUM_REGS
; regno
++)
99 if (regno
== 32 || regno
== 35 || regno
== 36 || regno
== 71)
101 regaddr
= register_addr (regno
, 1);
103 ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
106 sprintf (buf
, "writing all regs, number %d", regno
);
107 perror_with_name (buf
);
114 fetch_core_registers ()
119 for (regno
= 1; regno
< NUM_REGS
; regno
++) {
120 char buf
[MAX_REGISTER_RAW_SIZE
];
122 val
= bfd_seek (core_bfd
, register_addr (regno
, 0));
123 if (val
< 0 || (val
= bfd_read (core_bfd
, buf
, sizeof buf
)) < 0) {
125 strcpy (buffer
, "Reading register ");
126 strcat (buffer
, reg_names
[regno
]);
128 perror_with_name (buffer
);
130 supply_register (regno
, buf
);
This page took 0.033394 seconds and 5 git commands to generate.