You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have used lsp4ij to implement debugging support for an intermediate representation (IR) that we first generate from Java code and then execute with a custom interpreter for that IR. The screenshot shows an example of that IR for some Java method.
The problem is that in the view that is shown in IntelliJ I do not be able to set and breakpoints. The appropriate option is just not shown. I am currently working around this be just having the debugger halt at the first instruction, then step from there but that will not scale for larger programs.
Do you have any idea what may be causing this?
One point that may be important: the IR-code is generated in memory, i.e., not written to disk, so I am using a "virtual source" to have its content displayed.
Thanks a lot @angelozerr for helping out! You can find the current implementation here. It is in Kotlin and I have to admit that I created it with some support of Claude code - I am just not a DAP expert. I am sure it might well be missing something crucial. I would appreciate any help you could offer. Maybe is there some example code you could point me to?
To answer your questions:
No, there is currently no file type/language/file pattern mapping defined.
Because the FAIR code is generated from Java on the fly, the debugger uses a virtual source scheme — sources are served entirely via sourceReference integers (the DAP source request mechanism), not real files on disk. The source URIs look like:
fair-<token>://<methodName>.fair
(The token number I used to ensure that updated files are refreshed in IntelliJ's view - previously they were over-eagerly cached. That is also more of a workaround than a clean solution I guess.)
These .fair "files" are dynamically generated strings (see FairSourceProvider.generateSource()), never written to disk. The DAP run config (DAPConfiguration) has no fileType, language, or filePattern mapping set.
So in essence, the project uses a purely sourceReference-based virtual file scheme (no real .fair files on disk). The .fair extension appears only in the source.name and source.path fields of DAP StackFrame responses.
Given that, am I right to understand that it is expected that this would not work? Is there a way at all to make this work with such a virtual source scheme? As an alternative, I could have actual source files written to some temporary directory from which they can then be referenced and displayed.
Sounds great, thanks! About the mapping you describe: No I have not. Could you kindly give me some more specific instructions on how to try this, please?
But now when I set a breakpoint, I get the following message (and a similar one if I click "Run to cursor":
java.lang.UnsupportedOperationException: Failed to map LightVirtualFile: 82a9b8c8/DAP Constant Propagation/main.fair (filesystem com.redhat.devtools.lsp4ij.dap.client.files.DAPFileSystem@6fd5c11e) into nio Path
at com.intellij.openapi.vfs.VirtualFile.toNioPath(VirtualFile.java:167)
at com.redhat.devtools.lsp4ij.dap.DAPIJUtils.getFilePath(DAPIJUtils.java:32)
at com.redhat.devtools.lsp4ij.dap.breakpoints.DAPBreakpointHandlerBase.toDAPSource(DAPBreakpointHandlerBase.java:100)
at com.redhat.devtools.lsp4ij.dap.breakpoints.DAPBreakpointHandlerBase.addSourceBreakpoint(DAPBreakpointHandlerBase.java:85)
at com.redhat.devtools.lsp4ij.dap.breakpoints.DAPBreakpointHandlerBase.doSendBreakpoints(DAPBreakpointHandlerBase.java:117)
at com.redhat.devtools.lsp4ij.dap.breakpoints.BreakpointHandlerBase.sendBreakpoints(BreakpointHandlerBase.java:99)
at com.redhat.devtools.lsp4ij.dap.breakpoints.BreakpointHandlerBase.registerBreakpoint(BreakpointHandlerBase.java:73)
at com.intellij.xdebugger.impl.XDebugSessionImpl.handleBreakpoint(XDebugSessionImpl.kt:597)
at com.intellij.xdebugger.impl.XDebugSessionImpl.processBreakpoint(XDebugSessionImpl.kt:631)
at com.intellij.xdebugger.impl.XDebugSessionImpl.processAllHandlers(XDebugSessionImpl.kt:619)
at com.intellij.xdebugger.impl.XDebugSessionImpl.access$processAllHandlers(XDebugSessionImpl.kt:90)
at com.intellij.xdebugger.impl.XDebugSessionImpl$MyBreakpointListener.processAdd(XDebugSessionImpl.kt:1175)
at com.intellij.xdebugger.impl.XDebugSessionImpl$MyBreakpointListener.breakpointAdded(XDebugSessionImpl.kt:1151)
at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:820)
at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:764)
at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:503)
at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:482)
at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:545)
at jdk.proxy2/jdk.proxy2.$Proxy345.breakpointAdded(Unknown Source)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.lambda$addBreakpoint$5(XBreakpointManagerImpl.java:220)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.sendBreakpointEvent(XBreakpointManagerImpl.java:318)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.addBreakpoint(XBreakpointManagerImpl.java:220)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.lambda$addLineBreakpoint$15(XBreakpointManagerImpl.java:352)
at com.intellij.util.progress.CancellationUtil.withLockMaybeCancellable(cancellationUtil.kt:141)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.addLineBreakpoint(XBreakpointManagerImpl.java:345)
at com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl.addLineBreakpoint(XBreakpointManagerImpl.java:336)
at com.intellij.xdebugger.impl.XDebuggerUtilImpl.addLineBreakpoint(XDebuggerUtilImpl.java:567)
at com.intellij.xdebugger.impl.XDebuggerUtilImpl.addLineBreakpoint(XDebuggerUtilImpl.java:554)
at com.intellij.platform.debugger.impl.backend.BackendXBreakpointTypeApi.createBreakpointByVariant$lambda$0(BackendXBreakpointTypeApi.kt:204)
at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:111)
at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable$lambda$0(InternalReadAction.kt:101)
at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$0$0$0(cancellableReadAction.kt:32)
at com.intellij.platform.locking.impl.NestedLocksThreadingSupport.tryRunReadAction(NestedLocksThreadingSupport.kt:901)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1237)
at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$0$0(cancellableReadAction.kt:30)
at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:73)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:152)
at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$0(cancellableReadAction.kt:28)
at com.intellij.concurrency.ThreadContext.installThreadContext(threadContext.kt:305)
at com.intellij.concurrency.ThreadContext.installThreadContext$default(threadContext.kt:303)
at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:24)
at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:100)
at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:86)
at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:73)
at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:15)
at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$6.invokeSuspend(InternalReadAction.kt:52)
at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$6.invoke(InternalReadAction.kt)
at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$6.invoke(InternalReadAction.kt)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:44)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:166)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
at com.intellij.openapi.application.rw.InternalReadAction.runReadAction(InternalReadAction.kt:50)
at com.intellij.openapi.application.rw.PlatformReadWriteActionSupport.executeReadAction(PlatformReadWriteActionSupport.kt:66)
at com.intellij.openapi.application.ReadWriteActionSupport.executeReadAction$default(ReadWriteActionSupport.kt:15)
at com.intellij.openapi.application.CoroutinesKt.constrainedReadAction(coroutines.kt:60)
at com.intellij.openapi.application.CoroutinesKt.readAction(coroutines.kt:27)
at com.intellij.platform.debugger.impl.backend.BackendXBreakpointTypeApi.createBreakpointByVariant(BackendXBreakpointTypeApi.kt:203)
at com.intellij.platform.debugger.impl.backend.BackendXBreakpointTypeApi.toggleLineBreakpoint(BackendXBreakpointTypeApi.kt:158)
at com.intellij.xdebugger.impl.FrontendXLineBreakpointVariantKt$computeBreakpointProxy$1$1.invokeSuspend(FrontendXLineBreakpointVariant.kt:94)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:610)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runDefaultDispatcherTask(CoroutineScheduler.kt:1194)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:906)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:775)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:762)
Thanks! Now I no longer observe the previous exception, yet the debugger does not pause at the breakpoints, nor does it pause at the point where I click Run to cursor.
Thanks! Now I no longer observe the previous exception, yet the debugger does not pause at the breakpoints, nor does it pause at the point where I click Run to cursor.
I suggest that you active dap request response by settings vebose as trace in your run configuration.
Alright, below you can find an example trace. Here is what I did to produce it. First of all, the launch config uses "stopOnEntry": true so that the debugger stops once immediately at the beginning. This is because - given that the file is dynamically generated - there is no way to display it and let me set any breakpoints ahead of time.
Then, once the file opened, I set a breakpoint into line 3:
That also seems to have generated an appropriate event, however in the trace it shows with "FAIR breakpoint mapping not yet implemented". Did I maybe so far miss to implement some kind of callback in my code?
Activity
angelozerr commentedon Mar 28, 2026
Can you share your code?
angelozerr commentedon Mar 30, 2026
@ericbodden just one question, have you defined mapping in the dap debugger associated with your file type or file language or file pattern?
You need to define this mapping to allow setting breakpoint.
ericbodden commentedon Mar 31, 2026
Thanks a lot @angelozerr for helping out! You can find the current implementation here. It is in Kotlin and I have to admit that I created it with some support of Claude code - I am just not a DAP expert. I am sure it might well be missing something crucial. I would appreciate any help you could offer. Maybe is there some example code you could point me to?
To answer your questions:
No, there is currently no file type/language/file pattern mapping defined.
Because the FAIR code is generated from Java on the fly, the debugger uses a virtual source scheme — sources are served entirely via sourceReference integers (the DAP source request mechanism), not real files on disk. The source URIs look like:
fair-<token>://<methodName>.fair(The token number I used to ensure that updated files are refreshed in IntelliJ's view - previously they were over-eagerly cached. That is also more of a workaround than a clean solution I guess.)
These .fair "files" are dynamically generated strings (see FairSourceProvider.generateSource()), never written to disk. The DAP run config (DAPConfiguration) has no fileType, language, or filePattern mapping set.
So in essence, the project uses a purely sourceReference-based virtual file scheme (no real .fair files on disk). The .fair extension appears only in the source.name and source.path fields of DAP StackFrame responses.
Given that, am I right to understand that it is expected that this would not work? Is there a way at all to make this work with such a virtual source scheme? As an alternative, I could have actual source files written to some temporary directory from which they can then be referenced and displayed.
angelozerr commentedon Mar 31, 2026
Have you tried to define mapping with
*.fair?angelozerr commentedon Mar 31, 2026
@ericbodden your usecase is very interesting, so if LSP4IJ requires some improvment, I am opened to include it.
ericbodden commentedon Mar 31, 2026
Sounds great, thanks! About the mapping you describe: No I have not. Could you kindly give me some more specific instructions on how to try this, please?
angelozerr commentedon Mar 31, 2026
Please read https://github.com/redhat-developer/lsp4ij/blob/main/docs/dap/UserGuide.md#breakpoints
ericbodden commentedon Apr 1, 2026
Alright, I set an empty mapping...
... and indeed that did something:
But now when I set a breakpoint, I get the following message (and a similar one if I click "Run to cursor":
angelozerr commentedon Apr 1, 2026
@ericbodden could you please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds
ericbodden commentedon Apr 1, 2026
Thanks! Now I no longer observe the previous exception, yet the debugger does not pause at the breakpoints, nor does it pause at the point where I click Run to cursor.
angelozerr commentedon Apr 1, 2026
I suggest that you active dap request response by settings vebose as trace in your run configuration.
Perhaps we will understand more what it happens
angelozerr commentedon Apr 1, 2026
@ericbodden have you an IJ plugin which manages your fair files?
ericbodden commentedon Apr 1, 2026
No I do not. That is mainly because they are not meant to be editable files as such.
angelozerr commentedon Apr 1, 2026
Ok please share your dap traces
ericbodden commentedon Apr 5, 2026
Alright, below you can find an example trace. Here is what I did to produce it. First of all, the launch config uses
"stopOnEntry": trueso that the debugger stops once immediately at the beginning. This is because - given that the file is dynamically generated - there is no way to display it and let me set any breakpoints ahead of time.Then, once the file opened, I set a breakpoint into line 3:
That also seems to have generated an appropriate event, however in the trace it shows with "FAIR breakpoint mapping not yet implemented". Did I maybe so far miss to implement some kind of callback in my code?
Here is the full trace:
4 remaining items
ericbodden commentedon Apr 7, 2026
Yes you are right, setting/removing breakpoints works, but the UI refresh still does not yet. This is different from #1455, though, yet another issue.
fix: handle virtual files in DAP breakpoint matching (redhat-develope…
ericbodden commentedon Apr 7, 2026
@angelozerr the attached PR seems to fix the problem described here (UI refresh) for me. Could you kindly review it?
ericbodden commentedon Apr 7, 2026
(This also seems to fix #1455 by the way.)
fix: handle virtual files in DAP breakpoint matching (redhat-develope…
fix: handle virtual files in DAP breakpoint matching (#1447)
angelozerr commentedon Apr 7, 2026
@ericbodden when https://github.com/redhat-developer/lsp4ij/actions/runs/24085327539 will be finished (in few seconds/minutes), you will able to install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds to enjoy with your fix.
angelozerr commentedon Apr 7, 2026
@ericbodden you can install nighty.