Commit 4fd96557 authored by Jim Blandy's avatar Jim Blandy Committed by Chong Yidong
Browse files

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).
parent fa9a0855
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> 2012-02-26 Chong Yidong <cyd@gnu.org>
* help-fns.el (describe-function-1): Clarify description of * help-fns.el (describe-function-1): Clarify description of
......
...@@ -1672,8 +1672,6 @@ static char *magick[] = { ...@@ -1672,8 +1672,6 @@ static char *magick[] = {
(if (not (string= "" string)) (if (not (string= "" string))
(setq gdb-last-command string) (setq gdb-last-command string)
(if gdb-last-command (setq string gdb-last-command))) (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) (if (string-match "^-" string)
;; MI command ;; MI command
(progn (progn
...@@ -1683,10 +1681,22 @@ static char *magick[] = { ...@@ -1683,10 +1681,22 @@ static char *magick[] = {
(if (string-match "\\\\$" string) (if (string-match "\\\\$" string)
(setq gdb-continuation (concat gdb-continuation string "\n")) (setq gdb-continuation (concat gdb-continuation string "\n"))
(setq gdb-first-done-or-error t) (setq gdb-first-done-or-error t)
(process-send-string proc (concat "-interpreter-exec console \"" (let ((to-send (concat "-interpreter-exec console "
gdb-continuation string "\"\n")) (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)))) (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) (defun gdb-input (command handler-function)
"Send COMMAND to GDB via the MI interface. "Send COMMAND to GDB via the MI interface.
Run the function HANDLER-FUNCTION, with no arguments, once the command is Run the function HANDLER-FUNCTION, with no arguments, once the command is
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment