breakpad下载-编译-常见问题

一、概述

breakpad是google开源的一套用于进程crash的处理方案,跨平台。
但由于现在有沙盒技术,会导致breakpad无法生成dump,所以google又开发了一个crashpad项目,用来替代breakpad。

二、直接编译

不想自己弄这些的可以下载直接可以编译的源码:https://download.csdn.net/download/Carry_Qt/21541033

三、体验流程

1、源码下载(能访问googlesource访问googlesource,不能的github上找吧)
    breakpad (crash库源码): https://github.com/google/breakpad
    gyp(chromium开发的跨平台自动化项目构建工具):https://github.com/chromium/gyp
    google test:https://github.com/google/googletest
    python 2.7.x:https://www.python.org/downloads/release/python-2718/

2、在breakpad\src下新建testing目录,将gtest解压后的googlemock和googletest拷贝到新建的testing下

3、使用gyp生成sln文件:tools\gyp\gyp.bat --no-circular-check client\windows\breakpad_client.gyp
    成功后在\client\windows\目录下有生成的breakpad_client.sln vs工程文件

四、vs工程设置

1、右键项目名(如crash_generation_client),属性 -> C/C++ -> 常规 -> 把右侧的“将警告视为错误”选项选为否
2、debug构建:属性 -> C/C++ -> 代码生成 -> 运行库 -> 多线程调试dll(/MDd)
3、release构建:属性 -> C/C++ -> 代码生成 -> 运行库 -> 多线程DLL(/MD)

五、项目使用

1、链接库:
    common.lib
    exception_handler.lib
    crash_generation_server.lib
    crash_generation_client.lib
    
    包含路径:breakpad/client  breakpad/common  breakpad/google_breakpad
    
2、代码测试:

#include <cstdio>  
    #include "client/windows/handler/exception_handler.h"      

namespace {

      static bool callback(const wchar_t *dump_path, const wchar_t *id,
        void *context, EXCEPTION_POINTERS *exinfo,
        MDRawAssertionInfo *assertion,
        bool succeeded) {
        if (succeeded) {
          printf("dump guid is %ws\n", id);
        }
        else {
          printf("dump failed\n");
        }
        fflush(stdout);

        return succeeded;
      }

      static void CrashFunction() {
        int *i = reinterpret_cast<int*>(0x45);
        *i = 5;  // crash!  
      }

    }  // namespace  

    int main(int argc, char **argv) {
      google_breakpad::ExceptionHandler eh(
        L".", NULL, callback, NULL,
        google_breakpad::ExceptionHandler::HANDLER_ALL);
      CrashFunction();
      printf("did not crash?\n");
      return 0;
    }


3、在生成路径中找到dump文件,然后用vs打开dump文件,点击使用 仅限本机 进行调试,可以看到错误详情及错误具体发生在哪行代码。

六、常见错误

1、common.lib(guid_string.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MTd_StaticDebug”不匹配值“MDd_DynamicDebug”(main.obj 中)


2、release模式下没有调式信息

qt工程

# QMAKE *.pro-file: enable debugging info in release mode
#
# gcc
#QMAKE_CXXFLAGS_RELEASE += -O0 -g
#QMAKE_CFLAGS_RELEASE += -O0 -g
#QMAKE_LFLAGS_RELEASE =

# msvc
QMAKE_CXXFLAGS_RELEASE += /Zi
QMAKE_CXXFLAGS_RELEASE += /Od
QMAKE_LFLAGS_RELEASE += /DEBUG


# DEFINES +=QT_NO_DEBUG_OUTPUT # disable debug output
DEFINES -=QT_NO_DEBUG_OUTPUT # enable debug output

INCLUDEPATH += $$PWD/3rd/breakpad/include
DEPENDPATH += $$PWD/3rd/breakpad

 vs工程

属性 -> 链接器 -> 调试 -> 调试信息 -> 优化以便于调试 (/DEBUG)

七、参考博客

https://blog.csdn.net/wangshubo1989/article/details/53334033

https://blog.csdn.net/ljttianqin/article/details/78472613

https://blog.csdn.net/bingzhongdehuoyan/article/details/53860433

https://blog.csdn.net/Johnable/article/details/102552883

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搓搓程序狗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值