dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 671 forks source link

Debugger not working ARM64 M1 Mac Azure Functions 4 .NET 6 Unknown Error: 0x80131c3c #4900

Closed EthanSK closed 2 years ago

EthanSK commented 2 years ago

Steps to reproduce

Start VSCode debugger with Azure Functions v4 core tools on .net6 with the following launch.json config:

"configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureFunctions.pickProcess}",
     }
  ]

Expected behavior

Debugger should work

Actual behavior

Failed to attach to process: Unknown Error: 0x80131c3c

Work around:

Modify launch.json and add "targetArchitecture": "x86_64"

    "configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureFunctions.pickProcess}",
      "targetArchitecture": "x86_64"
     }
  ]

dotnet --info output

.NET SDK (reflecting any global.json): Version: 6.0.100 Commit: 9e8b04bbff

Runtime Environment: OS Name: Mac OS X OS Version: 12.0 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.100/

Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa

.NET SDKs installed: 6.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Azure functions info

Azure Functions Core Tools Core Tools Version: 4.0.3971 Commit hash: d0775d487c93ebd49e9c1166d5c3c01f3c76eaaf (64-bit) Function Runtime Version: 4.0.1.16815

Environment information

VSCode version: 1.62.2 C# Extension: 1.23.16

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.100 Commit: 9e8b04bbff Runtime Environment: OS Name: Mac OS X OS Version: 12.0 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.100/ Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa .NET SDKs installed: 6.0.100 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |angular-console|nrwl|17.12.3| |Angular2|johnpapa|12.0.0| |azure-account|ms-vscode|0.9.11| |cmake|twxs|0.0.17| |codespaces|GitHub|1.3.6| |cpptools|ms-vscode|1.7.1| |csharp|ms-dotnettools|1.23.16| |debugger-for-chrome|msjsdiag|4.13.0| |dotnet|formulahendry|0.0.4| |EditorConfig|EditorConfig|0.16.4| |gitlens|eamodio|11.6.1| |java|redhat|1.0.0| |jupyter|ms-toolsai|2021.10.1101450599| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.3| |markdown-preview-enhanced|shd101wyy|0.6.1| |matlab|Gimly81|2.2.1| |ng-template|Angular|13.0.0| |playfab-explorer|Playfab|0.1.15| |prettier-vscode|esbenp|9.0.0| |python|ms-python|2021.11.1422169775| |rainbow-csv|mechatroner|1.10.1| |remote-ssh|ms-vscode-remote|0.66.1| |remote-ssh-edit|ms-vscode-remote|0.66.1| |restore-terminals|EthanSK|1.1.6| |swdc-vscode|softwaredotcom|2.6.14| |tcl|bitwisecook|0.4.0| |terraform|4ops|0.2.2| |todo-tree|Gruntfuggly|0.0.214| |unity-code-snippets|kleber-swf|1.3.0| |unity-debug|Unity|3.0.2| |unity-tools|Tobiah|1.2.12| |vscode-apollo|apollographql|1.19.9| |vscode-azurefunctions|ms-azuretools|1.6.0| |vscode-azureresourcegroups|ms-azuretools|0.4.0| |vscode-eslint|dbaeumer|2.2.2| |vscode-graphql|GraphQL|0.3.18| |vscode-icons|vscode-icons-team|11.7.0| |vscode-java-debug|vscjava|0.36.0| |vscode-java-dependency|vscjava|0.18.8| |vscode-java-pack|vscjava|0.18.6| |vscode-java-test|vscjava|0.32.0| |vscode-jest-runner|firsttris|0.4.47| |vscode-maven|vscjava|0.34.1| |vscode-nuget-package-manager|jmrog|1.1.6| |vscode-pylance|ms-python|2021.11.1| |vscode-typescript-tslint-plugin|ms-vscode|1.3.3| |vscodeintellicode|VisualStudioExptTeam|1.2.14| |vsfire|toba|1.4.1|;

VS Code version: 1.62.2 commit 3a6960b964327f0e3882ce18fcebd07ed191b316 C# Extension version: v1.23.16

OmniSharp log

