pulumi/sdk/go/common/resource/plugin/debugging.go

26 lines
928 B
Go
Raw Normal View History

implement the engine bits for debugging support (#17072) We want to introduce dubugging support for Pulumi programs. This PR implements the engine changes necessary for that. Namely, we pass the information whether we expect a debugger to be started to the language runtime, and introduce a way for the language runtime plugins to report to the engine that we're waiting for a debugger to attach. The language runtime is expected to include the information relevant for the user to be able to attach to the debugger, as well as a shortened message. The idea is that the configuration can be picked up by an IDE, and the debugger can attach automatically. Meanwhile the short message should contain enough information to be able to attach a debugger manually, while being short enough to be displayed to the user in the CLI output. (this will commonly be either the port of the debugger, or the PID of the process being debugged). The implementation of the CLI flags and each of the language runtimes will follow in subsequent PRs. I tried adding a test to this, but I'm not sure it's possible with our current testing infrastructure. To do this properly, we'd need to make a RPC call to the engine, but we don't have that available in the lifecycletests (? please let me know if I'm missing something). Once more of the feature is implemented we might be able to implement an integration test for it. (Not straightforward either, as we'll have to tell the debugger to continue, but that should be more doable). Another thing that's not clear to me is that @EronWright mentions this could be used for MLC/provider debugging as well. However I'm not seeing how that's going to work, as MLCs/providers are being run as a binary plugin, which we don't compile from pulumi/pulumi, and thus wouldn't necessarily even know which debugger to launch it under without a bunch of additional configuration, that might be better in a shim around the program (or just keeping the debugging the way we're currently doing, launching the program and then letting the engine attach to it). --------- Co-authored-by: Eron Wright <eron@pulumi.com> Co-authored-by: Julien <julien@caffeine.lu>
2024-08-30 10:31:28 +00:00
// Copyright 2024, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package plugin
type DebugEventEmitter interface {
// StartDebugging asks the host to start a debug session for the given configuration.
StartDebugging(info DebuggingInfo) error
}
type DebuggingInfo struct {
// Config is the debug configuration (language-specific, see Debug Adapter Protocol)
Config map[string]interface{}
}