From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Dzhus Newsgroups: gmane.emacs.bugs Subject: bug#3794: Error in json from gdb-ui Date: Fri, 10 Jul 2009 17:26:37 +0400 Message-ID: <87r5wosm7m.fsf@sphinx.net.ru> References: Reply-To: Dmitry Dzhus , 3794@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1247234245 12190 80.91.229.12 (10 Jul 2009 13:57:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Jul 2009 13:57:25 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, 3794@emacsbugs.donarmstrong.com To: Herbert Euler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 10 15:57:18 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MPGbE-000064-FT for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Jul 2009 15:57:17 +0200 Original-Received: from localhost ([127.0.0.1]:55813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MPGbD-0003ta-SD for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Jul 2009 09:57:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MPGIC-0001mf-J2 for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:37:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MPGI6-0001dL-Fo for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:37:35 -0400 Original-Received: from [199.232.76.173] (port=48130 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MPGI6-0001cm-3z for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:37:30 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:35606) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MPGI5-0004oh-H8 for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:37:29 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6ADbRmv015955; Fri, 10 Jul 2009 06:37:28 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n6ADZ4Hj015344; Fri, 10 Jul 2009 06:35:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Dmitry Dzhus Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 10 Jul 2009 13:35:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 3794 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.124723253814410 (code B ref -1); Fri, 10 Jul 2009 13:35:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 10 Jul 2009 13:28:58 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n6ADSrui014400 for ; Fri, 10 Jul 2009 06:28:54 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MPG9k-0000tn-F5 for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:28:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MPG9W-0000fy-6U for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:28:52 -0400 Original-Received: from [199.232.76.173] (port=46998 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MPG9W-0000fs-3M for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:28:38 -0400 Original-Received: from sphinx.net.ru ([82.146.58.194]:49930) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MPG9V-0001D2-AX for bug-gnu-emacs@gnu.org; Fri, 10 Jul 2009 09:28:37 -0400 Original-Received: from blizzard (95-24-188-80.broadband.corbina.ru [95.24.188.80]) (authenticated bits=0) by sphinx.net.ru (8.14.3/8.14.2) with ESMTP id n6ADSIiX090244; Fri, 10 Jul 2009 17:28:19 +0400 (MSD) (envelope-from dima@sphinx.net.ru) In-Reply-To: (Herbert Euler's message of "Thu, 9 Jul 2009 20:14:27 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Fri, 10 Jul 2009 09:37:34 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:29297 Archived-At: --=-=-= > I tried M-x gdb to run emacs under gdb. The command line was > > gdb -i=mi ~/src/emacs/src/emacs > > and I got the error '(json-object-format ":" 44). Here is the backtrace: Thank you for reporting this bug. I could reproduce your problem and I wrote a workaround which fixes the bug for me. Could you please try the attached patch for gdb-mi.el? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=gdb-mi-breakpoint-script-fix.patch diff -r 36335b2a0438 -r 392a117f6afc gdb-mi.el --- a/gdb-mi.el Fri Jul 10 14:57:26 2009 +0400 +++ b/gdb-mi.el Fri Jul 10 16:52:55 2009 +0400 @@ -1570,7 +1570,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 @@ -1579,15 +1579,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 @@ -1691,7 +1713,7 @@ (defun gdb-breakpoints-list-handler-custom () (let ((breakpoints-list (gdb-get-field - (json-partial-output "bkpt") + (json-partial-output "bkpt" "script") 'BreakpointTable 'body))) (setq gdb-breakpoints-list nil) (insert "Num\tType\t\tDisp\tEnb\tHits\tAddr What\n") --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Background information: That's one of the GDB/MI syntax inconsistencies coming up in this case. The problem is caused by a script being attached to `init_sys_modes` breakpoint in `.gdbinit`. When GDB/MI includes script information in `-break-info`, it violates its own syntax by wrapping script field value in curly braces (like for tuples) instead of brackets (like for lists, which should be the case for script listing), for example: script=3D{"silent","xgetptr Vinitial_window_system","set $tem =3D ( struct Lisp_Symbol *) $ptr","xgetptr $tem->xname","set $tem =3D (struct Lisp_String *) $ptr","set $tem =3D (char *) $tem->data","if $tem[0] =3D=3D = 'x' && $tem[1] =3D=3D '\0'","break x_error_quitter","end","continue"} Whereas according to GDB/MI Output Syntax tuples (enclosed in {}) may contain only variable=3Dvalue pairs. As the result, the JSON parser used in gdb-mi.el chokes. We handle this nasty case by turning `script` value into what it's meant to be, which is a list, by replacing { -> [ and ] -> }. --=20 Happy Hacking. http://sphinx.net.ru =E3=82=80 --=-=-=--