Bug 21410 - Single Stepping over complex method call behaves as run instead of single step
Summary: Single Stepping over complex method call behaves as run instead of single step
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: 3.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Alexander Kyte
Depends on:
Reported: 2014-07-17 17:39 UTC by Jeff Greene
Modified: 2017-05-23 05:54 UTC (History)
6 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 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:

Description Jeff Greene 2014-07-17 17:39:53 UTC
https://gist.github.com/anonymous/6bdd32ed8dffdca23604 contains the activity class for an android application but the important part is in the method bla()

doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);

in order to repro this there must be at least 2 castclass instructions in the call setup.

in the source from the gist, if you set a breakpoint on the first call to doStuff then single step past it, the debugger will leave the method entirely.
Comment 1 Udham Singh 2014-07-22 05:59:14 UTC
We have tried to reproduce this issue and observed that this is working fine as expected, when we debug the code(using Step Over and Step Into). I have tried the steps mentioned below.

1. Create a simple android application.
2. Implement code provided in bug description.
3. Run and debug the application.

Screencast : http://www.screencast.com/t/YJXE5cax8c

Please let me know if I am on different page for this issue.
Also could you please provide your environment information and let me know if I missed anything.

Environment Info : 

=== Xamarin Studio ===

Version 5.1.4 (build 0)
Installation UUID: 312d4e9a-339c-433f-a27b-88ce0777af8f
	Microsoft .NET 4.0.30319.34014
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.25

=== Xamarin.Android ===

Version: 4.12.6 (Enterprise Edition)
Android SDK: D:\SDK\AndroidSDK
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode)

=== Build Information ===

Release ID: 501040000
Git revision: 7d45bbe2ee22625f125d0c52548524f02d005cca
Build date: 2014-07-14 13:38:46-04
Xamarin addins: c78f1d88e57baa928aeee1484d96e6f8edf8de33

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Jeff Greene 2014-07-22 12:16:28 UTC
in the video it looks like you've put breakpoints on all of the lines, that doesnt test single step, thats just testing breakpoints which as you can see work just fine. Please only set one breakpoint on the first call to doStuff then single step should take you directly to the line below it without stopping anywhere else, it instead skips over all of the other calls to doStuff
Comment 3 Jeffrey Stedfast 2014-07-24 17:45:31 UTC
David Karlas was able to repro
Comment 4 David Karlaš 2014-07-24 17:53:41 UTC
Udham, can you try to reproduce by removing breakpoints on every line?
Comment 5 Udham Singh 2014-07-25 07:07:51 UTC
Thanks Jeff and David

I have checked this issue again and able to reproduce this issue. Here is the screencast : http://www.screencast.com/t/DOJ5hZHf

Environment Info :

Windows 8.1
Xamarin Studio : 5.1.4 (build 0)
Xamarin.Android : 4.12.6 (Enterprise Edition)
Comment 6 Jeffrey Stedfast 2014-08-05 15:12:32 UTC
This seems to be a bug in the runtime. When I StepOver, the SoftDebuggerSession gets notified of a StepOver event completing and the top frame is back in Main() at the Console.WriteLine() instead of at the second line in blah().

Here's a simpler test case for a standard ConsoleApp:

using System;

namespace DebuggerStepping
	internal interface willy

	internal class snarf

	internal class flap : snarf, willy

	internal class point
		public string acme = "";
		public snarf lst = new flap();

	internal class zork
		public point point = new point();

	internal class narf
		public zork zork = new zork();

	class MainClass
		static int count = 1;
		static narf _narf = new narf();

		public static void Main (string[] args)

			Console.WriteLine ("Hello World!");

		static void bla()
			doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);  // place a breakpoint on this line and then hit StepOver
			doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);
			doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);
			doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);
			doStuff(_narf.zork.point.acme, _narf.zork.point.acme, (willy)_narf.zork.point.lst, _narf.zork.point.acme, (willy)_narf.zork.point.lst);

		static void doStuff(string str, string str2, willy lst, string str3, willy lst2)

Comment 7 Zoltan Varga 2014-11-18 23:06:38 UTC
Thanks for the testcase. This is because of the < 5 in collect_pred_seq_points () in mini.c.
Comment 8 David Karlaš 2017-05-23 05:54:59 UTC
This was fixed with https://github.com/mono/mono/commit/85d318b725a78c9d81cd01a52a80e573a300b6ec