1 /* Native-dependent code for Motorola 680x0 running LynxOS.
2 Copyright 1986, 1987, 1989, 1991, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include <sys/param.h>
29 #include <sys/types.h>
34 #include <sys/ioctl.h>
38 #include <sys/ptrace.h>
44 /* Return the address in the core dump or inferior of register REGNO.
45 BLOCKEND is the address of the end of the user structure. */
48 core_register_addr (regno
, blockend
)
49 unsigned int regno
, blockend
;
54 if (regno
>= 0 && regno
<= FP_REGNUM
)
55 offset
= (char *) &s
.ec
.regs
[regno
] - (char *) &s
;
56 else if (regno
== SP_REGNUM
)
57 offset
= (char *) &s
.stackp
- (char *) &s
;
58 else if (regno
== PS_REGNUM
)
59 offset
= (char *) &s
.ec
.status
- (char *) &s
;
60 else if (regno
== PC_REGNUM
)
61 offset
= (char *) &s
.ec
.pc
- (char *) &s
;
62 else if (regno
>= FP0_REGNUM
&& regno
<= (FPC_REGNUM
- 1))
63 offset
= (char *) &s
.ec
.fregs
[(regno
- FP0_REGNUM
) * 3] - (char *) &s
;
64 else if (regno
>= FPC_REGNUM
&& regno
<= FPI_REGNUM
)
65 offset
= (char *) &s
.ec
.fcregs
[regno
- FPC_REGNUM
] - (char *) &s
;
67 return blockend
+ offset
;
71 register_addr (regno
, blockend
)
77 if (regno
>= 0 && regno
<= FP_REGNUM
)
78 offset
= (char *) &s
.ec
.regs
[regno
] - (char *) &s
.ec
;
79 else if (regno
== SP_REGNUM
)
80 offset
= (char *) &s
.stackp
- (char *) &s
;
81 else if (regno
== PS_REGNUM
)
82 offset
= (char *) &s
.ec
.status
- (char *) &s
.ec
;
83 else if (regno
== PC_REGNUM
)
84 offset
= (char *) &s
.ec
.pc
- (char *) &s
.ec
;
85 else if (regno
>= FP0_REGNUM
&& regno
<= (FPC_REGNUM
- 1))
86 offset
= (char *) &s
.ec
.fregs
[(regno
- FP0_REGNUM
) * 3] - (char *) &s
.ec
;
87 else if (regno
>= FPC_REGNUM
&& regno
<= FPI_REGNUM
)
88 offset
= (char *) &s
.ec
.fcregs
[regno
- FPC_REGNUM
] - (char *) &s
.ec
;
90 return blockend
+ offset
;
93 #ifdef FETCH_INFERIOR_REGISTERS
95 /* Fetch one register. */
98 fetch_register (regno
, offset
, bpid
)
102 char buf
[MAX_REGISTER_RAW_SIZE
], mess
[128];
103 unsigned int regaddr
, i
, ptrace_request
;
105 ptrace_request
= regno
!= SP_REGNUM
? PTRACE_PEEKDATA
: PTRACE_PEEKUSP
;
106 regaddr
= register_addr (regno
, offset
);
107 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
110 *(int *) &buf
[i
] = ptrace (ptrace_request
, bpid
,
111 (PTRACE_ARG3_TYPE
) regaddr
, 0);
114 sprintf (mess
, "reading register %s (#%d)", reg_names
[regno
], regno
);
115 perror_with_name (mess
);
117 regaddr
+= sizeof (int);
119 supply_register (regno
, buf
);
123 store_register (regno
, offset
, bpid
)
127 unsigned int i
, regaddr
, ptrace_request
;
130 ptrace_request
= regno
!= SP_REGNUM
? PTRACE_POKEUSER
: PTRACE_POKEUSP
;
131 regaddr
= register_addr (regno
, offset
);
132 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
135 ptrace (ptrace_request
, bpid
, (PTRACE_ARG3_TYPE
) regaddr
,
136 *(int *) ®isters
[REGISTER_BYTE (regno
) + i
]);
139 sprintf (mess
, "writing register %s (#%d)", reg_names
[regno
], regno
);
140 perror_with_name (mess
);
142 regaddr
+= sizeof (int);
147 fetch_offset (pid
, write
)
151 unsigned int specpage_off
, offset
= (char *) &s
.ecp
- (char *) &s
;
156 specpage_off
= ptrace (PTRACE_THREADUSER
, pid
, (PTRACE_ARG3_TYPE
) 0, 0);
158 perror_with_name ("ptrace");
160 offset
= ptrace (PTRACE_PEEKTHREAD
, pid
, (PTRACE_ARG3_TYPE
) offset
, 0)
163 perror_with_name ("ptrace");
168 offset
= ptrace (PTRACE_PEEKTHREAD
, pid
, (PTRACE_ARG3_TYPE
) offset
, 0);
170 perror_with_name ("ptrace");
176 fetch_inferior_registers (regno
)
179 unsigned int offset
= fetch_offset (inferior_pid
, 0);
183 for (regno
= 0; regno
< NUM_REGS
; regno
++)
184 fetch_register (regno
, offset
, inferior_pid
);
187 fetch_register (regno
, offset
, inferior_pid
);
191 store_inferior_registers (regno
)
194 unsigned int offset
= fetch_offset (inferior_pid
, 1);
198 for (regno
= 0; regno
< NUM_REGS
; regno
++)
199 store_register (regno
, offset
, inferior_pid
);
202 store_register (regno
, offset
, inferior_pid
);
206 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, reg_addr
)
208 unsigned core_reg_size
;
210 unsigned int reg_addr
; /* Unused in this version */
214 for (regno
= 0; regno
< NUM_REGS
; regno
++)
218 addr
= core_register_addr (regno
, (unsigned) 0);
219 supply_register (regno
, core_reg_sect
+ addr
);
222 #endif /* FETCH_INFERIOR_REGISTERS */
224 /* Wait for child to do something. Return pid of child, or -1 in case
225 of error; store status through argument pointer STATUS. */
228 child_wait (pid
, status
)
240 set_sigint_trap(); /* Causes SIGINT to be passed on to the
250 if (save_errno
== EINTR
)
252 fprintf (stderr
, "Child process unexpectedly missing: %s.\n",
253 safe_strerror (save_errno
));
254 *status
= 42; /* Claim it exited with signal 42 */
258 if (pid
!= PIDGET (inferior_pid
)) /* Some other process?!? */
261 /* thread = WIFTID (*status);*/
262 thread
= *status
>> 16;
264 /* Initial thread value can only be acquired via wait, so we have to
265 resort to this hack. */
267 if (TIDGET (inferior_pid
) == 0)
269 inferior_pid
= BUILDPID (inferior_pid
, thread
);
270 add_thread (inferior_pid
);
273 pid
= BUILDPID (pid
, thread
);
This page took 0.03919 seconds and 4 git commands to generate.