schnell18
schnell18

Reputation: 320

jdb stop at given line or method

As a CLI-inclined programmer, I'd like to ask if the Java command line debugger JDB is capable of running from current position and stopping at given line?

For instance,

200   public Trade create(TradeCreateReq req) {
201        validatePayments(req);
202 =>     Trade t = new Trade(OutBizType.of(req.getOutBizType()), req.getOuterId());
203
204        buildItem
205            .andThen(buildBuyer)
206            .andThen(buildToAddress)
207            .andThen(buildInvoice)
208            .andThen(buildPayTools)
209            .accept(req, t);
210
211        if (!t.isSecured())
212            t.setSecured(true);
213
214        return t;
215    }

I'd like to advance to line 211 with a single jdb command rather than typing 7 'next' commands or set break point at 211. A cursory look at the 'step', 'next', 'cont' does not give me the answer.

I know the Perl CLI debugger can this job nicely with 'c' command.

Thanks!

Upvotes: 1

Views: 2769

Answers (1)

albfan
albfan

Reputation: 12940

"Run to cursor" is just a high level debug command composed from:

  • set breakpoint (stop at file:line)
  • continue
  • clear breakpoint

See there's no disable breakpoint or disable when count times reached, those are high level debug commands a debug cli should compound and keep in memory.

More info on available commands on http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html

You can compound easily those commands on a vim plugin like

https://github.com/yuratomo/dbg.vim/blob/master/autoload/dbg/engines/jdb.vim

Upvotes: 1

Related Questions