Welcome to MSDN Blogs Sign in | Join | Help

Stop Mid Func Eval, Nested Break States

A coworker mentioned Func Eval sounds like "Funky-val".  Stopping at a breakpoint in the middle of a function evaluation could be considered funky.  It is also useful.

 

VS Whidbey allows stopping at a BP or Exception during a function evaluation in C# or VB code.  To use it, you need to do the function evaluation from the 'Immediate Window', rather than the 'Watch', or 'Quick Watch' windows. 

 

Why is nesting restricted to the Immediate Window?  Despite the name, the Immediate window is not immediate.  Watch windows do synchronous Function evaluation.  If the evaluation takes too long, it will timeout and give an error.  That doesn't happen in the immediate window, because it is infinitely patient.  The immediate window is implementing a REPL (Read Eval Print Loop).  However, it doesn't bother to wait for the Eval & Print to finish, instead it executes an asynchronous func eval. The 'Print' is going to happen whenever the Eval gets done, which allows us to do the Nested Break States.  Here's an example:

 

static bool Foo()

{

return false;

}

 

In the immediate window evaluate Foo 3 times:

?Foo()

?Foo()

?Foo()

 

Here is the Callstack:

NestedFuncEval

 

 

When I unrolled the set of Evaluations by hitting F5 three times, here is what I got in the immediate Window:

?Foo()

?Foo()

?Foo()

false

false

true

 

You might ask … why is the last one true?  It's because I used Edit and Continue to change the return value to true before hitting F5 the third time.  Nested Func Eval allows you to literally "push a debug task" on the stack.  Once you've figured out why Foo was doing something wrong you can go back to debugging what you were looking at before.
 

Published Sunday, October 23, 2005 6:07 PM by SteveJS
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# What does a debugger author need to do to support func-eval?

I've mentioned func-eval (aka property eval) is evil for end-users; but it's also evil if you want to...
Sunday, March 05, 2006 12:47 PM by Mike Stall's .NET Debugging Blog

# Blog Category for Func-eval

I created a blog category for Func-eval (aka Property Evaluation), and I updated some of my old...
Sunday, March 05, 2006 12:48 PM by Mike Stall's .NET Debugging Blog

# » Stop Mid Func Eval, Nested Break States MSDN Blog Feed

Wednesday, January 16, 2008 4:21 AM by » Stop Mid Func Eval, Nested Break States MSDN Blog Feed

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker