|
|
1.1 ! root 1: /* Copyright (c) 1982 Regents of the University of California */ ! 2: ! 3: static char sccsid[] = "@(#)rdwr.c 1.1 1/18/82"; ! 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: ! 23: typedef int INTFUNC(); ! 24: ! 25: extern INTFUNC *onsyserr(); ! 26: ! 27: LOCAL badaddr; ! 28: LOCAL rwerr(); ! 29: ! 30: /* ! 31: * Read from the process' instruction area. For px, this is actually ! 32: * the data area. ! 33: */ ! 34: ! 35: iread(buff, addr, nbytes) ! 36: char *buff; ! 37: ADDRESS addr; ! 38: int 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: ! 58: iwrite(buff, addr, nbytes) ! 59: char *buff; ! 60: ADDRESS addr; ! 61: int 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: ! 80: dread(buff, addr, nbytes) ! 81: char *buff; ! 82: ADDRESS addr; ! 83: int 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: ! 97: dwrite(buff, addr, nbytes) ! 98: char *buff; ! 99: ADDRESS addr; ! 100: int 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: ! 114: LOCAL rwerr() ! 115: { ! 116: error("bad read/write process address 0x%x", badaddr); ! 117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.