Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Any way to create a breakpoint on a line number directly entered by me?
Any way to create a breakpoint on a line number directly entered by me? [message #551245] Thu, 05 August 2010 13:33 Go to next message
Eclipse UserFriend
I need to be able to set breakpoints in decompiled code. The decompiler output shows me the original line numbers, so I can at least follow through the code when I step into it, but it's very difficult to set breakpoints at specific line numbers in the original code. If I set the breakpoint in the editor, that uses the line number in the editor, not the line number in the original code. If I could just create a breakpoint on a line number that I enter in a text field, this would suffice.

Is there some capability that I've missed? Is it worth submitting a feature request for this?
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551392 is a reply to message #551245] Fri, 06 August 2010 05:00 Go to previous messageGo to next message
Eclipse UserFriend
I think (but haven't checked) you can do this in the breakpoints view
in the debug perspective

Cheers,

Steffen

On 05/08/2010 18:33, David M. Karr wrote:
> I need to be able to set breakpoints in decompiled code. The
> decompiler output shows me the original line numbers, so I can at
> least follow through the code when I step into it, but it's very
> difficult to set breakpoints at specific line numbers in the original
> code. If I set the breakpoint in the editor, that uses the line number
> in the editor, not the line number in the original code. If I could
> just create a breakpoint on a line number that I enter in a text
> field, this would suffice.
>
> Is there some capability that I've missed? Is it worth submitting a
> feature request for this?
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551514 is a reply to message #551245] Fri, 06 August 2010 14:54 Go to previous messageGo to next message
Eclipse UserFriend
It looks like you need to get one or more IToggleBreakpointsTarget for a given editorPart/selection.

Something like:

ISelection fakeSel = fudgeSelection(/*magic*/);
IToggleBreakpointsTarget target = theJavaEditor.adapt(IToggetBreakpointsTarget.class);

target.toggleLineBreakpoints(theJavaEditor, fudgeSelection( lineNumber) );



Or maybe create/run an org.eclipse.debug.ui.actions.ToggleBreakpointAction with a fake IVerticalRulerInfo specifying the line number you want.


Good luck.


Oh, through the UI? It doesn't look like it.
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551521 is a reply to message #551392] Fri, 06 August 2010 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
I think (but haven't checked) you can do this in the breakpoints view in the debug perspective
The reason I posted this is because I looked all through the debug view, and I didn't see any way to do this.
Quote:
Oh, through the UI? It doesn't look like it.
I guess I'll file an enhancement request, then. Perhaps I'll get this in another lifetime.
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551532 is a reply to message #551245] Fri, 06 August 2010 16:41 Go to previous messageGo to next message
Eclipse UserFriend
What's the Use Case here?

At a guess, I'd say you've got something like a customer-submitted exception stack trace, and you want to create a break point (or points) without all the scrolling?

I know in some views, a stack trace's line numbers gets turned into links. Perhaps there's one you can paste yours into?
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551537 is a reply to message #551532] Fri, 06 August 2010 17:22 Go to previous messageGo to next message
Eclipse UserFriend
The use case is anytime I have to extensively step into and debug code that I don't have the source code for. I can step through the decompiled code, but setting breakpoints in the decompiled code is very awkward because the line numbers in the decompiled code don't correspond to the line numbers in the original source.
Quote:
I know in some views, a stack trace's line numbers gets turned into links. Perhaps there's one you can paste yours into?
That would get me to the line number in the decompiled source that Eclipse thinks the line corresponds to, which is not the case, as it's decompiled source. In any case, that has nothing to do with setting breakpoints.
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551538 is a reply to message #551537] Fri, 06 August 2010 17:26 Go to previous messageGo to next message
Eclipse UserFriend
True, but once your cursor is there, its trivial to create toggle the breakpoint at the current line:

CTRL+SHIFT+B.
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551540 is a reply to message #551538] Fri, 06 August 2010 17:48 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
True, but once your cursor is there, its trivial to create toggle the breakpoint at the current line:

CTRL+SHIFT+B.
You're still not quite understanding the problem. I'm well aware of how to set a breakpoint on the current line in the editor view. The problem is that that line number is the one that will be communicated to the JVM, NOT the one that corresponds to the line in the original source code, which is not surprising, as Eclipse would have no way to know that.

For instance, let's say that the stack trace says that I'm on line 636 in the original code. However, in the decompiled code, that line is on line 212. I can set a breakpoint on the current line, but that will be line 212, not 636. When I execute the test case, it won't stop on line 636 in the original code, because the breakpoint I created was for line 212.

In this case, I can sometimes hack around this by scrolling down in the decompiled code to line 636 (which is nowhere near the code I actually want to debug), and if that line actually exists (the decompiled file could be shorter), AND that line is a valid line of executable code (I can't set a breakpoint on it otherwise), then I can set a breakpoint there, and it will do what I want.

In any case, when I filed the ER, I found that it was a duplicate of one entered 8 YEARS ago: https://bugs.eclipse.org/bugs/show_bug.cgi?id=23295
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551545 is a reply to message #551245] Fri, 06 August 2010 18:36 Go to previous messageGo to next message
Eclipse UserFriend
NOW I get it.

While I was rummaging around in various plugin.xml files looking for the appropriate command, I noticed that there's a different entry for the class file viewer, and ass-u-me'd that this entry would Actually Work Properly.

Silly me.


Eureka! Sort of. If you're feeling brave, you can crack open a given project's list of markers and monkey with them directly.

/workspace/.metadata/.plugins/org.eclipse.core.resources/Som eProjectName/.markers

It looks to be a binary file format, so tread lightly.

Alternatively, you can export and import breakpoints. You might be able to twiddle the exported breakpoint into what you want. The format is XML based, but poking around in it I see both line numbers and start/end character offsets. Could be tricky.

But in either case, if the "is there a line X" logic is applied to the class file before using such a breakpoint, you could be Thwarted.

Good luck.
Re: Any way to create a breakpoint on a line number directly entered by me? [message #551547 is a reply to message #551545] Fri, 06 August 2010 18:51 Go to previous message
Eclipse UserFriend
Quote:
Alternatively, you can export and import breakpoints. You might be able to twiddle the exported breakpoint into what you want. The format is XML based, but poking around in it I see both line numbers and start/end character offsets. Could be tricky.

But in either case, if the "is there a line X" logic is applied to the class file before using such a breakpoint, you could be Thwarted
Ah. Now you're talking. I tried a simple experiment using this technique, and I think it will basically work. I'm not worried about it validating that the original line number has a valid line of code. I would want it to do that. I'm not going to bother giving it a line number that DOESN'T correspond to a valid line of code in the original source.

The technique has a couple of minor warts, like when you re-import the hacked breakpoints file, you end up with two breakpoints, one at the old line, and one at the new line, and it also doesn't display the breakpoint marker in the editor view, but the breakpoint is there, and it stops there.
Previous Topic:How Eclipse debug Java
Next Topic:Displaying data in Problem View
Goto Forum:
  


Current Time: Sat Sep 20 04:49:28 EDT 2025

Powered by FUDForum. Page generated in 0.05044 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top