Author Topic: Problem pausing debugger using TDM-GCC64, C::B v13.12  (Read 21163 times)

Offline glindsey

  • Single posting newcomer
  • *
  • Posts: 3
Problem pausing debugger using TDM-GCC64, C::B v13.12
« on: May 01, 2014, 03:27:08 am »
Hey all:

I recently switched my toolchain from vanilla MinGW GCC 4.8 to TDM-GCC64 4.8.1, and since then, I've been unable to pause a running process in GDB using either the "pause" or "stop" buttons in Code::Blocks. If I set breakpoints before I start the program, GDB hits them with no trouble, and I can resume afterward. If I close the application normally, GDB exits like it should. It's only when I try to pause execution through Code::Blocks that nothing seems to happen.

Here's a debug log for the debugger:


Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\GDrive\hobby\gamedev\projects\GamePlan\Template\
Adding source dir: C:\GDrive\hobby\gamedev\projects\GamePlan\
Adding file: C:\GDrive\hobby\gamedev\projects\GamePlan\Template\bin\Debug\TemplateProject.exe
Changing directory to: C:/GDrive/hobby/gamedev/projects/GamePlan/Template/.
Set variable: PATH=.;C:\GDrive\hobby\gamedev\libraries\SFML-2.1\build\lib;C:\GDrive\hobby\gamedev\libraries\boost_1_55_0\boost\stage\lib;C:\TDM-GCC-64\bin;C:\TDM-GCC-64;C:\Python27;C:\Python27\Scripts;C:\Perl64\site\bin;C:\Perl64\bin;c:\Program Files (x86)\Intel\iCLS Client;c:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\CMake 2.8\bin;C:\Program Files\doxygen\bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;c:\boost_1_55_0\build\bin;C:\Users\Gregory Lindsey\AppData\Roaming\Python\Scripts

[debug]Command-line: C:\TDM-GCC-64\bin\gdb.exe -nx -fullname  -quiet  -args C:/GDrive/hobby/gamedev/projects/GamePlan/Template/bin/Debug/TemplateProject.exe
[debug]Working dir : C:\GDrive\hobby\gamedev\projects\GamePlan\Template

Starting debugger: C:\TDM-GCC-64\bin\gdb.exe -nx -fullname  -quiet  -args C:/GDrive/hobby/gamedev/projects/GamePlan/Template/bin/Debug/TemplateProject.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:\GDrive\hobby\gamedev\projects\GamePlan\Template\bin\Debug\TemplateProject.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/GDrive/hobby/gamedev/projects/GamePlan/Template/
[debug]Source directories searched: C:/GDrive/hobby/gamedev/projects/GamePlan/Template;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> directory C:/GDrive/hobby/gamedev/projects/GamePlan/
[debug]Source directories searched: C:/GDrive/hobby/gamedev/projects/GamePlan;C:/GDrive/hobby/gamedev/projects/GamePlan/Template;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:/GDrive/hobby/gamedev/projects/GamePlan/Template/bin/Debug/TemplateProject.exe

Child process PID: 3240

[debug][New Thread 3240.0x24fc]
[debug][New Thread 3240.0xd0c]
[debug][New Thread 3240.0x560c]
[debug][New Thread 3240.0x14e4]
[debug][New Thread 3240.0x23f8]
[debug][New Thread 3240.0x21b4]

Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...
Trying to pause the running process...



I should also note that Boost and SFML (the two libraries I am using) are also both compiled using TDM-GCC64, with SJLJ exception handling.

Any help you can give would be greatly appreciated!  Thanks!

GSL

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #1 on: May 01, 2014, 05:48:57 am »
1, can you try to write a simple loop in a hello world like console app, and see the same issue
2, to developers:

I suspect we should use a 64 bit windows API to halt the debugee under 64 bit windows system? I don't have a 64 bit windows at hand.
Currently, we use

