From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6001 invoked by alias); 26 May 2005 19:40:47 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 5922 invoked by uid 22791); 26 May 2005 19:40:41 -0000 Received: from 64-6-182-228.t1.lax.megapath.net (HELO abbott.domain.trailerparc.com) (64.6.182.228) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 26 May 2005 19:40:41 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: gdb 6.3 misses breakpoint on Linux when inferior does clone() Date: Thu, 26 May 2005 19:40:00 -0000 Message-ID: <2DC041637C94C64C8039281448B323B2870FBA@abbott.domain.trailerparc.com> From: "Satish Mohan" To: Cc: "Satish Mohan" X-SW-Source: 2005-05/txt/msg00338.txt.bz2 Hi =A0If the inferior does a clone(...,CLONE_VM,...) on Linux, then gdb delete= s breakpoints in the child which indirectly affects the parent because of C= LONE_VM. The following sample code illustrates the problem: int mythread (void * unused)=20 { =A0=A0 printf("my thread running\n"); =A0=A0 return 0; } int main (int argc, char **argv)=20 { =A0=A0 int status, pid; =A0=A0 char * stack =3D (char *)malloc(4096); =A0=A0 if ((pid =3D clone (mythread, (char *)(stack + 4096 - 4),=20 CLONE_VM | SIGCHLD, 0)) =3D=3D -1) =A0=A0 { =A0=A0=A0=A0=A0=A0 printf("clone failed, errno=3D%d\n", errno);=20 =A0=A0=A0=A0=A0=A0 return -1; =A0=A0 } =A0=A0 if (waitpid(pid, &status, 0) =3D=3D -1)=20 { =A0=A0=A0=A0=A0=A0 perror("waitpid failed\n"); =A0=A0=A0=A0=A0=A0 return -1; =A0=A0 } } If a breakpoint is set on the waitpid() call above, then gdb misses it. Thi= s seems to be because gdb deletes breakpoints in the child after the clone(= ) but doesn't seem to know that CLONE_VM is set, and that the breakpoints w= ill also get deleted from the parent.=20 Commenting the detach_breakpoints(child_pid) in child_follow_fork() in linu= x-nat.c fixes the problem as long as parent and child don't execute the sam= e code after clone.=20 Is this a gdb bug ? Could anyone let me know the right fix for this ? Thanks, Satish Mohan.