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
9 static char sccsid[] = "@(#)rdwr.c 8.1 (Berkeley) 06/06/93";
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
28 typedef int INTFUNC();
29
30 extern INTFUNC *onsyserr();
31
32 LOCAL badaddr;
33 LOCAL PIO_OP rwflg;
34 LOCAL rwerr();
35
36 /*
37 * Read/Write to the process' data area.
38 */
39
drdwr(rw,buff,addr,nbytes)40 drdwr(rw, buff, addr, nbytes)
41 PIO_OP rw;
42 char *buff;
43 ADDRESS addr;
44 int 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
rwerr()59 LOCAL rwerr()
60 {
61 error("bad %s process address 0x%x",
62 rwflg == PREAD ? "read" : "write", badaddr);
63 }
64