Bug 6976 - [Windows] When debugging, a breakpoint can not be attached to a line inside a anonymous delegate
Summary: [Windows] When debugging, a breakpoint can not be attached to a line inside a...
Status: RESOLVED DUPLICATE of bug 13354
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-09-07 05:42 UTC by Imgen Tata
Modified: 2013-07-29 12:33 UTC (History)
3 users (show)

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

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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 13354

Description Imgen Tata 2012-09-07 05:42:20 UTC
Description of Problem:
When debugging, a breakpoint can not be attached to a line inside a anonymous delegate, it will be replaced to the line next to the end of the anonymous delegate. 

Steps to reproduce the problem:
1. Debug MFA program
2. Try to add breakpoint in a anonymous delegate


Actual Results:
The breakpoint can not be attached to a line inside a anonymous delegate, it will be replaced to the line next to the end of the anonymous delegate.

Expected Results:
A breakpoint is rightfully added

How often does this happen? 
Always

Additional Information:
Comment 1 Mikayla Hutchinson [MSFT] 2012-09-07 11:07:03 UTC
What versions of MonoDevelop and MfA?
Comment 2 Imgen Tata 2012-09-07 11:34:50 UTC
All latest, MFA 4.2.5 beta, MD 3.0.4.5
Comment 3 Jeffrey Stedfast 2012-09-10 17:25:54 UTC
This seems to work fine for me w/ MonoDevelop 3.0.4.6 and MfA 4.2.5

I simply created a new MfA application project, built & ran it, then added a breakpoint on the line:

			button.Click += delegate {
=>				Console.WriteLine ("test");

				button.Text = string.Format ("{0} clicks!", count++);
			};

the breakpoint was applied to that location and when I clicked the button, it stopped on the CWL (and not the last line of the delegate).

If this doesn't work for you in MonoDevelop 3.0.4.6, can you give me an example of what isn't working for you?
Comment 4 Imgen Tata 2012-09-11 00:20:31 UTC
No. It's not OK with 3.0.4.6. Please, just create a new MFA app, use the default generated code. It's not OK.
Comment 5 Jeffrey Stedfast 2012-09-11 08:44:27 UTC
That's what I did, exactly as you described and it works for me.

The code snippet I pasted above was from the default generated code (other than the CWL). I tried with and without that CWL and it always works for me.

What does your delegate look like?
Comment 6 Imgen Tata 2012-09-11 09:41:57 UTC
I think we have some misunderstanding here, you missed the order
My original repro steps are:

Steps to reproduce the problem:
1. Debug MFA program
2. Try to add breakpoint in a anonymous delegate

Which means adding a breakpoint after we are in debug mode. This is not a weird corner case. This is actually very common.
Comment 7 Jeffrey Stedfast 2012-09-11 10:09:02 UTC
I tried it both ways and can't reproduce with either.

Are you debugging on the emulator (which is what I've been using) or with a device?
Comment 8 Imgen Tata 2012-09-12 04:50:53 UTC
No. It can't be. I have installed MonoDevelop on two PCs, and it's all behaving badly like I described. Although I'm using Windows 8 Release Preview and VS2012 RC on both PCs, but I don't think it's relevant, or is it?
Comment 9 Jeffrey Stedfast 2012-09-12 07:37:19 UTC
Windows might have something to do with it (and by that I mean the toolchain, not necessarily the OS itself). I'm on Mac OS X so that could explain why I haven't been able to reproduce this.
Comment 10 Mikayla Hutchinson [MSFT] 2012-09-12 14:03:59 UTC
On Windows, the Microsoft CSC compiler is used, which emits slightly different debug symbols.
Comment 11 Imgen Tata 2012-09-12 18:51:34 UTC
So this means we have to live with it? Or is it going to be fixed in the upcoming versions?
Comment 12 Jeffrey Stedfast 2012-09-12 22:19:59 UTC
No, it just means we might need to modify MonoDevelop to use slightly different logic on Windows.
Comment 13 Imgen Tata 2012-09-12 22:28:40 UTC
Cool. Thx.
Comment 14 Jeffrey Stedfast 2013-07-23 14:10:53 UTC
any chance we can get pdb2mdb to handle this?
Comment 15 Jeffrey Stedfast 2013-07-29 12:33:14 UTC

*** This bug has been marked as a duplicate of bug 13354 ***