Bug 2851 - Debugger should support multiple steps on one line
Summary: Debugger should support multiple steps on one line
Status: CONFIRMED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger (show other bugs)
Version: Trunk
Hardware: PC Windows
: Low minor
Target Milestone: ---
Assignee: David Karlaš
URL:
Depends on:
Blocks:
 
Reported: 2012-01-11 19:18 UTC by Mikayla Hutchinson [MSFT]
Modified: 2017-03-18 04:45 UTC (History)
5 users (show)

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


Attachments

Description Mikayla Hutchinson [MSFT] 2012-01-11 19:18:37 UTC
The debugger should support multiple steps on one line. This would be useful for things like for loops.

This will require changes in many places:
* mcs
* mdb format
* pdb2mdb
* soft debugger agent
* mono.debugging
* mono.debugging.soft
* monodevelop.debugger
Comment 1 Mikayla Hutchinson [MSFT] 2012-03-02 20:58:49 UTC
Let's get the ball rolling on this.

Marek, would it be possible to add the column information to mdb files without breaking the format?
Comment 2 Jeffrey Stedfast 2012-03-02 23:29:59 UTC
From what I could tell playing with the mdb stuff today, there is no column field. Just Row :-(

Or is Offset the column?
Comment 3 Marek Safar 2012-03-05 07:02:26 UTC
No, data is missing. I got some pointers from miguel how to implement it without breaking the format. I'll do it in mcs first.

What is actually missing is more than just column.

Current format has
ILOffset: Row

We need

ILOffset: StartRow, StartColumn, EndRow, EndColumn

This should also help to fix the adjustment bug for statements like

int
a
=
1;
Comment 4 Marek Safar 2012-06-13 10:22:43 UTC
Compiler can now write column info to MDB files. I have updated managed writer and reader.

I have also noticed that VS2012 no longer supports debugging selection. I could not find any note about why and decided not to implement extent info either, just start column.
Comment 5 Marek Safar 2012-06-13 10:23:29 UTC
Zoltan, could you implement runtime support for this
Comment 6 Mikayla Hutchinson [MSFT] 2012-06-13 12:04:31 UTC
What do you mean, "VS2012 no longer supports debugging selection"?

Why did you decide not to implement extents? That means we'll have to figure them out at runtime in order to figure out the range to determine and highlight the correct breakpoint for a given line/col position, and to show the position marker.
Comment 7 Marek Safar 2012-06-13 12:11:58 UTC
In VS2012 you won't see any highlighted range.

For example

int a = 1, b = 2;

in VS2012 you won't see where the breakpoint is set. You have to hover over (*) at the beginning of the line and the tooltip tells you column. I don't know why they done it but presumably there was a reason why extents are no longer supported in VS2012. That's why didn't implement it, it's quite tricky to do it 100% correct.
Comment 8 Mikayla Hutchinson [MSFT] 2012-06-13 13:38:49 UTC
Do you see location ranges when you pause/step?

It might be tricky for you do so it 100%, but it's even harder for MD :)
Comment 9 Marek Safar 2012-06-13 14:00:39 UTC
No, there are no ranges in VS2012.

stepping over

int
a
=
1;

selects single full row where int is (in VS2012). As I said I don't know why MS removed this features. The only reason I can think of is that it didn't work well with for anonymous methods/lambdas.
Comment 10 Mikayla Hutchinson [MSFT] 2012-06-13 14:34:07 UTC
What about stepping over the following two cases:

for (int i = 0; i < 10; i++) {
    Console.WriteLine (i);
}

foreach (var n in Enumerable.Range (1, 10).Where (i => i %2 == 0)) {
    Console.WriteLine (n);
}
Comment 11 Marek Safar 2012-06-13 15:17:49 UTC
VS2012 only sets cursor position but does not highlights anything. It's possible that something is wrong with my installation but I doubt.
Comment 12 Mikayla Hutchinson [MSFT] 2012-06-13 20:57:21 UTC
Then that's something we can do better than VS :)
Comment 13 Marek Safar 2012-06-14 03:11:16 UTC
right, so we are back at beginning where I said that I don't know why MS removed this features supported since VS2002 but I think they had a reason for that.
Comment 14 Zoltan Varga 2012-06-14 18:59:55 UTC
The column number info seems a bit off:

        for (int i = 0; i < 10; ++i) {
		}

Generates the following:

IL Line Column
X: 1 9 14
X: 8 9 38
X: 9 10 3
X: 10 9 33
X: 14 9 27
X: 22 11 3
X: 29 12 5

The for loop is at line 9.
Here i < 10 is at column 24 (1 based), but the column info contains 27.

Also, a line such as:
		object a = new object (),  b = new object ();
only has 1 line number entry.
Comment 15 Marek Safar 2012-06-15 13:29:24 UTC
This is now fixed
Comment 16 Mikayla Hutchinson [MSFT] 2012-06-15 18:29:25 UTC
Whether VS has a reason or not doesn't really matter if we don't know what it is. We should provide the best UX we can, and IMO for that we need to indicate the sequence point on which the breakpoint was inserted or execution is stopped. I'm not sure how we should do that, but the more info we have, the better.
Comment 17 Zoltan Varga 2012-06-15 20:06:19 UTC
Column numbers are now supported by sdb, i.e. Location.ColumnNumber returns a valid value instead of 0 if the runtime is new enough.
Comment 18 Jeffrey Stedfast 2013-01-09 15:04:05 UTC
MonoDeveloper's debugger now supports column info in breakpoints.

All that is left to do now is having the editor more accurately display which segment(s) on a line have a breakpoint and which statement is about to be executed.
Comment 19 Mike Krüger 2013-01-10 01:10:38 UTC
It's more or less a debugger issue - that's a plugin into the text editor. Text line markers can do 'anything' - display wise.
Comment 20 Jeffrey Stedfast 2013-01-10 12:22:17 UTC
it's not possible because it only provides API to change the background of the entire line, not a subset of the line.
Comment 21 Mike Krüger 2013-01-11 02:26:23 UTC
You need to calculate the position - see the underline text markers, they do the same.
It's a good chance to get used to the text editor API. If you need guidance just ping me in IRC.
Comment 22 Mikayla Hutchinson [MSFT] 2013-01-11 12:25:51 UTC
Mike, the debugger markers use GetStyle, instead of Draw, and GetStyle does not support ranges.
Comment 23 Mike Krüger 2014-04-18 07:47:00 UTC
It's not a limitation of the marker model ... markers can paint anything in or around text or change text styling.
Comment 24 Mike Krüger 2014-04-18 07:53:05 UTC
btw. for marking only a portion of the text I would recommend using a ITextSegmentMarker instead - that can span multiple lines as well.

It's like the gray out marker for the source analysis - it's using this marker instead of line markers.
Comment 25 Jeffrey Stedfast 2014-04-18 11:31:34 UTC
Hey, thanks Mike for pointing us in the right direction!
Comment 26 David Karlaš 2016-03-16 20:58:16 UTC
Btw, Highligthing segments instead of lines is already supported in XS...
If .mdb is created via pdb2mdb or Roslyn .ppdb format everything works as expected...
Lets wait few more months for migration from mcs to Roslyn compiler...
What will also have to change, XS will need to call StepInstruction instead of StepLine...
Comment 27 xamarin-release-manager 2017-03-17 16:38:45 UTC
Fixed in version 7.0.0.1878 (a11y)

Author: Jeffrey Stedfast
Commit: d1bb11681ea25191708a931f08a33f462db2bc00 (mono/debugger-libs)
Included in Commit: 815ccb4069c0e92b8db7231e8090f18556ea4e61 (mono/monodevelop)

Note You need to log in before you can comment on or make changes to this bug.