Bug 5145 - Breakpoints in if statements in delegates do not break during debugging
Summary: Breakpoints in if statements in delegates do not break during debugging
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2012-05-17 12:48 UTC by PJ
Modified: 2012-06-13 16:11 UTC (History)
4 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 Developer Community or GitHub 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 FIXED

Description PJ 2012-05-17 12:48:23 UTC
We have a debugging test case that runs multithreaded breakpoint testing. One of the tests has the tester set breakpoints on lines in a delegate. The test is not successful, as the breakpoint is not hit.

Cast:
http://screencast.com/t/4NDmVW08ckJ


App: github.com/xamarin/QualityAssurance/TestCaseCode/MonoTouchDebugging. 

Relevant Code:
		private void Test2()
		{
			Action threadOne = delegate { 
				for(;;) 
				{ 
					Get ();
					if(m_ChangeMe >= 100) 
						break; // BPLOC
				} 
			};
			Action threadTwo = delegate { 
				for(;;) 
				{
					Set (); 
					if(m_ChangeMe >= 100) 
						break; // BPLOC
				} 
			};
		
			var t1 = new Thread(new ThreadStart(threadOne));
			var t2 = new Thread(new ThreadStart(threadTwo));
			t1.Start();
			t2.Start();
			t1.Join();
			t2.Join();
		}


Some lines are identified correctly by the debugger - if I change the breakpoints to 'Set();' and 'Get();', the debugger stops on the breakpoints correctly.

If I remove the if statement, the break occurs as expected: http://screencast.com/t/LySkMCNHUsh


To reproduce:

1) debug the app
2) run the MultiThreadedBreakpoints test. 
3) you can skip the first set of breakpoints (or run both tests if you'd like)
4) Run the second MultiThreaded test as the app instructs.


Expected behavior:
Debugger will stop on the line I set a breakpoint on.

Actual result:
Application does not stop on the breakpoints.

 (Instructions are all included inside the app to run the test).
Comment 1 Jeffrey Stedfast 2012-06-04 16:15:29 UTC
This is a compiler bug...

there is no line-number information anywhere between line 123 and 131, so the entire delegate does not any ANY line number info in the .mdb file.
Comment 2 Marek Safar 2012-06-07 07:56:11 UTC
There are sequence points for every single line but runtime does not break.

Here is proper repro

using System;
using System.Collections.Generic;

class Program
{
	int m_ChangeMe = 444;

	void Get ()
	{
	}

	void Test (object o, IEnumerable<int> aa)
	{
		Action threadOne = delegate { 
			for (;;) { 
				Get ();
				if (m_ChangeMe >= 100) 
					break; // Set a breakpoint here
			} 
		};

		threadOne ();
	}

	static int Main ()
	{
		new Program ().Test (new object (), new [] { 12 });
		return 0;
	}
}
Comment 3 Zoltan Varga 2012-06-11 17:43:17 UTC
This seems more like an md issue, md never sets a breakpoint with sdb.
Comment 4 Zoltan Varga 2012-06-12 06:30:58 UTC
-> md for now.
Comment 5 Zoltan Varga 2012-06-12 06:52:58 UTC
This happens because of this line in SoftDebuggerSession:GetLocFromType ():

			if (target_loc != null && fuzzy && CheckBetterMatch (type, file, line, target_loc)) {
				insideTypeRange = false;
				return null;
			}
Comment 6 Jeffrey Stedfast 2012-06-13 16:11:32 UTC
fixed in git master & 3.0.3 branch