Mercurial > emacs
changeset 103886:d9b3b49cf6d3
(json-partial-output): Fix broken GDB/MI output in -break-info command
(Emacs bug #3794).
author | Dmitry Dzhus <dima@sphinx.net.ru> |
---|---|
date | Tue, 14 Jul 2009 08:40:58 +0000 |
parents | adbe0e36df45 |
children | 427b644c9e3b |
files | lisp/ChangeLog lisp/progmodes/gdb-mi.el |
diffstat | 2 files changed, 33 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Tue Jul 14 08:01:50 2009 +0000 +++ b/lisp/ChangeLog Tue Jul 14 08:40:58 2009 +0000 @@ -1,3 +1,8 @@ +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> * emacs-lisp/edebug.el (edebug-setup-hook, edebug-all-forms)
--- a/lisp/progmodes/gdb-mi.el Tue Jul 14 08:01:50 2009 +0000 +++ b/lisp/progmodes/gdb-mi.el Tue Jul 14 08:40:58 2009 +0000 @@ -1436,7 +1436,7 @@ (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-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'. If FIX-KEY is non-nil, strip all \"FIX-KEY=\" occurences from @@ -1445,15 +1445,37 @@ -break-info are examples of MI commands which issue such 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 cosmetically and (in some cases) structurally, so correct results are not guaranteed." (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (goto-char (point-min)) - (while (re-search-forward (concat "[\\[,]\\(" fix-key "=\\)") nil t) - (replace-match "" nil nil nil 1)) - (goto-char (point-min)) - (insert "{") + (when fix-key + (save-excursion + (while (re-search-forward (concat "[\\[,]\\(" fix-key "=\\)") nil t) + (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 ;; semicolon. ;; TODO: This breaks badly with foo= inside constants @@ -1542,7 +1564,7 @@ (setq gdb-pending-triggers (delq 'gdb-invalidate-breakpoints gdb-pending-triggers)) (let ((breakpoints-list (gdb-get-field - (json-partial-output "bkpt") + (json-partial-output "bkpt" "script") 'BreakpointTable 'body))) (setq gdb-breakpoints-list breakpoints-list) (insert "Num\tType\t\tDisp\tEnb\tHits\tAddr What\n")