利用DebugView調試Windows程序

調試程序時,普遍采用的方式是打印日志文字到文件。
利用DebugView調試Windows程序, 更方便查看動態(tài)信息。

DebugView

Introduction

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don't need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.
下載地址:https://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

基本配置
Capture
Options
清空信息 按鈕
設置時間格式 按鈕

時間格式主要有以下兩種:

  • 時間格式1


    時間格式1
  • 時間格式2


    時間格式2
過濾 按鈕

點過濾按鈕可設置對指定進程或含指定文字的信息進行高亮顯示。

如何在程序中打印信息到DebugView

在程序中用OutputDebugString即可將信息輸出到DebugView
舉例:

OutputDebugStringA("Hello World!!");
重要前提

在集成開發(fā)環(huán)境(如VS)直接運行程序,DebugView是捕獲不到的,因為OutputDebugString提前被控制臺捕獲了,顯示在控制臺上了。
所以應該直接運行Debug或者Release的程序。

Win7下DebugView無法捕獲信息

有時發(fā)現DebugView在Win7中無法查看OutputDebugString所拋出的消息,這可能是微軟為了安全原因考慮,所以把此功能給關閉。
解決方法:

1.打開注冊表
run -> regedit
2.打開
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager]
3.建立[Debug Print Filter]這個新鍵
4.新增加一個“DEFAULT”的DWORD值,將其內容設置0x0f
5.重啟OS后生效。

或者將以下文字拷貝到SetDebugPrintFilter.reg, 然后運行,重啟OS后生效。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/Debug Print Filter] 
"DEFAULT"=dword:0000000f
將指定鍵值加入到注冊表
如何過濾指定進程或字符串

to Highlight "Hello" and include all of the other input as well you would:
Set Include to "*".
Then in the Higlight section where you see the color (Red for Filter 1) - Click in the red color drop down area and add the text "Hello"
This will show you all of your output in DebugView and highlight "Hello" in red.

  • 過濾指定進程


    過濾指定進程

    過濾效果
  • 過濾指定文字

過濾包含`TCPListener的消息`
過濾指定文件的結果

DebugView ++

DebugView++ is a free viewer for Windows OutputDebugString() based logging in the style of Sysinternals DebugView.

DebugView ++

下載地址: https://debugviewpp.wordpress.com/

高亮指定進程

選中指定進程,點右鍵。


選中指定進程進行高亮
高亮結果
查找指定文字并高亮

查找指定文字并高亮

點擊NextPrevious可跳轉到下一個或上一個符合條件的消息。

手動設置過濾條件
過濾 按鈕
快捷鍵
  • 清空日志
Ctrl + X
  • Clock Time
Ctrl + T
  • Save View
Ctrl + S

References:

https://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
https://social.microsoft.com/Forums/en-US/f9c88f4a-7fc1-44e0-8f4a-e27491516f91/how-to-use-debugview-highlighting-filter?forum=Offtopic
https://debugviewpp.wordpress.com/

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容