-
Notifications
You must be signed in to change notification settings - Fork 687
/
Copy pathdebugConfigurationProvider.ts
64 lines (56 loc) · 2.71 KB
/
debugConfigurationProvider.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
}
}