From owner-freebsd-hackers Fri Nov 17 14:44:49 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id OAA04039 for hackers-outgoing; Fri, 17 Nov 1995 14:44:49 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id OAA04029 for ; Fri, 17 Nov 1995 14:44:42 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id JAA26667; Sat, 18 Nov 1995 09:42:17 +1100 Date: Sat, 18 Nov 1995 09:42:17 +1100 From: Bruce Evans Message-Id: <199511172242.JAA26667@godzilla.zeta.org.au> To: gavin@linux1.dlsu.edu.ph, hackers@FreeBSD.ORG Subject: Re: ptrace() Sender: owner-hackers@FreeBSD.ORG Precedence: bulk >How do you use the ptrace() call? We cannot find any documentation for it. >We are trying to use ptrace() to get the process's data and text >segments, also the proc structure and the user structure. How do we do >this using ptrace()? >We'd appreciate if you could include sample code to use ptrace. This program prints the user area. It should check for errors better. Much more complicated examples can be found in gdb. Bruce --- #include #include #include #include #include #include int main(void) { int i; pid_t p; int stat; switch(p = fork()) { case -1: exit(1); case 0: ptrace(PT_TRACE_ME, 0, 0, 0); kill(getpid(), SIGINT); exit(0); default: wait(&stat); for (i = 0; i < 2049; ++i) { printf("%08x ", ptrace(PT_READ_U, p, (caddr_t) (4 * i), 0)); if ((i & 7) == 7) printf("\n"); } printf("\n"); exit(0); } } ---