In the vanilla gdb interface, I can hit C-c to break the running program, insert breakpoints, etc., and then run continue to resume execution of the program being debugged. Is this possible with gud? C-c C-c in gud actually sends SIGKILL to the program, rather than breaking in gdb...

More info and repro

I'm actually trying to debug emacs (from a separate emacs+gud instance, of course) to try to get to the bottom of this guy. Here's what I'm doing:

$ cd path/to/emacs-24.5 # where I've built emacs with debugging symbols, etc
$ ./src/emacs -Q
M-x gdb
Run gdb (like this): gdb -i=mi ./src/emacs

At this point I'd like to break the execution of the new emacs process so that I can poke around, set breakpoints, etc. My end game is to wait for the new emacs process to get into the bad state described in my bug report (sometimes takes days). That's when I really want to break execution of emacs and set the breakpoints.

  • Maybe you could send SIGINT to the gdb process? – nispio Apr 20 '15 at 23:19
  • That actually kills my process as well... I'm guessing that's because gdb is running in gdb -i=mi mode so SIGINT is probably handled differently. – mgalgs Apr 20 '15 at 23:32
  • Ping! Do either of the posted answers help you? – Dan Sep 27 '15 at 18:33
  • Neither of the solutions worked... I'll try some more things and try to get some closure on this. – mgalgs Sep 28 '15 at 15:04
  • IIRC the issue is specific to debugging emacs, where you'll want to use C-c C-z, instead of C-c C-c. My memory is fuzzy and it's a part I'm not very familiar with, but IIRC it's linked to the fact that under a tty Emacs treats SIGINT as an input key (corresponding to C-g maybe?) – Stefan Jun 12 '18 at 16:07

This works for me using C-c C-c

Current directory is /src/build/emacs-24.5/src/
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
(gdb) run 
Starting program: /src/build/emacs-24.5/src/emacs 
[Thread debugging using libthread_db enabled]
[New Thread 0xb4bffb40 (LWP 735)]
 C-c C-c(gdb) 
C-c C-c(gdb) break main
Breakpoint 1 at 0x815d7b8: file emacs.c, line 707.

But here are two other things to try. First is without the -i=mi option. The second is to use realgud (available from MELPA); and in realgud this can be done in one of two ways. After M-x load-library realgud, then M-x realgud:gdb or you can go into a "shell" (comint) or "term" shell and run plain gdb, "set annotate 1", and then run the program. Run M-x realgud-track-mode and set the debugger to be gdb.


You can either use the stop command or you can use C-c C-z which sends the stop signal. You could also just add the new breakpoints, if the new breakpoints are after your current position, when you do continue it will stop in the new breakpoint. If the breakpoint is before your current position, then you can restart the program by doing run this will restart the process. You can find more information here GUD Commands

UPDATE: In that case, you might want to read etc/DEBUG.

As for the gdb shell, you can start it by doing: C-u M-x gdb and then pass the -i=mi -p PID as well as any other flag you might need.

  • I don't have a gdb shell (my program is already running) so I can't issue gdb's stop command (I assume that's what you meant?). Also, C-c C-z doesn't seem to do anything (nor does the Stop button in the toolbar)... I'll edit my post for full repro instructions (I'm trying to debug emacs within a separate emacs+gud instance. – mgalgs Apr 23 '15 at 17:00

A working solution for myself:

(global-set-key (kbd "<f6>") (lambda ()

comint-interrupt-subjob is the command bound to C-c C-c, it sends SIGINT to subprocess, gud-stop-subjob will send string "-interrupt-exec --all" to gdb mi interface. Neither of them works for me, but when I apply both, suprise, I don't know why, tell me if anybody knows the reason.

btw, sometimes I have to press Enter after F6, sometimes not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.