unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Fix M-x gdb when debugging over Tramp
@ 2021-04-07 23:14 Jim Porter
  2021-04-08 12:58 ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Porter @ 2021-04-07 23:14 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1095 bytes --]

Here's a pair of patches (one against the latest git revision, and one
against the emacs-27 branch) to fix debugging via M-x gdb over Tramp. There
were two problems:

1) In `gdb-jsonify-buffer', when replacing the "fullname" with a Tramp
path, the wildcard was greedy, resulting in only one "fullname" being
replaced. This had the effect of rendering it impossible to have more than
one breakpoint, as all but the first breakpoint would have unmodified
"fullname"s. This fix isn't needed for Emacs 28, since `gdb-jsonify-buffer'
was replaced with a more-accurate parser for GDB/MI.

2) In `gdb-frame-handler', `gdb-selected-file' needs to be the *local* file
path, since that's what `gud-last-frame' expects. Without this, the overlay
arrow for the current line in the source buffer won't show.

I've been running with these patches for a few months locally and haven't
found any further issues. Note that I haven't filled out copyright
assignment papers, but these patches are very small, so my understanding is
that's not necessary. If you'd like me to fill them out, just let me know.

- Jim

[-- Attachment #1.2: Type: text/html, Size: 1318 bytes --]

[-- Attachment #2: 0001-Emacs27-Fix-GDB-MI-usage-when-debugging-over-Tramp.patch --]
[-- Type: application/octet-stream, Size: 1668 bytes --]

From 5e11ec4362c6b56466477536ac1229ee2b8b8fcc Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 7 Apr 2021 15:55:15 -0700
Subject: [PATCH] Fix GDB/MI usage when debugging over Tramp

* lisp/progmodes/gdb-mi.el (gdb-jsonify-buffer): Fix modification of
GDB/MI "fullname" property for remote files
(gdb-frame-handler): Use local part of file name when setting
`gud-last-frame'.
---
 lisp/progmodes/gdb-mi.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 65fe997341..51a237a38e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -2696,7 +2696,7 @@ If `default-directory' is remote, full file names are adapted accordingly."
     (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
@@ -4376,7 +4376,7 @@ overlay arrow in source buffer."
   (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 (file-local-name (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)))
-- 
2.25.1


[-- Attachment #3: 0001-Emacs28-Fix-GUD-overlay-arrows-in-gdb-mi-when-debugging-over.patch --]
[-- Type: application/octet-stream, Size: 1107 bytes --]

From a3e4dee36559382067e511335137c4f6349120e9 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 7 Apr 2021 15:43:27 -0700
Subject: [PATCH] Fix GUD overlay arrows in gdb-mi when debugging over Tramp

* lisp/progmodes/gdb-mi.el (gdb-frame-handler): Use local part of
file name when setting `gud-last-frame'.
---
 lisp/progmodes/gdb-mi.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 1a96755bcf..8e6ce3d269 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -4512,7 +4512,7 @@ overlay arrow in source buffer."
   (let ((frame (gdb-mi--field (gdb-mi--partial-output) 'frame)))
     (when frame
       (setq gdb-selected-frame (gdb-mi--field frame 'func))
-      (setq gdb-selected-file (gdb-mi--field frame 'fullname))
+      (setq gdb-selected-file (file-local-name (gdb-mi--field frame 'fullname)))
       (setq gdb-frame-number (gdb-mi--field frame 'level))
       (setq gdb-frame-address (gdb-mi--field frame 'addr))
       (let ((line (gdb-mi--field frame 'line)))
-- 
2.25.1


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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-07 23:14 [PATCH] Fix M-x gdb when debugging over Tramp Jim Porter
@ 2021-04-08 12:58 ` Michael Albinus
  2021-04-15  5:02   ` Jim Porter
  2021-04-19 11:55   ` William Xu
  0 siblings, 2 replies; 9+ messages in thread
From: Michael Albinus @ 2021-04-08 12:58 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> Here's a pair of patches (one against the latest git revision, and one
> against the emacs-27 branch) to fix debugging via M-x gdb over Tramp.
> There were two problems:
>
> 1) In `gdb-jsonify-buffer', when replacing the "fullname" with a Tramp
> path, the wildcard was greedy, resulting in only one "fullname" being
> replaced. This had the effect of rendering it impossible to have more
> than one breakpoint, as all but the first breakpoint would have
> unmodified "fullname"s. This fix isn't needed for Emacs 28, since
> `gdb-jsonify-buffer' was replaced with a more-accurate parser for
> GDB/MI.
>
> 2) In `gdb-frame-handler', `gdb-selected-file' needs to be the *local*
> file path, since that's what `gud-last-frame' expects. Without this,
> the overlay arrow for the current line in the source buffer won't
> show.

From my POV these patches look OK, but I'm a very occasional gdb
user. It would be great if somebody else could verify.

I have also the impression that this is related to bug#39408, bug#28392
and bug#44151. Perhaps this could be checked, and in case of yes, I
would much appreciate if we could solve all of these bugs.

> I've been running with these patches for a few months locally and
> haven't found any further issues. Note that I haven't filled out
> copyright assignment papers, but these patches are very small, so my
> understanding is that's not necessary. If you'd like me to fill them
> out, just let me know.

Assign request sent. Jim has proposed a further patch on the Tramp ML.

> - Jim

Best regards, Michael.



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-08 12:58 ` Michael Albinus
@ 2021-04-15  5:02   ` Jim Porter
  2021-04-15  7:55     ` Michael Albinus
  2021-04-19 11:55   ` William Xu
  1 sibling, 1 reply; 9+ messages in thread
From: Jim Porter @ 2021-04-15  5:02 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

On Thu, Apr 8, 2021 at 5:58 AM Michael Albinus <michael.albinus@gmx.de> wrote:
>
> Jim Porter <jporterbugs@gmail.com> writes:
>
> Hi Jim,
>
> > Here's a pair of patches (one against the latest git revision, and one
> > against the emacs-27 branch) to fix debugging via M-x gdb over Tramp.
> > There were two problems:
> >
> > 1) In `gdb-jsonify-buffer', when replacing the "fullname" with a Tramp
> > path, the wildcard was greedy, resulting in only one "fullname" being
> > replaced. This had the effect of rendering it impossible to have more
> > than one breakpoint, as all but the first breakpoint would have
> > unmodified "fullname"s. This fix isn't needed for Emacs 28, since
> > `gdb-jsonify-buffer' was replaced with a more-accurate parser for
> > GDB/MI.
> >
> > 2) In `gdb-frame-handler', `gdb-selected-file' needs to be the *local*
> > file path, since that's what `gud-last-frame' expects. Without this,
> > the overlay arrow for the current line in the source buffer won't
> > show.
>
> From my POV these patches look OK, but I'm a very occasional gdb
> user. It would be great if somebody else could verify.

