惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - hyamw

【转】代码审查工具fisheye/crucible安装及破解 Win11单语言系统添加美式键盘的方法 Unity中AndroidJavaProxy方法参数为null的坑 CentOS下安装dotnet tools工具报错 (转)支持 PS/2 与 USB 的键盘过滤驱动(可卸载) Unity编辑器扩展-Custom List, displaying data your way 值得推荐的C/C++框架和库 (真的很强大)〔转〕 SIGGRAPH2016【转】 在64位windows下使用instsrv.exe和srvany.exe创建windows服务[转] VS2015调试UWP程序时提示错误DEP0700 : Registration of the app failed. Another user has already installed Unity 4.x Asset Bundle 重名 centos下postgresql的安装与配置[转] CentOS 访问Windows7共享文件夹 svn+ssh方式svn服务器和客户端的配置[转载] 利用Ptrace在Android平台实现应用程序控制[转] AS3地图拼接与战争迷雾的实现[转载] 一些游戏开发相关资料(收集) Bit Twiddling Hacks[转] Unity3D实用工具汇总[转]
VC++ Debugger Tips[转]
hyamw · 2013-12-16 · via 博客园 - hyamw

本文摘自:http://blogs.msdn.com/b/vcblog/archive/2006/08/04/689026.aspx

Hi, my name is Sergey Grankin and I'm a developer on the VC++ IDE Team.  I mostly work on the C++ debugger expression evaluators -- the code responsible for the magic behind the debugger watch windows. 

Visual Studio's (native) C++ debugger has many useful features that can make your debugging much more pleasant, if you know what they are.  These tend to accumulate over releases, and get forgotten and unused, unless you happen upon an archaic piece of documentation. On this topic, then, there are special expression and format specifiers that you can use to better examine the content in the debugger's watch windows.

For example, say we break after the following bit of code:

          int i = 0x12345678;

You can use the by, wo, and dw operators to view contents of a variable as an unsigned byte, word, or dword:

          i                 0x12345678             int

          by i            0x78 'x'                    unsigned char

          wo i           0x5678                    unsigned short

          dw i           0x12345678            unsigned long

You can also use the operators on a register to do the same to the destination of the register:

          eax 0x0012ff2c                       unsigned long

          by eax       0x78 'x'                 unsigned char

          wo eax      0x5678                 unsigned short

          dw eax      0x12345678         unsigned long

These come in handy when debugging through assembly.

Another way to change debugger output is through format specifiers.  These are directives passed after the expression, separated by a comma. For example, to change the radix out the output, you can append ',o' for octal, ',d' for decimal, or ',x' for hex:

          i       42                                  int

          i,o     052                              int

          i,d     42                                int

          i,x     0x0000002a                 int

To interpret a pointer expression as a string, you can use ',s' for an simple null-terminated string, ',s8' for a UTF-8 string, or ',su' for a Unicode string. (Note that the expression has to be a pointer type for this to work).

          char str[] = "hello";

          wchar_t str2[] = L"world";

    str                          0x0012ff00 "hello"                        char [6]

          str,s                        "hello"                                            char [6]

          str2                         0x0012fee8 "world"                     wchar_t [6]

          (void*)str2,su      "world"                                           void *

The memory operators can be used to display up to 64 bytes of memory in the preview line, as bytes, words, dwords, quads, or ascii characters. 

      str,m          0x0012ff00   68 65 6c 6c 6f 00 cc cc cc cc cc cc cc cc cc cc  hello.                   char [6]

       str,mb        0x0012ff00    68 65 6c 6c 6f 00 cc cc cc cc cc cc cc cc cc cc  hello.                   char [6]

       str,mw       0x0012ff00    6568 6c6c 006f cccc cccc cccc cccc cccc                                      char [6]

       str,md        0x0012ff00    6c6c6568 cccc006f cccccccc cccccccc                                          char [6]

       str2,mu      0x0012feec    0077 006f 0072 006c 0064 0000 cccc cccc  world.??              wchar_t [6]

       str,mq        0x0012ff00    cccc006f6c6c6568 cccccccccccccccc                                            char [6]

       str,ma         0x0012ff00    hello.(..(......T..                                                                     char [6]

You can use ,wc ,wm and ,hr to view data as a window class, window message, or HRESULT.

       0x00400000,wc     WS_OVERLAPPEDWINDOW                                                   int

       0x10,wm               WM_CLOSE                                                                                   int

       0x10,hr                 0x00000010 The directory cannot be removed.                              int

Finally, you can use ,! to turn off STL visualizations on the expression:

      str       "hello world"                                                                                                       std::basic_string< ... >

       str,!     {_Bx={...} _Mysize=0x0000000b _Myres=0x0000000f}                               std::basic_string<...>

All of these operators can be used to ease the way you get to data while debugging, and become necessary whern creating custom visualizations. You can check-out the autoexp.dat file in your Visual Studio directory for examples of how to combine these operators and the visualization language to create custom visualizers for your own data.

-- sergey grankin // vc++ dev team