eclipse-jdt / eclipse.jdt.debug

Eclipse Public License 2.0
16 stars 47 forks source link

Text blocks with backslash characters confuses debugger (jumps to wrong line) #423

Closed jubax closed 5 months ago

jubax commented 5 months ago

The debugger gets confused when you have text blocks with backslash characters.

I noticed that (maybe since 2024-03, but I'm not sure) the debugger sometimes seems to be in the wrong line. While trying to get a reproducible test I noticed that once you have a text block with a backslash character you cannot add a breakpoint afterwards.

public class EclipseBreakpoint {

    @Test
    public void test1() throws Exception {
    assertEquals("""
        p(1).\
        q(2).\
        r(3).""", "");
        assertEquals(1, 1); // <==== Cannot put a breakpoint in this line
    }

}

But it works this way:

public class EclipseBreakpoint {

    @Test
    public void test1() throws Exception {
    assertEquals("""
        p(1).
        q(2).
        r(3).""", "");
        assertEquals(1, 1); // <==== Here I can put a breakpoint in the line
    }

}

I'm not sure this is the same as my original problem, but this is certainly a bug. Not sure if this is related to the debugger, the UI or the compiler.

jubax commented 5 months ago

The classes where the debugger jumped to the wrong line contained such text blocks with backslashes at the end of the lines. After I removed those backslashes the debugger worked fine again.

jjohnstn commented 5 months ago

I have tracked the problem with setting the breakpoint to the line end table which isn't properly set up when the continuation characters are used (missing the line end registration so line numbers are incorrectly calculated for validating the breakpoint). That said, there is still some other work to do as after fixing that, the breakpoint line shows it is stopped, but it actually executes some additional lines (probably a similar line end issue elsewhere).

jjohnstn commented 5 months ago

Found the problem. I needed to run the exportplugin.xml file to regenerate some jar files. It works now. I will post the jdt.core patch today.

jjohnstn commented 5 months ago

Fixed by: https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2339

Verified with I20240414 I-build.