Skip to content

Commit b2c8deb

Browse files
authored
Add OSX-ARM64 support (#4498)
* Add OSX-ARM64 support This PR adds the packages for osx-arm64. * Handle launching correct debugger Added logic to launch correct debugger depending on OS Arch, Dotnet SDK, or launch.json override. Addressed PR issues.
1 parent 8dd7f44 commit b2c8deb

File tree

5 files changed

+254
-26
lines changed

5 files changed

+254
-26
lines changed

package.json

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@
239239
{
240240
"id": "Debugger",
241241
"description": ".NET Core Debugger (Windows / x64)",
242-
"url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/8ef4bedc8923b38b9a6ab98d7ec2df16/coreclr-debug-win7-x64.zip",
243-
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-win7-x64.zip",
242+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/d133bd53b5360d1041f8a6ab28b82d4e/coreclr-debug-win7-x64.zip",
243+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-win7-x64.zip",
244244
"installPath": ".debugger",
245245
"platforms": [
246246
"win32"
@@ -249,14 +249,14 @@
249249
"x86_64"
250250
],
251251
"installTestPath": "./.debugger/vsdbg-ui.exe",
252-
"integrity": "52D76850494F1F6B04B9CABB4C80B9E63C0762BFA676CFDD16292EBC77462989"
252+
"integrity": "D6B804513BA83E10B1428CEEDD6E2AC4749DC2AAFFD5BE56AEB6FD430C916618"
253253
},
254254
{
255255
"id": "Debugger",
256256
"description": ".NET Core Debugger (macOS / x64)",
257-
"url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/c091f9f76df625e2f6cbae32521c7149/coreclr-debug-osx-x64.zip",
258-
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-osx-x64.zip",
259-
"installPath": ".debugger",
257+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/829575bd3a1e1837b3be4c2d1e02fc85/coreclr-debug-osx-x64.zip",
258+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-osx-x64.zip",
259+
"installPath": ".debugger/x86_64",
260260
"platforms": [
261261
"darwin"
262262
],
@@ -268,14 +268,33 @@
268268
"./vsdbg-ui",
269269
"./vsdbg"
270270
],
271-
"installTestPath": "./.debugger/vsdbg-ui",
272-
"integrity": "E728CB6D8374D6F8BD75B23D352CB3C9B30C202C94F928AFB425E0A1CECEB54A"
271+
"installTestPath": "./.debugger/x86_64/vsdbg-ui",
272+
"integrity": "2C7CD642F8F3B405D0AB95FABD3CCAD51A6DD2B919B9BE221C0F18FC724604AE"
273+
},
274+
{
275+
"id": "Debugger",
276+
"description": ".NET Core Debugger (macOS / arm64)",
277+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/55697478c628061578739b1b2ae62dc4/coreclr-debug-osx-arm64.zip",
278+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-osx-arm64.zip",
279+
"installPath": ".debugger/arm64",
280+
"platforms": [
281+
"darwin"
282+
],
283+
"architectures": [
284+
"arm64"
285+
],
286+
"binaries": [
287+
"./vsdbg-ui",
288+
"./vsdbg"
289+
],
290+
"installTestPath": "./.debugger/arm64/vsdbg-ui",
291+
"integrity": "1B2954EB75B647D5168AD816A942F61D46EB8DCEF384A8C2514DB9898B1F0022"
273292
},
274293
{
275294
"id": "Debugger",
276295
"description": ".NET Core Debugger (linux / ARM)",
277-
"url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/83983aa140267cbf90b3780dfdf640a8/coreclr-debug-linux-arm.zip",
278-
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-arm.zip",
296+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/9ff9dada26542d0d6f3799cbc969339c/coreclr-debug-linux-arm.zip",
297+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-arm.zip",
279298
"installPath": ".debugger",
280299
"platforms": [
281300
"linux"
@@ -288,13 +307,13 @@
288307
"./vsdbg"
289308
],
290309
"installTestPath": "./.debugger/vsdbg-ui",
291-
"integrity": "9CCDD89F495BF8FD2168FBD9D15730B1F98CD03CB2EFC74F57FCA9AD22E278DD"
310+
"integrity": "2D45ABEB478F8234854AB2A0E801B9EA0143B47F208F97AFC95F6020BC4E7BB7"
292311
},
293312
{
294313
"id": "Debugger",
295314
"description": ".NET Core Debugger (linux / ARM64)",
296-
"url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/bfa6b939db12aacd40cf2ebda28b621d/coreclr-debug-linux-arm64.zip",
297-
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-arm64.zip",
315+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/e64e76d0bfb1e50da16678db728c8bad/coreclr-debug-linux-arm64.zip",
316+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-arm64.zip",
298317
"installPath": ".debugger",
299318
"platforms": [
300319
"linux"
@@ -307,13 +326,13 @@
307326
"./vsdbg"
308327
],
309328
"installTestPath": "./.debugger/vsdbg-ui",
310-
"integrity": "BF4C56C6A74175AC02C4DD96A1602457B318D7FE6309B1331FB535F7DF42E01D"
329+
"integrity": "0F1BED966A9FBF308A431995A1CC7EC49D690C8E3986F88F47FF3DA198B4F997"
311330
},
312331
{
313332
"id": "Debugger",
314333
"description": ".NET Core Debugger (linux / x64)",
315-
"url": "https://download.visualstudio.microsoft.com/download/pr/22843236-af09-4293-9d23-ca35003ca60a/5736b04572b255dee1c529cc41623a4b/coreclr-debug-linux-x64.zip",
316-
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-9/coreclr-debug-linux-x64.zip",
334+
"url": "https://download.visualstudio.microsoft.com/download/pr/15786370-6d35-4cac-8d70-618dfc5aa9ad/92eeb7715c63c006df2318abeefc15b4/coreclr-debug-linux-x64.zip",
335+
"fallbackUrl": "https://vsdebugger.blob.core.windows.net/coreclr-debug-1-23-12/coreclr-debug-linux-x64.zip",
317336
"installPath": ".debugger",
318337
"platforms": [
319338
"linux"
@@ -326,7 +345,7 @@
326345
"./vsdbg"
327346
],
328347
"installTestPath": "./.debugger/vsdbg-ui",
329-
"integrity": "29F5ABE6D317F956F0BCBF86C1344FD298D66F276597F6A0E15B5462CA8122A7"
348+
"integrity": "A1AF7EB043B14DB777108D6B9D91F8CA2DC5551E3BC8340C96477B5BDC974C4B"
330349
},
331350
{
332351
"id": "Razor",
@@ -1605,6 +1624,10 @@
16051624
"type": "string",
16061625
"description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
16071626
"default": "${workspaceFolder}/out.txt"
1627+
},
1628+
"targetArchitecture": {
1629+
"type": "string",
1630+
"description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
16081631
}
16091632
}
16101633
},
@@ -2702,6 +2725,10 @@
27022725
"type": "string",
27032726
"description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
27042727
"default": "${workspaceFolder}/out.txt"
2728+
},
2729+
"targetArchitecture": {
2730+
"type": "string",
2731+
"description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
27052732
}
27062733
}
27072734
},

