--- gdb-mi.el.orig 2020-01-26 18:46:35.351741525 +0200 +++ gdb-mi.el 2020-01-22 09:58:01.445834007 +0200 @@ -2693,7 +2693,7 @@ (let ((remote (file-remote-p default-directory))) (when remote (goto-char (point-min)) - (while (re-search-forward "[\\[,]fullname=\"\\(.+\\)\"" nil t) + (while (re-search-forward ",fullname=\"\\(.+\\)\"" nil t) (replace-match (concat remote "\\1") nil nil nil 1)))) (goto-char (point-min)) (when fix-key @@ -2967,6 +2967,13 @@ (insert (gdb-table-string table " ")) (gdb-place-breakpoints))) +(defun fix-filename (filename) + (let ((remote (file-remote-p default-directory))) + (if (and remote filename (not (file-remote-p filename))) + (concat remote (replace-regexp-in-string "^\\\"\\(.+\\)\"" "\\1" + filename nil)) + filename))) + ;; Put breakpoint icons in relevant margins (even those set in the GUD buffer). (defun gdb-place-breakpoints () ;; Remove all breakpoint-icons in source buffers but not assembler buffer. @@ -2980,7 +2987,7 @@ ; an associative list (line (bindat-get-field breakpoint 'line))) (when line - (let ((file (bindat-get-field breakpoint 'fullname)) + (let ((file (fix-filename (bindat-get-field breakpoint 'fullname))) (flag (bindat-get-field breakpoint 'enabled)) (bptno (bindat-get-field breakpoint 'number))) (unless (and file (file-exists-p file)) @@ -3019,7 +3026,7 @@ (message-box "Cannot find source file for breakpoint location. Add directory to search path for source files using the GDB command, dir.")) (throw 'file-not-found nil)) - (with-current-buffer (find-file-noselect (match-string 1)) + (with-current-buffer (find-file-noselect (fix-filename (match-string 1))) (gdb-init-buffer) ;; only want one breakpoint icon at each location (gdb-put-breakpoint-icon (eq flag ?y) bptno (string-to-number line))))) @@ -3977,7 +3984,7 @@ (let ((breakpoint (get-text-property (point) 'gdb-breakpoint))) (if breakpoint (let ((bptno (bindat-get-field breakpoint 'number)) - (file (bindat-get-field breakpoint 'fullname)) + (file (fix-filename (bindat-get-field breakpoint 'fullname))) (line (bindat-get-field breakpoint 'line))) (save-selected-window (let* ((buffer (find-file-noselect @@ -4373,7 +4380,7 @@ (let ((frame (bindat-get-field (gdb-json-partial-output) 'frame))) (when frame (setq gdb-selected-frame (bindat-get-field frame 'func)) - (setq gdb-selected-file (bindat-get-field frame 'fullname)) + (setq gdb-selected-file (fix-filename (bindat-get-field frame 'fullname))) (setq gdb-frame-number (bindat-get-field frame 'level)) (setq gdb-frame-address (bindat-get-field frame 'addr)) (let ((line (bindat-get-field frame 'line))) --- gud.el.orig 2020-01-26 18:46:41.563789189 +0200 +++ gud.el 2020-01-26 22:29:38.053975346 +0200 @@ -301,7 +301,8 @@ ;; remote part to f, which is the local file name. Fortunately, ;; `file-remote-p' returns exactly this remote file name part (or ;; nil otherwise). - (setq f (concat (or (file-remote-p default-directory) "") f)) + (unless (file-remote-p f) + (setq f (concat (or (file-remote-p default-directory) "") f))) (if (file-exists-p f) (expand-file-name f) (let ((directories (gud-val 'directories)) (result nil))