1

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!

schnell18
  • 290
  • 5
  • 8

1 Answers1

1

"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

albfan
  • 12,542
  • 4
  • 61
  • 80
  • 1
    Thanks for the answer. However, the way to set breakpoints in JDB is inconvenient as Java class name is usually lengthy and I have to clear the breakpoints afterward. – schnell18 Jan 16 '16 at 07:52
  • 2
    Non sense by just pasting the ~official~ document which really sucks with very poor readability. – MasterMind Jun 11 '19 at 08:49