Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
963 views
in Technique[技术] by (71.8m points)

signals - GDB: Ctrl+C doesn't interrupt process as it usually does but rather terminates the program

Normally when you run a program through GDB you can press Ctrl+C to interrupt it, e.g. if it gets stuck in an infinite loop and you want to get a backtrace.

I'm debugging a program (xmms2d as it happens) but in this program only, when I press Ctrl+C it gets treated as if GDB was not running - the program shuts down cleanly and then GDB tells me the program exited normally.

How do I get the usual GDB behaviour back, where Ctrl+C interrupts the program? Or is there another way to produce the same reaction in GDB as a Ctrl+C normally does?

question from:https://stackoverflow.com/questions/5857300/gdb-ctrlc-doesnt-interrupt-process-as-it-usually-does-but-rather-terminates-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'll bet that xmms2d is using sigwait() to handle signals, which breaks gdb's ability to catch CTRL-C. See https://bugzilla.kernel.org/show_bug.cgi?id=9039

I got an idea for a workaround by reading Continue to debug after failed assertion on Linux? -- when I'm ready to break in gdb, I run "kill -TRAP <pid>" from another terminal window.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...