4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / pascal / pdx / process / rdwr.c
CommitLineData
505bf312 1/*-
2839532b
KB
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
505bf312
KB
4 *
5 * %sccs.include.redist.c%
f644bb55 6 */
01a616f1 7
f644bb55 8#ifndef lint
2839532b 9static char sccsid[] = "@(#)rdwr.c 8.1 (Berkeley) %G%";
505bf312 10#endif /* not lint */
82d3cd01 11
01a616f1 12/*
82d3cd01 13 * This routine is used to access the debuggee process from
01a616f1
ML
14 * outside the "process" module.
15 *
16 * They invoke "pio" which eventually leads to a call to "ptrace".
17 * The system generates an I/O error when a ptrace fails, we catch
18 * that here and assume its due to a misguided address.
19 */
20
21#include "defs.h"
22#include <errno.h>
23#include "process.h"
24#include "process.rep"
25
82d3cd01 26# include "pxinfo.h"
01a616f1
ML
27
28typedef int INTFUNC();
29
30extern INTFUNC *onsyserr();
31
32LOCAL badaddr;
82d3cd01 33LOCAL PIO_OP rwflg;
01a616f1
ML
34LOCAL rwerr();
35
36/*
82d3cd01 37 * Read/Write to the process' data area.
01a616f1
ML
38 */
39
82d3cd01
KM
40drdwr(rw, buff, addr, nbytes)
41PIO_OP rw;
01a616f1
ML
42char *buff;
43ADDRESS addr;
44int nbytes;
45{
46 INTFUNC *f;
47
4fb790e8 48 f = onsyserr(EIO, rwerr);
01a616f1 49 badaddr = addr;
82d3cd01
KM
50 rwflg = rw;
51 pio(process, rw, DATASEG, buff, addr, nbytes);
01a616f1
ML
52 onsyserr(EIO, f);
53}
54
55/*
56 * Error handler.
57 */
58
59LOCAL rwerr()
60{
82d3cd01
KM
61 error("bad %s process address 0x%x",
62 rwflg == PREAD ? "read" : "write", badaddr);
01a616f1 63}