Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 May 2010 16:58:07 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Ali Polatel <alip@exherbo.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Ability to tell the difference between normal and syscall traps
Message-ID:  <20100509135807.GH83316@deviant.kiev.zoral.com.ua>
In-Reply-To: <20100509053303.GD8186@harikalardiyari>
References:  <20100508111509.GB8186@harikalardiyari> <20100508123626.GC83316@deviant.kiev.zoral.com.ua> <20100509053303.GD8186@harikalardiyari>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100509135807.GH83316>