-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true},"type":"request","seq":1}
<- (R) {"seq":1,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"exceptionBreakpointFilters":[{"filter":"all","label":"All Exceptions","description":"Break when an exception is thrown. For more information about exception settings, see: https://aka.ms/VSCode-CS-ExceptionSettings","default":false,"supportsCondition":true,"conditionDescription":"Comma-separated list of exception types to break on, or if the list starts with '!', a list of exception types to ignore. \nExample 1: System.NullReferenceException -- this will break on just null reference exceptions. \nExample 2: !System.Threading.Tasks.TaskCanceledException -- this will break on all exceptions except for task canceled.\n\nFor more information about exception settings, see: https://aka.ms/VSCode-CS-ExceptionSettings"},{"filter":"user-unhandled","label":"User-Unhandled Exceptions","description":"Break when an exception is caught in non-user code (system code) after having passed through user code. For more information about exception settings, see: https://aka.ms/VSCode-CS-ExceptionSettings","default":true,"supportsCondition":true,"conditionDescription":"Comma-separated list of exception types to break on, or if the list starts with '!', a list of exception types to ignore. \nExample 1: System.NullReferenceException -- this will break on just null reference exceptions. \nExample 2: !System.Threading.Tasks.TaskCanceledException -- this will break on all exceptions except for task canceled.\n\nFor more information about exception settings, see: https://aka.ms/VSCode-CS-ExceptionSettings"}],"supportsSetVariable":true,"supportsGotoTargetsRequest":true,"supportsModulesRequest":true,"supportedChecksumAlgorithms":["MD5","SHA1","SHA256"],"supportsExceptionOptions":true,"supportsValueFormattingOptions":true,"supportsExceptionInfoRequest":true,"supportTerminateDebuggee":true,"supportsSetExpression":true,"supportsReadMemoryRequest":true,"supportsCancelRequest":true,"supportsExceptionFilterOptions":true,"supportsExceptionConditions":true,"supportsLoadSymbolsRequest":true,"supportsModuleSymbolSearchLog":true,"supportsDebuggerProperties":true,"supportsSetSymbolOptions":true,"supportsHitBreakpointIds":true,"supportsVsIndividualBreakpointOperations":true,"supportsVsBreakpointLanguage":true,"supportsSetHitCount":true,"supportsVsCustomMessages":true,"supportsEvaluationOptions":true,"supportsExceptionStackTrace":true,"memoryReferencesAreAddresses":true,"supportsObjectFavorites":true,"supportsObjectId":true,"supportsVariableEnumerators":false}}
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true},"type":"request","seq":1}
-> (C) {"command":"attach","arguments":{"name":"Attach to .NET Functions","type":"coreclr","request":"attach","processId":"32880","debugServer":4711,"__configurationTarget":5,"__sessionId":"99b268cc-d048-4ec5-b382-3b54f38cfe9f"},"type":"request","seq":2}
<- (E) {"seq":4,"type":"event","event":"output","body":{"category":"console","output":"-------------------------------------------------------------------\nYou may only use the Microsoft .NET Core Debugger (vsdbg) with\nVisual Studio Code, Visual Studio or Visual Studio for Mac software\nto help you develop and test your applications.\n-------------------------------------------------------------------\n","severity":"ok"}}
<- (R) {"seq":5,"type":"response","request_seq":2,"success":true,"command":"attach"}
<- (E) {"seq":6,"type":"event","event":"initialized","body":{}}
-> (C) {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":3}
<- (R) {"seq":7,"type":"response","request_seq":3,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
-> (C) {"command":"setExceptionBreakpoints","arguments":{"filters":[],"filterOptions":[{"filterId":"user-unhandled"}]},"type":"request","seq":4}
<- (R) {"seq":8,"type":"response","request_seq":4,"success":true,"command":"setExceptionBreakpoints","body":{"breakpoints":[{"verified":true}]}}
-> (C) {"command":"configurationDone","type":"request","seq":5}
<- (E) {"seq":9,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/AttachFailed","data":{"VS.Diagnostics.Debugger.vsdbg.Distribution.Version":"21.1.0","VS.Diagnostics.Debugger.vsdbg.Distribution.Name":"Darwin","VS.Diagnostics.Debugger.vsdbg.Version":"17.0.10712.2 commit:70a83505117741ba30f92c713a4bb0d0395c3197","VS.Diagnostics.Debugger.vsdbg.OSFamily":"Darwin","VS.Diagnostics.Debugger.vsdbg.ErrorCode":-2146231236}}}
<- (E) {"seq":10,"type":"event","event":"output","body":{"category":"stderr","output":"Unable to start debugging. Failed to attach to process: Unknown Error: 0x80131c3c\n"}}
<- (R) {"seq":11,"type":"response","request_seq":5,"success":false,"command":"configurationDone","message":"Failed to attach to process: Unknown Error: 0x80131c3c"}
-> (C) {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":6}
<- (E) {"seq":12,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/DebugCompleted","data":{"VS.Diagnostics.Debugger.vsdbg.AdapterId":"coreclr","VS.Diagnostics.Debugger.vsdbg.Distribution.Version":"21.1.0","VS.Diagnostics.Debugger.vsdbg.Distribution.Name":"Darwin","VS.Diagnostics.Debugger.vsdbg.DebugCompleted.BreakCounter":0,"VS.Diagnostics.Debugger.vsdbg.Version":"17.0.10712.2 commit:70a83505117741ba30f92c713a4bb0d0395c3197","VS.Diagnostics.Debugger.vsdbg.OSFamily":"Darwin"}}}
<- (R) {"seq":13,"type":"response","request_seq":6,"success":true,"command":"disconnect"}
gregg-miskelly commented 2 years ago

I believe the problem here is that the way process picker commands work they can only specify one property: processId, but there is another property that also needs to be specified - targetArchitecture (see documentation).

This extension at least has a bug that we don't seem to specify targetArchitecture in the schema for attach configurations, and we don't list it in debugger-launchjson.md. @WardenGnaw I am assuming this wasn't done just because in most cases we will automatically figure it out?

Assuming that is it, this issue should probably move to the https://github.com/Microsoft/vscode-azurefunctions to provide a "${command:azureFunctions.targetArchitecture}" command.

WardenGnaw commented 2 years ago

I am assuming this wasn't done just because in most cases we will automatically figure it out?

Yep. The extension attempts to use the dotnet information to determine which architecture to use. However, if we fail to get this dotnet information, it uses the architecture of VS Code.

@EthanSK Which version of VS Code are you using? image

I can update the OptionsSchema and md file to add targetArchitecture.

EthanSK commented 2 years ago

@WardenGnaw I have Apple Silicon only VS Code version: 1.62.2 commit 3a6960b964327f0e3882ce18fcebd07ed191b316 Thanks for looking into it!

gregg-miskelly commented 2 years ago

@EthanSK Did it work for you after changing your launch.json to:

"configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureFunctions.pickProcess}",
      "targetArchitecture": "x86_64"
     }
  ]
EthanSK commented 2 years ago

@gregg-miskelly Oh. nice. that worked :D interesting...

gregg-miskelly commented 2 years ago

Thanks. I edited the original comment to add the work around, and I opened https://github.com/microsoft/vscode-azurefunctions/issues/3005 to track fixing the issue.