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

Auto start managed containers in Debug mode if client debug is detected #21

Open
aslakknutsen opened this issue Jul 6, 2015 · 14 comments

Comments

@aslakknutsen
Copy link
Member

If Client JVM is detected to be running in DebugMode, Chameleon should set JVM Debug options on the target Managed container.

  • Attempt to detect Client debug via JMX Command line args?
boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().
    getInputArguments().toString().indexOf("jdwp") >= 0;
  • Lookup javaVmArguments property from containers.yaml and set the required options.

We should probably start Managed Container with suspend=y to allow user to attach debug client.

note: check with JBDS ( @maxandersen ) if connecting to managed JVM could be automated in IDE.

@maxandersen
Copy link

so you want the IDE to listen (i.e. run what corresponds to 'jps' ever second or so) and automatically connect debugger to it ?

So, yeah we actually do have the misnamed but related view jmxview which scans for new jps detectable processes and here you should be able to see them show up.

Is it really necessary to automatically connect ? would it not be sufficient to just offer right click on the process and allow remote debug to setup ?

@maxandersen
Copy link

if yes, please try latest version since we've had this since alpha2 (https://issues.jboss.org/browse/JBIDE-19397)

@maxandersen
Copy link

blog about this feature in context of server adapters is at http://tools.jboss.org/blog/2015-03-17-debugging-an-externally-launched-wildfly.html

@aslakknutsen
Copy link
Member Author

@maxandersen that will kinda work, same with the discover remote debugging feature, but.. The general idea here would be to be able to provide the 'embedded' experience with non embedded JVM's. Automatic is key here.

@aslakknutsen
Copy link
Member Author

@maxandersen technically the IDE doesn't have to listen, I could tell you 'somehow', but that would make it less generic I guess. e.g. Arquillian Launcher could set a ENV variable with a temp file ref I could write the child PIDs to or similar..

aslakknutsen added a commit that referenced this issue Jul 8, 2015
If the Client is running in debug mode, a Managed target
type is started and the Adapter is configued with debug options;
Chameleon will automatically start the Managed Target in debug mode
as well.

fixes #21
aslakknutsen added a commit that referenced this issue Jul 8, 2015
If the Client is running in debug mode, a Managed target
type is started and the Adapter is configued with debug options;
Chameleon will automatically start the Managed Target in debug mode
as well.

fixes #21
@maxandersen
Copy link

Have you tried what we got now ? Do you really want it to automatically connect even more and therefore have it automatically continue without warning ? Actually I guess it could be interesting to say that if a process shows up actually have debug enabled just blindly connect to it could be an interesting thing to do ... I'll need to see how "expensive" it is to this check on all processes.

Feel free to open a jira on this idea.

btw. writing to a separate file is not really going to be better than what we have now - that is technically just listening to a "file"/stream that contains the list of running java processes.

@aslakknutsen
Copy link
Member Author

@maxandersen Not the JMX Navigator (having some local issues here), but a heavy user of Shift+Alt+D+D :) Love it! :) (might even have requested it it seems: https://issues.jboss.org/browse/JBIDE-8548)

@aslakknutsen
Copy link
Member Author

Currently this is fairly blocking to the auto connection part; https://issues.jboss.org/browse/JBIDE-20217

@aslakknutsen
Copy link
Member Author

@maxandersen The JMX Navigator (jbosstools-server provided integration) is suffering from the same issue as RemotDebug, it can't properly locate a suspended=y JVM. It never shows up in the Local Process menu. Running jps from command line hangs for a bit then returns the process id with a 'unknown main class' info line.

Depending on the size of the tests you're running it might take too long and be to unpredictable to manually go from 'Debug As -> JUnit Test' to 'Wait for Local Process to show up' to 'Right click -> Connect debugger'. Possible <2 s from you run Debug until first test starts to run when not starting the Managed container with suspend=y.

@aslakknutsen
Copy link
Member Author

For reference: https://issues.jboss.org/browse/JBIDE-20224

@maxandersen
Copy link

Good catch about JBIDE-20224 we'll look at fixing that!

About "too long and be to unpredictable" what do you mean here ? if the process is suspended then it will wait until you have connected wont it ?

I agree would be nice to automate it but just want to be sure i'm not missing something here since if we can't do it manually predictably I don't think we can do it automatically either.

@aslakknutsen
Copy link
Member Author

@maxandersen to sum up:

Start JVM with suspend=y

Start JVM with suspend=n

This only theoretically works. You have less then a second to "wait for the process to start" and "manually connect a remote debugger" after 'debug' is pressed. Manually doing this "takes too long and is to unpredictable". Chances are the Test is done before you manage to react.

@maxandersen
Copy link

yes so if we fix the one about suspend=y (it should be possible since jps works albeit slow) you should be good for majority of cases, right ?

then enabling automatic connect could be an enhancement, correct?

btw. remotedebug and jmx navigator should now be using same code for this thus why it fails in both places.

@aslakknutsen
Copy link
Member Author

yes so if we fix the one about suspend=y (it should be possible since jps works albeit slow) you should > be good for majority of cases, right ?

Correct, this would make it work.

then enabling automatic connect could be an enhancement, correct?

And this would make it Rock! :)

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

No branches or pull requests

2 participants