Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging not working with XCode 12 selected #42311

Closed
DavidKarlas opened this issue Sep 16, 2020 · 38 comments · Fixed by #44748
Closed

Debugging not working with XCode 12 selected #42311

DavidKarlas opened this issue Sep 16, 2020 · 38 comments · Fixed by #44748
Labels
area-Diagnostics-coreclr os-mac-os-x macOS aka OSX tracking This issue is tracking the completion of other related issues.
Milestone

Comments

@DavidKarlas
Copy link
Contributor

Description

In VSMac, we are using vsdbg(same as Omnisharp) to debug .NET Core applications... We have unit tests, but ever since bumping XCode from 11 to 12, debugging started failing... So here are repro steps:

  1. sudo xcode-select -s /Applications/Xcode_12.app
  2. mkdir xcodeTestProj
  3. cd xcodeTestProj
  4. dotnet new console
  5. dotnet publish --runtime osx-x64
  6. code .
  7. create launch.json via VSCode, and change:
  • "program": "${workspaceFolder}/bin/Debug/net5.0/xcodeTestProj.dll",
  • to
  • "program": "${workspaceFolder}/bin/Debug/net5.0/osx-x64/publish/xcodeTestProj.dll",
  1. Start debugging
  2. Observe Debug Console print Unable to attach to CoreCLR. Unknown Error: 0x80131c3c

Now try all steps, but change step 1 to sudo xcode-select -s /Applications/Xcode_11.app(notice change of Xcode version), it will work fine.

I tried to change to not use published version... But when tests are executing they fail either wrong variables values are reported or “Unable to evaluate expression because the code is optimized o...”.(Only when using XCode 12, fine with XCode 11). I believe underlining problem is same, hence I suggest trying debugging published app since its easier repro...

Im not sure how is selecting XCode 12 vs 11 effecting debugging of CoreCLR, but it does, I suspect its something related to lldb or some libraries used...

Configuration

  • Which version of .NET is the code running on? 3.1, but also tried with 5.0
  • What OS and version, and what distro if applicable? macOs
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? Yes(macOs)
  • If you're using Blazor, which web browser(s) do you see this issue in? N/A

Regression?

No.

Other information

We have to disable .NET Core unit tests for until this is resolved, but I also believe this will effect users when doing some complex debugging.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner labels Sep 16, 2020
@ghost
Copy link

ghost commented Sep 16, 2020

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Sep 16, 2020
@tommcdon tommcdon added this to the 6.0.0 milestone Sep 16, 2020
@tommcdon
Copy link
Member

@hoyosjs
FYI @caslan

@mrward
Copy link

mrward commented Sep 18, 2020

Looks like we may be seeing some customers running into this problem when debugging in VS Mac with Xcode 12 installed.

@c-lamont
Copy link

I can confirm this workaround.

  1. Download Xcode 11: https://download.developer.apple.com/Developer_Tools/Xcode_11.7/Xcode_11.7.xip
  2. Unzip and rename to Xcode_11
  3. Move it to your Applications folder
  4. Open terminal
  5. Go to root: cd /
  6. Run: sudo xcode-select -s /Applications/Xcode_11.app

Now everything works for me.

@marek-safar marek-safar added the os-mac-os-x macOS aka OSX label Sep 19, 2020
@brminnick
Copy link

brminnick commented Sep 19, 2020

Thanks!

Download Xcode

The direct link to the Xcode 11.7 file didn't work for me.

In case anyone else is having trouble, go to Apple's More Downloads for Apple Developers page and search Xcode 11.7 👍

image

@DavidKarlas
Copy link
Contributor Author

Hi @tommcdon @hoyosjs,

Im wonder how could priority on this be increased so someone takes a look at this since more and more developers will start switching to XCode 12 since it was released last week, and milestone .NET 6 feels too far away... At first I though this would only be problem for unit tests but looks like its effecting also developers...

Regards,
David

@borzuyehr
Copy link

@c-lamont and @brminnick solution worked for me as a workaround as well. Just to mention, my initial workaround was to Dockerize my .NET core app and run it in a Linux container. Just in case the above workaround does not work for others out there.

@hoyosjs
Copy link
Member

hoyosjs commented Sep 23, 2020

@DavidKarlas the milestone means that it will be completed in master first. If there's enough customer feedback, we take it to ship room for backport approval. I can imagine this fitting the requirements easily.

And sorry for the time it's taken me. I've had an avalanche of issues coming in and I tried getting XCode 12, but my Mac seems... a little hesitant to help here. With all of us working from home, I haven't been able to access a different device. I'll see if a teammate can help me out to repro this.

