Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Debug a Running Daemon (How to debug a running daemon )
Debug a Running Daemon [message #1715327] Sun, 22 November 2015 10:18 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 6
Registered: January 2011
Junior Member
Hi

In order to debug a daemon, I need to debug it when it is running and check different variables in various functions. The daemon is a server-client app and after running, it starts and listen on a specific port and waits for user's input and based on the input it calls different functions. I have added many breakpoints on those functions, but after the daemon starts to listen on the port, (say, the daemon is running completely), I can not able to debug anything and the debugger does not stop on defined breakpoints, seems the debugger is terminated. How can I debug such application in the running state?

Thanks in advance
Re: Debug a Running Daemon [message #1715335 is a reply to message #1715327] Sun, 22 November 2015 11:46 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
The classical way is to prevent the target program going to daemon state and run it as a normal program instead. The daemonization process gets rid of the original run environment pretty heavily and confuses the debugger.

You did not tell your operating system, so here is an example of an embedded Linux daemon:

--- clip clip ---

/* #includes and plenty of definitions left off */

#ifndef PCTEST
#define DAEMON 1
#endif

/* plenty of code left off */

int main(void)
{
#ifdef DAEMON
#ifdef PCTEST
daemon(1, 0);
#else
daemon(0, 0);
#endif
#endif
printlog("Version %s\n", get_ver());

for (;;)
{
net_setup();
setup();
runit();
release_all();
}

return 0;
}

--- clip clip ---

This example uses the Linux library function daemon() to perform the contortions needed to go into daemon state.



--

Tauno Voipio
Re: Debug a Running Daemon [message #1715389 is a reply to message #1715335] Mon, 23 November 2015 08:49 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 6
Registered: January 2011
Junior Member
Hi

Thanks a lot for your reply. The environment I am working on it is Linux.
Previous Topic:All Eclipse C++ Programs Fail to Run, Hangs on "Launching Delegate"
Next Topic:Debugger stuck on initializing debugger services
Goto Forum:
  


Current Time: Fri Apr 26 12:21:55 GMT 2024

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

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

Back to the top