Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add interactive pty to frontend #295

Closed
cs01 opened this issue Oct 5, 2019 · 6 comments · Fixed by #346
Closed

add interactive pty to frontend #295

cs01 opened this issue Oct 5, 2019 · 6 comments · Fixed by #346

Comments

@cs01
Copy link
Owner

cs01 commented Oct 5, 2019

Is your feature request related to a problem? Please describe.
The frontend terminal is not truly interactive. gdb behaves differently when it is connected to a terminal and will prompt and wait for user responses rather than assume things and carry on.

Describe the solution you'd like
A fully interactive terminal with gdb in the frontend. xterm.js can be used to render the terminal, and Python pty's can be used on the backend. One will be created for the user to interact with, and another for the UI to send/receive gdb's mi2 messages.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
https://xtermjs.org/ can be used to render the terminal in the frontend.

The new-ui command can be used to split I/O between the UI for the gui and the terminal for the user. https://sourceware.org/gdb/onlinedocs/gdb/Interpreters.html

@cs01
Copy link
Owner Author

cs01 commented Oct 5, 2019

I am able to create two ptys: one for the user to interact with, and another for the UI to interact with by using an mi2 interpreter. I first create a pty for mi2 protocol. I get its path (such as /dev/pts/19) then run cat in it. Next I create another pty and run gdb in it, and run the command new-ui mi2 /dev/pts/19. At this point I expect to be able to write arbitrary mi2 commands to /dev/pts/19, and parse mi2 responses from it, but it doesn't really work. Occasionally a message is read from it, but nothing seems to happen when I write to it. Any ideas where I am going wrong here? Should I not be running cat?

You can test this with gdbgui commit 2621c26 (branch cs01/use-pty), and pygdbmi commit 535522b99f71e1 (branch cs01/refactor).

The user-facing terminal works pretty well; it's just a matter of getting the mi2 messages passed back and forth to keep the UI in sync.
image

@simark
Copy link

simark commented Oct 5, 2019

I don't have time to look at your code right now, but I just wanted to point out that this is used (and works) for cdt-gdb-adapter:

https://github.com/eclipse-cdt/cdt-gdb-adapter/blob/478303332c5d1385e301b71e437a68f1c8551825/src/GDBBackend.ts#L61

So there's hope :)

@cs01 cs01 removed the help wanted label Oct 5, 2019
@cs01
Copy link
Owner Author

cs01 commented Oct 5, 2019

Thanks! Got it working. I had two threads competing to read from the pty at the same time.

@cs01
Copy link
Owner Author

cs01 commented Oct 7, 2019

Your link did give me more confidence that I wasn't wasting my time and there was a solution though 😄

@simark
Copy link

simark commented Oct 7, 2019

Nice :). I'll have to try it.

@cs01
Copy link
Owner Author

cs01 commented Oct 7, 2019

It would be great to get some folks testing it before it's released! I'll let you know when it's ready for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants