当前位置: 首页 > news >正文

网站建设有什么工作seo教程网站优化

网站建设有什么工作,seo教程网站优化,wordpress次级目录ftp,网络销售怎么做网站一,为什么需要dump文件 Windows客户端应用开发时,难免会遇到程序崩溃问题。当程序在Debug下运行崩溃时,我们可以直接定位到崩溃点。但是当程序打包成Release发布时,难免会遇到一些崩溃问题。一般遇到这样的崩溃,我们就…

一,为什么需要dump文件

    Windows客户端应用开发时,难免会遇到程序崩溃问题。当程序在Debug下运行崩溃时,我们可以直接定位到崩溃点。但是当程序打包成Release发布时,难免会遇到一些崩溃问题。一般遇到这样的崩溃,我们就需要使用 dump 文件加上符号表文件来进行调试程序。

二,如何生成dump文件

工欲善其事,必先利其器。这里直接给出一个CrashDump类,供各位大佬使用。在main函数实例化即可。生成不了dump文件你来打我~

三,CrashDump代码

CrashDump.h

#pragma once#include <Windows.h>
#include <Dbghelp.h>class CrashDump {
public:explicit CrashDump();~CrashDump();
private:static LONG WINAPI UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* pExceptionInfo);
private:LPTOP_LEVEL_EXCEPTION_FILTER        m_oldExceptionFilter;
};

CrashDump.cpp

#include "CrashDump.h"
#include <ctime>
#include <string>
#include <sstream>
#include <assert.h>
#include <DbgHelp.h>
#include <shellapi.h>
#include <iostream>typedef BOOL(WINAPI *getUserModeExceptionProc)(LPDWORD);
typedef BOOL(WINAPI *setUserModeExceptionProc)(DWORD);typedef BOOL(WINAPI *MINIDUMPWRITEDUMP) (HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,PMINIDUMP_CALLBACK_INFORMATION CallbackParam);static std::wstring format(const wchar_t* pszFormat, ...) {wchar_t buffer[MAX_PATH] = { 0 };va_list ap;va_start(ap, pszFormat);int nCount = ::vswprintf_s(buffer, _countof(buffer), pszFormat, ap);va_end(ap);if (nCount < 0) {assert(false);return pszFormat;}return buffer;
}CrashDump::CrashDump(): m_oldExceptionFilter(NULL) {// 堆异常BOOL bRet = ::HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);::OutputDebugStringW(format(L"HeapSetInformation, bRet: <%lu, %lu>.\n", bRet, ::GetLastError()).c_str());// DEP策略bRet = ::SetProcessDEPPolicy(PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);::OutputDebugStringW(format(L"SetProcessDEPPolicy, bRet: <%lu, %lu>.\n", bRet, ::GetLastError()).c_str());//standard app-wide unhandled exception filterm_oldExceptionFilter = ::SetUnhandledExceptionFilter(UnhandledExceptionFilter);//fix for exceptions being swallowed inside callbacks (see KB976038)HMODULE hKernel32 = GetModuleHandle(TEXT("KERNEL32"));if (NULL == hKernel32) {::OutputDebugStringW(L"GetModuleHandle faled.\n");} else {DWORD dwFlags = 0;getUserModeExceptionProc procGetProcessUserModeExceptionPolicy;setUserModeExceptionProc procSetProcessUserModeExceptionPolicy;procGetProcessUserModeExceptionPolicy = (getUserModeExceptionProc)::GetProcAddress(hKernel32, "GetProcessUserModeExceptionPolicy");procSetProcessUserModeExceptionPolicy = (setUserModeExceptionProc)::GetProcAddress(hKernel32, "SetProcessUserModeExceptionPolicy");if (procGetProcessUserModeExceptionPolicy && procSetProcessUserModeExceptionPolicy) {if (procGetProcessUserModeExceptionPolicy(&dwFlags)) {bRet = procSetProcessUserModeExceptionPolicy(dwFlags & ~1);::OutputDebugStringW(format(L"GetProcessUserModeExceptionPolicy, bRet: %lu.\n", bRet).c_str());}::OutputDebugStringW(format(L"SetProcessUserModeExceptionPolicy, bRet: %lu, dwFlags: %lu.\n", bRet, dwFlags).c_str());}}
}CrashDump::~CrashDump() {if (NULL != m_oldExceptionFilter) {::SetUnhandledExceptionFilter(m_oldExceptionFilter);}
}LONG WINAPI CrashDump::UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* pExceptionInfo) {//always break into a debugger if one is presentif (::IsDebuggerPresent()) {::OutputDebugStringW(L"IsDebuggerPresent return TRUE.\n");return EXCEPTION_CONTINUE_SEARCH;}static BOOL inExceptionHandler = FALSE;if (inExceptionHandler) {::OutputDebugStringW(L"Current function has crashed.Shit.\n");return EXCEPTION_CONTINUE_SEARCH;}inExceptionHandler = TRUE;WCHAR fullPath[MAX_PATH] = { 0 };DWORD pathLength = ::GetModuleFileNameW(NULL, fullPath, MAX_PATH);if (0 == pathLength) {::OutputDebugStringW(L"GetModuleFileNameW failed.\n");return EXCEPTION_CONTINUE_SEARCH;}LPCWSTR lastSlash = ::wcsrchr(fullPath, L'\\');if (NULL == lastSlash) {::OutputDebugStringW(L"wcsrchr return wrong.\n");return EXCEPTION_CONTINUE_SEARCH;}std::wstring exeDirPath(fullPath, lastSlash - fullPath + 1);WCHAR filePath[MAX_PATH] = { 0 };for (int i = 0; ; ++i) { // 避免同名 SYSTEMTIME sys_time = { 0 };::GetLocalTime(&sys_time);::swprintf_s(filePath, _countof(filePath) - 1, L"%s%04u_%02u_%02u_%02u_%02u_%02u_%d.dmp", exeDirPath.c_str(), sys_time.wYear, sys_time.wMonth, sys_time.wDay, sys_time.wHour, sys_time.wMinute, sys_time.wSecond, i);if (::GetFileAttributes(filePath) == INVALID_FILE_ATTRIBUTES) {break;}}HANDLE hFile = ::CreateFileW(filePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);if (INVALID_HANDLE_VALUE == hFile) {::OutputDebugStringW(L"CreateFileW failed.\n");return EXCEPTION_CONTINUE_SEARCH;}//load dbghelp dynamicallyHMODULE hDbgHelp = LoadLibraryW(L"DBGHELP");if (!hDbgHelp) {::OutputDebugStringW(L"LoadLibraryW DBGHELP failed.\n");return EXCEPTION_CONTINUE_SEARCH;}MINIDUMPWRITEDUMP fnMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDbgHelp, "MiniDumpWriteDump");if (!fnMiniDumpWriteDump) {::OutputDebugStringW(L"GetProcAddress MiniDumpWriteDump failed.\n");::FreeLibrary(hDbgHelp);return EXCEPTION_CONTINUE_SEARCH;}MINIDUMP_TYPE dumpFlags = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithUnloadedModules | MiniDumpWithProcessThreadData);MINIDUMP_EXCEPTION_INFORMATION miniInfo = {0};miniInfo.ClientPointers = TRUE;miniInfo.ExceptionPointers = pExceptionInfo;miniInfo.ThreadId = ::GetCurrentThreadId();//generate a minidump if possibleif (fnMiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(), hFile, dumpFlags, &miniInfo, NULL, NULL)) {WCHAR buffer[MAX_PATH] = { 0 };	::swprintf_s(buffer, _countof(buffer) - 1, L"Process has crashed.\nMinidump was saved to: \n\\%s\n", filePath);::OutputDebugStringW(buffer);// ::MessageBoxW(NULL, buffer, NULL, MB_ICONERROR | MB_OK);} else {::OutputDebugStringW(format(L"Minidump was saved failed: %hu.\n", ::GetLastError()).c_str());// ::MessageBoxW(NULL, format(L"Minidump was saved failed: %hu.\n", ::GetLastError()).c_str(), NULL, MB_ICONERROR | MB_OK);}::FreeLibrary(hDbgHelp);::CloseHandle(hFile);return EXCEPTION_CONTINUE_SEARCH;
}

四,在项目中调用

int main(int argc, char* argv[]) {
...CrashDump crashDump;  // 直接实例化即可
...
}

注意要用exe启动,不要用vs启动程序!

http://www.15wanjia.com/news/47338.html

相关文章:

  • 门户网站建设模板百度上打广告怎么收费
  • 营销型网站建设团队搜索引擎排名谷歌
  • 蚌埠网站建设费用网页制作网站
  • 哪里找装修设计师南宁哪里有seo推广厂家
  • 购买域名之后怎么做网站西seo优化排名
  • wordpress定义网站搭建谷歌seo
  • wordpress 主题预览广东seo推广公司
  • 苏州本地网站怎么注册网站免费的
  • 上海松江做网站建设seo分析报告怎么写
  • 初中生做网站挣钱百度总部公司地址在哪里
  • 网站设计制作费用公关公司排名
  • 做网站方案怎么写什么是外链
  • 一起做网站广州批发市场搜索风云榜
  • 网站循环滚动图片z怎么做网络优化器下载
  • 如和做视频解析网站百度做广告怎么收费
  • 学校网络营销推广方案seo网站排名推广
  • 电子商务简介宁波营销型网站建设优化建站
  • 玄武网站建设网络推广预算方案
  • 做婚介网站可行性报告模板促销方案
  • 厦门网站开发公做一个网站的步骤
  • 桂林网站建设官网蜜雪冰城推广软文
  • 单县网站建设企业广告宣传
  • 淮南网站建设服务企业培训权威机构
  • 做聚会的网站谷歌seo最好的公司
  • 销售型网站模板nba排名最新
  • 深圳约的网站设计杭州百度快照优化排名
  • 婚纱影楼网站模板制作网站的步骤和过程
  • 专业网站优化价格网络推广外包一年多少钱
  • 济南企业营销型网站建设价格商丘网络推广公司
  • 东莞做汽车有没有买票的网站软文推广怎么做