调试时如何在Visual Studio内存窗口中显示局部变量 [英] How to display a local variable in Visual Studio Memory Window while Debugging

查看:1838
本文介绍了调试时如何在Visual Studio内存窗口中显示局部变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我想调试C#中的一些二进制文件,尤其是整数(uint,int,ushort等)-变量或字节数组.
对于这种情况,如果我可以显示数据如何存储在内存中,那就太好了.

我已经发现了内存视图,但是只能通过在地址字段中键入变量名称来跳转到引用类型(如类实例).
如何在不使用Disassembly-window手动计算地址的情况下转到局部变量(如int或short)?
反汇编窗口读取的内容类似于"dword ptr [ebp-40h],1267Dh"-因此我需要的地址是ebp-40h(这可以正常工作,但是非常麻烦).
当我插入整数的变量名时,内存视图会选择整数作为指针,而不会跳转到值本身存储的位置.

问候,
Henning

Hello!

I want to debug some binary stuff in C#, especially integer (uint, int, ushort etc.)-variables or byte-arrays.
For this case it would be great, if I could display how the data is stored in memory.

I already discovered the memory view, but it is only possible to jump to reference-types (like class-instances) by typing the variable name into the address field.
How can I go to local variables (like int or short) without calculating the address manually with the Disassembly-window?
The disassembly windows reads something like "dword ptr [ebp-40h],1267Dh" - so the address I need is ebp-40h (this works, but is very cumbersome).
When I insert the variable name of an integer, the memory-view picks up the integer as pointer and doesn''t jump to the place where the value itself is stored.

Greetings,
Henning

推荐答案

只需键入该变量的名称,VS就会从该变量开始的地方开始显示内存.
Just type a name of that variable and VS will display memory starting from where that variable begins.


1.在Visual Studio(VS)中,在要更改值的变量的值更改后创建一个断点.这将使调试器在那里停止,并允许您查看该局部变量的值

2.在VS中,在调试器停止要查看值的位置之后,可以通过两种方法查看本地变量的值.
一个.右键单击变量,然后添加到监视==>该值将显示在监视"窗口中
b.您只需将光标移动到变量的顶部,就可以查看变量的值.

注意:如果局部变量是一个对象,则可以通过单击变量前面的+号来查看该对象的所有公共,私有成员变量.
1. In Visual Studio (VS), make a break point after the value change for your variable you want to view the value. This will make the debugger stop there and allow you to see the value for that local variable

2. in VS, After the debugger stop where you want to see the value, there are two ways to see the value for your local variable.
a. Right click on the variable and Add to Watch ==> The value will be displayed in the Watch Windows
b. You can just move your cursor on top of the variable, and you would be to view the value for your variable.

Note: if the local variable is a object, you would be able to see all the public, private member variables of your object via clicking on the + sign in front of your variable.


这篇关于调试时如何在Visual Studio内存窗口中显示局部变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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