如何在Visual Studio中读取调试内存窗口 [英] How to read the debug memory window in Visual Studio

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

问题描述

我以前在Visual Studio中使用过调试模式,但我从未使用过内存窗口.如果我有一个简单的应用程序来计算a = b + c并令b = 8和c = -2,该如何在不使用监视的情况下在内存窗口中找到地址a,b和c及其值?

I have used debug mode in Visual Studio before, but I never had to use the memory window. If I had a simple application that calculates a=b+c and made b =8 and c=-2, how can I find the addresses a, b, and c in memory window and their values without using watches?

当我尝试时,我看到了很多胡言乱语",这些我都不太理解.这是屏幕截图:

When I tried, I saw tons of "gibberish" that I cannot make much sense of. Here's a screenshot:

如果我想做同样的事情,但是在Linux环境中,我该如何实现呢?

If I wanted to do the same, but in a Linux environment, how could I achieve this?

推荐答案

在Visual Studio中查找变量地址的一种方法是使用QuickWatch窗口(如果您不知道热键,则在调试菜单下, Ctrl + Alt + Q ).如果键入&a,它将显示变量a的地址.然后,您可以在内存窗口中输入该地址.或者,您可以只在内存窗口中输入&a.

One way to find the address of a variable in Visual Studio is to use the QuickWatch window (under the debug menu if you don't know the hot key, Ctrl + Alt + Q). If you type &a, it will display the address of variable a. You can then enter that address in the memory window. Or you could just enter &a in the memory window.

但是要查看带有内存窗口的所有变量,它们必须位于彼此的几个字节之内,因为它显示了连续的内存.对于堆栈上的局部变量,通常不会出现问题.对于整数变量,通过右键单击内存窗口并更改布局(例如,选择带符号显示的4字节整数),可以更轻松地以可读格式查看它们.

But to see all variables with the memory window, they would need to be within a few bytes of each other since it shows contiguous memory. For local variables on the stack, that would not usually be a problem. For integer variables, you can more easily view them in a readable format by right clicking on the memory window and changing the layout (for example, choose 4-byte integers with a signed display).

说了这么多,似乎使用监视窗口会容易得多,因为所有内容都已经被很好地标记了,并且很容易分辨出哪个值与哪个变量相关联.

Having said all that, it seems like it would be much simpler to use the watch window since everything is labeled nicely already and it is easy to tell which value is associated with which variable.

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

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