me.at.coding
me.at.coding

Reputation: 17624

Trace code execution?

One of my programs is stopping at some position (no exception, also seems not to be crashed), but I don't know that position. Instead of setting up a breakpoint (which means you already need to know the position where something happens), is it possible to get an information which code line was executed as last (=before now)? I am using Eclipse, is this maybe somehow possible in the debug view?

Think of something like step-by-step code execution, except that I don't want to click step-by-step a million times, instead Eclipse or some other tool shall do that for me.

Thanks for any hint on this!

Upvotes: 2

Views: 3142

Answers (3)

peter.murray.rust
peter.murray.rust

Reputation: 38033

enter image description here

I faced the same problem. There is a "suspend" button (two vertical yellow bars - see top-right of image) on the right of the green arrow/triangle which will stop you in the debugger. You may need to look carefully at the debug stack until you recognize part of your code.

It was very useful for me - I was in a catastrophic backtrack in a regex (which could take years to terminate!) and I would never have guessed this.

[If you don't have any breakpoints you will need to start in debugger perspective to see the button.]

Upvotes: 1

DeltaLima
DeltaLima

Reputation: 5944

As others have said, Eclipse has the Suspend button.

But the good old fashioned way is to add a load of System.out.println("No problem so far at line 'x' " ) statements and track the bug down by hand.

Upvotes: 0

Jim Garrison
Jim Garrison

Reputation: 86774

In Eclipse, if you click the "suspend" button in the debug UI you can pause a thread or the entire VM. You are probably hung behind a wait of some kind and may have to walk down the stack trace to find the line in your code that invokes the service that is waiting.

Upvotes: 0

Related Questions