branch: master commit 4862a6f2643a7d38dc7c777dacffd0c74ab5098f Author: rocky <ro...@gnu.org> Commit: rocky <ro...@gnu.org>
Warn if gdb --interpreter=mi or -i mi is used --- realgud/debugger/gdb/core.el | 11 +++++++++-- test/test-gdb-core.el | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/realgud/debugger/gdb/core.el b/realgud/debugger/gdb/core.el index fc819d9..42a16cb 100644 --- a/realgud/debugger/gdb/core.el +++ b/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 <ro...@gnu.org> @@ -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 @@ -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 '()) @@ -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)) diff --git a/test/test-gdb-core.el b/test/test-gdb-core.el index dfc1a1a..8aabe69 100644 --- a/test/test-gdb-core.el +++ b/test/test-gdb-core.el @@ -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)