Commit bfc99364 authored by Dmitry Dzhus's avatar Dmitry Dzhus
Browse files

(json-partial-output): Fix broken GDB/MI output in -break-info command

(Emacs bug #3794).
parent 1e46f9e4
2009-07-14 Dmitry Dzhus <dima@sphinx.net.ru>
* progmodes/gdb-mi.el (json-partial-output): Fix broken GDB/MI
output in -break-info command (Emacs bug #3794).
2009-07-14 Glenn Morris <rgm@gnu.org> 2009-07-14 Glenn Morris <rgm@gnu.org>
* emacs-lisp/edebug.el (edebug-setup-hook, edebug-all-forms) * emacs-lisp/edebug.el (edebug-setup-hook, edebug-all-forms)
......
...@@ -1436,7 +1436,7 @@ static char *magick[] = { ...@@ -1436,7 +1436,7 @@ static char *magick[] = {
(with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
(erase-buffer))) (erase-buffer)))
(defun json-partial-output (&optional fix-key) (defun json-partial-output (&optional fix-key fix-list)
"Parse gdb-partial-output-buffer with `json-read'. "Parse gdb-partial-output-buffer with `json-read'.
If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurences from If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurences from
...@@ -1445,15 +1445,37 @@ in MI messages, e.g.: [key=.., key=..]. -stack-list-frames and ...@@ -1445,15 +1445,37 @@ in MI messages, e.g.: [key=.., key=..]. -stack-list-frames and
-break-info are examples of MI commands which issue such -break-info are examples of MI commands which issue such
responses. responses.
If FIX-LIST is non-nil, \"FIX-LIST={..}\" is replaced with
\"FIX-LIST=[..]\" prior to parsing. This is used to fix broken
-break-info output when it contains breakpoint script field
incompatible with GDB/MI output syntax.
Note that GDB/MI output syntax is different from JSON both Note that GDB/MI output syntax is different from JSON both
cosmetically and (in some cases) structurally, so correct results cosmetically and (in some cases) structurally, so correct results
are not guaranteed." are not guaranteed."
(with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (concat "[\\[,]\\(" fix-key "=\\)") nil t) (when fix-key
(replace-match "" nil nil nil 1)) (save-excursion
(goto-char (point-min)) (while (re-search-forward (concat "[\\[,]\\(" fix-key "=\\)") nil t)
(insert "{") (replace-match "" nil nil nil 1))))
(when fix-list
(save-excursion
;; Find positions of brackets which enclose broken list
(while (re-search-forward (concat fix-list "={\"") nil t)
(let ((p1 (goto-char (- (point) 2)))
(p2 (progn (forward-sexp)
(1- (point)))))
;; Replace braces with brackets
(save-excursion
(goto-char p1)
(delete-char 1)
(insert "[")
(goto-char p2)
(delete-char 1)
(insert "]"))))))
(goto-char (point-min))
(insert "{")
;; Wrap field names in double quotes and replace equal sign with ;; Wrap field names in double quotes and replace equal sign with
;; semicolon. ;; semicolon.
;; TODO: This breaks badly with foo= inside constants ;; TODO: This breaks badly with foo= inside constants
...@@ -1542,7 +1564,7 @@ OUTPUT-HANDLER-NAME handler uses customization of CUSTOM-DEFUN." ...@@ -1542,7 +1564,7 @@ OUTPUT-HANDLER-NAME handler uses customization of CUSTOM-DEFUN."
(setq gdb-pending-triggers (delq 'gdb-invalidate-breakpoints (setq gdb-pending-triggers (delq 'gdb-invalidate-breakpoints
gdb-pending-triggers)) gdb-pending-triggers))
(let ((breakpoints-list (gdb-get-field (let ((breakpoints-list (gdb-get-field
(json-partial-output "bkpt") (json-partial-output "bkpt" "script")
'BreakpointTable 'body))) 'BreakpointTable 'body)))
(setq gdb-breakpoints-list breakpoints-list) (setq gdb-breakpoints-list breakpoints-list)
(insert "Num\tType\t\tDisp\tEnb\tHits\tAddr What\n") (insert "Num\tType\t\tDisp\tEnb\tHits\tAddr What\n")
......
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