-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle ProcessPicker via resolveDebugConfiguration (#4509)
* Handle ProcessPicker via resolveDebugConfiguration VS Code commands are limited to only being able to have a single output. We will handle having an empty processId and show the dialog for ProcessPicker in resolveDebugConfigurationWithSubstitutedVariables. We need multiple outputs to handle the latest macOS on Apple M1. For Apple Silicon M1 (ARM64), we need to determine if we need to use the x86_64 or arm64 debugger. We are able to detect if the process is using S_TRANSLATED using the ps commandline with 'flags', if it is set with 0x20000, it is emulated. * Addressing PR issues Migrate remoteProcessPicker to also be in resolve configuration Handle 'clr' type for remote process picking. Addressing PR issues. Added comment about 0x20000 * Remove 'processId' from default config * Remove 'processId' from assets.ts
- Loading branch information
1 parent
ad19c37
commit 5497895
Showing
9 changed files
with
108 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
uname && if [ "$(uname)" = "Linux" ] ; then ps -axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; exit; elif [ "$(uname)" = "Darwin" ] ; then ps -axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi | ||
uname && if [ "$(uname)" = "Linux" ] ; then ps -axww -o pid=,flags=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= ; exit; elif [ "$(uname)" = "Darwin" ] ; then ps -axww -o pid=,flags=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args= -c; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
import { RemoteAttachPicker, DotNetAttachItemsProviderFactory, AttachPicker, AttachItem } from '../features/processPicker'; | ||
import { PlatformInformation } from '../platform'; | ||
|
||
export class DotnetDebugConfigurationProvider implements vscode.DebugConfigurationProvider { | ||
constructor(public platformInformation: PlatformInformation) {} | ||
|
||
public async resolveDebugConfigurationWithSubstitutedVariables(folder: vscode.WorkspaceFolder | undefined, debugConfiguration: vscode.DebugConfiguration, token?: vscode.CancellationToken): Promise<vscode.DebugConfiguration> | ||
{ | ||
if (!debugConfiguration) | ||
{ | ||
return null; | ||
} | ||
|
||
// Process Id is empty, handle Attach to Process Dialog. | ||
if (debugConfiguration.request === "attach" && !debugConfiguration.processId && !debugConfiguration.processName) | ||
{ | ||
let process: AttachItem = undefined; | ||
if (debugConfiguration.pipeTransport) | ||
{ | ||
process = await RemoteAttachPicker.ShowAttachEntries(debugConfiguration, this.platformInformation); | ||
} | ||
else | ||
{ | ||
let attachItemsProvider = DotNetAttachItemsProviderFactory.Get(); | ||
let attacher = new AttachPicker(attachItemsProvider); | ||
process = await attacher.ShowAttachEntries(); | ||
} | ||
|
||
if (process) | ||
{ | ||
debugConfiguration.processId = process.id; | ||
|
||
if (debugConfiguration.type == "coreclr" && | ||
this.platformInformation.isMacOS() && | ||
this.platformInformation.architecture == 'arm64') | ||
{ | ||
// For Apple Silicon M1, it is possible that the process we are attaching to is being emulated as x86_64. | ||
// The process is emulated if it has process flags has P_TRANSLATED (0x20000). | ||
if (process.flags & 0x20000) | ||
{ | ||
debugConfiguration.targetArchitecture = "x86_64"; | ||
} | ||
else | ||
{ | ||
debugConfiguration.targetArchitecture = "arm64"; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
throw new Error("No process was selected."); | ||
} | ||
} | ||
|
||
return debugConfiguration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters