简体   繁体   English

Qt应用程序和Google Breakpad

[英]Qt application and Google Breakpad

I am currently working with an application trying to integrate BreakPad into a Qt application. 我目前正在尝试将BreakPad集成到Qt应用程序中的应用程序。 I found a page that helped me out a bunch with the initial setup and quirks. 我找到了一个页面,该页面帮助我完成了初始设置和怪癖。

https://github.com/JPNaude/dev_notes/wiki/Using-Google-Breakpad-with-Qt https://github.com/JPNaude/dev_notes/wiki/Using-Google-Breakpad-with-Qt

I still cannot get it to work for actual exceptions. 我仍然无法使其适用于实际的例外情况。 I created a demo application and it is having the same issue. 我创建了一个演示应用程序,它存在相同的问题。 Here are the steps I am following to test. 这是我要测试的步骤。 I am testing in debug right now. 我正在调试中进行测试。

  1. Build the application Run dump_syms.exe BreakpadTest.pdb > BreakpadTest.sym 生成应用程序运行dump_syms.exe BreakpadTest.pdb> BreakpadTest.sym
  2. Run the application and generate a dump file 运行应用程序并生成转储文件
  3. Run minidump_stackwalk dumpfile.dmp symbols > out.txt 2>&1 运行minidump_stackwalk dumpfile.dmp符号> out.txt 2>&1
  4. Check out.txt for the file path to place the BreakpadTest.sym 在out.txt中查找放置BreakpadTest.sym的文件路径
  5. Move the BreakpadTest.sym file to the proper location 将BreakpadTest.sym文件移动到正确的位置
  6. Run minidump_stackwalk dumpfile.dmp symbols > out.txt 2>&1 again 再次运行minidump_stackwalk dumpfile.dmp符号> out.txt 2>&1

This leaves me with an out.txt file. 这给我留下了一个out.txt文件。

When I call dumpFunc in my demo application which executes this code 当我在执行此代码的演示应用程序中调用dumpFunc时

Breakpad::CrashHandler::instance()->writeMinidump();

I get the folowing output 我得到以下输出

Thread 0 (crashed)
 0  BreakpadTest.exe!Breakpad::CrashHandler::writeMinidump() [crashhandler.cpp : 118 + 0xb]
    eip = 0x00c03a44   esp = 0x00affe18   ebp = 0x00affe48   ebx = 0x009fe000
    esi = 0x00c01960   edi = 0x00c01960   eax = 0x00affaf0   ecx = 0x00affaf0
    edx = 0x00affdbc   efl = 0x00000216
    Found by: given as instruction pointer in context
 1  BreakpadTest.exe!dumpFunc() [main.cpp : 13 + 0xb]
    eip = 0x00c0364f   esp = 0x00affe50   ebp = 0x00affe50
    Found by: call frame info
 2  BreakpadTest.exe!main [main.cpp : 25 + 0x4]
    eip = 0x00c03746   esp = 0x00affe58   ebp = 0x00affea0
    Found by: call frame info
 3  BreakpadTest.exe!WinMain [qtmain_win.cpp : 113 + 0xc]
    eip = 0x00c14d3d   esp = 0x00affea8   ebp = 0x00affed4
    Found by: call frame info
 4  BreakpadTest.exe!invoke_main [exe_common.inl : 94 + 0x1a]
    eip = 0x00c13b7e   esp = 0x00affedc   ebp = 0x00affeec
    Found by: call frame info
 5  BreakpadTest.exe!__scrt_common_main_seh [exe_common.inl : 253 + 0x4]
    eip = 0x00c13a00   esp = 0x00affef4   ebp = 0x00afff44
    Found by: call frame info
 6  BreakpadTest.exe!__scrt_common_main [exe_common.inl : 295 + 0x4]
    eip = 0x00c1389d   esp = 0x00afff4c   ebp = 0x00afff4c
    Found by: call frame info
 7  BreakpadTest.exe!WinMainCRTStartup [exe_winmain.cpp : 16 + 0x4]
    eip = 0x00c13b98   esp = 0x00afff54   ebp = 0x00afff54
    Found by: call frame info
 8  kernel32.dll + 0x162c3
    eip = 0x76c962c4   esp = 0x00afff5c   ebp = 0x00afff68
    Found by: call frame info
 9  ntdll.dll + 0x60fd8
    eip = 0x77850fd9   esp = 0x00afff70   ebp = 0x00afffb0
    Found by: previous frame's frame pointer
