Bug 39345 - "Just My Code" fails to let the debugger skip exceptions that are thrown and caught entirely within external libraries (when the debugger is set to break on all thrown CLR exceptions)
Summary: "Just My Code" fails to let the debugger skip exceptions that are thrown and ...
Status: CONFIRMED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: Normal normal
Target Milestone: 15.6
Assignee: Joaquin Jares
URL:
Depends on: 39371
Blocks:
  Show dependency tree
 
Reported: 2016-03-04 03:01 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2017-08-23 20:09 UTC (History)
8 users (show)

Tags: papercut
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (235.37 KB, application/zip)
2016-03-04 03:01 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Break on all thrown exceptions, VS 2015 (14.22 KB, image/png)
2016-03-04 03:07 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Just My Code, VS 2015 (57.45 KB, image/png)
2016-03-04 03:08 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Break on all thrown exceptions, VS 2013 (29.54 KB, image/png)
2016-03-04 03:08 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Just My Code, VS 2013 (57.35 KB, image/png)
2016-03-04 03:09 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 39345 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
CONFIRMED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-03-04 03:01:49 UTC
Created attachment 15251 [details]
Test case

"Just My Code" fails to let the debugger skip exceptions that are thrown and caught entirely within external libraries (when the debugger is set to break on all thrown CLR exceptions)

This problem affects both Visual Studio and Xamarin Studio. I suspect the fix might be slightly different for each IDE, so I will file 2 separate bugs.

This also might be a tricky problem to solve if the soft debugger does not currently provide enough context about the exception to the IDEs to make this possible.




## Regression status: not a regression

> BAD: XamarinVS 99.0.0.1562 (a9dd59b) + Xamarin.iOS 9.7.0.334 (a8da28f) (Cycle 7 Alpha 1 preview)
> BAD: XamarinVS 3.11.1594.0 (a06d6d5) + Xamarin.iOS 9.1.0.27  (1f068b4) (Cycle 5 – Service Release 5)




## Setup steps for Visual Studio 2015

1. Under "Debug -> Windows -> Exception Settings", click the checkbox for "Common Language Runtime Exceptions" until the checkbox displays a check mark. (See the attached screenshot for "Break on all thrown exceptions, VS 2015".)

2. Enable the "Tools -> Options -> Debugging [heading] -> General [sub-heading] -> Enable Just My Code" checkbox. (See the attached screenshot for "Just My Code, VS 2015".)




## Setup steps for Visual Studio 2013

1. Under "Debug -> Exceptions", enable the "Thrown" checkbox for "Common Language Runtime Exceptions". (See the attached screenshot for "Break on all thrown exceptions, VS 2013".)

2. Enable the "Tools -> Options -> Debugging [heading] -> General [sub-heading] -> Enable Just My Code" checkbox. (See the attached screenshot for "Just My Code, VS 2013".)




## Steps to test

1. Unzip the attached test case.

2. If you have cleaned or manually deleted the `bin\Release` folder for the "PortableClassLibrary1" PCL project, build the "PortableClassLibrary1" project in the Release configuration. (The other projects use a direct `.dll` reference to that library as an example of a "not my code" assembly. The Release configuration for the PortableClassLibrary1 project enables compiler optimizations and disables all debugging information [1].)

3. Debug the "NativePortable1.Console", "NativePortable1.Droid", or "NativePortable1.iOS" project in the "Debug|AnyCPU", "Debug|AnyCPU", or "Debug|iPhoneSimulator" configuration, respectively.

4. A dialog window might appear to warn you that "You are debugging a Release build of PortableClassLibrary1.dll". If you see that dialog you can select "Continue Debugging".



[1] For additional information see "To distinguish user code from non-user code, Just My Code looks at open projects, symbol (.pdb) files, and program optimizations.", on:
https://msdn.microsoft.com/en-us/library/dn457346%28v=vs.120%29.aspx




## Expected result (as demonstrated by the console C# application)

The debugger does not break on any exceptions. (In the case of the console C# app, the app simply runs to completion and then closes.)




## Actual result

In all test scenarios other than the console C# application, the debugger breaks on the exception from `Class1.Foo()`.


### Test scenarios that show this "bad" behavior

VS 2013 + NativePortable1.Droid
VS 2013 + NativePortable1.iOS

VS 2015 + NativePortable1.Droid
VS 2015 + NativePortable1.iOS

(Note: in exactly 1 of my trials (out of maybe 20 total) Visual Studio did not break on the exception in the Android sample. I expect this was simply a funny little timing issue or perhaps a result of some stale files that I forgot to clean when switching test environments.)
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2016-03-04 03:07:53 UTC
Created attachment 15253 [details]
Break on all thrown exceptions, VS 2015
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2016-03-04 03:08:15 UTC
Created attachment 15254 [details]
Just My Code, VS 2015
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2016-03-04 03:08:44 UTC
Created attachment 15255 [details]
Break on all thrown exceptions, VS 2013
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-03-04 03:09:09 UTC
Created attachment 15256 [details]
Just My Code, VS 2013
Comment 7 Miha Markic 2017-07-24 12:57:06 UTC
Add VS2017 15.2 to the list.
Comment 8 Miha Markic 2017-07-24 13:06:21 UTC
BTW, this is highly annoying.
Comment 9 Joaquin Jares 2017-08-23 14:15:13 UTC
This is blocked on this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=39371. We need that to be fixed before we can fix this. Pushing internally.