softwareCobbler / luceedebug

line debugger for lucee
GNU Lesser General Public License v2.1
44 stars 15 forks source link

messy breakpoints #61

Closed pibica closed 2 weeks ago

pibica commented 3 weeks ago

For some cfm pages, (mostly with many directives), in step mode, the debugger highlights the first line of the file instead of the right line To reproduce the issue, clone this repo and run docker compose: https://github.com/pibica/luceedebug-bug-repo

attach the debugger, add breakpoints at lines 10 & 11 in file luceedebug-bug-repo\web\issue-61-KO.cfm image

open in a browser http://localhost:8888/issue-61-KO.cfm

The debugger stops at line 1, but in fact the code has run until breakpoint of line 10 (because VARIABLE_001 is set) image

click F5, the debugger is still on line 1, but it is in reality on line 11 (because VARIABLE_002 is set) image

do the same thing with luceedebug-bug-repo\web\issue-61-OK.cfm http://localhost:8888/issue-61-OK.cfm there is no issues

the only difference between issue-61-KO.cfm and issue-61-OK.cfm, is that KO has one more

than OK The DAP messages are available here: https://github.com/pibica/luceedebug-bug-repo/blob/develop/dap-issue-61.json > ``` json { "command": "stackTrace", "arguments": { "threadId": 1555, "startFrame": 0, "levels": 20 }, "type": "request", "seq": 8 } ``` < ``` json { "type": "response", "seq": 10, "request_seq": 8, "command": "stackTrace", "success": true, "body": { "stackFrames": [ { "id": 38, "name": "??", "source": { "path": "E:\\WS\\pibica\\luceedebug-bug-repo\\web/issue-61-KO.cfm" }, "line": 1, "column": 0 } ], "totalFrames": 1 } } ``` The issue come from "line": 1 instead of 10 The issue exists with jdk11 and jdk21
softwareCobbler commented 3 weeks ago

Thanks for the repro, really well put together and helpful. It seems Lucee generates java functions named call_000001, call_000002, ...etc., that we hadn't been adding bytecode instrumentation to. This oversight is fixed on the "next" branch.

pibica commented 3 weeks ago

thanks a lot for the very quick fix, I've cherry picked it in my master branch and it work like a charm! When I try to use your next/2.0.13.1 artifact, I got this error at startup: lucee-1 | Caused by: java.lang.IllegalAccessError: class luceedebug.coreinject.ExprEvaluator$Lucee6Evaluator cannot access its abstract superclass luceedebug.coreinject.ExprEvaluator$Evaluator (luceedebug.coreinject.ExprEvaluator$Lucee6Evaluator is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @6e1d4137; luceedebug.coreinject.ExprEvaluator$Evaluator is in unnamed module of loader 'app') lucee-1 | at java.base/java.lang.ClassLoader.defineClass1(Native Method) lucee-1 | at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) lucee-1 | at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:889) lucee-1 | at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) l I suppose that the next branch is still wet