@DavidKarlas
Copy link
Contributor Author

@hoyosjs Tnx for explaining, I just thought that milestone means it will have to wait few months... If you want me to do some testing/debugging let me know.

@mklement0
Copy link

mklement0 commented Sep 29, 2020

Re workaround:

It seems that downloading and installing the "Command Line Developer Tools for Xcode 11.5" (*.dmg, contains an installer package (*.pkg), about 260MB) from https://developer.apple.com/download/more/ is sufficient (no need for Xcode 11 as a whole).

Once installed, switch to this version of the tools with sudo xcode-select -s /Library/Developer/CommandLineTools

@ftntming
Copy link

Re workaround:

It seems that downloading and installing the "Command Line Developer Tools for Xcode 11.5" (*.dmg, contains an installer package (*.pkg), about 260MB) from https://developer.apple.com/download/more/ is sufficient (no need for Xcode 11 as a whole).

Once installed, switch to this version of the tools with sudo xcode-select -s /Library/Developer/CommandLineTools

Works like a charm in OSX 10.15.7, VS Studio 2019

@MisterJimson
Copy link

Re workaround:

It seems that downloading and installing the "Command Line Developer Tools for Xcode 11.5" (*.dmg, contains an installer package (*.pkg), about 260MB) from https://developer.apple.com/download/more/ is sufficient (no need for Xcode 11 as a whole).

Once installed, switch to this version of the tools with sudo xcode-select -s /Library/Developer/CommandLineTools

Also fixes the issue on Rider for me as well.

@hoyosjs
Copy link
Member

hoyosjs commented Oct 19, 2020

This is most likely fixed by #42900

@icelated
Copy link

icelated commented Nov 4, 2020

I upgraded Xcode to the new version 12.1 and now the debugger is busted. Not to mention in the simulator the perform segue goes to the view controller but the view doesn't render. Worked before the update and works on my phone. Also, the date picker is coming up different in the simulator.

@kuromukira
Copy link

Hi, I'm experiencing this bug since I updated my XCode to 12 (now 12.1). Would it affect my mobile app builds if I install the build tools for XCode 11? It's frustrating to not be able to debug code in Rider and Visual Studio.

@hoyosjs
Copy link
Member

hoyosjs commented Nov 11, 2020

Hi, I'm experiencing this bug since I updated my XCode to 12 (now 12.1). Would it affect my mobile app builds if I install the build tools for XCode 11? It's frustrating to not be able to debug code in Rider and Visual Studio.

This is related to the tools that are installed on the machine that's running the app under the debugger. We used to rely on vmmap, which was updated in a way that broke our usage. It's only used in debugging scenarios. There was a contribution to fix this for .NET 6 (master), but it needs to be ported to other releases. As I get feedback of it affecting users I can justify getting it backported.

cc: @gregg-miskelly the affected API needed for this lives in the PAL and is only really used through dbgshim (apis like CreateVersionStringFromModule and EnumerateCLRs).
cc: @tommcdon

@kuromukira
Copy link

Thanks @hoyosjs . It's manageable for the meantime debugging code only through Console.WriteLine. As long Running without Debugging doesn't break anytime soon.

But it would really be great to have this fixed and be able to debug code normally again.

@MisterJimson
Copy link

@kuromukira you can use the workarounds posted above to debug normally. Using an older copy of Xcode. Its pretty easy to switch back and forth if you also do other things with Xcode 12.

@8or15
Copy link

8or15 commented Nov 14, 2020

@hoyosjs after upgrading to Big Sur I'm unable to use the workaround, so a back port of the fix would be helpful.

@stevo-knievo
Copy link

I have the same issue as @8or15.

Here the error if you try to install the Command Line Tools 11.5:
Command Line Tools 11.5 can't be installed on the disk. The version of macOS is too new.

@hoyosjs
Please back port the fix to .NET Core 3 and .NET 5.

- .NET Core SDK 3.1.404 (Commit: 470f6754b3)
- macOS: 11.0.1 (20B29) - Darwin 20.1.0
- Xcode
    Version:	12.2 (12B45b)
    Xcode:	12.2 (17535)
    Instruments:	12.2 (64541.11)
- CommandLineToolsForXcode: 2384 (via xcode-select --version)

@wingchunninja
Copy link

I was experiencing the same issue before and the fix did it for me. But after updating to BigSur
and with Visual Studio Version 1.51.1 doesn't work anymore. Anybody else experiencing this?
And also the same issue when trying to install Command Line Tools 11.5.

