开发者

In the Visual Studio debugger, you can view special 'variables' beginning with '$'. What are they?

开发者 https://www.devze.com 2023-01-08 03:48 出处:网络
For instance, write a function such as: void foo() { try { throw new Exception(@\"whatever\"); } catch { int n=1; //put a breakpoint here

For instance, write a function such as:

void foo()
{
    try
    {
        throw new Exception(@"whatever");
    }
    catch
    {
        int n=1; //put a breakpoint here
    }
}

When the debugger is on the line in the catch block, typing $exception will show the exception information.

Are there any more? What are these things? There seems to be no official documentation on them. I've used $exception for quite a while, but was 开发者_运维知识库hoping there were others that, for example, would show the return value of a method.


These are variables created by the debugger for your convenience. You get similar variables if you use the Immediate window: int x = 10;

would result in $x in the locals window


More of the special variables are described in this article. There's also a comprehensive list of the variables available in windbg - not sure how many are supported in VisualStudio though

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号