Commit | Line | Data |
---|---|---|
505bf312 KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
f644bb55 | 6 | */ |
01a616f1 | 7 | |
f644bb55 | 8 | #ifndef lint |
505bf312 KB |
9 | static char sccsid[] = "@(#)rdwr.c 5.4 (Berkeley) %G%"; |
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 | |
28 | typedef int INTFUNC(); | |
29 | ||
30 | extern INTFUNC *onsyserr(); | |
31 | ||
32 | LOCAL badaddr; | |
82d3cd01 | 33 | LOCAL PIO_OP rwflg; |
01a616f1 ML |
34 | LOCAL rwerr(); |
35 | ||
36 | /* | |
82d3cd01 | 37 | * Read/Write to the process' data area. |
01a616f1 ML |
38 | */ |
39 | ||
82d3cd01 KM |
40 | drdwr(rw, buff, addr, nbytes) |
41 | PIO_OP rw; | |
01a616f1 ML |
42 | char *buff; |
43 | ADDRESS addr; | |
44 | int 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 | ||
59 | LOCAL rwerr() | |
60 | { | |
82d3cd01 KM |
61 | error("bad %s process address 0x%x", |
62 | rwflg == PREAD ? "read" : "write", badaddr); | |
01a616f1 | 63 | } |