122511Sdist /* 222511Sdist * Copyright (c) 1980 Regents of the University of California. 322511Sdist * All rights reserved. The Berkeley software License Agreement 422511Sdist * specifies the terms and conditions for redistribution. 522511Sdist */ 65504Slinton 722511Sdist #ifndef lint 8*30848Smckusick static char sccsid[] = "@(#)rdwr.c 5.3 (Berkeley) 04/07/87"; 922511Sdist #endif not lint 10*30848Smckusick 115504Slinton /* 12*30848Smckusick * This routine is used to access the debuggee process from 135504Slinton * outside the "process" module. 145504Slinton * 155504Slinton * They invoke "pio" which eventually leads to a call to "ptrace". 165504Slinton * The system generates an I/O error when a ptrace fails, we catch 175504Slinton * that here and assume its due to a misguided address. 185504Slinton */ 195504Slinton 205504Slinton #include "defs.h" 215504Slinton #include <errno.h> 225504Slinton #include "process.h" 235504Slinton #include "process.rep" 245504Slinton 25*30848Smckusick # include "pxinfo.h" 265504Slinton 275504Slinton typedef int INTFUNC(); 285504Slinton 295504Slinton extern INTFUNC *onsyserr(); 305504Slinton 315504Slinton LOCAL badaddr; 32*30848Smckusick LOCAL PIO_OP rwflg; 335504Slinton LOCAL rwerr(); 345504Slinton 355504Slinton /* 36*30848Smckusick * Read/Write to the process' data area. 375504Slinton */ 385504Slinton 39*30848Smckusick drdwr(rw, buff, addr, nbytes) 40*30848Smckusick PIO_OP rw; 415504Slinton char *buff; 425504Slinton ADDRESS addr; 435504Slinton int nbytes; 445504Slinton { 455504Slinton INTFUNC *f; 465504Slinton 4730651Slepreau f = onsyserr(EIO, rwerr); 485504Slinton badaddr = addr; 49*30848Smckusick rwflg = rw; 50*30848Smckusick pio(process, rw, DATASEG, buff, addr, nbytes); 515504Slinton onsyserr(EIO, f); 525504Slinton } 535504Slinton 545504Slinton /* 555504Slinton * Error handler. 565504Slinton */ 575504Slinton 585504Slinton LOCAL rwerr() 595504Slinton { 60*30848Smckusick error("bad %s process address 0x%x", 61*30848Smckusick rwflg == PREAD ? "read" : "write", badaddr); 625504Slinton } 63