From: Eli Zaretskii Date: Tue, 15 Dec 2020 17:19:43 +0000 (+0200) Subject: Fix setting breakpoints in "M-x gdb" when a source file is missing X-Git-Tag: emacs-28.0.90~4694 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f3e21483106cb3ff64adcf21d30c8327a23a3401;p=emacs.git Fix setting breakpoints in "M-x gdb" when a source file is missing * lisp/progmodes/gdb-mi.el (gdb-get-location): Fix control flow logic when "fullname" is not found. Unquote and unescape the full file name by calling gdb-mi--c-string-from-string. FLAG is a string, not a character. (Bug#15051) --- diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 4c248f771cd..330a8511bab 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -3127,24 +3127,27 @@ See `def-gdb-auto-update-handler'." (concat "fullname=\\(" gdb--string-regexp "\\)")) (defun gdb-get-location (bptno line flag) - "Find the directory containing the relevant source file. -Put in buffer and place breakpoint icon." + "Glean name of source file using `gdb-source-file-regexp', and visit it. +Place breakpoint icon in its buffer." (goto-char (point-min)) (catch 'file-not-found - (if (re-search-forward gdb-source-file-regexp nil t) - (delete (cons bptno "File not found") gdb-location-alist) - ;; FIXME: Why/how do we use (match-string 1) when the search failed? - (push (cons bptno (match-string 1)) gdb-location-alist) - (gdb-resync) - (unless (assoc bptno gdb-location-alist) - (push (cons bptno "File not found") gdb-location-alist) - (message-box "Cannot find source file for breakpoint location. + (let (source-file) + (if (re-search-forward gdb-source-file-regexp nil t) + (progn + (setq source-file (gdb-mi--c-string-from-string (match-string 1))) + (delete (cons bptno "File not found") gdb-location-alist) + (push (cons bptno source-file) gdb-location-alist)) + (gdb-resync) + (unless (assoc bptno gdb-location-alist) + (push (cons bptno "File not found") gdb-location-alist) + (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)) - (gdb-init-buffer) - ;; only want one breakpoint icon at each location - (gdb-put-breakpoint-icon (eq flag ?y) bptno (string-to-number line))))) + (throw 'file-not-found nil)) + (with-current-buffer (find-file-noselect source-file) + (gdb-init-buffer) + ;; Only want one breakpoint icon at each location. + (gdb-put-breakpoint-icon (string-equal flag "y") bptno + (string-to-number line)))))) (add-hook 'find-file-hook 'gdb-find-file-hook)