src/coreclr-debug/activate.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import * as path from 'path';
77
import * as vscode from 'vscode';
88
import * as common from './../common';
9-
import { CoreClrDebugUtil } from './util';
9+
import { CoreClrDebugUtil, getTargetArchitecture } from './util';
1010
import { PlatformInformation } from './../platform';
1111
import { DebuggerPrerequisiteWarning, DebuggerPrerequisiteFailure, DebuggerNotInstalledFailure } from '../omnisharp/loggingEvents';
1212
import { EventStream } from '../EventStream';
1313
import CSharpExtensionExports from '../CSharpExtensionExports';
1414
import { getRuntimeDependencyPackageWithId } from '../tools/RuntimeDependencyPackageUtils';
15-
import { DotnetInfo } from '../utils/getDotnetInfo';
15+
import { getDotnetInfo, DotnetInfo } from '../utils/getDotnetInfo';
1616

1717
let _debugUtil: CoreClrDebugUtil = null;
1818

@@ -36,16 +36,22 @@ export async function activate(thisExtension: vscode.Extension<CSharpExtensionEx
3636

3737
async function checkForInvalidArchitecture(platformInformation: PlatformInformation, eventStream: EventStream): Promise<boolean> {
3838
if (platformInformation) {
39-
if (platformInformation.isMacOS() && !CoreClrDebugUtil.isMacOSSupported()) {
40-
eventStream.post(new DebuggerPrerequisiteFailure("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."));
41-
return true;
39+
if (platformInformation.isMacOS()) {
40+
if (platformInformation.architecture === "arm64") {
41+
eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: arm64 macOS is not officially supported by the .NET Core debugger. You may experience unexpected issues when running in this configuration.`));
42+
return false;
43+
}
44+
45+
// Validate we are on compatiable macOS version if we are x86_64
46+
if ((platformInformation.architecture !== "x86_64") ||
47+
(platformInformation.architecture === "x86_64" && !CoreClrDebugUtil.isMacOSSupported())) {
48+
eventStream.post(new DebuggerPrerequisiteFailure("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."));
49+
return true;
50+
}
4251
}
4352
else if (platformInformation.architecture !== "x86_64") {
4453
if (platformInformation.isWindows() && platformInformation.architecture === "x86") {
4554
eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: x86 Windows is not currently supported by the .NET Core debugger. Debugging will not be available.`));
46-
} else if (platformInformation.isMacOS() && platformInformation.architecture === "arm64") {
47-
eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: arm64 macOS is not officially supported by the .NET Core debugger. You may experience unexpected issues when running in this configuration.`));
48-
return false;
4955
} else {
5056
eventStream.post(new DebuggerPrerequisiteWarning(`[WARNING]: Processor architecture '${platformInformation.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`));
5157
}
@@ -155,9 +161,12 @@ export class DebugAdapterExecutableFactory implements vscode.DebugAdapterDescrip
155161

156162
// debugger has finished installation, kick off our debugger process
157163

164+
// Check for targetArchitecture
165+
const targetArchitecture: string = getTargetArchitecture(this.platformInfo, _session.configuration.targetArchitecture, await getDotnetInfo());
166+
158167
// use the executable specified in the package.json if it exists or determine it based on some other information (e.g. the session)
159168
if (!executable) {
160-
const command = path.join(common.getExtensionPath(), ".debugger", "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
169+
const command = path.join(common.getExtensionPath(), ".debugger", targetArchitecture, "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
161170
executable = new vscode.DebugAdapterExecutable(command);
162171
}
163172

src/coreclr-debug/util.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path';
77
import * as fs from 'fs';
88
import * as semver from 'semver';
99
import * as os from 'os';
10+
import { PlatformInformation } from './../platform';
1011
import { getDotnetInfo, DotnetInfo, DOTNET_MISSING_MESSAGE } from '../utils/getDotnetInfo';
1112

1213
const MINIMUM_SUPPORTED_DOTNET_CLI: string = '1.0.0';
@@ -117,3 +118,61 @@ export class CoreClrDebugUtil {
117118
return '';
118119
}
119120
}
121+
122+
const MINIMUM_SUPPORTED_OSX_ARM64_DOTNET_CLI: string = '6.0.0';
123+
124+
export function getTargetArchitecture(platformInfo: PlatformInformation, launchJsonTargetArchitecture: string, dotnetInfo: DotnetInfo): string
125+
{
126+
if (!platformInfo)
127+
{
128+
throw new Error(`Unable to retrieve 'TargetArchitecture' without platformInfo.`);
129+
}
130+
131+
let targetArchitecture = "";
132+
133+
// On Apple M1 Machines, we need to determine if we need to use the 'x86_64' or 'arm64' debugger.
134+
if (platformInfo.isMacOS())
135+
{
136+
// 'targetArchitecture' is specified in launch.json configuration, use that.
137+
if (launchJsonTargetArchitecture)
138+
{
139+
if (launchJsonTargetArchitecture !== "x86_64" && launchJsonTargetArchitecture !== "arm64")
140+
{
141+
throw new Error(`The value '${launchJsonTargetArchitecture}' for 'targetArchitecture' in launch configuraiton is invalid. Expected 'x86_64' or 'arm64'.`);
142+
}
143+
targetArchitecture = launchJsonTargetArchitecture;
144+
}
145+
else if (dotnetInfo)
146+
{
147+
// Find which targetArchitecture to use based on SDK Version or RID.
148+
149+
// If we are lower than .NET 6, use 'x86_64' since 'arm64' was not supported until .NET 6
150+
if (dotnetInfo.Version && semver.lt(dotnetInfo.Version, MINIMUM_SUPPORTED_OSX_ARM64_DOTNET_CLI))
151+
{
152+
targetArchitecture = 'x86_64';
153+
}
154+
else if (dotnetInfo.RuntimeId)
155+
{
156+
if (dotnetInfo.RuntimeId.includes('arm64'))
157+
{
158+
targetArchitecture = 'arm64';
159+
}
160+
else if (dotnetInfo.RuntimeId.includes('x64'))
161+
{
162+
targetArchitecture = 'x86_64';
163+
}
164+
else
165+
{
166+
throw new Error(`Unexpected RuntimeId '${dotnetInfo.RuntimeId}'.`);
167+
}
168+
}
169+
}
170+
171+
if (!targetArchitecture) {
172+
// Unable to retrieve any targetArchitecture, go with platformInfo.
173+
targetArchitecture = platformInfo.architecture;
174+
}
175+
}
176+
177+
return targetArchitecture;
178+
}

src/tools/OptionsSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@
386386
"type": "string",
387387
"description": "When set, text that the target application writes to stdout and stderr (ex: Console.WriteLine) will be saved to the specified file. This option is ignored if console is set to something other than internalConsole.",
388388
"default": "${workspaceFolder}/out.txt"
389+
},
390+
"targetArchitecture": {
391+
"type": "string",
392+
"description": "[Only supported in local macOS debugging] The architecture of the debuggee. This will automatically be detected unless this parameter is set. Allowed values are x86_64 or arm64."
389393
}
390394
}
391395
},

0 commit comments

Comments
 (0)