Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » C/C++ Remote Application and multiprocess debugging
C/C++ Remote Application and multiprocess debugging [message #749925] Tue, 25 October 2011 14:18 Go to next message
Mark  is currently offline Mark Friend
Messages: 8
Registered: October 2011
Junior Member
Hello,

I use Eclipse Indigo Service Release 1 with gdb version 7.3.1. Gdb is running on a x86_64 linux system and the gdbserver on a mips processor with kernel 2.6.32.

I try to debug the following simple program, which uses the fork command to create a child process:

#include <unistd.h>
#include <stdio.h>

int main()
{
  pid_t  pid;

  pid = fork();
  if (pid == 0)
    {
      while(1)
      {
    	  sleep(5);
    	  printf("Child process is running!\n");
      }
    }
  else
    {
       while(1)
       {
	  sleep(5);
	  printf("Parent process is running!\n");
       }
    }
  return 0;
}

The option "automatically debug forked process" is set. However, the debugger only lunches the parent process.

I also added several options in the .gdbinit file like "set detach-on-fork off" or
"set follow-fork-mode child", but without success. In the program list only the parent process is registered.

Then I have read, that the gdbserver only enters the multiprocess mode with the command "target extended-remote". Is it possible to change the connection mode in "C/C++ Remote Application".

If I use gdb from the command line and establish the connection with "target extended-remote" and "run" - both processes are running...

Why is it not possible to debug both processes with the Eclipse debug environment?

Mark

[Updated on: Tue, 25 October 2011 14:28]

Report message to a moderator

Re: C/C++ Remote Application and multiprocess debugging [message #749936 is a reply to message #749925] Tue, 25 October 2011 14:27 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
Use the launch "C/C++ Attach to Application" and make sure to choose 'gdbserver' in the the Debugger tab.
You will have to start your gdbserver on your target using 'gdbserver --multi :<port>', and your application will have to be already running on your target.
If you want to follow a forked process, you need to enable Non-stop mode (also in the Debugger launch tab) to enable multi-process.

Marc
Re: C/C++ Remote Application and multiprocess debugging [message #749945 is a reply to message #749936] Tue, 25 October 2011 14:33 Go to previous messageGo to next message
Mark  is currently offline Mark Friend
Messages: 8
Registered: October 2011
Junior Member
Thanks for your fast reply.

Is there no way to use the automatic gdbserver start mechanism of the "C/C++ Remote Application"-Implementation?

Mark
Re: C/C++ Remote Application and multiprocess debugging [message #749959 is a reply to message #749945] Tue, 25 October 2011 14:41 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
Falcon83 wrote on Tue, 25 October 2011 10:33
Thanks for your fast reply.

Is there no way to use the automatic gdbserver start mechanism of the "C/C++ Remote Application"-Implementation?

Mark


Using extended-remote with gdbserver is meant to have gdbserver be a kind of daemon running on your target. gdbserver could be started automatically when your target boots. In such a case, Eclipse should not start it again automatically.

That is why there is no automatic launch for this particular case.

Marc
Re: C/C++ Remote Application and multiprocess debugging [message #749974 is a reply to message #749959] Tue, 25 October 2011 14:55 Go to previous messageGo to next message
Mark  is currently offline Mark Friend
Messages: 8
Registered: October 2011
Junior Member
Ok, thanks to start the gdbserver at startup, could be a solution. I will try this.

However, why is in the "C/C++ Remote Application" the option "automatically debug forked process" available?

index.php/fa/4523/0/

In my test only the parent process is attached - is this perhaps a bug?

Mark

[Updated on: Tue, 25 October 2011 14:56]

Report message to a moderator

Re: C/C++ Remote Application and multiprocess debugging [message #749986 is a reply to message #749974] Tue, 25 October 2011 15:05 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
To be honest, the options are always nicely filtered based on the current launch.
I'm not sure if this option works or not in the Remote Application launch.
If you believe it shouldn't be there in that case, you can write a bug (bugs.eclipse.org)
to hopefully get that cleaned-up

Marc
Re: C/C++ Remote Application and multiprocess debugging [message #752216 is a reply to message #749986] Wed, 26 October 2011 10:08 Go to previous messageGo to next message
Mark  is currently offline Mark Friend
Messages: 8
Registered: October 2011
Junior Member
Is it possible that the gdbserver started with "gdbserver --multi :<port>" stops all processes or a specific process automatically in the main function, without any adaption in the source code?

I have compiled my application with the compiler option "-g -g3 -ggdb -ggdb3 -O0". However, it seems that the compiler optimize the binary and therefore I cannot set breakpoints in some lines or step through the code: "Error accessing memory address 0x0: Input/output error."

Any hints?

Mark

[Updated on: Wed, 26 October 2011 13:28]

Report message to a moderator

Re: C/C++ Remote Application and multiprocess debugging [message #752673 is a reply to message #752216] Wed, 26 October 2011 13:28 Go to previous messageGo to next message
Marc Khouzam is currently offline Marc KhouzamFriend
Messages: 357
Registered: July 2009
Senior Member
Mark wrote on Wed, 26 October 2011 06:08
Is it possible that the gdbserver started with "gdbserver --multi :<port>" stops all processes or a specific process automatically in the main function, without any adaption in the source code?

Mark


You can ask gdbserver --multi to start a new process on your remote target. This is not fully supported in eclipse, but you can still do it by using the eclipse console.

1- start "gdbserver --multi :<port>" on your target
2- use C/C++ Attach to Application to your target
3- go to the eclipse console for gdb (clicking on the gdb incon in the debug view will bring it to the front) and issue the following commands:

add-inferior -exec <full path to your binary ON HOST>
inferior 2
set remote exec-file <full path to your binary ON TARGET>
start

When I tried that it showed up in the debug view properly stopped at main.

Marc

Re: C/C++ Remote Application and multiprocess debugging [message #752751 is a reply to message #752673] Wed, 26 October 2011 14:02 Go to previous message
Mark  is currently offline Mark Friend
Messages: 8
Registered: October 2011
Junior Member
Ok, thanks for your reply I will try this workaround.

Have you an idea why I get the "Error accessing memory address 0x0: Input/output error.", when I step around the code.

Mark

[Updated on: Thu, 27 October 2011 06:16]

Report message to a moderator

Previous Topic:Makefile colours
Next Topic:passing parameter to project template (template.xml)
Goto Forum:
  


Current Time: Mon Sep 23 02:31:41 GMT 2024

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

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

Back to the top