> > If you trace an execve, you're going to get its syscall exit stop
> > before you get its old-style traced-exec SIGTRAP.
> 
> No, you don't.

How did you come to that conclusion?  My assertion was based on knowing the
kernel code.  But below is a test program that illustrates the truth of it.
Here's the beginning of its output:

        935 0xa7f
        935 0x857f
                5 0x85
                59
        935 0x857f
                5 0x85
                59
        935 0x57f
                5 0
                59
        935 0x857f
                5 0x85
                12

935 is the PID.  0xa7f is stopped with SIGUSR1.
Next, two syscall stops for execve (59 on x86_64), one entry and one exit.
Next, a signal stop for the post-exec SIGTRAP.
Next, a syscall entry stop for brk (12 on x86_64), the first syscall in the
new program after exec.

> > But, for exec doesn't it make sense to call it a possible ptrace stop only
> > if TCB_STARTUP?
> 
> What if PTRACE_O_TRACEEXEC doesn't work?  That contradicts your own
> words.

So either TCB_STARTUP will be set or TCB_WAITEXECVE will be set.


Thanks,
Roland

#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include <sys/wait.h>
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int
main ()
{
  int status;
  pid_t pid;
  long l;
  siginfo_t info;
  long a = -12345;

  switch (fork ())
    {
    case 0:
      ptrace (PTRACE_TRACEME);
      raise (SIGUSR1);
      execl ("/bin/echo", "echo", "hello world", (char *) 0);
      _exit (127);

    case -1:
      perror ("fork");
      return 2;
    }

  pid = waitpid (WAIT_ANY, &status, WUNTRACED);
  printf ("%d %#x\n", pid, status);
  assert (WIFSTOPPED (status));
  assert (WSTOPSIG (status) == SIGUSR1);

  l = ptrace (PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACESYSGOOD);
  assert (l == 0);

  do
    {
      l = ptrace (PTRACE_SYSCALL, pid, 0, 0);
      if (l)
        {
          perror ("ptrace");
          return 1;
        }

      pid = waitpid (WAIT_ANY, &status, WUNTRACED);
      printf ("%d %#x\n", pid, status);

      l = ptrace (PTRACE_GETSIGINFO, pid, 0, &info);
      if (l)
        perror ("PTRACE_GETSIGINFO");
      else
        printf ("\t%d %#x\n", info.si_signo, info.si_code);
      errno = 0;
      l = ptrace (PTRACE_PEEKUSER, pid, 120, &a);
      if (errno)
        perror ("PTRACE_PEEKUSER");
      else
        printf ("\t%ld\n", l);
    }
  while (WIFSTOPPED (status));

  return 0;
}
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to