This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add --core-pattern option to eu-stack


On Thu, 2014-11-27 at 22:47 +0100, Jan Kratochvil wrote:
> On Thu, 27 Nov 2014 12:17:39 +0100, Mark Wielaard wrote:
> > The waitpid () really is just waiting for PTRACE_EVENT_EXIT. So if you
> > wrap that in a while loop wouldn't it just work fine too in case the
> > user uses it with -p <tid> on a thread that they want to get the
> > backtrace of when it exits instead of in a core file pattern handler
> > pipe?
> 
> Which way?

Something like the following quick hack seems to work:

  int status;
  do
    {
      pid_t got = waitpid (pid, &status, 0);
      if (got == -1)
       error (EXIT_BAD, errno, "waitpid ()");
      if (got != pid)
       error (EXIT_BAD, 0, "waitpid () returned %d but %d was expected",
              got, pid);
    }
  while (! WIFSTOPPED (status)
        && (status >> 8) != (SIGTRAP | (PTRACE_EVENT_EXIT << 8)));

Then I can point eu-stack at some thread and get a backtrace when it
exits. I am sure there is some more error handling to do. And I might
have some of corner cases. But that seems to be the basic idea to get
things to work outside the core_pattern filter. And IMHO it is an
interesting feature if you just want to know when and how a running
thread exits.

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]