javagdbjdb

Equivalent of GDB 'start' in JDB?


I'm a bit confused by JDB. Being fairly good at using GDB, I'm aware of the various simple commands used to control the execution, i.e. start, run, cont, step, stepi, break, etc. but there are a number of (in my opinion) unusual differences.

If I wish to start an application (as opposed to running it, so I can step it from the start), instinctively, I type jdb MyApp and then start. I get an unrecognized command error. Reading the JDB help gives me no indication at all of a start command or its equivalent. So, I try step - that doesn't work either; I am told that I need to start the Java VM with the run command!

Clearly, it must be possible, because there is a step command explained in the help. So, I figure that maybe I can type run and very quickly press ctrl+c to interrupt it as, in GDB, this stops the execution. Instead, it just quits JDB.

I've tried googling this, to no avail. I hope I'm not being totally blind stupid!

Rant over: how on earth do you just start running a java application in JDB so that you can step it, from the start?


Solution

  • The problem is the VM hasn't launched, which is why you can't step into the first line. The solution is to start JDB with "-launch" as a command line argument. From there you can type "step" or "cont" to start debugging from the start.

    The best bit is it only takes a second and doesn't require installing an IDE :-)