Bug 4432 - breakpoint placed on single-line if statement is triggered only after condition evaluates to true
Summary: breakpoint placed on single-line if statement is triggered only after conditi...
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: unspecified
Hardware: PC Linux
: Low enhancement
Target Milestone: ---
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2012-04-13 19:55 UTC by Csaba Halász
Modified: 2012-04-27 17:18 UTC (History)
2 users (show)

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:

Description Csaba Halász 2012-04-13 19:55:19 UTC
Given this test case:

namespace TestApp
	public class MainClass
		public static void Main(string[] args)
			if (args == null) return;

If you set a breakpoint on the line with the "if", it won't be hit.
If you split the line in two, like:

			if (args == null) 

Then a breakpoint on the condition will be hit, as expected.
If you use a function call in the condition, you can see that the breakpoint is only triggered after the condition has been evaluated as true.

I would expect the breakpoint to be hit before the condition is evaluated.
Comment 1 Jeffrey Stedfast 2012-04-24 14:01:13 UTC
The way breakpoints work is that they are set on the last instruction on the line, that's why it doesn't get hit.

Once Mono 2.12 is released and everyone is using that, we can start to look into supporting line & column positioning for breakpoints (assuming the compiler is fixed to provide that information... currently it does not).
Comment 2 Csaba Halász 2012-04-24 18:47:47 UTC
That's interesting because if the condition is on a separate line, the breakpoint happens before the expression is evaluated, that is clearly not the last instruction, is it?

        static string Test()
            return null;
	public static void Main(string[] args)
            if (Test() != null)

With this, after the breakpoint is hit I can step into the Test().
Comment 3 Jeffrey Stedfast 2012-04-27 17:18:15 UTC
the debugger sets the breakpoint at the last IL Offset on the line

in any case, I've been rethinking this logic (the original logic has existed since before I took over the debugger and the code in question had a huge comment saying that it was necessary to use the last ILOffset of the line (and wrap onto the next line if the ILOffsets are the same) because that's where the runtime debugger would stop.

This seems to no longer be true, the soft debugger seems to have been improved since the original code/comment was written and no longer reflects reality.