help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GDB over TRAMP: problem with user I/O


From: Vladilen Kozin
Subject: GDB over TRAMP: problem with user I/O
Date: Wed, 6 Dec 2017 14:18:25 +0000

Ran into problem with GDB over TRAMP. To me it looks like a bug in TRAMP
but could be that I've missed some settings required for such setup. Hence
posting here instead of bugs for now.

Setup is described in more details below, but in a nutshell:
- target machine with code to debug runs a vanilla Linux,
- Emacs on the host machine starts multi window GDB session over TRAMP,
works fine,
- excep I/O buffer gets intercepted by (probably) remote shell, so user
input can't be passed to the process being debugged (see below).

Source code being debugged
--------------------------
#include <stdio.h>
#include <stdlib.h>

int main()
{
     int num;
     printf ("Enter the number: ");
     scanf ("%d", &num );

     printf("Your number %d\n", num);
     exit(0);
}

Makefile executed on Target
---------------------------
CFLAGS = -std=c99 -pedantic -Wall -O2 -fPIC
DEBUG = -g -std=c99 -pedantic -Wall -O0 -fPIC

debug: fact.c
$(CC) $(DEBUG) $(LDFLAGS) -o $@ $< $(LDLIBS)

clean:
$(RM) -rf *.o *.so fact debug debug.dSYM


Remote debug session started from Host
--------------------------------------
M-x gdb
gdb -i=mi /fact:/vagrant/debug

Relevant GDB windows:

*gud-debug*
-----------
Reading symbols from /vagrant/debug...done.
(gdb) run
Starting program: /vagrant/debug

*input/output of debug*
-----------------------
&"warning: GDB: Failed to set controlling terminal: Operation not
permitted\n"
Enter the number: 3
/bin/sh: 22: 3: not found
///fe8a2e50a45c66d598f9ae7a276764a2#$

Notice how the input prompt in IO buffer appears fine and awaits for user
entry, but said entry gets snatched by /bin/sh and wouldn't let me send it
to the process debugged.

Note that running the same debug session locally works out fine, user
input doesn't get stolen.

I managed to reproduce this with absolutely barebones setup.

Emacs Host
----------
GNU Emacs 25.3.1 (x86_64-apple-darwin17.2.0, NS appkit-1561.10
Version 10.13.1 (Build 17B48)) of 2017-11-12

Debug Target
------------
vagrant@precise64:/vagrant$ uname -a
Linux precise64 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10
20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

init.el
-------
(require 'gdb-mi)
(require 'tramp)

(setq gdb-many-windows t
      gdb-show-main t)

(setq tramp-default-method "ssh"
      tramp-default-user "vagrant")

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/";) t)
(package-initialize)
(unless (file-exists-p (concat user-emacs-directory "elpa/archives/melpa"))
  (package-refresh-contents))

(defvar required-packages '(exec-path-from-shell))

(let ((install #'(lambda (package)
                   (unless (package-installed-p package)
                     (package-install package))
                   (require package))))
  (message "Installing required packages %s" required-packages)
  (mapc install required-packages)
  (delete-other-windows))

(exec-path-from-shell-initialize)


Setting tramp-debug-on-error to true, doesn't show anything.

Could anyone help me figure out how to fix this? Or should I post to the
bug list?

Thanks

-- 
Best regards
Vlad Kozin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]