Thanks for taking a look. Of course, if anyone with more experience
using M-x gdb could take a look, that would be helpful too.

> I have also the impression that this is related to bug#39408, bug#28392
> and bug#44151. Perhaps this could be checked, and in case of yes, I
> would much appreciate if we could solve all of these bugs.

Indeed, it looks like bug#39408 is my issue (1) above, and bug#28392
is my issue (2). bug#44151 looks like it's done(ish): the first part
is something you've already fixed in Tramp, and the second part
(mentioned in comment 11) is a duplicate of bug#28392.

Given that these are already tracked as bugs, should I just submit
patches to both bug#39408 and bug#28392? I'd have to rearrange my
existing patches slightly, but that's easy.

- Jim



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-15  5:02   ` Jim Porter
@ 2021-04-15  7:55     ` Michael Albinus
  2021-04-16  5:03       ` Jim Porter
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2021-04-15  7:55 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>> From my POV these patches look OK, but I'm a very occasional gdb
>> user. It would be great if somebody else could verify.
>
> Thanks for taking a look. Of course, if anyone with more experience
> using M-x gdb could take a look, that would be helpful too.
>
>> I have also the impression that this is related to bug#39408, bug#28392
>> and bug#44151. Perhaps this could be checked, and in case of yes, I
>> would much appreciate if we could solve all of these bugs.
>
> Indeed, it looks like bug#39408 is my issue (1) above, and bug#28392
> is my issue (2). bug#44151 looks like it's done(ish): the first part
> is something you've already fixed in Tramp, and the second part
> (mentioned in comment 11) is a duplicate of bug#28392.

That's why bug#28392 and bug#44151 are merged :-)

> Given that these are already tracked as bugs, should I just submit
> patches to both bug#39408 and bug#28392? I'd have to rearrange my
> existing patches slightly, but that's easy.

Yes, please do. And since nobody else has reacted to these bugs for
years, I'm in the mood to commit your patches as soon as your paperwork
with FSF is fixed. Unless somebody comments until.

> - Jim

Best regards, Michael.



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-15  7:55     ` Michael Albinus
@ 2021-04-16  5:03       ` Jim Porter
  2021-05-01  4:13         ` Jim Porter
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Porter @ 2021-04-16  5:03 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

On Thu, Apr 15, 2021 at 12:55 AM Michael Albinus <michael.albinus@gmx.de> wrote:
> Jim Porter <jporterbugs@gmail.com> writes:
> >> I have also the impression that this is related to bug#39408, bug#28392
> >> and bug#44151. Perhaps this could be checked, and in case of yes, I
> >> would much appreciate if we could solve all of these bugs.
> >
> > Indeed, it looks like bug#39408 is my issue (1) above, and bug#28392
> > is my issue (2). bug#44151 looks like it's done(ish): the first part
> > is something you've already fixed in Tramp, and the second part
> > (mentioned in comment 11) is a duplicate of bug#28392.
>
> That's why bug#28392 and bug#44151 are merged :-)

