This series of patches for strace should let you trace child processes
across vfork on recent Linux kernels with no MMU.  The current strace
gets stuck at vfork, because it's waiting for the parent to return
before it can begin tracing the child, and vfork won't return.

In theory the patches should work with old kernels, going back a long
way (2.1-ish), but there are some bug reports about PTRACE_SETOPTIONS
elsewhere which suggest it might only work starting from about 2.6.28
or so.  I will check into this.

The patches work by changing how forking and cloning are traced, to
use PTRACE_SETOPTIONS instead of changing vfork to fork and modifying
clone flags.  Changing vfork to fork doesn't work with no MMU, so it
gets stuck.

The main visible benefit is to no-MMU Linux.  With an MMU, it doesn't
make much difference, but a few of your debugging sessions might go
better now that a process doing vfork gets a genuine vfork.

I haven't tested Linux containers using CLONE_NEWPID, but in principle
that might work now.  It would certainly have failed on the
grandchildren processes before.

There are some related tidying ups too.

This series applies on top of the recent strace-4.5.20 release,
which can be fetched from here (tag v4.5.20):

    git://strace.git.sourceforge.net/gitroot/strace/strace

I would appreciate feedback from no-MMU users before adding kernel
version checks and preparing the series for strace upstream.

Thanks and enjoy,
-- Jamie


Jamie Lokier (15):
  Don't call initgroups for Linux/no-mmu when vfork is used
  Fix error to say "vfork" when it was vfork that failed
  Linux/no-mmu generalisations for using vfork
  More tests for fork and vfork, to test PTRACE_EVENT changes
  Linux clearbpt: check if breakpoint is already clear
  Change clearbpt/setbpt messages about "TCB" to "fork breakpoint"
  Refactor Linux setbpt for consistency and possible bug fix
  Remove #ifdefs on CLONE_PTRACE and TCB_CLONE_THREAD
  Move code to attach a new child on Linux to its own function
  Linux definitions for PTRACE_SETOPTIONS, PTRACE_O_TRACEFORK etc.
  Prepare to handle PTRACE_EVENT_{FORK,VFORK,CLONE}
  Handle Linux PTRACE_EVENT_{FORK,VFORK,CLONE} events
  When forking on Linux, enable PTRACE_EVENT_{FORK,VFORK,CLONE}
  Clear CLONE_UNTRACED for reliable PTRACE_EVENT_{FORK,VFORK,CLONE}
  Decode more Linux CLONE_* flags

 defs.h             |   42 ++++++++-
 process.c          |  270 ++++++++++++++++++++++++++++++----------------------
 strace.c           |  104 +++++++++++++++++----
 test/Makefile      |    2 +-
 test/fork_delay.c  |   24 +++++
 test/vfork_delay.c |   21 ++++
 test/vfork_exec.c  |   36 +++++++
 util.c             |  171 +++++++++++++++++++++++++--------
 8 files changed, 494 insertions(+), 176 deletions(-)
 create mode 100644 test/fork_delay.c
 create mode 100644 test/vfork_delay.c
 create mode 100644 test/vfork_exec.c

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to