大家指点下VS中调试的监视、内存窗口的技巧

C++语言 码拜 7年前 (2017-05-08) 5060次浏览
         最近在开发的时候调试问题,发现本人的调试技术简直是渣的要死,羞愧难当。监视窗口的变量不是很明显的告诉你,压根就看不懂大家指点下VS中调试的监视、内存窗口的技巧,监视窗口的变量表达式又不会用~ 大家指点下VS中调试的监视、内存窗口的技巧 至于内存窗口、。、本人也是醉了、、、大家指点下VS中调试的监视、内存窗口的技巧
无颜以对江东父老。求给高手拯救下本人这个调试的小菜B。帮忙推荐下调试的,尤其是监视和内存窗口的使用技巧,资料和书都行~~感激不尽~大家指点下VS中调试的监视、内存窗口的技巧
解决方案

10

网上搜教程,然后多联系,入门一个东西总是需要时间的积累的

10

看一个指针数组, 例如
int a[5];
int *p = a;
可以 p,5

10

没什么特别的吧:
断点进去的时候 把想要的变量选中 拖到监视里面 就是了  手写也可以的  当然了  有些 例如指针 是看不到值的
鼠标移动到上面的时候得到的是内存值 把这个值复制到内存窗口里面  回车一下 能看到该内存块的值

15

断点调试的时候选中要查看内容的变量或表达式,甚至有返回值的函数.
例如 (pMsg->wParam), 右键–>快速监视, 或Shift+F9即可实时查看, 拖拽到”监视”窗口也可.
内存需要在断点状态下, 鼠标悬停显示十六进制内存地址, 复制粘贴到内存窗口, 然后回车可见, 分析内存是调试中不怎么常用的技巧, 一般发生问题最常用的是”调用堆栈”

20

查MSDN是Windows程序员必须掌握的技能之一。
Symbols for Watch Variables
Home Page (Debugger) |  Overview |  How Do I… Topics
You can change the display format of variables in the QuickWatch dialog box or in the Watch window using the formatting symbols in the following table.
Symbol Format Value Displays
d,i signed decimal integer 0xF000F065 -268373915
u unsigned decimal integer 0x0065 101
o unsigned octal integer 0xF065 0170145
x,X Hexadecimal integer 61541 (decimal) 0x0000F065
l,h long or short prefix for: d, i, u, o, x, X 00406042,hx 0x0c22
f signed floating-point 3./2. 1.500000
e signed scientific notation 3./2. 1.500000e+000
g signed floating-point or signed scientific notation, whichever is shorter 3./2. 1.5
c Single character 0x0065 “e”
s String 0x0012fde8 “Hello world”
su Unicode string  “Hello world”
st Unicode string or ANSI string, depending on Unicode Strings setting in autoexp.dat.
hr HRESULT or Win32 error code. 0x00000000L S_OK
wc Window class flag. 0x00000040  WC_DEFAULTCHAR
wm Windows message numbers 0x0010 WM_CLOSE
To use a formatting symbol, type the variable name, followed by a comma and the appropriate symbol. For example, if var has a value of 0x0065, and you want to see the value in character form, type var,c in the Name column on the tab of the Watch window. When you press ENTER, the character-format value appears:
var,c = “e”
You can use the formatting symbols shown in the following table to format the contents of memory locations.
Symbol Format Displays
ma 64 ASCII characters 0x0012ffac .4…0…”.0W&…….1W&.0.:W..1….”..1.JO&.1.2..”..1…0y….1
m 16 bytes in hexadecimal, followed by 16 ASCII characters  0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A 30 57 26 00 00 .4…0…”.0W&..
mb 16 bytes in hexadecimal, followed by 16 ASCII characters  0x0012ffac B3 34 CB 00 84 30 94 80 FF 22 8A 30 57 26 00 00 .4…0…”.0W&..
mw 8 words 0x0012ffac 34B3 00CB 3084 8094 22FF 308A 2657 0000
md 4 doublewords 0x0012ffac 00CB34B3 80943084 308A22FF 00002657
mq 4 quadwords 0x0012ffac 7ffdf00000000000 5f441a790012fdd4
mu 2-byte characters (Unicode) 0x0012fc60 8478 77f4 ffff ffff 0000 0000 0000 0000
With the memory location formatting symbols, you can type any value or expression that evaluates to a location.
To display the value of a character array as a string, precede the array name with an ampersand (&):
&yourname
A formatting character can follow an expression also:
rep+1,x
alps[0],mb
xloc,g
count,d
To watch the value at an address or the value pointed to by a register, use the BY, WO, or DW operator.
BY returns the contents of the byte pointed to.
WO returns the contents of the word pointed to.
DW returns the contents of the doubleword pointed to.
Follow the operator with a variable, register, or constant. If the BY, WO, or DW operator is followed by a variable, then the environment watches the byte, word, or doubleword at the address contained in the variable.
You can also use thecontext operator { } to display the contents of any location.
To display a Unicode string in the Watch window or the QuickWatch dialog box, use the su format specifier. To display data bytes with Unicode characters in the Watch window or the QuickWatch dialog box, use the mu format specifier.
Note   You can apply formatting symbols to structures, arrays, pointers, and objects as unexpanded variables only. If you expand the variable, the specified formatting affects all members. You cannot apply formatting symbols to individual members.

10

引用:
Quote: 引用:

没什么特别的吧:
断点进去的时候 把想要的变量选中 拖到监视里面 就是了  手写也可以的  当然了  有些 例如指针 是看不到值的
鼠标移动到上面的时候得到的是内存值 把这个值复制到内存窗口里面  回车一下 能看到该内存块的值

就是这个不会~大家指点下VS中调试的监视、内存窗口的技巧

这个不难的 就本人上面说的做就差不多了吧 当然了  前提至少是你找到监视 和内存窗口这两个窗口了
断点 进去的时候 鼠标放在变量上  普通变量就直接看到值了  但是 结构体之类的 可能需要展开 所以把变量名放到
监视窗口去看相对要方便点  也可以直接在变量上单击右键  选择快速监视  就在监视窗口了
内存窗口没啥好说的  直接把指针所指示的地址放进去 回车后 第一个字符就是想到于数组的第一个元素的值

10

这个鼠标直接指在变量上不就显示内容了吗?数组或是容器的话会显示每条内容的啊

15

http://vs2003.net
本人在视频里面已经讲了N遍了,为啥不耐心去开开呢

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明大家指点下VS中调试的监视、内存窗口的技巧
喜欢 (0)
[1034331897@qq.com]
分享 (0)