From 2e965b3324b32be00a2193bf304dcb936f02824b Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 5 May 2004 04:22:16 +0000 Subject: various bug fixes --- src/libmach/Linux.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- src/libmach/map.c | 2 +- 2 files changed, 43 insertions(+), 8 deletions(-) (limited to 'src/libmach') diff --git a/src/libmach/Linux.c b/src/libmach/Linux.c index 62796adb..12b0f9b8 100644 --- a/src/libmach/Linux.c +++ b/src/libmach/Linux.c @@ -37,6 +37,9 @@ struct PtraceRegs static int ptracerw(Map*, Seg*, ulong, void*, uint, int); static int ptraceregrw(Regs*, char*, ulong*, int); +static int attachedpids[1000]; +static int nattached; + void unmapproc(Map *map) { @@ -55,21 +58,36 @@ unmapproc(Map *map) int mapproc(int pid, Map *map, Regs **rp) { + int i; Seg s; PtraceRegs *r; - if(ptrace(PTRACE_ATTACH, pid, 0, 0) < 0) - if(ptrace(PTRACE_PEEKUSER, pid, 0, 0) < 0) + if(nattached==1 && attachedpids[0] == pid) + goto already; + if(nattached) + detachproc(attachedpids[0]); + + for(i=0; ir.rw = ptraceregrw; r->pid = pid; *rp = (Regs*)r; @@ -92,6 +114,14 @@ mapproc(int pid, Map *map, Regs **rp) int detachproc(int pid) { + int i; + + for(i=0; iswap8(v); return 8; -- cgit v1.2.3