Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/azd/pkg/azdext/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (
"google.golang.org/grpc/metadata"
)

// waitForDebugger checks if AZD_EXT_DEBUG environment variable is set to a truthy value.
// WaitForDebugger checks if AZD_EXT_DEBUG environment variable is set to a truthy value.
// If set, prompts the user to attach a debugger to the current process.
func waitForDebugger(ctx context.Context, extensionId string, azdClient *AzdClient) {
// This should be called at the start of extension command implementations to enable debugging.
func WaitForDebugger(ctx context.Context, azdClient *AzdClient) {
debugValue := os.Getenv("AZD_EXT_DEBUG")
if debugValue == "" {
return
Expand All @@ -28,6 +29,7 @@ func waitForDebugger(ctx context.Context, extensionId string, azdClient *AzdClie
return
}

extensionId := getExtensionId(ctx)
message := fmt.Sprintf("Extension '%s' ready to debug (pid: %d).", extensionId, os.Getpid())

_, err = azdClient.Prompt().Confirm(ctx, &ConfirmRequest{
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/pkg/azdext/extension_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (er *ExtensionHost) Run(ctx context.Context) error {
er.init(extensionId)

// Wait for debugger if AZD_EXT_DEBUG is set
waitForDebugger(ctx, extensionId, er.client)
WaitForDebugger(ctx, er.client)

// Determine which managers will be active
hasServiceTargets := len(er.serviceTargets) > 0
Expand Down
Loading