Subject: bug#23608: 24.5; Breakpoints don't show in GDB over TRAMP

From: Michael Albinus <[email-masked]>
Date: Mon, 22 Aug 2016 20:15:30 +0200

Tim Marston <[email-masked]> writes:

> Hi,

Hi Tim,

> I've noticed that breakpoints don't show up in the source code when
> running GDB over TRAMP.  It's quite reproducible.
>
> Steps to reproduce:
>
> 1/  run emacs
>     $ emacs -q
>
> 2/  visit a some remote source code
>     C-x C-f /laptop:/home/edam/src/lang/c++/hello-world/hw.cc
>
> 3/  run GDB
>     M-x gdb RET RET
>
> 4/  switch back to source code window
>     C-x b RET
>
> 5/  add breakpoint
>     C-x C-a C-b

Thanks for the proper recipe!

> What happens:
>
> The breakpoint doesn't show up in the source code buffer.  When you run
> the program, the breakpoint still works.  And when the program "breaks
> out", you get a current line indicator, showing you where execution is
> at.  But no breakpoint.

gdb-mi.el retrieves file names from the running (remote) gdb
process. Obviously, this process cannot know remote (Tramp) file names.

I've committed the following fix to Emacs master:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs/lisp/progmodes/gdb-mi.el.~c1b5000d8c484d7acd39414119838c78eaaf9cca~	2016-08-22 20:04:45.263775082 +0200
--- /home/albinus/src/emacs/lisp/progmodes/gdb-mi.el	2016-08-22 19:58:33.826031791 +0200
***************
*** 2661,2668 ****
  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."
    (save-excursion
      (goto-char (point-min))
      (when fix-key
        (save-excursion
--- 2661,2675 ----
  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.
! 
! If `default-directory' is remote, full file names are adapted accordingly."
    (save-excursion
+     (let ((remote (file-remote-p default-directory)))
+       (when remote
+         (goto-char (point-min))
+         (while (re-search-forward "[\\[,]fullname=\"\\(.+\\)\"" nil t)
+           (replace-match (concat remote "\\1") nil nil nil 1))))
      (goto-char (point-min))
      (when fix-key
        (save-excursion
--8<---------------cut here---------------end--------------->8---

Could you, pls, check whether this works for you? I would also be
interested in any undesired side effect, since I couldn't test this
extensively.

> Tim Marston
> ed.am

Best regards, Michael.