Xamarin-macios: BreakPoints in iOS Xamarin Studio on Mac do not stop Debugger

Created on 16 Dec 2017  路  17Comments  路  Source: xamarin/xamarin-macios

Steps to Reproduce

  1. Debug an iOS project
  2. Set a breakpoint in the iOS project
  3. The breakpoint will not stop the debugger

Expected Behavior

The breakpoints should pause the debugger in iOS project. The breakpoints work fine in PCl and Android projects.

Actual Behavior

The breakpoints that I set do not, although if I write them in the code they do work ( ex. 'Debugger.breakpoint'

Environment

iOS support

Most helpful comment

In order to have the debugger working in your project you can delete the following from the solution file:

 <PropertyGroup Condition=" '$(OS)' == 'Unix' ">
    <CscToolExe>mcs.exe</CscToolExe>
  </PropertyGroup>

There is no need to add anything. I have tested it locally and it works. Please let me know if this is a workaround you are willing to use.

All 17 comments

Can you provide more context for the issue? Does it happen in all iOS projects? Does it matter where the breakpoint is set (does it work in some places but not others, or doesn't work anywhere)? I'm testing on the versions as in your description and the debugger stops correctly for me on breakpoints in VSfM.

If it does not happen all the time or for all projects, an example project where it is happening would be very helpful.

I cannot recreate except in my own project. I created a new project from scratch and everything worked properly. I tried to sync up the debug configuration from the 'test' project with my project and still had no luck. Also, breakpoints works fine in VS on Windows.
It does not matter where the breakpoint is, it will never hit in my iOS project. I will attach my application logs.
log3.txt

@nfritsche so, in summary and to try and keep everyone in the same page:

  1. Break points in an specific project DO NOT work on VS for Mac.
  2. Break points in a specific project DO work on VS for Windows.
  3. Break points in a new project DO work.

Can you please let me know the following:

  1. Where is the break point set?
  2. What are the settings for the linker? It is probably not related, but I wonder if the code is removed because is never used. I just want an explicit word from you saying "the linker has nothing to do with it because my linker settings are 'x'"
  3. Could you share the project with us?

We added some work in the debugger recently to add the sources files of xamarin an everything worked on both VS for Mac and Vs for Windows. So the complete information of you environment would be useful (specially the env where it fails). Since the debugger DOES work on Windows, I'm inclined to think that this might be an issue with the IDE and has nothing to do with the xamarin sources, but lets get some extra info.

PS: You can find the specific info on VS for Mac -> "Visual Studio" menu, "About Visual Studio" item, "Show Details" button. Then simply use the copy button.

Yes, your summary is accurate, I apologize for not being more clear and not providing much info.
To answer your questions:

  1. The breakpoints have been set all over the iOS project, it does not matter where it is in the iOS project, it will not break. In the shared code it will break, but even stepping out back to iOS it will just run.

  2. I will attach my iOS project file

learnermobile.iOS.txt

  1. I can share the project privately with you, if you have a bitbucket account.

This issue has been happening since probably October or November. I am attaching the environment info in a file.
I really appreciate your feedback, thank you!

mac_vs_env.txt

Interesting, so, we have break points that are set in the iOS project that are part of your code and do not get loaded YET breakpoints in a shared dll are correctly stepped into.

Before we look into your application, which probably is not the culprit, do you have a small test case that does behave the same way? Can you use correctly the debugger in other simpler projects?

I have not been able to create a small test that does the same. This is an older project, created back in 2015, but has the most up to date packages and libraries. I can use the debugger just fine in sample projects that I create. I can even drop 'System.Diagnostics.Debugger.Break()' this in the iOS code and it will break.

Interesting, is there a way you could share the project?

If you have a bitbucket account I could share the project with you.

@nfritsche yes, please lets talk a about it via email so that I can get the project and debug the issue. [email protected]

We will update any information about the progress in this public issue.

Setting the bug to be in a future cycle and removing needs-info since I have received access to the private repo.

Assigning myself the bug since I have access to the project.

Hello,

I had some issues trying to compile the project, and rather than wasting time investigating I thought of asking you first, since you know the project and you might be able to give me some tips to get it to compile to move fwd the investigation. I get the following compiling issues:

/Users/mandel/Xamarin/issue-projects/learnermobile/packages/Xamarin.Forms.2.3.1.114/build/portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10/Xamarin.Forms.targets(3,3): Error MSB4018: The "XamlCTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not find file "/Users/mandel/Xamarin/issue-projects/learnermobile/iOS/obj/iPhoneSimulator/Debug/learnerMobileiOS.exe.mdb"
File name: '/Users/mandel/Xamarin/issue-projects/learnermobile/iOS/obj/iPhoneSimulator/Debug/learnerMobileiOS.exe.mdb'

Server stack trace:
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00259] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:274
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:149
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access) [0x00000] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/FileStream.cs:86
at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess)
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile.ReadSymbolFile (System.String mdbFilename) [0x00000] in :0
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile.ReadSymbolFile (System.String mdbFilename, System.Guid assemblyGuid) [0x00000] in :0
at Mono.Cecil.Mdb.MdbReaderProvider.GetSymbolReader (Mono.Cecil.ModuleDefinition module, System.String fileName) [0x00012] in :0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x00032] in :0
at Mono.Cecil.ModuleReader.CreateModuleFrom (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00042] in :0
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00028] in :0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000a] in :0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in :0
at Xamarin.Forms.Build.Tasks.XamlCTask.Compile () [0x001ca] in :0
at Xamarin.Forms.Build.Tasks.XamlCTask.Execute () [0x00007] in :0
at (wrapper xdomain-dispatch) Xamarin.Forms.Build.Tasks.XamlCTask.Execute(object,byte[]&,byte[]&)

Exception rethrown at [0]:
at (wrapper xdomain-invoke) Xamarin.Forms.Build.Tasks.XamlCTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:631
at Microsoft.Build.BackEnd.TaskBuilder+d__26.MoveNext () [0x00212] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:787 (MSB4018) (learnerMobile.iOS)

Any update on this?
Did you get it building by switching to dev branch?

Yes, I have the dev branch building. I'm going step by step through all the dlls to find the culprit and report it here. Sorry for the lack of feedback.

In order to have the debugger working in your project you can delete the following from the solution file:

 <PropertyGroup Condition=" '$(OS)' == 'Unix' ">
    <CscToolExe>mcs.exe</CscToolExe>
  </PropertyGroup>

There is no need to add anything. I have tested it locally and it works. Please let me know if this is a workaround you are willing to use.

This is amazing! I have lived with using inline breakpoints and console for debugging for the past 5 months. It works perfectly now, looking at the blame. It looks like I added this as a workaround for this bug.

Thanks for all your help!

Glad to help! Please do remember to remove me from the bitbucket project :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juepiezhongren picture juepiezhongren  路  3Comments

sharmashiv picture sharmashiv  路  4Comments

wcoder picture wcoder  路  3Comments

chamons picture chamons  路  4Comments

jzeferino picture jzeferino  路  3Comments