unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp
@ 2012-12-29 11:00 Dima Kogan
       [not found] ` <handler.13304.B.13567788884884.ack@debbugs.gnu.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dima Kogan @ 2012-12-29 11:00 UTC (permalink / raw)
  To: 13304

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

This patch fixes a bug I hit when remotely-debugging a python program
with gud through tramp. If I tried to set a breakpoint from the source
buffer, the python debugger would be given the full path to the file,
tramp fields and all. This made it impossible to set breakpoints in this
manner.

Attached is a patch that strips out the remote pieces of the path when
communicating with the backend debugger.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2054 bytes --]

From 3bfe6f560a8c6f96ef0ed9200015bab0d29235c9 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sat, 29 Dec 2012 02:54:40 -0800
Subject: [PATCH] full-path gud breakpoints now don't get confused by tramp

prior to this patch if gud used a path to set a breakpoint, the FULL
path would be sent to the backend debugger, including the tramp
pieces. The backends don't know anything about tramp, so they were
naturally confused by this. Most notably, it was impossible to set
from-source breakpoints in pdb, the python debugger.
---
 lisp/progmodes/gud.el |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 13eac83..45e0ddf 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2743,6 +2743,11 @@ Obeying it means displaying in another window the specified file and line."
 (defun gud-format-command (str arg)
   (let ((insource (not (eq (current-buffer) gud-comint-buffer)))
 	(frame (or gud-last-frame gud-last-last-frame))
+	(buffer-file-name-localized
+	 (if (and (buffer-file-name) (file-remote-p (buffer-file-name)))
+	     (tramp-file-name-localname (tramp-dissect-file-name
+					 (buffer-file-name) t))
+	   (buffer-file-name)))
 	result)
     (while (and str
 		(let ((case-fold-search nil))
@@ -2752,15 +2757,15 @@ Obeying it means displaying in another window the specified file and line."
 	(cond
 	 ((eq key ?f)
 	  (setq subst (file-name-nondirectory (if insource
-						  (buffer-file-name)
+						  buffer-file-name-localized
 						(car frame)))))
 	 ((eq key ?F)
 	  (setq subst (file-name-base (if insource
-                                          (buffer-file-name)
+                                          buffer-file-name-localized
                                         (car frame)))))
 	 ((eq key ?d)
 	  (setq subst (file-name-directory (if insource
-					       (buffer-file-name)
+					       buffer-file-name-localized
 					     (car frame)))))
 	 ((eq key ?l)
 	  (setq subst (int-to-string
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#13304: Acknowledgement ([PATCH] full-path gud breakpoints now don't get confused by tramp)
       [not found] ` <handler.13304.B.13567788884884.ack@debbugs.gnu.org>
@ 2012-12-29 20:23   ` Dima Kogan
  0 siblings, 0 replies; 7+ messages in thread
From: Dima Kogan @ 2012-12-29 20:23 UTC (permalink / raw)
  To: 13304

Here's a recipe to reproduce the bug as it was. Note that I'm on an amd64 linux
box.

1. Create a new python program. I put it in /tmp/tst.py with these contents:

#!/usr/bin/python
print("hi")


2. Run pdb on this file via tramp. I did this:

M-x pdb     pdb /127.0.0.1:/tmp/tst.py

This launches pdb and opens the remote /tmp/tst.py



3. Now navigate to the print("hi") line, and do C-x SPC. This is supposed to set
a breakpoint there, but it doesn't work. If it did, pdb would say "Breakpoint 1
at /tmp/tst.py:2". Instead it says "End of file". The command being sent to the
pdb backend is

break /scpc:127.0.0.1:/tmp/tst.py:2

but it should be

break /tmp/tst.py:2





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp
  2012-12-29 11:00 bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Dima Kogan
       [not found] ` <handler.13304.B.13567788884884.ack@debbugs.gnu.org>
@ 2012-12-31 15:41 ` Michael Albinus
  2012-12-31 19:53   ` Dima Kogan
  2015-09-21  2:37 ` bug#13304: ping Dima Kogan
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2012-12-31 15:41 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 13304

Dima Kogan <dima@secretsauce.net> writes:

> +	     (tramp-file-name-localname (tramp-dissect-file-name
> +					 (buffer-file-name) t))

Don't use Tramp internal functions, they are not documented by
intention. You could use instead

(file-remote-p (buffer-file-name) 'localname)

Best regards, Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp
  2012-12-31 15:41 ` bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Michael Albinus
