From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29492 invoked by alias); 5 Sep 2014 14:20:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 29436 invoked by uid 89); 5 Sep 2014 14:20:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Sep 2014 14:20:19 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s85EKG61019877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 5 Sep 2014 10:20:17 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s85EKF5A004323; Fri, 5 Sep 2014 10:20:16 -0400 Message-ID: <5409C69F.8030906@redhat.com> Date: Fri, 05 Sep 2014 14:20:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: Don Breazeal , gdb-patches@sourceware.org Subject: Re: [PATCH 01/16 v2] Refactor native follow-fork References: <1407434395-19089-1-git-send-email-donb@codesourcery.com> <1408580964-27916-2-git-send-email-donb@codesourcery.com> In-Reply-To: <1408580964-27916-2-git-send-email-donb@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-09/txt/msg00147.txt.bz2 linux_child_follow_fork ends up with: static int linux_child_follow_fork (struct target_ops *ops, int follow_child, int detach_fork) { int has_vforked; int parent_pid, child_pid; has_vforked = (inferior_thread ()->pending_follow.kind == TARGET_WAITKIND_VFORKED); parent_pid = ptid_get_lwp (inferior_ptid); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if (parent_pid == 0) parent_pid = ptid_get_pid (inferior_ptid); child_pid = ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid); if (!follow_child) { ... } else { struct lwp_info *child_lp; child_lp = add_lwp (inferior_ptid); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ child_lp->stopped = 1; child_lp->last_resume_kind = resume_stop; /* Let the thread_db layer learn about this new process. */ check_for_thread_db (); } } Nothing appears to switch inferior_ptid to the child, so seems like we're adding the child_lp with the wrong lwp (and calling check_for_thread_db in the wrong context) ? Is this managing to work by chance because follow_fork_inferior leaves inferior_ptid pointing to the child? Then this at the top uses the wrong inferior_thread (): has_vforked = (inferior_thread ()->pending_follow.kind == TARGET_WAITKIND_VFORKED); and we're lucky that nothing end up using has_vforked in the follow child path? I'd much rather we don't have these assumptions in place. These files / targets also have to_follow_fork implementations: inf-ptrace.c: t->to_follow_fork = inf_ptrace_follow_fork; inf-ttrace.c: t->to_follow_fork = inf_ttrace_follow_fork; which will break if we don't adjust them as well. Did you check whether the refactored code (follow_fork_inferior) makes sense for those? Thanks, Pedro Alves