Community
Participate
Working Groups
Under normal conditions if you edit some code, Eclipse tries to keep markers (such as breakpoints) on the same logical line of code. For example if I have a breakpoint on the "if" in this piece of code: volatile int i = 0; int main(void) { while (1) { i++; i++; if(i > 10000) i = 0; } return 0; } and then I delete the two lines with "i++", the breakpoint continues to point to the "if" line, as expected. However, if you happen to make the same edit while the debugger is connected, then the breakpoint is initially moved to the "if" line as expected. But when you terminate the debug session the breakpoint is relocated to its original line number, which means it now points (unexpectedly) at the "return" line.
I am looking at this issue.
This is happening because of the features added in Bug 360280. In that bug when a breakpoint is fully uninstalled (decrementInstallCount decrements fInstallCount to 0), AbstractLineBreakpoint.resetInstalledLocation() is called. This repositions the breakpoint from the current line to the "REQUESTED_LINE", which is the line number it was originally planted on. The problem is that resetInstalledLocation assumes that any change to the LINE_NUMBER attribute must have come because of repositioning the breakpoint based on GDB information. However, platform updates the line number based on the edits made in the editor.
One possible solution to this is to add a flag/condition that only causes the breakpoint to be moved back if org.eclipse.cdt.debug.internal.core.breakpoints.AbstractLineBreakpoint.setInstalledLineNumber(int) has been called to move the breakpoint in the first place. At the moment, the breakpoint property page is the only thing calling setInstalledLineNumber, and that is in part an error (perhaps in the API exposed) AFAICT. Alternatively such a flag could be set if REQUESTED_LINE and LINE_NUMBER differed. By using such a flag, the functionality can remain for CDT extenders who use it, without affecting those that don't.
New Gerrit change created: https://git.eclipse.org/r/69374
This bug contains two different issues. 1.) If you save the edit while the debugger is connected and terminate the debug session. 2.) If you don't save the edit and just terminate the debug session. Both lead to a misplaced Breakpoint. Number 1 is resolveable like Jonah suggested before. I'm currently looking on number 2, which seems to be more tricky.
Gerrit change https://git.eclipse.org/r/69374 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2469e0e11731fa2ab4a6ecc4e0e897626b5ae514
(In reply to Stefan Sprenger from comment #5) > This bug contains two different issues. > > 1.) If you save the edit while the debugger is connected and terminate the > debug session. This bug and associated fix is for this issue. > > 2.) If you don't save the edit and just terminate the debug session. Bug 490996 covers this issue.