[PATCH] make strace handle SIGTRAP properly

Dmitry V. Levin ldv at altlinux.org
Mon Jun 20 21:25:28 UTC 2011


On Mon, Jun 20, 2011 at 09:24:15PM +0200, Denys Vlasenko wrote:
[...]
>                         int options = ptrace_setoptions_for_all;
>                         if (followfork)    // && (tcp->parent == NULL))  <=== HERE
>                                 options |= ptrace_setoptions_followfork;
>                         if (options) {
>                                 if (debug)
>                                         fprintf(stderr, "setting opts %x on pid %d\n", options, tcp->pid);
>                                 if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, options) < 0) {
>                                         if (errno != ESRCH) {
>                                                 /* Should never happen, really */
>                                                 error_msg_and_die("PTRACE_SETOPTIONS");
>                                         }
>                                 }
>                         }
> 
> The check (tcp->parent == NULL) in old code was meant to check
> "if we are not a child created by auto-attach" - in this case,
> options need to be set on the child; otherwise they are inherited
> and do not need to be set.
> 
> I misunderstood the check and if tcp->parent is not NULL, I was
> setting only ptrace_setoptions_for_all bits!
> 
> Simple solution is depicted above - just comment out "&& (tcp->parent == NULL))".
> 
> I will test the "more optimal" solution which does the check, but sets correct opts.
> 
> Meanwhile, can you confirm that commenting-out works for you too?

Yes, removing this "tcp->parent == NULL" check fixes the issue, thanks.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20110621/40fe4f7f/attachment.bin>


More information about the Strace-devel mailing list