TransWikia.com

How can I get a stack trace when running Qt5 applications in a debugger?

Stack Overflow Asked on January 21, 2021

I’m compiling my Qt program with -g -O0 options to get debug symbols. I then run it in lldband it crashes in my code, not the library. But the backtrace I’m getting looks like this:

Target 0: (mastercontrol) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff5c27f2c2 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff5c33abf1 libsystem_pthread.dylib`pthread_kill + 284
    frame #2: 0x00007fff5c1e96a6 libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff593c4641 libc++abi.dylib`abort_message + 231
    frame #4: 0x00007fff593c47c7 libc++abi.dylib`default_terminate_handler() + 243
    frame #5: 0x00007fff5a977eeb libobjc.A.dylib`_objc_terminate() + 105
    frame #6: 0x00007fff593d019e libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x00007fff593c3c7e libc++abi.dylib`__cxa_rethrow + 99
    frame #8: 0x00007fff5a975e35 libobjc.A.dylib`objc_exception_rethrow + 40
    frame #9: 0x00007fff301a05ec CoreFoundation`CFRunLoopRunSpecific + 609
    frame #10: 0x00007fff2f3ff1ab HIToolbox`RunCurrentEventLoopInMode + 292
    frame #11: 0x00007fff2f3feee5 HIToolbox`ReceiveNextEventCommon + 603
    frame #12: 0x00007fff2f3fec76 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
    frame #13: 0x00007fff2d79677d AppKit`_DPSNextEvent + 1135
    frame #14: 0x00007fff2d79546b AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
    frame #15: 0x00007fff2d78f588 AppKit`-[NSApplication run] + 699
    frame #16: 0x000000012264033c libqcocoa.dylib`___lldb_unnamed_symbol693$$libqcocoa.dylib + 2652
    frame #17: 0x0000000108a9b75f QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 431
    frame #18: 0x0000000108a9fb62 QtCore`QCoreApplication::exec() + 130
    frame #19: 0x000000010001b20d mastercontrol`main(argc=1, argv=0x00007ffeefbfe2a0) at master_control.cpp:108:10
    frame #20: 0x00007fff5c1443d5 libdyld.dylib`start + 1
(lldb)

I.e. the actual site of the crash, which is inside my own code somewhere does not show up.

How do I need to configure my CMake build to get an actual stack trace?

One Answer

The exception was caught and rethrown in CoreFoundation::CFRunLoopRunSpecific, not in QT.

You have to run the application under a debugger with first-chance-exception enabled in order to break when the exception is thrown first, rather than breaking when it's left uncaught last.

In gdb, that should be catch throw for enabling breakpoint on exception. In lldb use break set -E c++.

Answered by Ext3h on January 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP