Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » follow-fork-mode child makes exception
follow-fork-mode child makes exception [message #668603] Fri, 06 May 2011 11:45 Go to next message
siliconarm is currently offline siliconarmFriend
Messages: 5
Registered: May 2011
Junior Member
I have this simple code:

#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main()
{
    pid_t pID = 0;

    cout << "<<START PROC " << getpid() << ">>";

    pID = fork();
    if (pID == 0) // child
    {
        cout << endl << "Child Process: I'm alive "  << getpid();
    }
    else if (pID < 0) // failed to fork
    {
        cerr << "Failed to fork" << endl;
        exit(-1);
    }
    else // parent
    {
        cout << endl << "Parent Process: <<END " << getpid() << ">>";
        exit(1);
    }

    cout << endl << "<<END PROC " << getpid() << ">>";
    return 0;
}


And in the current dir I have the .gdbinit file:
set follow-fork-mode child


I have a breakpoint on last "cout", when I start the debug session it exits with an exception message: "No source available for "_kernel_vsyscall () at 0x12d422".

What i'm doing wrong?
Thanks a lot.

Re: follow-fork-mode child makes exception [message #668624 is a reply to message #668603] Fri, 06 May 2011 13:29 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
You didn't mention which GDB version you are using, so I'm not totally sure what "follow-fork-mode" does in your case. However, the message "No source available for _kernel_vsyscall ()" happens when you interrupt a process in the middle of an operation, like when you attach to a running process.

So, my guess is that the "follow-fork-mode" tells GDB to replace the parent process with the forked process and attach to it immediately. When GDB attaches to the new processes, it interrupts it in the middle of an operation and you see the message you mention. If you resume execution, it should continue all the way to your breakpoint.

So, I don't think you are doing anything wrong, assuming you want to debug the forked process, instead of the parent.

Marc

P.S. In the next release of Eclipse, coming this June, you will be able to automatically debug a forked process and the parent process at the same time, using multi-process. Look for the CDT New and Noteworthy when it comes out.
Re: follow-fork-mode child makes exception [message #669406 is a reply to message #668624] Tue, 10 May 2011 08:53 Go to previous message
siliconarm is currently offline siliconarmFriend
Messages: 5
Registered: May 2011
Junior Member
Hi!

I'm using GNU gdb 7.1-ubuntu and Eclipse C/C++ 7.0.2

The GDB replace the parent process with the forked process correctly. However when I resume execution after the message "No source available for _kernel_vsyscall ()", it doesn't continue, the excution terminate without evaluate the brekpoint.

I using "GDB (DSF) Create Process Laucher", If I use the "Standard Create Process Launcher" I have the same result, but in this case I have dicovered that if I uncheck the option "Connect process input & output to a terminal" it works!, unfortunately this option is not available with "GDB (DSF) Create Process Laucher".

Thank you!




Previous Topic:Finding references doesn't work properly
Next Topic:Watching strings in the watch window
Goto Forum:
  


Current Time: Thu Sep 26 20:24:55 GMT 2024

Powered by FUDForum. Page generated in 0.13093 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top