qt app crash 但不容易重现,我已经捕获了转储堆栈以及如何通过堆栈找出源代码

qt app crash but is not reproduced easily,I have captured the dump stack and how to find out the source code by the stack

  1. Qt 应用程序崩溃但不易重现
  2. 我已经捕获了转储堆栈以及如何通过堆栈找出源代码

编译工具:mingw

OS: windows

我以前一直用android(linux)工作,我们可以用addr2line找出崩溃源码

所以:

当应用程序被测试工程师测试并崩溃并出现dump stack时,我们如何找到源代码函数或行?

最后,尽我最大的努力,我找到了两种离线调试crash app的方法:


首先,我们可以使用位于{mingw路径}/bin的addr2line.exe。例如,如果您得到这样的崩溃日志:

"E:\qt\untitled5.exe"
"Exception Addr:  00904B21 :Module: C:\Qt\Qt5.9.0\5.9\mingw53_32\bin\Qt5Widgetsd.dll"
"Exception Code:  C0000005 :Read Address:  00000000"
"Instruction:  8B 01 8B 40 34 C7 04 24 00 00 00 00 FF D0 83 EC"
"Registers: "
"EAX: 00904B1E  EBX: 185304C8  ECX: 00000000  EDX: 18500048"
"ESI: 1851DD60  EDI: 755E16DD  ESP: 0028FD20  EBP: 0028FD68"
"EIP: 00904B21  EFlags: 00010202"
"00904B21  :C:\Qt\Qt5.9.0\5.9\mingw53_32\bin\Qt5Widgetsd.dll"
"0040187C  :E:\qt\untitled5.exe"
"004017AB  :E:\qt\untitled5.exe"
"004016BC  :E:\qt\untitled5.exe"
"00403B45  :E:\qt\untitled5.exe"

然后我们使用addr2line找出崩溃点

C:\Qt\Qt5.9.0\Tools\mingw530_32\bin>addr2line.exe -f -e e:\qt\untitled5.exe 0040187C 004017AB 004016BC 00403B45
_ZN4testC2Ev
E:\qt\untitled5/test.cpp:6
_ZN10MainWindowC2EP7QWidget
E:\qt\untitled5/mainwindow.cpp:12
_Z5qMainiPPc
E:\qt\untitled5/main.cpp:35
WinMain@16
c:\Users\qt\work\qt\qtbase\src\winmain/qtmain_win.cpp:104


second,使用ExcHndl,Dr.mingw的一部分。我认为这是一个很好的工具。 github 项目 link: enter link description here

而且它还有一个样本,你不会错过的。它有这样的崩溃报告:

Error occurred on Wednesday, September 6, 2017 at 14:25:57.

untitled5.exe caused an Access Violation at location 008F4B21 in module Qt5Widgetsd.dll Reading from location 00000000.

Registers:
eax=008f4b1e ebx=005ff278 ecx=00000000 edx=184b0048 esi=005fdf48 edi=755e16dd
eip=008f4b21 esp=0028fd20 ebp=0028fd68 iopl=0         nv up ei pl nz na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202

AddrPC   Params
008F4B21 00000001 00000000 00000001  Qt5Widgetsd.dll!hide  [c:/Users/qt/work/qt/qtbase/src/widgets/kernel/qwidget.cpp @ 8037]
00401890 00000001 00000000 00050900  untitled5.exe! ??   [E:/qt/untitled5/test.cpp @ 6]
     4: test::test()
     5: {
>    6:     test3 *p = new test3;
     7: }
     8: 
004017BF 00000000 184CED38 00050900  untitled5.exe! ??   [E:/qt/untitled5/mainwindow.cpp @ 10]
     8: {
     9:     ui->setupUi(this);
>   10:     test *t = new test;
    11: }
    12: 
004016D2 00000001 184CED38 00673108  untitled5.exe!qMain  [E:/qt/untitled5/main.cpp @ 29]
    27: 
    28:     QApplication a(argc, argv);
>   29:     MainWindow w;
    30:     w.show();
    31: