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

Adding debugger for languages? #167

Open
RahulBadenkal opened this issue Nov 11, 2022 · 7 comments
Open

Adding debugger for languages? #167

RahulBadenkal opened this issue Nov 11, 2022 · 7 comments

Comments

@RahulBadenkal
Copy link

RahulBadenkal commented Nov 11, 2022

Hi,
How hard/compilcated do you think it is to add a debugger option like this. ?
I went through the roadmap but didn't see any plans of adding debugger and was thinking if maybe I can help with it, but I am unsure on how one would go about it?
Any ideas?

@RahulBadenkal
Copy link
Author

I was trying to understand how this website does it but i noticed that no http/websockets calls that go when i run/debug the code. Does this mean its just compiling every language to javascript and just executing it on browser?

@raxod502
Copy link
Member

See #168, just FYI.

That said, let me see what I can do about answering your questions.

  • How hard do I think it would be? Probably a big project, but doable.
  • Is it on the roadmap? Yeah, I didn't have any plans for it, and I have other things on my mind, but it doesn't seem out of line for the project, so if it were implemented (and I get things unbroken enough to actually deploy updates) then I wouldn't object to merging it in.
  • How to go about it? I'm not sure. I'd have to do a survey of different languages' debuggers to see what the typical behavior is. You'd want to start by coming up with a set of abstractions that describes a debugger for an arbitrary language, and then figure out how those abstractions could be configured to invoke different language debuggers specifically. Then you'd wire up buttons on the frontend to trigger the relevant configurations on the backend, like how LSP is set up currently.
  • How does onlinegdb work? Looks like it's got a websocket to me, you might have just missed it.

image

I'm not 100% sure how the debugger integration works, it's possible that the buttons are literally just sending words like continue and next on stdin to the pty, although that doesn't quite explain all the behavior I see. pdb might have some kind of control port that can be used to issue commands out of band.

@rahulwecp
Copy link

  1. Ya they use websockets, my bad. Most likely I opened my network tab after the websocket connection was established, so missed it.
  2. Thanks for the input. Will try to make one for python just to get an idea of how things happen.

PS: Awesome project!

@raxod502
Copy link
Member

Yeah, if you want to have a good time, rather than starting from the mess I have made in Riju, you might want to actually take https://github.com/radian-software/python-in-a-box as a starting point.

@raxod502
Copy link
Member

(Same underlying technology but way simpler because it does not attempt to do everything.)

@RahulBadenkal
Copy link
Author

Yeah, if you want to have a good time, rather than starting from the mess I have made in Riju, you might want to actually take https://github.com/radian-software/python-in-a-box as a starting point.

This is really easy to understand. Thanks!

@RahulBadenkal
Copy link
Author

RahulBadenkal commented Nov 28, 2022

Hi,
This is what i could come up with:
https://github.com/RahulBadenkal/python-in-a-box-debugger

Reference loom: https://www.loom.com/share/0f0d65d0087b46babfc8f1e1c03515ae

Minor change:

  • Using built in child process package of node instead of node-pty. As needed to separate out stdin and stdout content.

Idea:

  • Same as what you suggested last time, using python3's pdb module and piping the output from the terminal to browser.

Trying to replicate pycharm's debug functionality, but faced a few issues right off the bat:

  • The program in pdb auto restarts after ending, i would prefer it to terminate
  • Not sure how to get the current line number. The info is there in the terminal's stdout, but the only way i can think of extracting it is some sort of regex/string processing but then since the data from the terminal comes in batches and not all together not sure how to apply regex on a continuos stream?

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

No branches or pull requests

3 participants