10  ntdll.dll + 0x60fa3
    eip = 0x77850fa4   esp = 0x00afffb8   ebp = 0x00afffc0
    Found by: previous frame's frame pointer

This is good and what I want. 这很好,我想要的。 But when I actually cause an exception with badFunc(). 但是当我实际上使用badFunc()导致异常时。

int *myNull = NULL;
*myNull = 42;

I get the following output 我得到以下输出

Thread 0 (crashed)
 0  ntdll.dll + 0x6e5fc
    eip = 0x7785e5fc   esp = 0x00eff09c   ebp = 0x00eff10c   ebx = 0x00000001
    esi = 0x00000000   edi = 0x00000368   eax = 0x00000000   ecx = 0x6d278097
    edx = 0x00000000   efl = 0x00000206
    Found by: given as instruction pointer in context
 1  KERNELBASE.dll + 0xcad51
    eip = 0x74d7ad52   esp = 0x00eff114   ebp = 0x00eff120
    Found by: previous frame's frame pointer
 2  BreakpadTest.exe!google_breakpad::ExceptionHandler::WriteMinidumpOnHandlerThread(_EXCEPTION_POINTERS *,MDRawAssertionInfo *) [exception_handler.cc : 720 + 0x11]
    eip = 0x009f72d0   esp = 0x00eff128   ebp = 0x00eff138
    Found by: previous frame's frame pointer
 3  BreakpadTest.exe!google_breakpad::ExceptionHandler::HandleException(_EXCEPTION_POINTERS *) [exception_handler.cc : 504 + 0xd]
    eip = 0x009f6d71   esp = 0x00eff140   ebp = 0x00eff178
    Found by: call frame info
 4  KERNELBASE.dll + 0x15d411
    eip = 0x74e0d412   esp = 0x00eff180   ebp = 0x00eff20c
    Found by: call frame info
 5  ntdll.dll + 0x9e0bc
    eip = 0x7788e0bd   esp = 0x00eff214   ebp = 0x00effa10
    Found by: previous frame's frame pointer
 6  ntdll.dll + 0x60fa3
    eip = 0x77850fa4   esp = 0x00effa18   ebp = 0x00effa20
    Found by: previous frame's frame pointer

This is not the actual stack trace where the exception occurred. 这不是发生异常的实际堆栈跟踪。 Any ideas on what is going wrong or how I can change it to get the actual stack? 关于出什么问题或如何更改它以获取实际堆栈的任何想法?

Demo Application http://s000.tinyupload.com/?file_id=26352983283926785193 演示应用程序http://s000.tinyupload.com/?file_id=26352983283926785193

I have been recently down the same rabbit hole as well. 我最近也到过同样的兔子洞。 Taking resources from many places, I put together everything I found in this repo . 从许多地方获取资源,我将在此仓库中找到的所有内容汇总在一起。

One of the things that might affect the stack output is if the optimization level that you are using to compile your application. 可能会影响堆栈输出的一件事是,如果您正在使用优化级别来编译应用程序。 It doesn't matter if you force the creation of debug symbols. 是否强制创建调试符号都没有关系。 The stack will sometimes appear incorrect if you apply any optimization, so what you can try is to disable optimization in your Qt project ( *.pro file) for your release builds as follows: 如果应用任何优化,则堆栈有时会显示为不正确,因此您可以尝试在Qt项目( *.pro文件)中为发布版本禁用优化,如下所示:

CONFIG *= force_debug_info
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -O2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM