code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

FR: allow terminal support over SSH (x11-forwarding)

Open GitMensch opened this issue 3 years ago • 8 comments

I currently get:

WARNING: Output to terminal emulators are not supported over SSH

but I want to let the ssh connection use the X11 forwarding setup I've already done, start xterm there for the console and let gdb do the debugging.

@WebFreak001 Did you found an issue with that or is it "just not implemented"? Any things to watch out for a possible implementation?

GitMensch avatar May 06 '22 11:05 GitMensch

it's not implemented, but I don't think it's possible as GDB needs a pty to output and with X11 forwarding I think you only get a terminal window rendered on your machine, but not actually the virtual terminal on your PC.

With a helper application on the remote allowing to connect the terminal to the PC, maybe even possible through the existing SSH tunnel, you might be able to make it work though.

WebFreak001 avatar May 06 '22 12:05 WebFreak001

The idea was to start the xterm and use the existing port forwarding; pass its pty to GDB via -tty, then let GDB start. In this case the application would go to the xterm, which sends its output via X11forwarding to the client, and gdb would send its output via the current logic. ... did I screw or misunderstand something concerning this specification already?

GitMensch avatar May 06 '22 12:05 GitMensch

Hm, I'll hopefully will try to find some time using a plain ssh session, then report back.

GitMensch avatar May 06 '22 13:05 GitMensch

I think there will be a problem in just trying to pass the terminal's pty to GDB as the terminal is actually running on the remote machine, so the pty is also just local to the remote machine and not accessible by the local GDB.

If you mean you want to open a terminal on the remote with the remote GDB that should work though, you just need to somehow start a terminal and get its tty path, see https://github.com/WebFreak001/code-debug/blob/db007409fad3e38cff36925897d09ab03fdaaece/src/backend/linux/console.ts

WebFreak001 avatar May 11 '22 09:05 WebFreak001

Are you looking for this functionality because you need stdin support, or are you just trying to get line-buffered stdout? ...or maybe you have more involved needs than this.

brownts avatar May 12 '22 04:05 brownts

The external terminal solves a bunch of issues that one could have, most are mentioned in other issues already, including line-buffered stdout and apart from GDB output, much better stdin support than with mixed GDB input and finally: debugging curses based programs just doesn't work well in an integrated GDB terminal, much less in the one that we have.

terminal solves all of those issues (we may should encourage its use for stdin/stoud working programs in the README more), but currently it isn't available via remote; but I think it should work fine if terminal is an xterm and x11-forwarding is enabled (or, for the WSL case, "just works").

GitMensch avatar May 12 '22 05:05 GitMensch

@marcsosduma can you please work on integrating your changes from the other debugger extension here, so we get multiple terminal types? This should fix both this one and #237.

GitMensch avatar Feb 07 '24 09:02 GitMensch

Hello Simon! I downloaded the code but I'm having trouble running the extension in debug mode to study it.

marcsosduma avatar Feb 07 '24 23:02 marcsosduma