Expose the debugger ephemeral port before the debug session starts in the API

Answered

Hi,

replying to https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1687431397606729?thread_ts=1686026928.050009&cid=C5U8BM1MK

for exposing the debugger port in the API,

our use case is that our project, extension: https://github.com/metalbear-co/mirrord-intellij  <-> extension relies on: https://github.com/metalbear-co/mirrord
mirrord, mirrorrs traffic from a remote k8s cluster by hooking libc functions using LD_PRELOAD/DYLD_INSERT_LIBRARIES,

for example, a debugger works on a socket that is locally created and it binds/connects to it, we wouldn't want that to happen on remote, but rather locally, and hence we don't forward such a request to remote on that particular port, so we need to know what the port is before the session starts. Currently, our workaround to this issue is to ignore all the higher number of ports to be forwarded by mirrord to remote, this is, however, not desirable. We also implemented another approach for RIder, where we set an env in the runConfigurationExtension's patchCommandLine to let know the mirrord dylib to parse the command line to find the debugger port. This is also quite ugly and doesn't scale well.

The best way out to this would be that if we could know the ephemeral port that would be used by the debugger before the debugger starts so that the plugin can know for the debugger port is it to be ignored.

 

0
1 comment

Hi, the local port is selected at com/intellij/debugger/engine/DebugProcessImpl.java:613, you can try to add a listener for com.intellij.debugger.engine.DebugProcessListener#connectorIsReady and there get the address from com.intellij.debugger.DebugEnvironment#getRemoteConnection

0

Please sign in to leave a comment.