unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28392: 26.0.50; gdb-mi runs into error with tramp
@ 2017-09-08 10:52 Zhongwei Yao
  2020-11-30 10:57 ` Lars Ingebrigtsen
  2021-04-16  5:03 ` Jim Porter
  0 siblings, 2 replies; 5+ messages in thread
From: Zhongwei Yao @ 2017-09-08 10:52 UTC (permalink / raw)
  To: 28392

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

emacs runs on Mac with tramp . And I have a test project on a remote
machine (dev-sever): /home/xxx/project/test_gdb/. It has a simple file:
test.c. test.c is compiled by gcc with -O0 -g to test_bin.

test.c:
1 int foo(int a, int b) {
2  int c = a + b;
3  return c;
4 }
5
6 int main(void) {
7  return foo(3, 4);
8 }

Steps:
1. Open test.c on dev-server in emacs
2. run 'M-x gdb'  gdb -i=mi test_bin and open gdb-many-window mode.
3. In *gud-test* buffer, run: break 7
4. Run: run and gdb stop at line 7
5. Step into line 7

But the cursor of source buffer will not move at all. And then emacs become
irresponsive after running several step commands. I press Ctrl-G several
times. Then it returns error: json-read-string: Bad string format: "doesn't
start with `\"'!"

Here is the backtrace for above error:

Debugger entered--Lisp error: (json-string-format "doesn't start with
`\"'!")
  signal(json-string-format ("doesn't start with `\"'!"))
  json-read-string()
  json-read-object()
  apply(json-read-object nil)
  json-read()
  gdb-json-read-buffer(nil nil)
  gdb-json-partial-output()
  gdb-thread-list-handler-custom()
  gdb-thread-list-handler()
  apply(gdb-thread-list-handler nil)
  (save-current-buffer (set-buffer #<buffer *threads of test*>) (apply
(quote gdb-thread-list-handler) args))
  (with-current-buffer #<buffer *threads of test*> (apply (quote
gdb-thread-list-handler) args))
  (lambda (&rest args) (with-current-buffer #<buffer *threads of test*>
(apply (quote gdb-thread-list-handler) args)))()
  gdb-handle-reply(27)
  gdb-done-or-error("27" done "threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\""
t)
  gdb-done("27" "threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\""
t)
  gdbmi-bnf-incomplete-record-result("27" (gdb-done . progressive))
  #[0 "\302\300\301\242\"\207" ["27" ((gdb-done . progressive))
gdbmi-bnf-incomplete-record-result] 3]()
  gdbmi-bnf-result-and-async-record-impl()
  gdbmi-bnf-async-record()
  gdbmi-bnf-out-of-band-record()
  gdbmi-bnf-output()
  gud-gdbmi-marker-filter("27^done,threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\"\n(gdb)
\n28^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"18\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x00000000004004f4\",func=\"main\",file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\",thread-groups=[\"i1\"],times=\"1\",original-location=\"/home/xxx/projects/tests/test_gdb/test.c:7\"}]}\n(gdb)
\n29^done,locals=[]\n(gdb) \n30^done,stack=[frame={level=\"0\",addr=\"")
  apply(gud-gdbmi-marker-filter
"27^done,threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\"\n(gdb)
\n28^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"18\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x00000000004004f4\",func=\"main\",file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\",thread-groups=[\"i1\"],times=\"1\",original-location=\"/home/xxx/projects/tests/test_gdb/test.c:7\"}]}\n(gdb)
\n29^done,locals=[]\n(gdb) \n30^done,stack=[frame={level=\"0\",addr=\"")
  gud-marker-filter("27^done,threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\"\n(gdb)
\n28^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"18\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x00000000004004f4\",func=\"main\",file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\",thread-groups=[\"i1\"],times=\"1\",original-location=\"/home/xxx/projects/tests/test_gdb/test.c:7\"}]}\n(gdb)
\n29^done,locals=[]\n(gdb) \n30^done,stack=[frame={level=\"0\",addr=\"")
  gud-filter(#<process gud-test>
"27^done,threads=[{id=\"1\",target-id=\"process
25128\",name=\"test\",frame={level=\"0\",addr=\"0x00000000004004f4\",func=\"main\",args=[],file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\"},state=\"stopped\",core=\"24\"}],current-thread-id=\"1\"\n(gdb)
\n28^done,BreakpointTable={nr_rows=\"1\",nr_cols=\"6\",hdr=[{width=\"7\",alignment=\"-1\",col_name=\"number\",colhdr=\"Num\"},{width=\"14\",alignment=\"-1\",col_name=\"type\",colhdr=\"Type\"},{width=\"4\",alignment=\"-1\",col_name=\"disp\",colhdr=\"Disp\"},{width=\"3\",alignment=\"-1\",col_name=\"enabled\",colhdr=\"Enb\"},{width=\"18\",alignment=\"-1\",col_name=\"addr\",colhdr=\"Address\"},{width=\"40\",alignment=\"2\",col_name=\"what\",colhdr=\"What\"}],body=[bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x00000000004004f4\",func=\"main\",file=\"test.c\",fullname=\"/home/xxx/projects/tests/test_gdb/test.c\",line=\"7\",thread-groups=[\"i1\"],times=\"1\",original-location=\"/home/xxx/projects/tests/test_gdb/test.c:7\"}]}\n(gdb)
\n29^done,locals=[]\n(gdb) \n30^done,stack=[frame={level=\"0\",addr=\"")



In GNU Emacs 26.0.50 (build 1, x86_64-apple-darwin13.4.0, NS appkit-1265.21
Version 10.9.5 (Build 13F1911))
 of 2017-06-11 built on builder10-9.local
Windowing system distributor 'Apple', version 10.3.1504
Recent messages:
Warning: arch-dependent data dir
’/Users/build/workspace/Emacs-Multi-Build/label/mavericks/emacs-source/nextstep/Emacs.app/Contents/MacOS/libexec/’:
No such file or directory

For information about GNU Emacs and the GNU system, type C-h C-a.
user-error: Beginning of history; no preceding item
user-error: End of history; no default available
Quit

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils thingatpt time-date
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors frame cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 203699 7694)
 (symbols 48 19849 1)
 (miscs 40 71 164)
 (strings 32 18182 5316)
 (string-bytes 1 600826)
 (vectors 16 34880)
 (vector-slots 8 694435 4243)
 (floats 8 49 67)
 (intervals 56 194 0)
 (buffers 976 12))

[-- Attachment #2: Type: text/html, Size: 14070 bytes --]

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

* bug#28392: 26.0.50; gdb-mi runs into error with tramp
  2017-09-08 10:52 bug#28392: 26.0.50; gdb-mi runs into error with tramp Zhongwei Yao
@ 2020-11-30 10:57 ` Lars Ingebrigtsen
  2020-11-30 11:48   ` Michael Albinus
  2021-04-16  5:03 ` Jim Porter
  1 sibling, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-11-30 10:57 UTC (permalink / raw)
  To: Zhongwei Yao; +Cc: 28392

Zhongwei Yao <ashi08104@gmail.com> writes:

> Steps:
> 1. Open test.c on dev-server in emacs
> 2. run 'M-x gdb'  gdb -i=mi test_bin and open gdb-many-window mode.
> 3. In *gud-test* buffer, run: break 7
> 4. Run: run and gdb stop at line 7
> 5. Step into line 7
>
> But the cursor of source buffer will not move at all. And then emacs become
> irresponsive after running several step commands. I press Ctrl-G
> several times

(This bug report unfortunately got no response at the time.)

I vaguely remember seeing a bug report about gdb and Tramp, so this may
or may not have been fixed in the years since this was reported.  Are
you still seeing this problem in Emacs 28?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#28392: 26.0.50; gdb-mi runs into error with tramp
  2020-11-30 10:57 ` Lars Ingebrigtsen
@ 2020-11-30 11:48   ` Michael Albinus
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2020-11-30 11:48 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 28392, Zhongwei Yao

Lars Ingebrigtsen <larsi@gnus.org> writes:

Hi,

>> Steps:
>> 1. Open test.c on dev-server in emacs
>> 2. run 'M-x gdb'  gdb -i=mi test_bin and open gdb-many-window mode.
>> 3. In *gud-test* buffer, run: break 7
>> 4. Run: run and gdb stop at line 7
>> 5. Step into line 7
>>
>> But the cursor of source buffer will not move at all. And then emacs become
>> irresponsive after running several step commands. I press Ctrl-G
>> several times
>
> I vaguely remember seeing a bug report about gdb and Tramp, so this may
> or may not have been fixed in the years since this was reported.  Are
> you still seeing this problem in Emacs 28?

Bug#44151. The Tramp part is solved in Emacs' master branch, but there's
still something left for the gdb part. I've merged both bugs.

(Unfortunately, I'm not a gdb-mi.el expert).

Best regards, Michael.





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

* bug#28392: 26.0.50; gdb-mi runs into error with tramp
  2017-09-08 10:52 bug#28392: 26.0.50; gdb-mi runs into error with tramp Zhongwei Yao
  2020-11-30 10:57 ` Lars Ingebrigtsen
@ 2021-04-16  5:03 ` Jim Porter
  2021-05-01 10:13   ` Michael Albinus
  1 sibling, 1 reply; 5+ messages in thread
From: Jim Porter @ 2021-04-16  5:03 UTC (permalink / raw)
  To: 28392

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

Attached are patches to fix this in Emacs 27 and 28; they're
essentially the same, but with slightly different contexts around the
diff. I'm not sure if this is wanted for Emacs 27, but it's a small
bugfix, and combined with my patch in bug#39408 (and the GNU ELPA
version of Tramp to fix bug#44151), M-x gdb should work correctly for
Tramp. For Emacs 28, this is the only outstanding issue (that I know
of) preventing M-x gdb from working with Tramp.

The problem here was that `gud-last-frame', set in
`gdb-frame-handler', expects a local file path, so the full Tramp path
was confusing it.

(Note: I have a couple of patches in Tramp already that put me at the
limit for patches without copyright assignment paperwork. However,
I've already requested the form.)

[-- Attachment #2: 0002-Emacs-27-Fix-GUD-overlay-arrows-in-M-x-gdb-when-debugging-ove.patch --]
[-- Type: application/octet-stream, Size: 1136 bytes --]

From 77d0f1f753e0e08ddc1751abb6615c9fd2453de6 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 15 Apr 2021 21:39:39 -0700
Subject: [PATCH 2/2] Fix GUD overlay arrows in M-x gdb 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 1b2642fae7..51a237a38e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -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-Emacs-28-Fix-GUD-overlay-arrows-in-gdb-mi-when-debugging-over.patch --]
[-- Type: application/octet-stream, Size: 1108 bytes --]

From e1ff9f91150c5d8b11954c59e4240063616033e9 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 15 Apr 2021 20:36:43 -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] 5+ messages in thread

* bug#28392: 26.0.50; gdb-mi runs into error with tramp
  2021-04-16  5:03 ` Jim Porter
@ 2021-05-01 10:13   ` Michael Albinus
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2021-05-01 10:13 UTC (permalink / raw)
  To: Jim Porter; +Cc: 28392-done

Version: 27.3

Jim Porter <jporterbugs@gmail.com> writes:

> Attached are patches to fix this in Emacs 27 and 28; they're
> essentially the same, but with slightly different contexts around the
> diff. I'm not sure if this is wanted for Emacs 27, but it's a small
> bugfix, and combined with my patch in bug#39408 (and the GNU ELPA
> version of Tramp to fix bug#44151), M-x gdb should work correctly for
> Tramp. For Emacs 28, this is the only outstanding issue (that I know
> of) preventing M-x gdb from working with Tramp.
>
> The problem here was that `gud-last-frame', set in
> `gdb-frame-handler', expects a local file path, so the full Tramp path
> was confusing it.

Pushed to both the emacs-27 and master branch. Closing the bug.

I don't know whether there will be an Emacs 27.3, but it doesn't hurt to
push the fix, I believe.

Best regards, Michael.





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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-08 10:52 bug#28392: 26.0.50; gdb-mi runs into error with tramp Zhongwei Yao
2020-11-30 10:57 ` Lars Ingebrigtsen
2020-11-30 11:48   ` Michael Albinus
2021-04-16  5:03 ` Jim Porter
2021-05-01 10:13   ` 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).