調試程序時,普遍采用的方式是打印日志文字到文件。
利用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
基本配置




時間格式主要有以下兩種:
-
時間格式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.
-
過濾指定進程
過濾指定進程
過濾效果 過濾指定文字


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

下載地址: https://debugviewpp.wordpress.com/
高亮指定進程
選中指定進程,點右鍵。


查找指定文字并高亮

點擊
Next和Previous可跳轉到下一個或上一個符合條件的消息。
手動設置過濾條件

快捷鍵
- 清空日志
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/



