From: "Satish Mohan" <Satish.Mohan@Accenia.com>
To: <gdb@sources.redhat.com>
Cc: "Satish Mohan" <Satish.Mohan@accenia.com>
Subject: gdb 6.3 misses breakpoint on Linux when inferior does clone()
Date: Thu, 26 May 2005 19:40:00 -0000 [thread overview]
Message-ID: <2DC041637C94C64C8039281448B323B2870FBA@abbott.domain.trailerparc.com> (raw)
Hi
If the inferior does a clone(...,CLONE_VM,...) on Linux, then gdb deletes breakpoints in the child which indirectly affects the parent because of CLONE_VM. The following sample code illustrates the problem:
int mythread (void * unused)
{
printf("my thread running\n");
return 0;
}
int main (int argc, char **argv)
{
int status, pid;
char * stack = (char *)malloc(4096);
if ((pid = clone (mythread, (char *)(stack + 4096 - 4),
CLONE_VM | SIGCHLD, 0)) == -1)
{
printf("clone failed, errno=%d\n", errno);
return -1;
}
if (waitpid(pid, &status, 0) == -1)
{
perror("waitpid failed\n");
return -1;
}
}
If a breakpoint is set on the waitpid() call above, then gdb misses it. This 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 will also get deleted from the parent.
Commenting the detach_breakpoints(child_pid) in child_follow_fork() in linux-nat.c fixes the problem as long as parent and child don't execute the same code after clone.
Is this a gdb bug ? Could anyone let me know the right fix for this ?
Thanks,
Satish Mohan.
next reply other threads:[~2005-05-26 19:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-26 19:40 Satish Mohan [this message]
2005-05-26 19:43 ` Daniel Jacobowitz
2005-05-26 20:02 Satish Mohan
2005-05-26 20:03 ` Daniel Jacobowitz
2005-05-31 17:06 tronics93-gdb
2005-06-01 13:23 ` Daniel Jacobowitz
2005-06-11 23:31 ` Mark Kettenis
2005-06-12 0:23 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2DC041637C94C64C8039281448B323B2870FBA@abbott.domain.trailerparc.com \
--to=satish.mohan@accenia.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).