Debugging 在WinDbg内存窗口中查看结构的语法?

Debugging 在WinDbg内存窗口中查看结构的语法?,debugging,windbg,Debugging,Windbg,所以无论出于什么原因,我在编程时没有使用IDE。我编译程序并在命令行上生成相应的PDB。因此,我使用WinDbg进行调试,我不介意。无论如何请考虑以下数据: typedef struct _ex { char *ptr0; char *ptr1; char *ptr2; } ex; ex *example; // assume example and members point to somewhere memory 如何在内存窗口中查看示例结构的成员?我尝试了ex

所以无论出于什么原因,我在编程时没有使用IDE。我编译程序并在命令行上生成相应的PDB。因此,我使用WinDbg进行调试,我不介意。无论如何请考虑以下数据:

typedef struct _ex
{
    char *ptr0;
    char *ptr1;
    char *ptr2;
} ex;

ex  *example; // assume example and members point to somewhere memory
如何在内存窗口中查看
示例
结构的成员?我尝试了
example->ptr0
example.ptr0
以及放置在这里和那里的
*
,但总是出现
无法检索信息的错误。我有一个工作区设置,希望有一对内存窗口,在它们进入作用域时准备好一些结构值,而不必每次都复制粘贴地址,或者更糟糕地键入它们。是否有正确的语法来执行此操作?

源代码

:>dir /b
disptype.cpp

:>type disptype.cpp
// compile with cl /Zi /W4 /O1 /analyze /nologo disptype.cpp /link /nologo /release
// either disable inlining or compile as debug
// optimisation will blow away stuffstruct function and load rcx,rdx,r8 with argv[]
// and call printf directly
#include <stdio.h>
#include <stdlib.h>
typedef struct _ex
{
    char *ptr0;
    char *ptr1;
    char *ptr2;
} ex;
__declspec(noinline) void stuffstruct (ex *myex,char *a,char *b,char *c) {
                myex->ptr0 = a;
                myex->ptr1 = b;
                myex->ptr2 = c;
                return;
}
int main (int argc, char * argv[])
{
        if(argc != 4)
        {
                printf( "usage %s how are you\n" , argv[0]);
                exit(0);
        }
        ex myex;
        stuffstruct(&myex,argv[1],argv[2],argv[3]);
        printf ("%s repeats 3 argv's \n%s\n%s\n%s\n",argv[0],myex.ptr0,myex.ptr1,myex.ptr2);
        return 0;
}
windbg(使用cdb以便于复制粘贴)

C++表达式求值器、DT和DX用法

的一个例子
0:000> ?? myex
struct _ex * 0x00000044`02cffe60
   +0x000 ptr0             : 0x0000019c`437f65b5  "how"
   +0x008 ptr1             : 0x0000019c`437f65b9  "are"
   +0x010 ptr2             : 0x0000019c`437f65bd  "you"

you can also ask windbg to display type and coerce pointer 
either with dt or the new dx 

0:000> dt /v disptype!myex

Local var [AddrFlags c8  AddrOff 0000000000000000  Reg/Val rcx (3)] @ rcx Type _ex*

disptype!myex = 4402cffe60
struct _ex, 3 elements, 0x18 bytes
   +0x000 ptr0             : 0x0000019c`437f65b5  "how"
   +0x008 ptr1             : 0x0000019c`437f65b9  "are"
   +0x010 ptr2             : 0x0000019c`437f65bd  "you"


 0:000> dx (disptype!_ex *) @rcx
(disptype!_ex *) @rcx : 0x4402cffe60 [Type: _ex *]
    [+0x000] ptr0             : 0x19c437f65b5 : "how" [Type: char *]
    [+0x008] ptr1             : 0x19c437f65b9 : "are" [Type: char *]
    [+0x010] ptr2             : 0x19c437f65bd : "you" [Type: char *]
0:000>
强制将地址解释为我们的结构

0:000> dx (disptype!_ex *) @rax
(disptype!_ex *) @rax : 0x19c437ff290 [Type: _ex *]
    [+0x000] ptr0             : 0x19c437f6880 : "ALLUSERSPROFILE=C:\ProgramData" [Type: char *]
    [+0x008] ptr1             : 0x19c437f5dc0 : "APPDATA=C:\Users\xxxx\AppData\Roaming" [Type: char *]
    [+0x010] ptr2             : 0x19c437f5e20 : "CommandPromptType=Native" [Type: char *]
0:000>
您正在谈论gui中的内存窗口(atl+5) 该窗口不能显示类型,它只能显示预定义类型的数据,如 位、字节、字、双字、浮点、双精度、字符串等

设置本地人或手表(以我的拙见,两者都很麻烦,使用不动产会降低性能等等,但我认为,如果你愿意,你可以愉快地使用它们)

这是屏幕截图

“您正在讨论gui(atl+5)中的内存窗口,该窗口不能显示[类型],它只能显示预定义类型的数据,如位、字节、字、dword、浮点、双精度、字符串等。”。好的,那么我的意思是如何让内存窗口显示example->ptr1所指向的内存*编辑:意思不是->意思
0:000> ?? myex
struct _ex * 0x00000044`02cffe60
   +0x000 ptr0             : 0x0000019c`437f65b5  "how"
   +0x008 ptr1             : 0x0000019c`437f65b9  "are"
   +0x010 ptr2             : 0x0000019c`437f65bd  "you"

you can also ask windbg to display type and coerce pointer 
either with dt or the new dx 

0:000> dt /v disptype!myex

Local var [AddrFlags c8  AddrOff 0000000000000000  Reg/Val rcx (3)] @ rcx Type _ex*

disptype!myex = 4402cffe60
struct _ex, 3 elements, 0x18 bytes
   +0x000 ptr0             : 0x0000019c`437f65b5  "how"
   +0x008 ptr1             : 0x0000019c`437f65b9  "are"
   +0x010 ptr2             : 0x0000019c`437f65bd  "you"


 0:000> dx (disptype!_ex *) @rcx
(disptype!_ex *) @rcx : 0x4402cffe60 [Type: _ex *]
    [+0x000] ptr0             : 0x19c437f65b5 : "how" [Type: char *]
    [+0x008] ptr1             : 0x19c437f65b9 : "are" [Type: char *]
    [+0x010] ptr2             : 0x19c437f65bd : "you" [Type: char *]
0:000>
0:000> dx (disptype!_ex *) @rax
(disptype!_ex *) @rax : 0x19c437ff290 [Type: _ex *]
    [+0x000] ptr0             : 0x19c437f6880 : "ALLUSERSPROFILE=C:\ProgramData" [Type: char *]
    [+0x008] ptr1             : 0x19c437f5dc0 : "APPDATA=C:\Users\xxxx\AppData\Roaming" [Type: char *]
    [+0x010] ptr2             : 0x19c437f5e20 : "CommandPromptType=Native" [Type: char *]
0:000>