Camelcade / Devel-Camelcadedb

Perl module for debugging with Perl5 plugin for IntelliJ
Other
23 stars 9 forks source link

(for discussion) uWSGI + Plack support #26

Closed mbarbon closed 7 years ago

mbarbon commented 7 years ago

Hi, first of all, I'm very excited about remote debugging support in the Perl/IDEA plugin, thanks for working on it!

The specific use case I have at work is debugging various large Plack applications running under uWSGI (with pre-forking). What I have for other editors/IDEs (using https://github.com/mbarbon/perl-remote-debugging-client and https://github.com/mbarbon/plack-middleware-dbgp) is:

I'd like to replicate the same setup with IDEA, and I have a tentative set of changes in this pull request (I only tested this on a trivial test application, so I might need some tweaks once I test it at work). Example usage is at https://github.com/mbarbon/plack-middleware-camelcadedb/blob/master/lib/Plack/Middleware/Camelcadedb.pm#L116

Not in this PR, and wishlist, I'd like to add an option to connect over an Unix domain socket (I will need to use connection forwarding anyway, and using an Unix domain avoids the need for an open port on the application host which communicates directly with the IDE). I'd like to have this because the development environment is semi-shared, but it's not critical.

Let me know if this set of changes is something you're interested in incorporating, and if there is anything you would prefer to be done a different way (I will document the changes in the final PR).

Thanks! Mattia

mbarbon commented 7 years ago

I was able to test this with one of our applications.

It seems to be working correctly except for a speed issue related to the number of Perl files loaded by the application: after the debugger hits the first breakpoint, it sends a large LOADED_FILES_DELTA event to IDEA; the event contains ~60k added items (~5k files and ~55k evals). After that I see IDEA using CPU for almost two minutes [1]; and then debugging works fine.

I had a quick look at the plugin, and it it should be relatively simple to fix [2]. I will finish this pull request first and then have a stab at reducing reducing CPU usage for large LOADED_FILES_DELTA events.

Cheers, Mattia

[1] the first time around I was too impatient and gave up after ~30 seconds [2] but I know nothing about Swing, so maybe I'm being overly optimistic

mbarbon commented 7 years ago

I pushed an updated version of the branch; it's pretty much the same code as the oroginal PR, with some print()s removed and some comments added.

I added some POD documenting enable/disable/connect/disconnect/is_connected (because they form a sort of "API"); feel free to leave it out if you don't want it advertised or you don't think it is relevant.

akjohnston commented 6 years ago

Could someone please provide some details of how to set up Apache and IntelliJ to get this working?

If someone can provide some information to get me started I am very happy to write this up formally as a Wiki page so that others can get started more quickly.

I think I need to know how to set up the environment, what to put in the Apache conf file, and the debug config for IntelliJ.

Thanks Andrew

simonschaufi commented 4 years ago

@mbarbon I can only repeat the message from @akjohnston: Please provide a step by step tutorial how to configure IntelliJ and Apache/Nginx on how to setup browser debugging. Thank you!

I have tried adding the following lines to ~/.profile

PERL5_DEBUG_AUTOSTART=1
PERL5_DEBUG_ROLE="client"
PERL5_DEBUG_HOST="localhost"
PERL5_DEBUG_PORT="12345"

but nothing happened even though my IDE listens at localhost:12345

simonschaufi commented 4 years ago

@akjohnston I got it working with nginx. Maybe it is similar with apache, I don't know. See my documentation here: https://github.com/Camelcade/Perl5-IDEA/issues/2127#issuecomment-564773031