注意一下自己vs的版本!以及編譯平台!
//本程式是基於 vs2015 版本,x86 !!!
//建立標頭檔案dumpfile.h, 將下列**放進檔案中
#pragma once
#include #include #include #include #include using namespace std;
#pragma comment(lib, "dbghelp.lib")
namespace nsdumpfile
lptop_level_exception_filter winapi mydummysetunhandledexceptionfilter(lptop_level_exception_filter lptoplevelexceptionfilter)
bool preventsetunhandledexceptionfilter()
long winapi unhandledexceptionfilterex(struct _exception_pointers *pexception)
; ::getmodulefilename(null, szmbsfile, max_path);
tchar* pfind = _tcsrchr(szmbsfile, '\\');
if (pfind)
//這邊提示的訊息可根據自己的需求設計
// todo: minidumpwritedump
messagebox(null,_t("***又雙叒叕崩潰了,驚不驚喜?意不意外?***"),_t("錯誤"),mb_ok);
return exception_continue_search;
} void runcrashhandler() };
#define declaredumpfile() nsdumpfile::runcrashhandler();
然後再自己主程式中(建議在開頭)新增 declaredumpfile() ,一旦軟體執行奔潰,可直接定位到對應**奔潰處
生成的dump檔案只適用於對應軟體的版本,也是說需要生成dump檔案後,最好儲存對應的符號檔案以及可執行檔案(.exe)!一旦你再次編譯自已的程式,就算程式內容沒變,之前生成的dump檔案也無法使用了!
C 除錯之建立Dump檔案和除錯Dump檔案
如何在發布後程式中捕獲程式的崩潰和異常往往是比較麻煩的事情,一般採用日誌記錄的方法來記錄程式執行的每個流程,但是通常為了程式執行的效能,日誌記錄的方法只是記錄程式執行的每個主要的處理流程,不能進行具體詳細的記錄,比如for 迴圈中的崩潰記錄。c 語言中呼叫window api函式createfile...
C 程式儲存dump檔案
程式異常崩潰前使用此類為程序建立dump檔案,之後可以使用windbg等工具進行分析。using system using system.diagnostics using system.io using system.runtime.interopservices namespace infras...
C 中大量字串拼接導致程式執行過慢奔潰等問題
剛剛入職,需要根據給定的二進位制檔案翻譯成大白話文,涉及到了很多優先順序 幀號等等,前期程式設計過程中沒有過多的注意加上沒有拿實際資料測試,大量使用了拼接字串 在文字量or資料量很小的情況下執行很完美,幾乎沒什麼卡頓,最後拿採集到的實際資料 50m左右二進位制檔案 進行測試時,程式執行奇慢無比,甚至...