[Declaration] If you need to copy, spread, please attach this statement, thank you. Original source: http://morningspace.51.net/ ,moyingzz@etang.com
The leader of the leader is covered with the "Visual C 6 Collection" book because of the needs of work. Although I have been in contact with VC, I have found that there are many contents in it, I have a little understanding. The following is some of the content I extracted and organized, I hope that I will have a friend who often uses VCs. Help, this paper taken "pumet" is also for this meaning. Of course, the items selected here may be slightly biased, because after all, from its own point of view, extract the content that it is easy to ignore. If you need to understand anything mentioned here, please check the relevant books. Necessary to set up the application before debugging the application Project Settings-> C / C tab -> General Category
Debug Info Select ProGram Database for Edit and Continue Optimizations Select Disable (Debug) Question Time Project Settings-> C / C tab -> C / C tab -> Code Generation Category
Use Run-Time Library Select the Debug Library (such as: Debug Multithreaded DLL) Project Settings-> Link Tab -> General Category
Select Generate Debug Info If you debug DLL, you need: Project Settings-> Debug tab -> General Category
Executable for debug session fills in the name of the programs loaded and accessed DLL (such as: To debug the ActiveX control, you can use the VC's Utility TSTCON32.exe) Variables Window Variables window contains three tabs. The Auto tab displays the current line of the running program and the variables used in the previous row; the locals tab displays all variables (including local variables and parameters of the incoming function) in the currently executed function; the THIS tab shows this The member variable of the inside of the object to which you can modify the current value of the simple type variable (such as: int, double) by the Variable window, as long as you double-click this value in the window. The Watch window can manually enter the expression into the Name domain in the Watch window, or drag the expression, or paste from the clipboard. The Watch window can also modify the value of the simple type of variables. The Memory window can check the memory content in the address space of all debug processes. Memory content can be displayed in byte format, word format, and double word format. To display the storage content at the specific location, type the expression in the Address column of the Memory window. The Memory window may display the memory content before the specified value, but it positions the cursor at the address corresponding to the expression. The Disassembly window set next statement feature can change the processor's instruction pointer to select the next instruction you want to perform. However, if you set the statement in another function or you can't maintain the stack correctly, the consequence is unpredictable, usually the program being debugging will crash. When debugging multithreaded debugging multithreaded applications, you can open the Threads dialog through the Threads feature under the debug menu (debugging ", which will open the focus to a specific thread in the program. You can also hang, restore a thread debug exception through the Exceptions feature in the debug menu (debugging ", open the Excetions dialog, specify the debugging, the program's response (including: stop always, and stop if NOT HANDLEDs. Simple debugging skills Use AFXMessageBox If the appearance of the debugger window interferes with the execution of the application, or the error appears in the Release version, you can use the information you are interested in using the information you are interested in. This is similar to a method of outputting debug information with PrintF earlier. Use Trace Macro: MFC provides macro trace, trace0, trace1, trace2, trace3 to generate tuning output. They output debug information to the AFXDUMP object, which is an instance of the MFC's CDumpContext class, which sends information to the Output window. Try to use Trace0 ~ Trace3 because they need to store the storage space less than Trace. Trace0 outputs a string, the trace1 outputs a string and can be included with a variable, and TRACE2 can come with two variables, and Trace3 can come with three. When you create a Unicode application, Trace must use the _t macro format string, while Traceen does not need. The Release version app will ignore all Trace and Tracen macros. Using assertions: In addition to Assert, an Assert_Valid macro verifies the validity of a pointer to the COBJECT derived class object. The Release version application will ignore all Assert and Assert_Valid macros.
Using the Dump COBJECT class contains the dump () member function, it outputs the content through the AFXDUMP object to the Output window. You can overload it in the derived class. Memory leak: You can detect memory leakage using CMEMeoryState. METHODS: If full dump is not required to invoke all objects assigned between checkpoint twice, CMEMORYSTATE cannot be used to detect Malloc / Free, GlobalAlloc / GlobalFree, Localalloc / LocalFree. Using the MFC Tracer MFC Tracer (file name: Tracer.exe), you can enable or disable the partial or all MFC tracking debugging information (Trace and Tracen Macro). Remote Debug Remote Debug allows you to debug programs that run on other machines connected to your machine. The remote machine must run Visual C Debug Monitor (MSVCMon.exe, and MSDev.exe in the same directory), in order to run MSVCMon.exe, the remote machine must be: MSVCRT.DLL, TLN0T.DLL, DM.DLL, MSVCP60. DLL, MSDis100.dll. Step: Run MSVCMon.exe on the remote machine, select Network (TCP / IP), select Settings to set the name of the target machine, and select the program that runs on the remote machine Run Visual Studio on the local machine, select Build- > Debugger Remote Connection Opens Remote Connection, select Network (TCP / IP), select Settings Settings Target Machine Name Press F5 Start Debugger Remote Debugging The main advantage is that the application runs in one machine that does not affected by the debugging program The upper, suitable for debugging involving programs such as display, keyboard, audio driving and other programs. At the same time, it is also suitable for debugging the Debug version to run normally and the Release version cannot run properly. (to be continued)