Visual Studio中“调用堆栈"窗口的目的是什么? [英] What is the purpose of the Call Stack window in Visual Studio?

查看:231
本文介绍了Visual Studio中“调用堆栈"窗口的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio中调用堆栈"窗口的用途是什么?

What is the purpose of the Call Stack window in Visual Studio?

推荐答案

每次调用方法时,该线程的堆栈"上都会有一个条目,描述该方法和用于调用该方法的参数.当方法返回时,该方法及其参数将从堆栈中删除.这就是操作环境如何知道方法完成时返回的位置.它只是从堆栈中删除顶部条目,清除在该堆栈帧期间创建的所有局部变量,然后返回上一个方法. (这已经过简化,但总的来说是这样.)

Each time you call a method, an entry is place on the "stack" for that thread describing the method and the parameters used to call the method. When the method returns, the method and it's parameters are removed from the stack. That's how the operating environment knows where to return when a method finishes. It just removes the top entry from the stack, cleans up any local variables that were created during that stack frame, and returns to the previous method. (That's over simplified, but generally the idea.)

您可以从字面上将其视为使您到达此处的指令的堆栈".

You can think of it literally as a "stack" of the instructions that got you here.

这就是操作环境的意义.

That's what it means to the operating environment.

对开发人员来说,实际的目的是帮助您了解程序为何处于其状态.无论何时,程序的执行在调试器中停止,无论是通过断点还是引发异常(取决于Visual Studio), Studio设置),您将可以访问当前堆栈.请记住,此堆栈不会显示到目前为止已调用的所有方法.从堆栈中删除所有完成的方法.这不是日志.

To the developer, the practical purpose is to help you understand why your program is in the state it is in. Whenever execution of the program stops in the debugger, either by breakpoint or by an exception being thrown (depending on your Visual Studio settings), you will have access to the current stack. Remember that this stack doesn't show ALL methods that have been called up to this point. Any method that completed was removed from the stack. It's not a log.

您可以双击堆栈中的任何条目以转到该源代码(如果您的计算机上可用).在此期间,您可以检查局部变量等.它是一种侦探工具,可以帮助您弄清到目前为止程序中发生了什么.

You can double click on any of the entries in the stack to go to that source code (if it's available on your machine). While you're there, you can inspect local variables, etc. It's a kind of detective tool to help you figure out what has happened in your program up to this point.

这篇关于Visual Studio中“调用堆栈"窗口的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