-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dlv/dap: do not override backend process' own environment variables with those meant for debuggee #3876
Comments
This is how this feature is implemented, delve's backends do not have the capability to manipulate the environment of the child process. The other frontends of delve do not even have the ability to change the environment at all. |
There's two cases of manipulating the environment:
I made a dummy change for Linux only and it doesn't appear impossible. It:
I'm curious as to what I'm missing. |
I'm curious why this would be a problem for a lldb shim. |
The problem goes like this:
We have a workaround: pass |
You can set the path of debugserver using DELVE_DEBUGSERVER_PATH, the way it's called is slightly different than lldb-server but if you are writing a shim anyway... |
I thought I had tried this path and concluded it was somehow macOS-only and I'd need to PATH-shim. Perhaps I was mistaken, we'll try it out. Even if this works though, changing the environment of the backend instead of the debuggee feels wrong. While I can't readily think of any variable that would have an adverse effect on a running program (GOMAXPROCS, GOGC, GOMEMLIMIT, GODEBUG, ...), it's not out of the question that this could happen in the future. Also changing the environment would change it for a spawned lldb-server or debugserver as well (any children). |
The env field of launch.json was added because vscode doesn't let you easily specify the environment to be used for the debugger (like you would be able to do on a shell with
It's adding a bunch of complexity for something few people need. |
I agree that's too much. But does the current option need to apply to the backend process, or could it (for the current use cases) also be made to apply just to the debuggee? |
But the debugger is spawned by your shim. We would have to apply the env
for delve, unapply it when calling debugserver and tell debugserver to
reapply it (how?)
Il mer 11 dic 2024, 10:59 Nicolas Hillegeer ***@***.***> ha
scritto:
… I agree that's too much. But does the current option *need* to apply to
the backend process, or could it (for the current use cases) also be made
to apply just to the debuggee?
—
Reply to this email directly, view it on GitHub
<#3876 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKEBD2ITTMIXFKRFH7EJ32FAEHZAVCNFSM6AAAAABTJFY2SOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZVGM3DMMJUGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
[Disclaimer: I've worked with @aktau on this project, but I don't speak for him. I'm a long time LLDB dev, but have very little experience with go/delve] I think there's too much focus here on our shim use case. With my upstream hat, I'd say that this is a niche use case that's not worth it. I think we could agree on that. However, I don't think that's why this bug was filed. We have a workaround for this that works adequately. I believe we filed the bug because we found it odd that the "environment" field in the launch request affects the environment of the debugger. I certainly found it very surprising. The debuggers I'm familiar with (gdb, lldb, including the lldb vscode plugin) all support the ability to run the debuggee with a different environment, and they all do it by applying the environment to the debuggee alone. For gdb and lldb this is particularly important, as they support debugging more than one process simultaneously, but even for one process, it's possible to come up scenarios where one would want to run the debuggee with an environment var (TMP? HOME? GOGC? LD_PRELOAD? TCMALLOC_***?) that one would not want to be applied to the debugger (or any other process spawned by the debugger). Is that likely scenario? Probably not. I don't remember if I've ever needed to set an debuggee environment variable, that couldn't also be set on the debugger as well. However, it's common enough that both lldb and gdb (and probably other debuggers as well) have the ability to do that, and I, as a debugger developer am very happy that the I don't have to worry about the user breaking the debugger by setting some env variable meant for the debuggee. That said, it seems delve is not one of those "other debuggers" -- even the command line client is not capable of setting debuggee-only variables. The only way to do it is to set it for both, as you pointed out in #3876 (comment), so I can see this issue (feature request?) being rejected on those grounds. However:
I agree that's too much, but do we need the ability to set the variables for the first three? From what you've said, I surmise that's true. I can certainly believe that, but do you have a specific use case in mind? Can you share it? If it is necessary, what would you say to having just two fields? One which applies to everything -- that would be the equivalent of
This is possible, but you may have to change the way you communicate with it. The mode that works right now in lldb-server and debugserver (the question is moot for rr -- in the replay mode at least -- because the environment variables have already been set) is where you start them without a debuggee, and then launch it later by sending a packet ( As an alternative, debugserver also supports a way to change the environment for the debuggee alone using command line arguments. lldb-server doesn't support that right now, but if there's a demand for it (and you're willing to wait for a new release -- I'm not sure what's your compatibility story) I think I could add an equivalent feature to it. |
NOTE: The title implies what I would want for my use case, but I don't know if that's desired. See below.
dlv version
)? Current HEAD (477e46e), v1.32.2-devgo version
)? Go 1.24-devdlv dap
with a shim for LLDB (so that Delve contacts a proprietary debugging backend instead of LLDB). This works normally, but not withdlv dap
.Env
to child without modifying its own environment.delve/service/dap/server.go
Lines 919 to 931 in 477e46e
I'm not sure if this is a bug, or what the purpose of this is, given the documentation of
LaunchConfig.Env
implying thatEnv
really should apply to the Delve backend/server:delve/service/dap/types.go
Lines 150 to 157 in 477e46e
If someone knows what Chesterton's fence I'm looking at, I'd be happy to find out. Thanks.
The text was updated successfully, but these errors were encountered: