Bug 3181 - Step into from static initializer jumps to invalid location
Summary: Step into from static initializer jumps to invalid location
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: Trunk
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2012-02-01 12:41 UTC by Marek Safar
Modified: 2012-02-03 07:25 UTC (History)
2 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 Marek Safar 2012-02-01 12:41:07 UTC
class C
{
	static C ()
	{
	}
}

class C1
{
	static int a = 55;
}

class C2
{
	static int a = 55;   // SET a breakpoint here and F11
	
	static C2 ()
	{
	}
}

class Test
{
	public static void Main ()
	{
		new C2 ();
	}
}


MD debuggers jump to instance constructor instead of static constructor when debugging static initializers

NOTE: You need master mcs to get valid sequence point info in mdb
Comment 1 Mikayla Hutchinson [MSFT] 2012-02-02 14:10:35 UTC
Since the static constructors are empty, perhaps they are optimized away?
Comment 2 Marek Safar 2012-02-02 14:12:29 UTC
The constructor is not empty, when the breakpoint is hit you are already inside the constructor
Comment 3 Zoltan Varga 2012-02-03 05:26:20 UTC
Single stepping was completely broken in head, not sure why nobody run into this before. It should be fixed now. However, the mcs line number info seems to be off, if I single step twice from that breakpoint, md shows line 1 as the pc location.
Comment 4 Marek Safar 2012-02-03 05:29:26 UTC
mcs line number is correct. It's probably MD or debugger issue and that's what this bug is about.
Comment 5 Zoltan Varga 2012-02-03 05:34:02 UTC
I mean if you step from the static .cctor twice, the stack trace shows the normal .ctor as it should, but md shows line 1 as the pc.
Comment 6 Marek Safar 2012-02-03 06:19:29 UTC
Here is updated test after runtime changes

class C
{
    static C ()
    {
    }
}

class C1
{
    static int a = 55;
}

class C2
{
    static int a = 55;

    static C2 ()
    {
    }     // SET a breakpoint here and F11, IP jumps to line 1
}

class Test
{
    public static void Main ()
    {
        new C2 ();
    }
}
Comment 7 Zoltan Varga 2012-02-03 06:52:01 UTC
Here is what the debugger prints as the line number table:

Line number table for method C2:.ctor ():
IL0 -> 1

This is the info returned by mono_debug_symfile_get_line_numbers (), so this is what the .mdb file contains.
Comment 8 Marek Safar 2012-02-03 06:56:25 UTC
Zoltan, please try this is master mcs.

There is no user instance constructor and master mcs does not generate any sequence points for it. If this is with master mcs I am not sure where you are getting it from as the array is empty for me
Comment 9 Zoltan Varga 2012-02-03 07:25:25 UTC
Fixed in HEAD.