Right, just making sure we were on the same page. :)

> > Given that these are already tracked as bugs, should I just submit
> > patches to both bug#39408 and bug#28392? I'd have to rearrange my
> > existing patches slightly, but that's easy.
>
> Yes, please do. And since nobody else has reacted to these bugs for
> years, I'm in the mood to commit your patches as soon as your paperwork
> with FSF is fixed. Unless somebody comments until.

Ok, I submitted the patches to the corresponding bugs.

Thanks,
- Jim



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-08 12:58 ` Michael Albinus
  2021-04-15  5:02   ` Jim Porter
@ 2021-04-19 11:55   ` William Xu
  2021-04-19 12:44     ` Michael Albinus
  1 sibling, 1 reply; 9+ messages in thread
From: William Xu @ 2021-04-19 11:55 UTC (permalink / raw)
  To: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

>> 2) In `gdb-frame-handler', `gdb-selected-file' needs to be the *local*
>> file path, since that's what `gud-last-frame' expects. Without this,
>> the overlay arrow for the current line in the source buffer won't
>> show.
>
> From my POV these patches look OK, but I'm a very occasional gdb
> user. It would be great if somebody else could verify.
>
> I have also the impression that this is related to bug#39408, bug#28392
> and bug#44151. Perhaps this could be checked, and in case of yes, I
> would much appreciate if we could solve all of these bugs.

I can confirm it fixes the bug#44151.

Thanks!

-- 
William




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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-19 11:55   ` William Xu
@ 2021-04-19 12:44     ` Michael Albinus
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Albinus @ 2021-04-19 12:44 UTC (permalink / raw)
  To: William Xu; +Cc: emacs-devel

William Xu <william.xwl@gmail.com> writes:

>>> 2) In `gdb-frame-handler', `gdb-selected-file' needs to be the *local*
>>> file path, since that's what `gud-last-frame' expects. Without this,
>>> the overlay arrow for the current line in the source buffer won't
>>> show.
>>
>> From my POV these patches look OK, but I'm a very occasional gdb
>> user. It would be great if somebody else could verify.
>>
>> I have also the impression that this is related to bug#39408, bug#28392
>> and bug#44151. Perhaps this could be checked, and in case of yes, I
>> would much appreciate if we could solve all of these bugs.
>
> I can confirm it fixes the bug#44151.

Thanks! When the FSF paperwork for Jim Porter is fixed, we will push the changes.

> Thanks!

Best regards, Michael.



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-04-16  5:03       ` Jim Porter
@ 2021-05-01  4:13         ` Jim Porter
  2021-05-01 10:18           ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Porter @ 2021-05-01  4:13 UTC (permalink / raw)
  To: emacs-devel

On Thu, Apr 15, 2021 at 10:03 PM Jim Porter <jporterbugs@gmail.com> wrote:
> On Thu, Apr 15, 2021 at 12:55 AM Michael Albinus <michael.albinus@gmx.de> wrote:
> > Jim Porter <jporterbugs@gmail.com> writes:
> > > Given that these are already tracked as bugs, should I just submit
> > > patches to both bug#39408 and bug#28392? I'd have to rearrange my
> > > existing patches slightly, but that's easy.
> >
> > Yes, please do. And since nobody else has reacted to these bugs for
> > years, I'm in the mood to commit your patches as soon as your paperwork
> > with FSF is fixed. Unless somebody comments until.
>
> Ok, I submitted the patches to the corresponding bugs.

My FSF paperwork has been completed, so my patches on bug#39408 and
bug#28392 should be able to be merged now.

- Jim



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

* Re: [PATCH] Fix M-x gdb when debugging over Tramp
  2021-05-01  4:13         ` Jim Porter
@ 2021-05-01 10:18           ` Michael Albinus
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Albinus @ 2021-05-01 10:18 UTC (permalink / raw)
  To: Jim Porter; +Cc: emacs-devel

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>> > Yes, please do. And since nobody else has reacted to these bugs for
>> > years, I'm in the mood to commit your patches as soon as your paperwork
>> > with FSF is fixed. Unless somebody comments until.
>>
>> Ok, I submitted the patches to the corresponding bugs.
>
> My FSF paperwork has been completed, so my patches on bug#39408 and
> bug#28392 should be able to be merged now.

Congratulations! I've pushed your patches.

> - Jim

Best regards, Michael.



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

end of thread, other threads:[~2021-05-01 10:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 23:14 [PATCH] Fix M-x gdb when debugging over Tramp Jim Porter
2021-04-08 12:58 ` Michael Albinus
2021-04-15  5:02   ` Jim Porter
2021-04-15  7:55     ` Michael Albinus
2021-04-16  5:03       ` Jim Porter
2021-05-01  4:13         ` Jim Porter
2021-05-01 10:18           ` Michael Albinus
2021-04-19 11:55   ` William Xu
2021-04-19 12:44     ` Michael Albinus

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).