Bug 813 - Enable "Run to Cursor" when debugging
Summary: Enable "Run to Cursor" when debugging
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Debugger ()
Version: 2.8 Alpha 2
Hardware: PC Mac OS
: Low enhancement
Target Milestone: ---
Assignee: Bugzilla
: 4035 15383 ()
Depends on:
Blocks: 4035
  Show dependency tree
Reported: 2011-09-14 13:37 UTC by Chris Hardy [MSFT]
Modified: 2014-04-17 18:22 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 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 Chris Hardy [MSFT] 2011-09-14 13:37:47 UTC
Debugging; right click on text menu in editor option "Run to Cursor" so it executes upto the where the cursor is (typically where one right clicks)
Comment 2 michael 2011-09-14 14:01:32 UTC
Thanks for posting chris, I used the feedback option in Mono Develop not knowing of this bugzilla repository.  When executing, it should stop at the next breakpoint if it it's hit before arriving to the desired position.
Comment 3 Mikayla Hutchinson [MSFT] 2011-09-14 15:31:11 UTC
I guess this pretty much involves adding a temporary breakpoint that's removed when any breakpoint is hit.
Comment 4 michael 2011-09-14 16:04:54 UTC
that sounds like the generalized solution; if the cursor is in a location which cannot have a breakpoint (ex. a blank line between statements) then a simple dialog should appear saying "Cannot run to that location, choose a valid break point area".
Comment 5 Mikayla Hutchinson [MSFT] 2011-09-14 16:27:16 UTC
We can't really verify whether a location is valid for a breakpoint until the project has been built in that configuration. Instead, you get a breakpoint resolution warning when the type in loaded. We could probably special-case these breakpoints so that if they failed to resolve, we'd instead insert one in the closest possible location.
Comment 6 michael 2011-09-14 16:47:39 UTC
I have concerns of the closest location possibly annoying and not conforming to a good user experience.  While in most cases it would be a line above or below, it's will not appear to be to the cursor and the line could actually be many lines apart in the cases of comments, documentation, etc.   Even a few lines off, while deterministic from an implementation standpoint, may feel non-deterministic to the user who may expect otherwise.

I'm currently neive to the mono develop architecture, but perhaps a different approach would be comparing line location with the debugging metadata.

In the original approach, if nearest were to be applied, then nearest above would be strongly preferred to avoid executing a line inadvertently below the cursor.
Comment 7 Mikayla Hutchinson [MSFT] 2011-09-14 17:26:23 UTC
It's not that simple. Firstly, in order to have debugging metadata, the project has to have been built in that configuration. Since we don't have a background compiler, that means you'd have to build before you could use the 'run to this location' command, which would be really cumbersome. Secondly, debugging metadata only provides mappings of line numbers to IL offsets, and not every IL offset is guaranteed to be a valid location for a breakpoint or stepping, since that depends on implementation details of the runtime and debugger. The best we could reliably do in advance is to filter out the really obvious ones (blank lines etc).

If you consider this problem applied to breakpoints in general, it's harder, since breakpoints' validity could change as other code in the file changes. The only really reliable way is to trigger a warning at runtime when a breakpoint fails to resolve.

The reason I suggested inserting the temporary breakpoint in the closest location is because I think that'd provide the best user experience. Stopping a couple of lines too early is much more useful than just continuing on and issuing a warning. I'd almost go so far as to suggest we do this for all breakpoints.
Comment 8 michael 2011-09-14 17:58:22 UTC
sounds fair; thanks for the details.  Running to desired point is useful enough to warrant some solution and under the circumstances described is stopping on the last line available on or before the cursor would be the better user experience
Comment 9 Mike Krüger 2013-02-14 03:57:40 UTC
*** Bug 4035 has been marked as a duplicate of this bug. ***
Comment 10 Mikayla Hutchinson [MSFT] 2013-10-14 14:11:09 UTC
*** Bug 15383 has been marked as a duplicate of this bug. ***
Comment 11 Rodrigo Kumpera 2013-10-14 14:14:30 UTC
Can we, pretty please, implement this?
Comment 12 Jeffrey Stedfast 2014-04-17 18:22:17 UTC