User forums > Using Code::Blocks

Pausing the debugger?

(1/2) > >>

DrewBoo:
Is there a way to abruptly halt the debugger, so I may add breakpoints or do other debugging tasks?

I'm using Code::Blocks in a unix-like environment, using gcc4.2 to build and gdb6.7 to debug.

When I use gdb on the command line, I can freeze an already running program by hitting Ctrl+C.  I get my debugger prompt right away.  Other IDEs usually have a "pause button" or similar to do that in the graphic environment.

The only enabled debugging button that I see in C::B is "Stop Debugging", which seems to end the entire debugging session.  Have I missed something, or is this feature still in the oven?



Thanks in advance for your help.   :)

thomas:
I suspect this wasn't implemented because it is not cross-platform.


--- Quote from: MSDN ---Note: SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs, Win32 operating systems generate a new thread to specifically handle that interrupt. This can cause a single-thread application such as UNIX, to become multithreaded, resulting in unexpected behavior.
--- End quote ---
So... this would have to be implemented Linux-only and hidden under Windows, if anything.

DrewBoo:

--- Quote from: thomas on March 10, 2008, 06:03:17 pm ---I suspect this wasn't implemented because it is not cross-platform.

So... this would have to be implemented Linux-only and hidden under Windows, if anything.

--- End quote ---

The reply speeds on C:B's forums are amazing.  Thank, you, thomas.

This feature may prove useful enough that I end up implementing it myself.  If I understand things correctly, currently if I debug a program with no breakpoints (and it doesn't crash) I have no way to get into the debugger functionality.  All I can do from C::B is end the debugging session.

Is there someone here I could coordinate with while writing this Windows-exempt feature (I'm not on Linux either...Solaris) so others may take advantage of this?  Or does having a Windows-exempt feature go too far against the team's philosophy?


(As a side-thought, I'm sure there's a similar Windows solution, even if it doesn't involve Ctrl+C)

(Side thought #2, this would allow editing of breakpoints even while the debuggee is running, as it could pause, add the break and immediately resume)

DrewBoo:

--- Quote from: thomas on March 10, 2008, 06:03:17 pm ---I suspect this wasn't implemented because it is not cross-platform.

So... this would have to be implemented Linux-only and hidden under Windows, if anything.

--- End quote ---

thomas, from looking at the code, it looks like that stop button is indeed supposed to pause first, then end the debugging session if hit again.  (Even works in Windows)

It seems that my issue is that the button currently does nothing. I'm not sure if there's anything left to say, unless someone here is familiar with that issue.

eranif:
I am not familiar with C::B debugger code, but for my debugger code I am using this code, which works fine on Windows & Linux:


--- Code: ---bool DbgGdb::Interrupt()
{
if (m_debuggeePid > 0) {
#ifdef __WXMSW__
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)m_debuggeePid);
BOOL res = DebugBreakProcess(process);
return res == TRUE;
#else
m_observer->UpdateAddLine(wxT("Interrupting debugee process"));
kill(m_debuggeePid, SIGINT);
#endif
}
return true;
}
--- End code ---

Note that m_debugeePid is the PID of the child process of gdb, and not gdb itself.

Eran

Navigation

[0] Message Index

[#] Next page

Go to full version