After a long period of time, the product is coming soon. Faced with the market and users, there are always a lot of inexplicable and wonderful problems that make you have to spend a lot of energy and time on bugs every day. I think the most difficult problem is the randomness of the problem, it appears occasionally and cannot be captured. During the holidays, I went around the Internet over the past few days. Some of them had some gains and surprises. Some of them could not be digested, making it easier for me to remember them later. According to Mr. Lu Xun's tailism, I would like to share some notes, in the future, I will have the opportunity to organize it again. Most of the text is from the Internet. Thank you for sharing it with many netizens. Thank you for your selflessness.
1. correct usage:
Place the DMP, PDB, and exe files of the crashed program in the same directory, and double-click to run DMP (or open with ), then a project named dumpfile is displayed and contains a dumpfile. Right-click the project, select debug-> Start a new instance (or start and start a new instance in one step). At this time, the program is automatically adjusted to the line that crashes in the source code, in addition, the call stack contains complete stack information, and the value of temporary variables can also be displayed through vs, as well as module information and thread information.
Http://blog.csdn.net/vagrxie/archive/2009/07/31/4398721.aspx
C ++ core dump problem Locating Method
Http://wenku.baidu.com/view/3b49ffdba58da0116c174962.html
2. Download windbg:
Install debugging tools for Windows 32-bit version
Http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx
3. Generate the dump source code.
#include <stdio.h>#include <windows.h>#include <dbghelp.h>#pragma comment(lib, "Dbghelp.lib")LONG WINAPI MyUnhandledFilter(struct _EXCEPTION_POINTERS *lpExceptionInfo){ LONG ret = EXCEPTION_EXECUTE_HANDLER; TCHAR szFileName[64]; SYSTEMTIME st; ::GetLocalTime(&st); wsprintf(szFileName, TEXT("%04d-%02d-%02d-%02d-%02d-%02d-%02d-%02d.dmp"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, rand()%100); HANDLE hFile = ::CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if (hFile != INVALID_HANDLE_VALUE) { MINIDUMP_EXCEPTION_INFORMATION ExInfo; ExInfo.ThreadId = ::GetCurrentThreadId(); ExInfo.ExceptionPointers = lpExceptionInfo; ExInfo.ClientPointers = false; // write the dump BOOL bOK = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL ); if (bOK) { printf("Create Dump File Success!/n"); } else { printf("MiniDumpWriteDump Failed: %d/n", GetLastError()); } ::CloseHandle(hFile); } else { printf("Create File %s Failed %d/n", szFileName, GetLastError()); } return ret;}
4. Call
int main(){ ::SetUnhandledExceptionFilter(MyUnhandledFilter); int *p;*p = 100; return 0;}
5. debug the dump file
Place the DMP file and the EXE and PDB files in the same directory, and then open the file with a compiler (such as Vc). Then, the debugging will be interrupted to the point where the file was interrupted.
6. Use windbg to analyze the DMP file to locate the program bug
Http://www.cppblog.com/woaidongmao/archive/2011/05/11/146206.html
7. Generate minidump compilation settings under vc6 release
Http://www.cppblog.com/woaidongmao/archive/2011/05/10/146100.html
8. Use vs2005 for Dump File debugging
Http://www.cppblog.com/woaidongmao/archive/2009/10/21/99135.html
9. windbg Practical Manual
Http://www.cppblog.com/weiym/archive/2012/06/07/177958.html
Note: It is not easy to send a blog post on csdn. Text layout is hard to understand, and we hope to get better and better.