共用方式為


dx (顯示除錯程式物件模型表示式)

dx 命令會使用 NatVis 延伸模組模型來顯示 C++ 運算式。 如需 NatVis 的詳細資訊,請參閱 建立原生物件的自定義檢視。

dx [-g|-gc #][-c #][-n|-v]-r[#] Expression[,<FormatSpecifier> ]
dx [{-?}|{-h}]

參數

運算式

要顯示的 C++ 運算式。

-g

顯示為可反覆運算的數據網格線物件。 每個逐一查看的專案都是方格中的數據列,而這些專案的每個顯示子系都是數據行。 這可讓您檢視結構數位之類的專案,其中每個數位元素都會顯示在一個數據列中,而結構的每個欄位都會顯示在數據行中。

選取資料行名稱(其中有可用的 DML 連結)會依該數據行排序。 如果已經依該數據行排序,則會反轉排序順序。

任何可反覆運算的物件都會有一個選取並保留(或以滑鼠右鍵單擊)操作功能表項,透過稱為「顯示為方格」的 DML 新增。 選取並按住輸出視窗中的物件(或以滑鼠右鍵按兩下),然後選取這會在方格檢視中顯示物件,而不是標準樹檢視。

由數據行名稱顯示的 (+) 提供選取和保留(或按鼠右鍵)和選取行為。

  • 選取會將該數據行分解成自己的數據表。 您會看到原始資料列加上展開數據行的子系。
  • 選取並按住 (或按滑鼠右鍵) 提供「展開至方格」,它會取得數據行,並將它新增回目前數據表作為最右邊的數據行。

-Gc#

顯示為方格,並將方格單元格大小限製為指定的字元數(#)。

-c # 顯示容器接續(略過容器的 #元素)。此選項通常用於自定義輸出自動化案例,並提供 “...”清單底部的接續專案。

-n 有兩種方式可以轉譯數據。 使用 NatVis 視覺效果 (預設值) 或使用基礎原生 C/C++ 結構。 指定 -n 參數,只使用原生 C/C++ 結構來轉譯輸出,而不是 NatVis 視覺效果。

-v

顯示包含方法和其他非典型對象的詳細資訊。

-r#

遞迴顯示子類型(欄位)至 # 層級。 如果未 # 指定,遞歸層級為一,則為預設值。

[<,FormatSpecifier>]

使用下列任何格式規範來修改預設轉譯。

格式規範 描述
X 以十六進位顯示序數
D 以十進位顯示序數
,o 以八進位顯示序數
B 以二進位顯示序數
,en 只依名稱顯示列舉(無值)
C 顯示為單一字元 (不是字串)
,s 以 ASCII 引號顯示 8 位字串
某人 將8位字串顯示為未加上批注的ASCII
,s8 以UTF-8引號顯示8位字串
,s8b 將8位字串顯示為UTF-8未加上批注
以UTF-16引號顯示16位字串
將16位字串顯示為UTF-16 unqouted
,! 只以原始模式顯示物件(例如沒有 NatVis)
,# 將指標/陣列/容器的長度指定為常值 #(以數值取代)
,[<expression>] 將指標/陣列/容器的長度指定為表達式 <表達式>
,nd 找不到物件的衍生 (runtype) 類型。 僅顯示靜態值

dx-?

顯示命令行說明。

dx-h 顯示調試程式中可用對象的說明。

dx-id

僅供 Microsoft 內部使用。 用來遵循命令輸出中的數據模型連結。

命令行使用範例

.dx 設定命令可用來顯示Debug 設定對象的相關信息。 如需偵錯設定對象的詳細資訊,請參閱 .settings

kd> dx -r1 Debugger.Settings
Debugger.Settings  
    Debug            
    Display           
    EngineInitialization 
    Extensions       
    Input             
    Sources           
    Symbols           
    AutoSaveSettings : false

使用 -r1 遞歸選項來檢視其他調試程序物件 - 會話、設定 和狀態。

kd> dx -r1 Debugger
Debugger  
  Sessions  
  Settings 
  State    
  Utility
  LastEvent 

使用 -r3 遞歸選項指定 Debugger.Sessions 物件,以進一步向下移動物件鏈結。

kd> dx -r3 Debugger.Sessions
Debugger.Sessions  
  [0]              : Remote KD: KdSrv:Server=@{<Local>},Trans=@{1394:Channel=0}
    Processes  
      [0]              : <Unknown Image>
      [4]              : <Unknown Image>
      [304]            : smss.exe
      [388]            : csrss.exe
      [456]            : wininit.exe
      [468]            : csrss.exe
      [528]            : services.exe
      [536]            : lsass.exe
      [544]            : winlogon.exe
      [620]            : svchost.exe
       ...               ...

新增 x 格式規範,以十六進位顯示序數值。

kd> dx -r3 Debugger.Sessions,x
Debugger.Sessions,x  
  [0x0]            : Remote KD: KdSrv:Server=@{<Local>},Trans=@{1394:Channel=0}
    Processes  
      [0x0]            : <Unknown Image>
      [0x4]            : <Unknown Image>
      [0x130]          : smss.exe
      [0x184]          : csrss.exe
      [0x1c8]          : wininit.exe
      [0x1d4]          : csrss.exe
      [0x210]          : services.exe
      [0x218]          : lsass.exe
      [0x220]          : winlogon.exe
      [0x26c]          : svchost.exe
      [0x298]          : svchost.exe
      [0x308]          : dwm.exe
      [0x34c]          : nvvsvc.exe
      [0x37c]          : nvvsvc.exe
      [0x384]          : svchost.exe
       ...               ...

這個範例會使用作用中的偵錯會話來列出第一個進程中第一個線程的呼叫堆棧。

kd> dx -r1 Debugger.Sessions.First().Processes.First().Threads.First().Stack.Frames
Debugger.Sessions.First().Processes.First().Threads.First().Stack.Frames 
    [0x0]            : nt!RtlpBreakWithStatusInstruction
    [0x1]            : nt!KdCheckForDebugBreak + 0x7a006
    [0x2]            : nt!KiUpdateRunTime + 0x42
    [0x3]            : nt!KiUpdateTime + 0x129
    [0x4]            : nt!KeClockInterruptNotify + 0x1c3
    [0x5]            : hal!HalpTimerClockInterruptEpilogCommon + 0xa
    [0x6]            : hal!HalpTimerClockInterruptCommon + 0x3e
    [0x7]            : hal!HalpTimerClockInterrupt + 0x1cb
    [0x8]            : nt!KiIdleLoop + 0x1a

使用 -g 選項,將輸出顯示為數據格。 選取要排序的數據行。

kd> dx -g @$curprocess.Modules

dx -g @$curprocess.modules 命令輸出的螢幕快照,其中顯示單欄網格線輸出。

使用 -h 選項來顯示對象的相關信息。

kd>  dx -h Debugger.State
Debugger.State   [State pertaining to the current execution of the debugger (e.g.: user variables)]
    DebuggerVariables [Debugger variables which are owned by the debugger and can be referenced by a pseudo-register prefix of @$]
    PseudoRegisters   [Categorized debugger managed pseudo-registers which can be referenced by a pseudo-register prefix of @$]
    UserVariables     [User variables which are maintained by the debugger and can be referenced by a pseudo-register prefix of @$]

使用 Environment 物件顯示 TEB 和 PEB 資訊

使用 Environment 物件來顯示與線程和進程相關聯的 TEB 和 PEB 資訊。

若要顯示與目前線程相關聯的 TEB,請使用此命令。

0: kd> dx -r2 @$curthread.Environment
@$curthread.Environment                
    EnvironmentBlock [Type: _TEB]
        [+0x000] NtTib            [Type: _NT_TIB]
        [+0x038] EnvironmentPointer : Unable to read memory at Address 0x38
        [+0x040] ClientId         [Type: _CLIENT_ID]
        [+0x050] ActiveRpcHandle  : Unable to read memory at Address 0x50
        [+0x058] ThreadLocalStoragePointer : Unable to read memory at Address 0x58
        [+0x060] ProcessEnvironmentBlock : Unable to read memory at Address 0x60
        [+0x068] LastErrorValue   : Unable to read memory at Address 0x68
        [+0x06c] CountOfOwnedCriticalSections : Unable to read memory at Address 0x6c
        [+0x070] CsrClientThread  : Unable to read memory at Address 0x70
        [+0x078] Win32ThreadInfo  : Unable to read memory at Address 0x78
        [+0x080] User32Reserved   [Type: unsigned long [26]]
        [+0x0e8] UserReserved     [Type: unsigned long [5]]
        [+0x100] WOW32Reserved    : Unable to read memory at Address 0x100
        [+0x108] CurrentLocale    : Unable to read memory at Address 0x108
        [+0x10c] FpSoftwareStatusRegister : Unable to read memory at Address 0x10c
         ...

若要顯示與目前進程相關聯的PEB,請使用此命令。

0: kd> dx -r2 @$curprocess.Environment
@$curprocess.Environment                
    EnvironmentBlock [Type: _PEB]
        [+0x000] InheritedAddressSpace : Unable to read memory at Address 0x0
        [+0x001] ReadImageFileExecOptions : Unable to read memory at Address 0x1
        [+0x002] BeingDebugged    : Unable to read memory at Address 0x2
        [+0x003] BitField         : Unable to read memory at Address 0x3
        [+0x003 ( 0: 0)] ImageUsesLargePages : Unable to read memory at Address 0x3
        [+0x003 ( 1: 1)] IsProtectedProcess : Unable to read memory at Address 0x3
        [+0x003 ( 2: 2)] IsImageDynamicallyRelocated : Unable to read memory at Address 0x3
        [+0x003 ( 3: 3)] SkipPatchingUser32Forwarders : Unable to read memory at Address 0x3
        [+0x003 ( 4: 4)] IsPackagedProcess : Unable to read memory at Address 0x3
        [+0x003 ( 5: 5)] IsAppContainer   : Unable to read memory at Address 0x3
        [+0x003 ( 6: 6)] IsProtectedProcessLight : Unable to read memory at Address 0x3
        [+0x003 ( 7: 7)] IsLongPathAwareProcess : Unable to read memory at Address 0x3
        [+0x004] Padding0         [Type: unsigned char [4]]
        [+0x008] Mutant           : Unable to read memory at Address 0x8
        [+0x010] ImageBaseAddress : Unable to read memory at Address 0x10
        [+0x018] Ldr              : Unable to read memory at Address 0x18
        [+0x020] ProcessParameters : Unable to read memory at Address 0x20
        ...

Kernel Io.Handles 物件

使用目前的進程 Io.Handle 物件來顯示核心句柄資訊。

0: kd> dx -r1 @$curprocess.Io.Handles
@$curprocess.Io.Handles                
    [0x8]           
    [0xc]           
    [0x10]          
    [0x14]          
    [0x18]       
    ...

使用 。First() 函式,以顯示第一個句柄的相關信息。

0: kd> dx -r2 @$curprocess.Io.Handles.First()
@$curprocess.Io.Handles.First()                
    Handle           : 0x8
    Type             : Unexpected failure to dereference object
    GrantedAccess    : Unexpected failure to dereference object
    Object           [Type: _OBJECT_HEADER]
        [+0x000] PointerCount     : 228806 [Type: __int64]
        [+0x008] HandleCount      : 6 [Type: __int64]
        [+0x008] NextToFree       : 0x6 [Type: void *]
        [+0x010] Lock             [Type: _EX_PUSH_LOCK]
        [+0x018] TypeIndex        : 0xf2 [Type: unsigned char]
        [+0x019] TraceFlags       : 0x0 [Type: unsigned char]
        [+0x019 ( 0: 0)] DbgRefTrace      : 0x0 [Type: unsigned char]
        [+0x019 ( 1: 1)] DbgTracePermanent : 0x0 [Type: unsigned char]
        [+0x01a] InfoMask         : 0x0 [Type: unsigned char]
        [+0x01b] Flags            : 0x2 [Type: unsigned char]
        [+0x01b ( 0: 0)] NewObject        : 0x0 [Type: unsigned char]
        [+0x01b ( 1: 1)] KernelObject     : 0x1 [Type: unsigned char]
        [+0x01b ( 2: 2)] KernelOnlyAccess : 0x0 [Type: unsigned char]
        [+0x01b ( 3: 3)] ExclusiveObject  : 0x0 [Type: unsigned char]
        [+0x01b ( 4: 4)] PermanentObject  : 0x0 [Type: unsigned char]
        [+0x01b ( 5: 5)] DefaultSecurityQuota : 0x0 [Type: unsigned char]
        [+0x01b ( 6: 6)] SingleHandleEntry : 0x0 [Type: unsigned char]
        [+0x01b ( 7: 7)] DeletedInline    : 0x0 [Type: unsigned char]
        [+0x01c] Reserved         : 0x0 [Type: unsigned long]
        [+0x020] ObjectCreateInfo : 0xfffff801f6d9c6c0 [Type: _OBJECT_CREATE_INFORMATION *]
        [+0x020] QuotaBlockCharged : 0xfffff801f6d9c6c0 [Type: void *]
        [+0x028] SecurityDescriptor : 0xffffb984aa815d06 [Type: void *]
        [+0x030] Body             [Type: _QUAD]
        ObjectType       : Unexpected failure to dereference object
        UnderlyingObject : Unexpected failure to dereference object

請注意,Io.Handles 對像是僅限核心的物件。

使用轉換解決符號檔限制

顯示各種 Windows 系統變數的相關信息時,有時候公用符號中沒有所有類型資訊可供使用。 此範例說明這種情況。

0: kd> dx nt!PsIdleProcess
Error: No type (or void) for object at Address 0xfffff800e1d50128

dx 命令支援參考沒有類型資訊之變數位址的功能。 這類「位址」參考會被視為「void *」,因此可以轉型為 。 這表示如果已知數據類型,可以使用下列語法來顯示變數的類型資訊。

dx (Datatype *)&VariableName

例如 nt!PsIdleProcess 的數據類型為 nt!_EPROCESS,請使用此命令。

dx (nt!_EPROCESS *)&nt!PsIdleProcess
(nt!_EPROCESS *)&nt!PsIdleProcess                 : 0xfffff800e1d50128 [Type: _EPROCESS *]
    [+0x000] Pcb              [Type: _KPROCESS]
    [+0x2c8] ProcessLock      [Type: _EX_PUSH_LOCK]
    [+0x2d0] CreateTime       : {4160749568} [Type: _LARGE_INTEGER]
    [+0x2d8] RundownProtect   [Type: _EX_RUNDOWN_REF]
    [+0x2e0] UniqueProcessId  : 0x1000 [Type: void *]
    [+0x2e8] ActiveProcessLinks [Type: _LIST_ENTRY]
    [+0x2f8] Flags2           : 0x218230 [Type: unsigned long]
    [+0x2f8 ( 0: 0)] JobNotReallyActive : 0x0 [Type: unsigned long]

dx 命令不支援使用 @@ MASM 語法切換表達式評估工具。 如需表達式評估工具的詳細資訊,請參閱 評估表達式

使用 LINQ 搭配調試程序物件

LINQ 語法可以與調試程序物件搭配使用,以搜尋及操作數據。 LINQ 在概念上類似於用來查詢資料庫的 結構化查詢語言 (SQL) (SQL)。 您可以使用許多 LINQ 方法來搜尋、篩選和剖析偵錯數據。 如需搭配調試程序物件使用 LINQ 的資訊,請參閱 搭配調試程式物件使用 LINQ。

搭配 NatVis 和 JavaScript 使用調試程序物件

如需搭配 NatVis 使用調試程式對象的詳細資訊,請參閱 NatVis 中的原生調試程序物件。

如需搭配 JavaScript 使用調試程式對象的詳細資訊,請參閱 JavaScript 延伸模組中的原生調試程序物件。

另請參閱

使用 LINQ 搭配調試程序物件

NatVis 中的原生調試程序物件

JavaScript 延伸模組中的原生調試程序物件