@ 2012-12-31 19:53   ` Dima Kogan
  0 siblings, 0 replies; 7+ messages in thread
From: Dima Kogan @ 2012-12-31 19:53 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 13304

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

> On Mon, 31 Dec 2012 16:41:42 +0100
> Michael Albinus <michael.albinus@gmx.de> wrote:
>
> Dima Kogan <dima@secretsauce.net> writes:
> 
> > +	     (tramp-file-name-localname (tramp-dissect-file-name
> > +					 (buffer-file-name) t))
> 
> Don't use Tramp internal functions, they are not documented by
> intention. You could use instead
> 
> (file-remote-p (buffer-file-name) 'localname)

Great point; this is really much better. I'm attaching an updated patch.

[-- Attachment #2: 0001-full-path-gud-breakpoints-now-don-t-get-confused-by-.patch --]
[-- Type: text/x-patch, Size: 1978 bytes --]

From f27e176b58dc9fd813ad5f9228066d3fcc2c226c Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sat, 29 Dec 2012 02:54:40 -0800
Subject: [PATCH] full-path gud breakpoints now don't get confused by tramp

prior to this patch if gud used a path to set a breakpoint, the FULL
path would be sent to the backend debugger, including the tramp
pieces. The backends don't know anything about tramp, so they were
naturally confused by this. Most notably, it was impossible to set
from-source breakpoints in pdb, the python debugger.
---
 lisp/progmodes/gud.el |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index 13eac83..c178a53 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -2743,6 +2743,9 @@ Obeying it means displaying in another window the specified file and line."
 (defun gud-format-command (str arg)
   (let ((insource (not (eq (current-buffer) gud-comint-buffer)))
 	(frame (or gud-last-frame gud-last-last-frame))
+	(buffer-file-name-localized
+	 (and (buffer-file-name) (or (file-remote-p (buffer-file-name) 'localname)
+				     (buffer-file-name))))
 	result)
     (while (and str
 		(let ((case-fold-search nil))
@@ -2752,15 +2755,15 @@ Obeying it means displaying in another window the specified file and line."
 	(cond
 	 ((eq key ?f)
 	  (setq subst (file-name-nondirectory (if insource
-						  (buffer-file-name)
+						  buffer-file-name-localized
 						(car frame)))))
 	 ((eq key ?F)
 	  (setq subst (file-name-base (if insource
-                                          (buffer-file-name)
+                                          buffer-file-name-localized
                                         (car frame)))))
 	 ((eq key ?d)
 	  (setq subst (file-name-directory (if insource
-					       (buffer-file-name)
+					       buffer-file-name-localized
 					     (car frame)))))
 	 ((eq key ?l)
 	  (setq subst (int-to-string
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#13304: ping
  2012-12-29 11:00 bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Dima Kogan
       [not found] ` <handler.13304.B.13567788884884.ack@debbugs.gnu.org>
  2012-12-31 15:41 ` bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Michael Albinus
@ 2015-09-21  2:37 ` Dima Kogan
  2015-09-21 10:56   ` Eli Zaretskii
  2 siblings, 1 reply; 7+ messages in thread
From: Dima Kogan @ 2015-09-21  2:37 UTC (permalink / raw)
  To: 13304

Hi. This is a gentle ping. This patch is useful and fixes a real bug.
Can somebody please take a look and maybe merge it? Thanks!






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13304: ping
  2015-09-21  2:37 ` bug#13304: ping Dima Kogan
@ 2015-09-21 10:56   ` Eli Zaretskii
  2015-09-21 18:38     ` Dima Kogan
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2015-09-21 10:56 UTC (permalink / raw)
  To: Dima Kogan; +Cc: 13304

> From: Dima Kogan <dima@secretsauce.net>
> Date: Sun, 20 Sep 2015 19:37:38 -0700
> 
> Hi. This is a gentle ping. This patch is useful and fixes a real bug.
> Can somebody please take a look and maybe merge it? Thanks!

Thanks, pushed.

Should we close the bug now?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13304: ping
  2015-09-21 10:56   ` Eli Zaretskii
@ 2015-09-21 18:38     ` Dima Kogan
  0 siblings, 0 replies; 7+ messages in thread
From: Dima Kogan @ 2015-09-21 18:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13304-done

Eli Zaretskii <eliz@gnu.org> writes:

> Thanks, pushed.
>
> Should we close the bug now?

Thanks for doing that. You accidentally pushed the original patch, the
one from before I addressed Michael's comments, so it might be good to
update the tree with the later patch. In any case, I'm closing the bug.
Thanks again.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-21 18:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-29 11:00 bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Dima Kogan
     [not found] ` <handler.13304.B.13567788884884.ack@debbugs.gnu.org>
2012-12-29 20:23   ` bug#13304: Acknowledgement ([PATCH] full-path gud breakpoints now don't get confused by tramp) Dima Kogan
2012-12-31 15:41 ` bug#13304: [PATCH] full-path gud breakpoints now don't get confused by tramp Michael Albinus
2012-12-31 19:53   ` Dima Kogan
2015-09-21  2:37 ` bug#13304: ping Dima Kogan
2015-09-21 10:56   ` Eli Zaretskii
2015-09-21 18:38     ` Dima Kogan

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).