Code
DebuggerGDB::DebuggerGDB() :
    cbDebuggerPlugin(wxT("GDB/CDB debugger"), wxT("gdb_debugger")),
    m_State(this),
    m_pProcess(0L),
    m_LastExitCode(0),
    m_Pid(0),
    m_PidToAttach(0),
    m_NoDebugInfo(false),
    m_StoppedOnSignal(false),
    m_pProject(0),
    m_stopDebuggerConsoleClosed(false),
    m_TemporaryBreak(false),
    m_printElements(0)
{
    if (!Manager::LoadResource(_T("debugger.zip")))
    {
        NotifyMissingFile(_T("debugger.zip"));
    }

    // get a function pointer to DebugBreakProcess under windows (XP+)
    #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501)
    kernelLib = LoadLibrary(TEXT("kernel32.dll"));
    if (kernelLib)
    {
        DebugBreakProcessFunc = (DebugBreakProcessApiCall)GetProcAddress(kernelLib, "DebugBreakProcess");
        //Windows XP
        CreateToolhelp32SnapshotFunc = (CreateToolhelp32SnapshotApiCall)GetProcAddress(kernelLib, "CreateToolhelp32Snapshot");
        Process32FirstFunc = (Process32FirstApiCall)GetProcAddress(kernelLib, "Process32First");
        Process32NextFunc = (Process32NextApiCall)GetProcAddress(kernelLib, "Process32Next");
    }
    #endif
}

I'm not sure what happens under a 64 bit windows system.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #2 on: May 01, 2014, 07:44:16 am »
@ollydbg: What 64bit API?
@glindsey:
Can you try the latest night build?
Do you have more than one line in initial commands edit box?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #3 on: May 03, 2014, 02:56:00 pm »
@ollydbg: What 64bit API?
I guess/suspect that DebugBreakProcess from kernel32.dll can not break the debugee.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline glindsey

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #4 on: May 07, 2014, 03:22:47 am »
Thanks for the help!

I tried making a simple console app as you requested. The code is below:


#include <iostream>
#include <chrono>
#include <thread>

int main()
{
  unsigned int x;
  std::cout << "Hello world!" << std::endl;
  while(1)
  {
    std::cout << x << "... Pausing for a second..." << std::endl;
    std::this_thread::sleep_for(std::chrono::seconds(1));
    ++x;
  }

  return 0;
}


Once again, the pause/stop debugger buttons don't work; the only way to stop the program is to close it via its own close box, or kill it with Task Manager.

I haven't tried the latest nightly build yet; I'll see if I can get to it this weekend. (I only get to work on my own projects when I'm not developing at work!  :) )

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
« Last Edit: May 07, 2014, 07:16:16 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline glindsey

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #6 on: May 10, 2014, 04:33:46 am »
Interesting -- thanks for looking into the problem. For the time being I can work fine setting breakpoints before running the program; heck, it's better than what I have at work, where I usually don't have a debugger and have to trace code execution with cout statements!

Since I assume porting C::B to 64 bits is a pretty big project, maybe in the meantime the existing app could call some sort of small 64-bit "shim" app which could pause the running process? I'm just shooting in the dark here...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #7 on: May 10, 2014, 09:36:00 am »
What an unpleasant situation. :(
The second executable seems like the only choice, but this requires some work and lots of testing.
I have no time to do it so patches are welcome! I'll try to review and push them with priority!

C::B is buildable in 64bit mode, but I'm not sure how well does it work on windows.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #8 on: May 10, 2014, 01:58:01 pm »
I've compiled SVN 9744 in 64 bit mode with TDM 4.8.1-3. Pausing the debugger works - sort of. It does not return control to the program, so you can pause the process, but you cannot resume it or debug code.

Code
Trying to interrupt process with pid: 2432; child pid: 2432 gdb pid: 3560
Program received signal SIGTRAP, Trace/breakpoint trap.
In ?? () ()

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #9 on: May 10, 2014, 08:47:29 pm »
Can you post the full log from the debugger?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #10 on: May 11, 2014, 07:32:23 pm »
I used glindsey's code from this topic. After pausing the debugger, this is all I get from the debugger log:

Code

Trying to interrupt process with pid: 448; child pid: 448 gdb pid: 2068

[debug][New Thread 448.0x73c]
[debug]Program received signal SIGTRAP, Trace/breakpoint trap.
[debug][Switching to Thread 448.0x73c]
[debug]0x00007ffe8932c6b1 in ?? ()
[debug]>>>>>>cb_gdb:

Program received signal SIGTRAP, Trace/breakpoint trap.
In ?? () ()

[debug]> bt 30
[debug]#0  0x00007ffe8932c6b1 in ?? ()
[debug]#1  0x00007ffe8935b964 in ?? ()
[debug]#2  0x0000000000000000 in ?? ()
[debug]>>>>>>cb_gdb:

At this moment, I can resume the program and it runs. I can set a breakpoint in the code and it stops there. But I can't get to the program code in which the program is at the moment of pausing (the loop in this example). As you see, the program is not even in the stack trace. If I try to do a Step out anyway, I get:
Code
[debug]> finish
[debug]Run till exit from #0  0x00007ffe8932c6b1 in ?? ()
[debug]0x00007ffe8935b964 in ?? ()
[debug]>>>>>>cb_gdb:

In ?? () ()

[debug]> bt 30
[debug]#0  0x00007ffe8935b964 in ?? ()
[debug]#1  0x0000000000000000 in ?? ()
[debug]>>>>>>cb_gdb:

And the next attempt to Step out:
Code
[debug]> finish
[debug]Warning:
[debug]Cannot insert breakpoint 0.
[debug]Error accessing memory address 0x0: Input/output error.
[debug]Run till exit from #0  0x00007ffe8935b964 in ?? ()
[debug]>>>>>>cb_gdb:

Error accessing memory address 0x0: Input/output error.

[debug]> info frame
[debug]Stack level 0, frame at 0xb2ff38:
[debug] rip = 0x7ffe8935b964; saved rip 0x0
[debug] called by frame at 0xb2ff40
[debug] Arglist at 0xb2ff28, args:
[debug] Locals at 0xb2ff28, Previous frame's sp is 0xb2ff38
[debug] Saved registers:
[debug]  rip at 0xb2ff30
[debug]>>>>>>cb_gdb:

In  ()

[debug]> bt 30
[debug]#0  0x00007ffe8935b964 in ?? ()
[debug]#1  0x0000000000000000 in ?? ()

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #11 on: May 12, 2014, 12:56:31 am »
1. Do you have debug info enabled?
2. Does it work if you use the same gdb executable from the command line?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #12 on: May 12, 2014, 11:33:06 am »
1. Yes, I can debug the program in normal mode.
2. The only way I know is to press CTRL+C in command line debugger. And it stops in KERNEL32!CtrlRoutine, there is no way to return to the code. I thought that this "DebugBreakProcess" method is smarter than this.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #13 on: May 12, 2014, 08:57:53 pm »
Does the continue gdb command work?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #14 on: May 13, 2014, 08:10:36 am »
Yes, it works.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #15 on: May 13, 2014, 09:12:59 am »
Can you post a log from a command ling gdb session?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #16 on: May 13, 2014, 09:13:22 am »
I guess the GDB stack sniffer just failed to unwind a frame. This is because when you halt the debugee, it may paused in a system dll which does not have any debug information GDB knows. (Maybe, you can try a more recent GDB to see its sniffer get more robust :))

Do the below steps work after those situation happens? (either in the command line or under C::B)
Code
1, set a bp in the line such as "++x;", 
2, you run the continue command
3, the debugee will hit this breakpoint.


I used glindsey's code from this topic. After pausing the debugger, this is all I get from the debugger log:
....
At this moment, I can resume the program and it runs. I can set a breakpoint in the code and it stops there. But I can't get to the program code in which the program is at the moment of pausing (the loop in this example). As you see, the program is not even in the stack trace.
...
Oh, it looks like you can hit the BP, which verify my guess.
Quote
I can't get to the program code
This means GDB can't map the instruction address to source code location.  :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #17 on: May 13, 2014, 02:51:13 pm »
Can you post a log from a command ling gdb session?

I've compiled the latest gdb 7.7.1 but it didn't help. Seems it's a limitation of gdb on 64-bit windows.
gdb log below.

Code
Reading symbols from ttt.exe...done.
(gdb) r
Starting program: c:\C\MinGW\MSYS\home\Greg\gdb-7.7.1\_build\bin\ttt.exe
[New Thread 10800.0x1a38]
Hello world!
0... Pausing for a second...
1... Pausing for a second...
2... Pausing for a second...
3... Pausing for a second...
[New Thread 10800.0x1588]

Program received signal SIGINT, Interrupt.
[Switching to Thread 10800.0x1588]
0x0000000077a449f2 in KERNEL32!CtrlRoutine ()
   from C:\Windows\system32\kernel32.dll
(gdb) bt
#0  0x0000000077a449f2 in KERNEL32!CtrlRoutine ()
   from C:\Windows\system32\kernel32.dll
#1  0x0000000077a059ed in KERNEL32!BaseThreadInitThunk ()
   from C:\Windows\system32\kernel32.dll
#2  0x0000000077c3c541 in ntdll!RtlUserThreadStart ()
   from C:\Windows\system32\ntdll.dll
#3  0x0000000000000000 in ?? ()
(gdb) c
Continuing.
[Thread 10800.0x1588 exited with code 0]
4... Pausing for a second...
5... Pausing for a second...
6... Pausing for a second...
[New Thread 10800.0x1c60]

Program received signal SIGINT, Interrupt.
[Switching to Thread 10800.0x1c60]
0x0000000077a449f2 in KERNEL32!CtrlRoutine ()
   from C:\Windows\system32\kernel32.dll
(gdb) bt
#0  0x0000000077a449f2 in KERNEL32!CtrlRoutine ()
   from C:\Windows\system32\kernel32.dll
#1  0x0000000077a059ed in KERNEL32!BaseThreadInitThunk ()
   from C:\Windows\system32\kernel32.dll
#2  0x0000000077c3c541 in ntdll!RtlUserThreadStart ()
   from C:\Windows\system32\ntdll.dll
#3  0x0000000000000000 in ?? ()
(gdb) b 13
Breakpoint 1 at 0x401571: file ttt.cpp, line 13.
(gdb) c
Continuing.
[Switching to Thread 10800.0x1a38]

Breakpoint 1, main () at ttt.cpp:13
13          ++x;
(gdb)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #18 on: May 13, 2014, 03:08:32 pm »
Hi, Vuki, in the previous post, do you press the CTRL+C to stop the debugee? I mean can we send a CTRL+C signal to debugee or GDB to halt the debugee.

Something like: http://stackoverflow.com/questions/7085604/sending-c-to-python-subprocess-objects-on-windows
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Vuki

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #19 on: May 14, 2014, 09:13:39 am »
I do press CTL+C, because it's the only way I know to stop GDB in command line. But since it does not return to the program, I doubt that it would be better solution than the current one. From the discussion so far, it seems that the problem is on the gdb side.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #20 on: May 24, 2014, 05:38:35 am »
I see some source code in GDB: windows-nat.c

Code
/* Wait for interesting events to occur in the target process.  */
static ptid_t
windows_wait (struct target_ops *ops,
      ptid_t ptid, struct target_waitstatus *ourstatus, int options)
{
  int pid = -1;

  target_terminal_ours ();

  /* We loop when we get a non-standard exception rather than return
     with a SPURIOUS because resume can try and step or modify things,
     which needs a current_thread->h.  But some of these exceptions mark
     the birth or death of threads, which mean that the current thread
     isn't necessarily what you think it is.  */

  while (1)
    {
      int retval;

      /* If the user presses Ctrl-c while the debugger is waiting
for an event, he expects the debugger to interrupt his program
and to get the prompt back.  There are two possible situations:

   - The debugger and the program do not share the console, in
     which case the Ctrl-c event only reached the debugger.
     In that case, the ctrl_c handler will take care of interrupting
     the inferior.  Note that this case is working starting with
     Windows XP.  For Windows 2000, Ctrl-C should be pressed in the
     inferior console.

   - The debugger and the program share the same console, in which
     case both debugger and inferior will receive the Ctrl-c event.
     In that case the ctrl_c handler will ignore the event, as the
     Ctrl-c event generated inside the inferior will trigger the
     expected debug event.

     FIXME: brobecker/2008-05-20: If the inferior receives the
     signal first and the delay until GDB receives that signal
     is sufficiently long, GDB can sometimes receive the SIGINT
     after we have unblocked the CTRL+C handler.  This would
     lead to the debugger stopping prematurely while handling
     the new-thread event that comes with the handling of the SIGINT
     inside the inferior, and then stop again immediately when
     the user tries to resume the execution in the inferior.
     This is a classic race that we should try to fix one day.  */
      SetConsoleCtrlHandler (&ctrl_c_handler, TRUE);
      retval = get_windows_debug_event (ops, pid, ourstatus);
      SetConsoleCtrlHandler (&ctrl_c_handler, FALSE);

So, it looks like CTRL+C should work. But I don't know how to send a CTRL+C from Codeblocks(32bit) to GDB(64bit).
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Problem pausing debugger using TDM-GCC64, C::B v13.12
« Reply #21 on: May 24, 2014, 09:44:40 am »
See the logic for interrupting the debugger for remote debugging on windows.

It opens a console and sends the SIGINT equivalent. On Linux I couldn't make sending SIGINT directly to gdb to work as far as I remember.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]