148096Sbostic /*-
2*62144Sbostic * Copyright (c) 1980, 1993
3*62144Sbostic * The Regents of the University of California. All rights reserved.
448096Sbostic *
548096Sbostic * %sccs.include.redist.c%
622511Sdist */
75504Slinton
822511Sdist #ifndef lint
9*62144Sbostic static char sccsid[] = "@(#)rdwr.c 8.1 (Berkeley) 06/06/93";
1048096Sbostic #endif /* not lint */
1130848Smckusick
125504Slinton /*
1330848Smckusick * This routine is used to access the debuggee process from
145504Slinton * outside the "process" module.
155504Slinton *
165504Slinton * They invoke "pio" which eventually leads to a call to "ptrace".
175504Slinton * The system generates an I/O error when a ptrace fails, we catch
185504Slinton * that here and assume its due to a misguided address.
195504Slinton */
205504Slinton
215504Slinton #include "defs.h"
225504Slinton #include <errno.h>
235504Slinton #include "process.h"
245504Slinton #include "process.rep"
255504Slinton
2630848Smckusick # include "pxinfo.h"
275504Slinton
285504Slinton typedef int INTFUNC();
295504Slinton
305504Slinton extern INTFUNC *onsyserr();
315504Slinton
325504Slinton LOCAL badaddr;
3330848Smckusick LOCAL PIO_OP rwflg;
345504Slinton LOCAL rwerr();
355504Slinton
365504Slinton /*
3730848Smckusick * Read/Write to the process' data area.
385504Slinton */
395504Slinton
drdwr(rw,buff,addr,nbytes)4030848Smckusick drdwr(rw, buff, addr, nbytes)
4130848Smckusick PIO_OP rw;
425504Slinton char *buff;
435504Slinton ADDRESS addr;
445504Slinton int nbytes;
455504Slinton {
465504Slinton INTFUNC *f;
475504Slinton
4830651Slepreau f = onsyserr(EIO, rwerr);
495504Slinton badaddr = addr;
5030848Smckusick rwflg = rw;
5130848Smckusick pio(process, rw, DATASEG, buff, addr, nbytes);
525504Slinton onsyserr(EIO, f);
535504Slinton }
545504Slinton
555504Slinton /*
565504Slinton * Error handler.
575504Slinton */
585504Slinton
rwerr()595504Slinton LOCAL rwerr()
605504Slinton {
6130848Smckusick error("bad %s process address 0x%x",
6230848Smckusick rwflg == PREAD ? "read" : "write", badaddr);
635504Slinton }
64