WinDBG 技巧: 如何用WinDBG遠端偵錯程式

來源:互聯網
上載者:User

在某些情況下我們需要進行遠端偵錯(比如該程式運行需要時候全屏,或者程式在客戶的機器上crash崩潰), 這時候可以使用WinDBG的遠端偵錯功能。

 

WinDBG的遠端偵錯由服務端和用戶端組成,和visual studio類似。 被調試的機器是服務端(server), 我們做調試的機器是用戶端(client)。 兩台機器都需要安裝WinDBG。

 

第一步, 建立WinDBG server 端。

 

使用 -server 參數可以使WinDBG 以伺服器方式啟動。 WinDBG可以用多種連線協定讓用戶端串連,比如具名管道(named pipe), 安全管道(secure pipe), TCP 協議(socket), SSL 協議, 串口/並口(COM port) 等等。

 

具名管道

WinDBG.exe -server npipe:pipe=PipeName[,hidden][,password=Password][,IcfEnable] [-noio] [Options] 

 

TCP 協議

WinDBG.exe -server tcp:port=Socket[,hidden][,password=Password][,ipversion=6][,IcfEnable] [-noio] [Options]
WinDBG.exe -server tcp:port=Socket,clicon=Client[,password=Password][,ipversion=6] [-noio] [Options] 

 

串口/並口
WinDBG.exe -server com:port=COMPort,baud=BaudRate,channel=COMChannel[,hidden],password=Password] [-noio] [Options] 

 

安全管道

WinDBG.exe -server spipe:proto=Protocol,certuser=Cert|machuser=Cert},pipe=PipeName[,hidden],password=Password] [-noio] [Options] 

 

SSL 協議

WinDBG.exe -server ssl:proto=Protocol,certuser=Cert|machuser=Cert},port=Socket[,hidden],password=Password] [-noio] [Options]
WinDBG.exe -server ssl:proto=Protocol,certuser=Cert|machuser=Cert},port=Socket,clicon=Client[,password=Password] [-noio] [Options]

 

 

樣本:

WinDBG.exe -server npipe:pipe=DbgPipe winmine.exe (使用具名管道DbgPipe 建立調試服務,調試winmine.exe 程式)

 

WinDBG.exe -server tcp:port=1025 -p 122 (使用TCP協議,在連接埠1025建立調試服務, 調試機器上進程號為122的程式, 或者說Attach 到122進程進行調試)

 

 

第二步, 用WinDBG client 端串連服務端

 

使用 -remote 參數可以使WinDBG 以用戶端方式啟動去串連服務端, 可以指定不同的串連方式:

 

具名管道

WinDBG.exe -remote npipe:server=Server,pipe=PipeName[,password=Password]

 

TCP 協議

WinDBG.exe -remote tcp:server=Server,port=Socket[,password=Password][,ipversion=6]
WinDBG.exe -remote tcp:clicon=Server,port=Socket[,password=Password][,ipversion=6]

 

串口/並口

WinDBG.exe -remote com:port=COMPort,baud=BaudRate,channel=COMChannel[,password=Password]

 

安全管道

WinDBG.exe -remote spipe:proto=Protocol,{certuser=Cert|machuser=Cert},server=Server,pipe=PipeName[,password=Password]

 

SSL 協議

WinDBG.exe -remote ssl:proto=Protocol,{certuser=Cert|machuser=Cert},server=Server,port=Socket[,password=Password]
WinDBG.exe -remote ssl:proto=Protocol,{certuser=Cert|machuser=Cert},clicon=Server,port=Socket[,password=Password]

 

 

樣本 (假設被調試的機器名字是dbgPC):


WinDBG.exe-remote npipe:server=dbgPC,pipe=DbgPipe (使用具名管道DbgPipe 建立串連被調試機器dbgPC)


WinDBG.exe-remote tcp:server=dbgPC,port=1025 (使用TC協議, 串連被調試機器dbgPC的連接埠1025)

 

 

關於Windows 遠端偵錯更多詳細的內容,請參考MSDN http://msdn.microsoft.com/en-us/library/cc266457.aspx

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.