In GDB on MinGW, how do I make Ctrl-C stop the program?

后端 未结 8 1032
灰色年华
灰色年华 2021-02-05 11:50

I\'m on Windows, running GDB on an executable built under MinGW. The program has an infinite loop. I want to find it by hitting Ctrl + C. When I do, both t

8条回答
  •  北恋
    北恋 (楼主)
    2021-02-05 12:32

    I've just hit the same problem.

    The workaround from the wiki is to run debugbreak with the pid of the debugged process, but ps doesn't show this pid, only pid of gdb. Maybe there is another way to obtain it.

    But there is simpler workaround. Just start the program normally (not in gdb), check pid from ps and start gdb with this pid as second argument. When gdb is attached the process stops and I can print backtrace.

提交回复
热议问题