vc/vs开发的应用程序添加dump崩溃日志<转>

原贴地址:https://blog.csdn.net/wangkui1331/article/details/78029940

vc/vs开发的应用程序出现崩溃的时候,由于没有任何记录,导致开发人员很难追踪,但是添加dump文件后,就可以免除这些烦恼

1.添加方法

(1)添加头文件

#include <imagehlp.h>
#pragma comment(lib, "DbgHelp.lib")

(2)在InitInstance()函数中添加:

//抓捕异常文件
::SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)ExceptionCrashHandler);  //cash代码

其中ExceptionCrashHandler是自自己添加的回调函数,代码如下:

//抓捕异常信息
LONG ExceptionCrashHandler(EXCEPTION_POINTERS *pException)  
{     
    // 创建Dump文件
    HANDLE hDumpFile = CreateFileW(L"Exception.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    // Dump信息
    MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
    dumpInfo.ExceptionPointers = pException;
    dumpInfo.ThreadId = GetCurrentThreadId();
    dumpInfo.ClientPointers = TRUE;
    // 写入Dump文件内容
    MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL);
    CloseHandle(hDumpFile);
    return EXCEPTION_EXECUTE_HANDLER;  
}

崩溃时会在exe所在目录生成Exception.dmp文件


2.调试方法
调试时需要的文件包括:exe文件,dump文件,还有编译生成对应exe的pdb文件(这就需要提前保存好对应版本的pdb文件,否则提示pdb文件不匹配),保证它们在同一目录下,用vs2010打开dump文件(安装了vs2010的双击dump即可自动打开),按下图操作即可


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<!DOCTYPE html> <?php require_once('MkEncrypt.php'); MkEncrypt('1234'); //这个就是密码 ?> <html> <head> <meta charset="UTF-8"> <title>GOLA 2.0</title> </head> <style type="text/css"> .wrapper {width: 1000px;margin: 20px auto;} h2 {text-align: center;} .add {margin-bottom: 20px;} .add a {text-decoration: none;color: #fff;background-color: green;padding: 6px;border-radius: 5px;} td {text-align: center;} </style> <body> <div class="wrapper"> <h2>GOLA 2.0</h2> <div class="add"> <!--<a href="adduser.html">增加新闻</a>--> </div> <table width="960" border="1"> <tr> <th>ID</th> <th>用户呀</th> <th>手机呀</th> <th>刷新密码</th> <th>总资</th> <th>可用</th> <th>操作</th> </tr> <?php // 1.导入配置文件 require "dbconfig.php"; // 2. 连接mysql $link = @mysql_connect(HOST,USER,PASS) or die("提示:数据库连接失败!"); // 选择数据库 mysql_select_db(DBNAME,$link); // 编码设置 mysql_set_charset('utf8',$link); // 3. 从DBNAME中查询到user数据库,返回数据库结果集,并按照addtime降序排列 $sql = 'select * from user order by id asc'; // 结果集 $result = mysql_query($sql,$link); // var_dump($result);die; // 解析结果集,$row为新闻所有数据,$userNum为新闻数目 $userNum=mysql_num_rows($result); for($i=0; $i<$userNum; $i++){ $row = mysql_fetch_assoc($result); echo "<tr>"; echo "<td>{$row['id']}</td>"; echo "<td>{$row['agent_name']}</td>"; echo "<td>{$row['phone']}</td>"; echo "<td>{$row['with_pwd']}</td>"; echo "<td>{$row['user_amt']}</td>"; echo "<td>{$row['enable_amt']}</td>"; echo "<td> <a href='javascript:del({$row['id']})'>删除</a> <a href='editnews.php?id={$row['id']}'>修改</a> </td>"; echo "</tr>"; } // 5. 释放结果集 mysql_free_result($result); mysql_close($link); ?> </table> </div> <script type="text/javascript"> function del (id) { if (confirm("确定删除这条新闻吗?")){ window.location = "action-del.php?id="+id; } } </script> </body> </html> 美化一下页面
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值