summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>2012-02-26 17:38:45 +0800
committerChong Yidong <cyd@gnu.org>2012-02-26 17:38:45 +0800
commit4fd9655790324ce4b0a321ddae45e98af3953fe1 (patch)
tree9423541146950219b11ef924122cc082b4086fc0
parentfa9a08553937a87d6162bb0a7b21dfd3b3f47164 (diff)
downloademacs-4fd9655790324ce4b0a321ddae45e98af3953fe1.tar.gz
Fix handling of commands containing double quotes in gdb-mi
* lisp/progmodes/gdb-mi.el (gdb-mi-quote): New function. (gdb-send): Apply it to the operand of the '-interpreter-exec console' command, so that we can pass arguments with (say) quotes in them. Store exact string sent in gdb-debug-log (Bug#10765).
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/gdb-mi.el18
2 files changed, 21 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9f1c4e71444..a6783b87baa 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2012-02-26 Jim Blandy <jimb@red-bean.com>
+
+ * progmodes/gdb-mi.el (gdb-mi-quote): New function.
+ (gdb-send): Apply it to the operand of the '-interpreter-exec
+ console' command, so that we can pass arguments with (say) quotes
+ in them. Store exact string sent in gdb-debug-log (Bug#10765).
+
2012-02-26 Chong Yidong <cyd@gnu.org>
* help-fns.el (describe-function-1): Clarify description of
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 301714ec55f..0c45c3f5e5d 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1672,8 +1672,6 @@ static char *magick[] = {
(if (not (string= "" string))
(setq gdb-last-command string)
(if gdb-last-command (setq string gdb-last-command)))
- (if gdb-enable-debug
- (push (cons 'mi-send (concat string "\n")) gdb-debug-log))
(if (string-match "^-" string)
;; MI command
(progn
@@ -1683,10 +1681,22 @@ static char *magick[] = {
(if (string-match "\\\\$" string)
(setq gdb-continuation (concat gdb-continuation string "\n"))
(setq gdb-first-done-or-error t)
- (process-send-string proc (concat "-interpreter-exec console \""
- gdb-continuation string "\"\n"))
+ (let ((to-send (concat "-interpreter-exec console "
+ (gdb-mi-quote string)
+ "\n")))
+ (if gdb-enable-debug
+ (push (cons 'mi-send to-send) gdb-debug-log))
+ (process-send-string proc to-send))
(setq gdb-continuation nil))))
+(defun gdb-mi-quote (string)
+ "Return STRING quoted properly as an MI argument.
+The string is enclosed in double quotes.
+All embedded quotes, newlines, and backslashes are preceded with a backslash."
+ (setq string (replace-regexp-in-string "\\([\"\\]\\)" "\\\\\\&" string))
+ (setq string (replace-regexp-in-string "\n" "\\n" string t t))
+ (concat "\"" string "\""))
+
(defun gdb-input (command handler-function)
"Send COMMAND to GDB via the MI interface.
Run the function HANDLER-FUNCTION, with no arguments, once the command is