From owner-freebsd-hackers@FreeBSD.ORG Sun May 9 13:58:14 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DFC311065674 for ; Sun, 9 May 2010 13:58:13 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 7C4E68FC19 for ; Sun, 9 May 2010 13:58:12 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o49Dw73Q080738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 May 2010 16:58:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o49Dw7qk004233; Sun, 9 May 2010 16:58:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o49Dw7kT004232; Sun, 9 May 2010 16:58:07 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 9 May 2010 16:58:07 +0300 From: Kostik Belousov To: Ali Polatel Message-ID: <20100509135807.GH83316@deviant.kiev.zoral.com.ua> References: <20100508111509.GB8186@harikalardiyari> <20100508123626.GC83316@deviant.kiev.zoral.com.ua> <20100509053303.GD8186@harikalardiyari> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9sSKoi6Rw660DLir" Content-Disposition: inline In-Reply-To: <20100509053303.GD8186@harikalardiyari> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_40, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: Ability to tell the difference between normal and syscall traps X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 May 2010 13:58:14 -0000 --9sSKoi6Rw660DLir Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 09, 2010 at 08:33:03AM +0300, Ali Polatel wrote: > Kostik Belousov yazm??: > > On Sat, May 08, 2010 at 02:15:09PM +0300, Ali Polatel wrote: > > > Does FreeBSD's ptrace have a way to tell the difference between normal > > > traps and those caused by a system call? > > >=20 > > > On Linux? this is possible by passing PTRACE_O_TRACESYSGOOD option to= the > > > ptrace request PTRACE_SETOPTIONS which makes the kernel set bit 7 in = the > > > syscall number when delivering system call traps, > > > (i.e., deliver (SIGTRAP | 0x80)). > > >=20 > > > I'm not sure if this is possible on FreeBSD. PT_LWPINFO request looks > > > related but can't be sure. > > >=20 > > > ?: http://linux.die.net/man/2/ptrace > >=20 > > There is already procfs(5)-based interface to get a reason for stop. > > Look at the ioctl PIOCSTATUS. Yes, you have to mount procfs. > >=20 > > The interface can be lifted to ptrace(2), but I think using the capacity > > of procfs is not wrong there. >=20 > Hmm ok, I've been playing around with PIOCSTATUS but it doesn't seem to > work, there's not much documentation about it either so I figured I'll > just ask. >=20 > The code is here: http://alip.github.com/code/piocstatus.c >=20 > The traced child is stopped at the beginning of a system call. I await > that the PIOCSTATUS request sets ps.why to S_SCE but it's always zero. > Can you help me figure out what I'm doing wrong? :) Apparently I missed the fact that S_PT_SCE and S_SCE are different flags. It seems you have to use procfs stop events (PIOCBIS) and procfs-based loop to get p_step set to 1. --9sSKoi6Rw660DLir Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkvmv28ACgkQC3+MBN1Mb4jm8ACcCJiV+AcVpGvAvO/hyO+QEF/T 2rcAoMrQrd16cH5qRiENMQOhI5AwgYmG =iX9b -----END PGP SIGNATURE----- --9sSKoi6Rw660DLir--