Date: Thu, 16 Jun 2011 20:30:19 -0500 From: John Schumacher <schumjs@gmail.com> To: freebsd-threads@freebsd.org Subject: ptrace and threads (libthr) Message-ID: <BANLkTik73ryAGhdRqgFOepRkrgobnzUaQQ@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Does anybody know if FreeBSD allow for ptracing to be done on threads ex. PT_ATTACH, or PT_SUSPEND? I recall this being impossible before, http://lists.freebsd.org/pipermail/freebsd-threads/2004-January/001511.html but maybe this has changed now. Is there a viable alternative to getting around this? if (ptrace (PT_ATTACH, ikipp->ki_tid, 0, 0) != 0) { fprintf (stderr, "Cannot attach to lwp %ld: %s (%d)\n", tid,strerror (errno), errno); fflush (stderr); } if (ptrace (PT_SUSPEND, ikipp->ki_tid, 0, 0) != 0) { fprintf (stderr, "Cannot attach to lwp %ld: %s (%d)\n",tid,strerror (errno), errno); fflush (stderr); } both yield: Cannot suspend lwp 100167: Device busy (16) Cannot attach to lwp 100167: Device busy (16) In my understanding how ptrace works, the thread or process to be traced must be 'stopped'. Is there a way to pause threads to allow an attach to occur(SIGSTOP)? Is thread the correct term in this case? Or is anything the kernel can manipulate via signals and pt_methods technically a light-weight-process or kernel thread 'mapped' to that user-thread (pthread)? This is FreeBSD 8.1 with the libthr library. Thanks ! -- John Schumacher University of Minnesota (TC) Electrical Engineering
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTik73ryAGhdRqgFOepRkrgobnzUaQQ>