Skip to content

Commit

Permalink
Warn if gdb --interpreter=mi or -i mi is used
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jun 28, 2016
1 parent 2316417 commit 4862a6f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
11 changes: 9 additions & 2 deletions realgud/debugger/gdb/core.el
@@ -1,4 +1,4 @@
;; Copyright (C) 2015 Free Software Foundation, Inc
;; Copyright (C) 2015, 2016 Free Software Foundation, Inc

;; Author: Rocky Bernstein <rocky@gnu.org>

Expand Down Expand Up @@ -54,7 +54,7 @@ ORIG_ARGS should contain a tokenized list of the command line to run.
We return the a list containing
* the name of the debugger given (e.g. gdb) and its arguments - a list of strings
* nil (a placehoder in other routines of this ilk for a debugger
* nil (a placeholder in other routines of this ilk for a debugger
* the script name and its arguments - list of strings
* whether the annotate or emacs option was given ('-A', '--annotate' or '--emacs) - a boolean
Expand All @@ -79,6 +79,7 @@ Note that path elements have been expanded via `expand-file-name'.
(gdb-two-args '("x" "-command" "b" "-exec"
"cd" "-pid" "-core" "-directory"
"-annotate"
"i" "-interpreter"
"se" "-symbols" "-tty"))
;; gdb doesn't optionsl 2-arg options.
(gdb-opt-two-args '())
Expand Down Expand Up @@ -119,6 +120,12 @@ Note that path elements have been expanded via `expand-file-name'.
((string-match "^--annotate=[0-9]" arg)
(nconc debugger-args (list (pop args) (pop args)) )
(setq annotate-p t))
((string-match "^--interpreter=" arg)
(warn "realgud doesn't support the --interpreter option; option ignored")
(setq args (cdr args)))
((equal "-i" arg)
(warn "realgud doesn't support the -i option; option ignored")
(setq args (cddr args)))
;; path-argument ooptions
((member arg '("-cd" ))
(setq arg (pop args))
Expand Down
30 changes: 30 additions & 0 deletions test/test-gdb-core.el
Expand Up @@ -33,4 +33,34 @@
(realgud:gdb-parse-cmd-args
'("gdb" "-p" "4511")))

(eval-when-compile
(defvar test:warn-save)
(defvar last-mess)
)

(setq test:warn-save (symbol-function 'warn))

(note "Stripping --interpreter=mi option")
(defun warn (mess &optional args)
"Fake realgud:run-process used in testing"
(setq last-mess mess)
)

(setq last-mess nil)
(assert-equal '(("gdb" "-p") nil ("1955") nil)
(realgud:gdb-parse-cmd-args
'("gdb" "--interpreter=mi" "-p" "1955")))

(assert-nil (null last-mess))
(setq last-mess nil)

(assert-equal '(("gdb" "-p") nil ("1954") nil)
(realgud:gdb-parse-cmd-args
'("gdb" "-i" "mi" "-p" "1954")))

;; Restore the old value of realgud:run-process
(assert-nil (null last-mess))
(fset 'warn test:warn-save)


(end-tests)

0 comments on commit 4862a6f

Please sign in to comment.