1

I have been trying around getting one keybinding <F7> to perform one gud-step command if a debugging process is running. If it is not running it shall perform gud-run. I am not very familiar with gdb/gud yet, so while trying to get gdb-running to work as a condition for my defun I am exposed to lisp argument errors, that 2 arguments are required (string-or-char-p and nil), where the first argument is a token, as it seems. In the end my goal is to use <F7> to invoke a gud-run and to step-through with the same key afterwards, after reaching a breakpoint.

Following snippet is my first attempt. It becomes obvious that gdb-running is missing 2 arguments as aforementioned.

(require 'gud)
(defun my-gud-run-or-step ()
  (interactive)
  (if (gdb-running)
      (gud-step nil)
    (gud-run nil)))

(global-set-key (kbd "<f7>") 'my-gud-run-or-step)
  • Could you share the code you've written? It will make answering the question easier. – db48x Aug 27 '16 at 19:45
  • Where did you find out about gdb-running? I find only the variable gud-running. – JeanPierre Aug 28 '16 at 7:47
  • I'd like to comment on my Question to answer JeanPierres Question, but apparently I have to reach a reputation of 50 first. I can find gdb-running for example by tab-completing in M-: Eval: while gdb is running. (defun gdb-running (_token output-field) appears to be located in gdb-mi.el.gz. – user13120 Aug 28 '16 at 19:17
0

So the error tells you that gdb-running needs two arguments, but that's kindof a red herring. gdb-running doesn't actually do what you want; it doesn't return true or false to tell you whether gdb is currently running. I think it's called when gdb starts receiving gdb's output, as it appears to set several state variables that are used elsewhere. It looks like you could use the gud-running variable, or gdb-inferior-status. The former will be t, and the latter will be "running", so these might work:

(if gud-running
  ...)

or

(if (equal gdb-inferior-status "running")
  ...)
  • Very helpful. Since hitting a breakpoint gud-running doesn't seem to result in t. Instead; I now use gdb-inferior-status comparing to "running", "end-stepping-range" and "breakpoint-hit" to invoke gud-step. – user13120 Sep 2 '16 at 23:22

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.