How To Initiate Debug Session in Stopped State?

Hi,

I'd like to be able to initiate a debug run and have the JVM stop just before calling main(...).

I can't seem to find a way to do this. Am I overlooking something? Is it possible? If so, how?


Thanks.

Randall Schulz

14 comments

Maybe a method breakpoint covers your need (it's not really before, but on entry).

0

I suppose, but then I have to go back and remove it when I don't want it. It makes more sense to make it an option of the Debug Configuration.

Furthermore, the target of my debugging is quite often nowhere near the entry-point class.

Randall Schulz

0

Launch remote debug session with the following parameters:
Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=YOUR_PREFFERED_PORT

Notice suspend=y

Eugene.

0

OK. I guess that will suffice.

It seems a check box in the Debug Configuration would be justified.


Randall Schulz

0

Actually, it does not seem to work. I added this:


to the VM Parameters field of the Debug Configuration in question, but the target just launches and runs.

Randall Schulz

0

Well, it does not matter what type of run configuration you invoke, it could be even externally launched process, you just need to supply this in JVM parameters. (or in command line in case you launch externally)

0

I don't understand. I added the options you specified (except for the socket number) to the VM Parameters in the Debug Configuration but the process did not start up in a suspended state.

Why not?

Randall Schulz

0

What about it?

Surely when I click the Debug icon I'm telling IDEA to launch the VM for debugging, right?

Nonethless, adding -Xdebug it to the VM Parameters doesn't change anything.

Out of curiosity, instead of clicking the debug icon, I just used the run icon. When I did this (in addition to not getting a debugger display, of course), I just get this in the Run window:


Then it hangs and I have to terminate the process manually (i.e., click the red square icon) in the Run window.

Randall Schulz

0

It does not hang, but waits for you to attach a debugger to it:) So just launch a remote debug session with the port given and you'll attach.

0

Well, once it gets that complicated, it's pointless, I might as well just set a breakpoint at the beginning of the main and be done with it.

Why doesn't IDEA support this debug launch option directly?


RRS

0

Hello Eugene,

Well, it does not matter what type of run configuration you invoke, it could be even externally launched process, you just need to supply this in JVM parameters. (or in command line in case you launch externally)


the important detail is that this is what IDEA actually does itself when starting a local
debug session (it uses "server=n" though). That way the debugged process is started in
suspended mode anyway and is resumed in the moment IDEA connects.

To achieve the desired effect, the debugged process would have to be started manually with
those options and connected to through a Remote Debug Session. This is not really
convenient, but I don't see how this could be achieved per run configuration (i.e. without
a line- or method-breakpoint) otherwise.

Sascha

PS: Happy New Year :)

0

PS: Happy New Year :)


Thank you, and happy new year to you and everybody on this list!

0

...

To achieve the desired effect, the debugged process
would have to be started manually with
those options and connected to through a Remote Debug
Session. This is not really
convenient, but I don't see how this could be
achieved per run configuration (i.e. without
a line- or method-breakpoint) otherwise.


I'm certain I've used a debugger in the past that had this option. ... I suppose it's possible I'm thinking of a debugger for a language other Java (I used to do a lot of C and later C++).

Nonetheless, it is a nicety, to be certain, but it does seem like an obvious thing to want to do.

Sascha

>

PS: Happy New Year :)



Happy New Year to all!


Randall Schulz

0

Please sign in to leave a comment.