to debug multi processes app. (fork) [message #1738574] |
Thu, 21 July 2016 00:02  |
Eclipse User |
|
|
|
Hello,
a multi processes app, with fork()
#include <unistd.h>
#include <stdio.h>
int main(int argc, const char **argv)
{
int p;
int a = fork();
if (a>0) { // parent
p = getpid();
printf("parent ..: %d %d\n", p, a);
}
else if(a==0) { // child
p = getppid();
a = getpid();
printf("child ... :%d %d\n", p, a);
}
else {
printf("fork failed ..");
return -1;
}
return 0;
}
when running this app, with following both options are checked in Debugger tab of Debugger Configurations
1. Non-Stop mode
2. Automatically debug forked processes ,
only breakpoint in parent process is hit.
I added following lines in .gdbinit file, and specify the absolute path in
"GDB command file"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set follow-fork-mode child
set detach-on-fork off
I noticed in the eclipse Debug tab, two apps are attached, as before,
only parent process can step code.
the problem is, when I switch to another process(child), and press F6,
the app receives SIGHUP and terminated.
I tested this on the latest Eclipse-CDT Neno Release.
My GDB version:
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
OS: Ubuntu 14.04.
how to debug into forked processes ?
Thank you very much !
chenzero
|
|
|
|
Re: to debug multi processes app. (fork) [message #1738664 is a reply to message #1738645] |
Thu, 21 July 2016 21:17   |
Eclipse User |
|
|
|
Hi,
My gcc version: gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
for mitrace, please see the mi-1.txt
for the whole Neon project, please see testdmp.zip.
perhaps what I described in previous post is confusing, I would rephrase here:
1. Not specify any .gdbinit file, just check
Non-Stop mode and Automatically debug forked processes ,
in Debug configurations,
only parent process can step code. the breakpoint in child process is hit, however,
can not step code.(when press F6, the process receives SIGHUP and terminated.
2. specify the .gdbinit with lines:
set follow-fork-mode child
set detach-on-fork off
same result as 1, seems .gdbinit is not effect.
Thanks!
chenzero
Attachment: mi-1.txt
(Size: 56.05KB, Downloaded 261 times)
Attachment: testdmp.zip
(Size: 3.92KB, Downloaded 270 times)
|
|
|
|
Powered by
FUDForum. Page generated in 0.02770 seconds