date and time created 85/06/06 11:06:25 by dist
[unix-history] / usr / src / usr.bin / pascal / pdx / process / rdwr.c
CommitLineData
01a616f1
ML
1/* Copyright (c) 1982 Regents of the University of California */
2
3static char sccsid[] = "@(#)rdwr.c 1.1 %G%";
4
5/*
6 * These routines are used to access the debuggee process from
7 * outside the "process" module.
8 *
9 * They invoke "pio" which eventually leads to a call to "ptrace".
10 * The system generates an I/O error when a ptrace fails, we catch
11 * that here and assume its due to a misguided address.
12 */
13
14#include "defs.h"
15#include <errno.h>
16#include "process.h"
17#include "process.rep"
18
19# if (isvaxpx)
20# include "pxinfo.h"
21# endif
22
23typedef int INTFUNC();
24
25extern INTFUNC *onsyserr();
26
27LOCAL badaddr;
28LOCAL rwerr();
29
30/*
31 * Read from the process' instruction area. For px, this is actually
32 * the data area.
33 */
34
35iread(buff, addr, nbytes)
36char *buff;
37ADDRESS addr;
38int nbytes;
39{
40 INTFUNC *f;
41
42 f = onsyserr(EIO, &rwerr);
43# if (isvaxpx)
44 badaddr = addr + ENDOFF;
45 pio(process, PREAD, DATASEG, buff, addr + ENDOFF, nbytes);
46# else
47 badaddr = addr;
48 pio(process, PREAD, TEXTSEG, buff, addr, nbytes);
49# endif
50 onsyserr(EIO, f);
51}
52
53/*
54 * Write to the process' instruction area, usually in order to set
55 * or unset a breakpoint.
56 */
57
58iwrite(buff, addr, nbytes)
59char *buff;
60ADDRESS addr;
61int nbytes;
62{
63 INTFUNC *f;
64
65 f = onsyserr(EIO, &rwerr);
66# if (isvaxpx)
67 badaddr = addr + ENDOFF;
68 pio(process, PWRITE, DATASEG, buff, addr + ENDOFF, nbytes);
69# else
70 badaddr = addr;
71 pio(process, PWRITE, TEXTSEG, buff, addr, nbytes);
72# endif
73 onsyserr(EIO, f);
74}
75
76/*
77 * Read for the process' data area.
78 */
79
80dread(buff, addr, nbytes)
81char *buff;
82ADDRESS addr;
83int nbytes;
84{
85 INTFUNC *f;
86
87 f = onsyserr(EIO, &rwerr);
88 badaddr = addr;
89 pio(process, PREAD, DATASEG, buff, addr, nbytes);
90 onsyserr(EIO, f);
91}
92
93/*
94 * Write to the process' data area.
95 */
96
97dwrite(buff, addr, nbytes)
98char *buff;
99ADDRESS addr;
100int nbytes;
101{
102 INTFUNC *f;
103
104 f = onsyserr(EIO, &rwerr);
105 badaddr = addr;
106 pio(process, PWRITE, DATASEG, buff, addr, nbytes);
107 onsyserr(EIO, f);
108}
109
110/*
111 * Error handler.
112 */
113
114LOCAL rwerr()
115{
116 error("bad read/write process address 0x%x", badaddr);
117}