@stevo-knievo
Copy link

I had to downgrade back to macOS Catalina 10.15.7 (19H2) and the Command Line Developer Tools for Xcode 11.5 (version 2373). Currently, that is the only way I can be productive on .NET Core 3.1

@hoyosjs
Copy link
Member

hoyosjs commented Nov 16, 2020

@mikem8361 has started the discussions for the backport in #44748

@mii9000
Copy link

mii9000 commented Nov 28, 2020

None of the solutions work for me on Big Sur 😢

@hoyosjs
Copy link
Member

hoyosjs commented Nov 29, 2020

The fix had been merged in time to make it into our next official build. After that it needs to be picked up by the different debuggers in the ecosystem. VS for mac and VSCode use the same debugger engine and the owners expressed interest in including the fix as soon as possible.

@sdmaclea
Copy link
Contributor

sdmaclea commented Dec 1, 2020

@hoyosjs Looks like it was backported to .NET 5. Does the issue affect .NET 2.1 and/or .NET 3.1? Are those backports being requested too?

@gregg-miskelly
Copy link
Contributor

@sdmaclea Because this is a dbgshim fix - it doesn't need to be. Any debugger that wants this fix can use the .NET 5 dbgshim.

@mrward
Copy link

mrward commented Dec 4, 2020

Ran a test of this fix and it looks good to me with Xcode 12.2.

  • Installed .NET 5.0.1
  • Ran David's repro steps.
  • Debugger fails
  • Copied the dylib from .net 5.0.1 from /usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.1/libdbgshim.dylib to ~/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.debugger
  • Restarted VS Code and then debugged the project again
    • the debugger runs and breakpoints can be hit in the console project.

I am assuming there will be a more official debugger zip at some point with this updated libdbgshim.dylib that can be bundled with OmniSharp and VS Mac?

@mrward
Copy link

mrward commented Dec 4, 2020

@wingchunninja Sorry, I was testing an internal 5.0.1 build. Not sure if this change has made it into the 5.0.200 preview builds from https://github.com/dotnet/installer yet.

@wingchunninja
Copy link

@mrward Ah okay. Thank you. I will take a look if there are some changes there. It is a pretty blocking issue for me since i cannot debug in the normal way without console logging.

@gregg-miskelly
Copy link
Contributor

I am assuming there will be a more official debugger zip at some point with this updated libdbgshim.dylib that can be bundled with OmniSharp and VS Mac?

Yes, soon after 5.0.1 ships the VS debugger team expects to put out a new release of vsdbg-ui which can be included into the VS Code C# extension and VS For Mac.

@wingchunninja
Copy link

@wingchunninja Sorry, I was testing an internal 5.0.1 build. Not sure if this change has made it into the 5.0.200 preview builds from https://github.com/dotnet/installer yet.

@mrward Thank you for the hint. This did the work for me 🙂

@hoyosjs hoyosjs added the tracking This issue is tracking the completion of other related issues. label Dec 8, 2020
@hoyosjs hoyosjs modified the milestones: 6.0.0, Future Dec 8, 2020
@hoyosjs
Copy link
Member

hoyosjs commented Dec 8, 2020

@tommcdon set this to tracking as all the runtime side of the work is done.

@gregg-miskelly
Copy link
Contributor

There is now a beta release of the VS Code C# extension that contains this fix: v1.23.8-beta1.

@kuromukira
Copy link

kuromukira commented Dec 9, 2020

@gregg-miskelly How about for VS for Mac? Still can't debug with VS for Mac even with 5.0.1 installed

@mrward
Copy link

mrward commented Dec 10, 2020

@kuromukira There should be a new VS Mac 8.8.4 release with the updated debugger at some point - I do not have a specific date as yet.

For a workaround you can probably copy the libdbgshim.dylib from /usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.1/libdbgshim.dylib into VS Mac's app bundle /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/DotNetCore.Debugger/Adapter/libdbgshim.dylib - making a backup copy of this file in the Adapter directory so you can rollback if it breaks something.

@joshardt
Copy link

joshardt commented Dec 17, 2020

VS4M version 8.8.4.30 which contains a fix for this issue is available by now: https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2019-mac-relnotes#884

Issue can probably get closed.

@DavidKarlas
Copy link
Contributor Author

Looking at VSCode extension, looks like they have fix available in preview and will probably land very soon on stable, closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Diagnostics-coreclr os-mac-os-x macOS aka OSX tracking This issue is tracking the completion of other related issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.