Subject: bug#14129: 24.3.50; gdb/gud: wrong-type-argument

From: Jean-Philippe Gravel <[email-masked]>
Date: Fri, 5 Apr 2013 00:07:36 -0400

Try the following patch.

The current buffer offset (gdbmi-bnf-offset) was incorrectly adjusted
when receiving incomplete responses from GDB.

=== modified file 'lisp/progmodes/gdb-mi.el'
*** lisp/progmodes/gdb-mi.el    2013-03-11 17:13:39 +0000
--- lisp/progmodes/gdb-mi.el    2013-04-05 03:47:08 +0000
***************
*** 2152,2167 ****
         (is-complete (not (null newline-pos)))
         result-str)

        ;; Update the gdbmi-bnf-offset only if the current chunk of data can
        ;; be processed by the class-command handler:
        (when (or is-complete is-progressive)
      (setq result-str
                (substring gud-marker-acc gdbmi-bnf-offset newline-pos))
-     (setq gdbmi-bnf-offset (+ 1 newline-pos)))

!       (if gdbmi-debug-mode
!           (message "gdbmi-bnf-incomplete-record-result: %s"
!                    (substring gud-marker-acc gdbmi-bnf-offset newline-pos)))

        ;; Update the parsing state before invoking the handler in class-command
        ;; to make sure it's not left in an invalid state if the handler was
--- 2152,2171 ----
         (is-complete (not (null newline-pos)))
         result-str)

+       (when gdbmi-debug-mode
+     (message "gdbmi-bnf-incomplete-record-result: %s"
+          (substring gud-marker-acc gdbmi-bnf-offset newline-pos)))
+
        ;; Update the gdbmi-bnf-offset only if the current chunk of data can
        ;; be processed by the class-command handler:
        (when (or is-complete is-progressive)
      (setq result-str
                (substring gud-marker-acc gdbmi-bnf-offset newline-pos))

!     ;; Move gdbmi-bnf-offset past the end of the chunk
!     (setq gdbmi-bnf-offset (+ gdbmi-bnf-offset (length result-str)))
!     (when newline-pos
!       (setq gdbmi-bnf-offset (1+ gdbmi-bnf-offset))))

        ;; Update the parsing state before invoking the handler in class-command
        ;; to make sure it's not left in an invalid state if the handler was