0306 VC debug trace afxDump AfxDump
TRACE Sends the specified string to the debugger of the current application.
TRACE(exp ) TRACE(DWORD category, UINT level, LPCSTR lpszFormat, … )
Remarks See ATLTRACE2 for a description of TRACE. TRACE and ATLTRACE2 have the same behavior.
This macro is available only in the debug version of MFC.
For more information, see Debugging MFC Applications.
See Also MFC Macros and Globals &line; AfxDump &line; afxTraceEnabled
AfxDump Call this function while in the debugger to dump the state of an object while debugging.
void AfxDump( const CObject* pOb );
Parameters pOb A pointer to an object of a class derived from CObject.
Remarks
AfxDump calls an object\’s Dump member function and sends the information to the location specified by the afxDump variable. AfxDump is available only in the Debug version of MFC.
Your program code should not call AfxDump, but should instead call the Dump member function of the appropriate object.
See Also CObject::Dump &line; afxDump
MFC Library Reference
afxDump
Provides basic object-dumping capability in your application.
CDumpContext afxDump;
Remarks
afxDump is a predefined CDumpContext object that allows you to send CDumpContext information to the debugger output window or to a debug terminal. Typically, you supply afxDump as a parameter to CObject::Dump.
Under Windows NT and all versions of Windows, afxDump output is sent to the Output-Debug window of Visual C++ when you debug your application.
This variable is defined only in the Debug version of MFC. For more information on afxDump, see Debugging MFC Applications. Technical Note 7 and Technical Note 12 contain additional information.
Note This function works only in the Debug version of MFC.
Example
// example for afxDump
CPerson myPerson = new CPerson;
// set some fields of the CPerson object…
//..
// now dump the contents
#ifdef _DEBUG
afxDump << "Dumping myPerson:\\n";
myPerson->Dump( afxDump );
afxDump << "\\n";
#endif
1)TRACE();/TRACE0();/TRACE1();/TRACE2();/TRACE3();:其用法和C中的printf()函数类似;TRACEn()和TRACE()的区别是前者使用的资源较少,前者中n表示所带参数的个数。使得TRACE可用:Tools-MFCTracer-Enabling trace。
2)AfxDump();//其用法和C++中的cout类似;
3)AfxDump(const Cobject* obj);会输出obj的相关信息(属性的值)。
4)MessageBox();/AfxMessageBox();
#ifdef _DEBUG
afxDump<<x;
#endif
将结果显示在OutPut,不能在Release状态下。Ctrl+F5似乎无效,F5可以。
afxDump.SetDepth(1);
设置深度,如maps,arrays,它只打出有几个可元素,我们用上面的这个函数,它会将所有的内容打出来.
#ifdef _DEBUG
char test[] = "0123456789\\n";
afxDump.HexDump( "–", (BYTE*) test, 11, 6 );
#endif
结果为:
– 30 31 32 33 34 35
– 36 37 38 39 0A
第一个参数,行首的打头字符.
第二个参数,要打的内容.
第三个参数,要打的元素个数.
第四个参数,每行的个数.
4,TRACE(…), TRACE0, TRACE1, TRACE2, TRACE3 也只能在调试时用注意打字符串时有长度限制,包括结束符在内,不超过512个字符.
5.在Debug状态下
F9设置断点后,F5到下一个断点,F10下一行,F11进入函数(包括系统函数)内部,Shift + F11出来.
F5后,Debug菜单有相应的菜单项.
F5后,View->Debug Window的子菜单项比较有用.
Watch 查看你指定的变量
variables 显示auot变量,local变量,this的值
memory 显示指定内存地址存储的值
call stack 显示函数调用关系
registers 寄存器的值
Disabblemble 汇编代码
其实Release下也可调试F5
Alt + f7 工程设置
c\\c++ Generate Browse info 选上.
Debug info 选 Progame database for edit and continue
Link Generate debug info 选上
Link incrementally 选上
历史博文
- 20080806 YippeeSoft@pick xpi - 2009
- 20071016 gui ide 可视化 - 2008
- 20070203 perl ping - 2007
- 单片机C51复习-入门1 - 2005
- 乱七八糟猜想18门户网站19DUDU加速器病毒 - 2005
- TortoiseCVS中文帮助-取回旧版本 - 2005
- 从ASP.NET看BIN DLL所放置的目录 - 2005
- vs.net c# 一个调用外部程序的例子 - 2005
- vs.net环境下开发C# asp.net时,试图运行项目时出错 - 2005