4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / usr.bin / pascal / pdx / process / rdwr.c
... / ...
CommitLineData
1/*-
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#ifndef lint
9static char sccsid[] = "@(#)rdwr.c 8.1 (Berkeley) %G%";
10#endif /* not lint */
11
12/*
13 * This routine is used to access the debuggee process from
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
26# include "pxinfo.h"
27
28typedef int INTFUNC();
29
30extern INTFUNC *onsyserr();
31
32LOCAL badaddr;
33LOCAL PIO_OP rwflg;
34LOCAL rwerr();
35
36/*
37 * Read/Write to the process' data area.
38 */
39
40drdwr(rw, buff, addr, nbytes)
41PIO_OP rw;
42char *buff;
43ADDRESS addr;
44int nbytes;
45{
46 INTFUNC *f;
47
48 f = onsyserr(EIO, rwerr);
49 badaddr = addr;
50 rwflg = rw;
51 pio(process, rw, DATASEG, buff, addr, nbytes);
52 onsyserr(EIO, f);
53}
54
55/*
56 * Error handler.
57 */
58
59LOCAL rwerr()
60{
61 error("bad %s process address 0x%x",
62 rwflg == PREAD ? "read" : "write", badaddr);
63}