[KDE/Mac] Review Request 121286: Adding support for lldb in DrKonqi (step 1)

René J.V. Bertin rjvbertin at gmail.com
Sun Nov 30 19:53:44 UTC 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/121286/
-----------------------------------------------------------

(Updated Nov. 30, 2014, 8:53 p.m.)


Review request for KDE Software on Mac OS X and KDE Runtime.


Changes
-------

Includes fixes for the remaining open issues, and adds a generic Debugger::backendValueForParameter method that is used to read an ExecInputFile from lldbrc. With that parameter set to %tempfile, there is no more need to redirect from /dev/null .

I asked about post-mortem debugging on the lldb-dev ML, here's the feedback I got from Jason Molenda:

```
The short backtrace in that discussion is a tricky one -- _sigtramp followed by objc_msgSend.  Both of these can be difficult for the unwinder to backtrace out of (_sigtramp because the register context is saved out-of-band by the kernel and we rely on accurate eh_frame instructions to find it) and objc_msgSend because it is hand-written assembly with some hand-written eh_frame instructions that are accurate at many -- but not all -- points in the function.

I have seen some edge cases on Mavericks (Mac OS X 10.10) where _sigtramp unwinding is not completely accurate.  It's on my todo list to figure out what's going on there.

If your process was at a location in objc_msgSend that did not have accurate eh_frame unwind descriptions, that would also account for this.

I think it will be difficult to hit this backtrace again, it is likely to be rare.  Your process of attaching and collecting information looks reasonable to me.

I gather you're scraping the output of lldb for information about the crash.  This can be a problem as the debugger output changes over time ... if I were writing a tool like this, I would probably write it in Python using the SB API that lldb supports.  lldb is actually a debugger *library* and the lldb command line program is one client of that library (Xcode is another).  You can write a Python script (or C++ program) that uses the library to attach to the process, iterate over the threads, print the backtrace information you want, etc.

It's probably more work than you want to do right now but for long-term maintainability, it would be the way to go.  
```


Repository: kde-runtime


Description
-------

DrKonqi currently lacks support for lldb, which means KDE users on recent OS X versions cannot generate and submit post-mortem backtraces.

The patches in this RR introduce simple logic (based on *compile-time* OS version detection) to select either gdb or lldb, as well as appropriate lldbrc files.

This is the first step to be taken: determine when lldb should be launched, and how (to obtain a backtrace).


Diffs (updated)
-----

  drkonqi/data/debuggers/external/lldbrc PRE-CREATION 
  drkonqi/data/debuggers/internal/lldbrc PRE-CREATION 
  drkonqi/debugger.h 1451397 
  drkonqi/backtracegenerator.cpp 1107e11 
  drkonqi/parser/backtraceparserlldb.h PRE-CREATION 
  drkonqi/debugger.cpp 26ca338 
  drkonqi/drkonqibackends.cpp 064d07d 
  drkonqi/parser/CMakeLists.txt d08d0d7 
  drkonqi/parser/backtraceparser.cpp 7f62c97 
  drkonqi/parser/backtraceparserlldb.cpp PRE-CREATION 

Diff: https://git.reviewboard.kde.org/r/121286/diff/


Testing
-------

On OS X 10.9.4 with kdelibs git/4.14 .
Launching lldb works, as does the BatchCommand to obtain a backtrace; parsing of that information will be tackled later.
The backtrace isn't particularly useful though, because it doesn't (always/never/...?) display the location of the crash and steps leading up to it, *presumably* because of an issue in the interaction between KDE's crash reporter and lldb. This will need work...

```
Application: Kate (kate), signal: Segmentation fault: 11
(lldb) process attach --pid 88853
Process 88853 stopped
Executable module set to "/opt/local/bin/kate".
Architecture set to: x86_64-apple-macosx.
(lldb) command source -s 0 '/private/var/folders/j1/1439ppj08xj8h6006s6drbq00000gs/T/kde-bertin/drkonqiB88857.tmp'
Executing commands in '/private/var/folders/j1/1439ppj08xj8h6006s6drbq00000gs/T/kde-bertin/drkonqiB88857.tmp'.
(lldb) set set term-width 200
(lldb) set set interpreter.prompt-on-quit false
(lldb) thread info
thread #1: tid = 0x1bda48, 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP

(lldb) bt all
* thread #1: tid = 0x1bda48, 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8
    frame #1: 0x000000010272bc8e libkdeui.5.dylib`KCrash::startProcess(int, char const**, bool) [inlined] startProcessInternal(argc=<unavailable>, directly=<unavailable>) + 265 at kcrash.cpp:556
    frame #2: 0x000000010272bb85 libkdeui.5.dylib`KCrash::startProcess(argc=<unavailable>, argv=<unavailable>, waitAndExit=<unavailable>) + 21 at kcrash.cpp:538
    frame #3: 0x000000010272adb9 libkdeui.5.dylib`KCrash::defaultCrashHandler(sig=<unavailable>) + 1209 at kcrash.cpp:441
    frame #4: 0x00007fff8fe965aa libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x00007fff8a55c098 libobjc.A.dylib`objc_msgSend + 24

  thread #2: tid = 0x1bda4b, 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff905a1421 libdispatch.dylib`_dispatch_mgr_invoke + 239
    frame #2: 0x00007fff905a1136 libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #3: tid = 0x1bda4c, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #4: tid = 0x1bda52, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #5: tid = 0x1bda75, 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10, name = 'com.apple.CFSocket.private'
    frame #0: 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10
    frame #1: 0x00007fff8b12fa03 CoreFoundation`__CFSocketManager + 867
    frame #2: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #3: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #4: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #6: tid = 0x1bda83, 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff8cb80d18 libsystem_kernel.dylib`mach_msg + 64
    frame #2: 0x00007fff8b0e3f15 CoreFoundation`__CFRunLoopServiceMachPort + 181
    frame #3: 0x00007fff8b0e3539 CoreFoundation`__CFRunLoopRun + 1161
    frame #4: 0x00007fff8b0e2e75 CoreFoundation`CFRunLoopRunSpecific + 309
    frame #5: 0x00007fff8e30d05e AppKit`_NSEventThread + 144
    frame #6: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #7: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #8: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #7: tid = 0x1bdcba, 0x00007fff8cb85a3a libsystem_kernel.dylib`__semwait_signal + 10, name = 'com.apple.appkit-heartbeat'
    frame #0: 0x00007fff8cb85a3a libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fff88fbcdc0 libsystem_c.dylib`nanosleep + 200
    frame #2: 0x00007fff88fbccb2 libsystem_c.dylib`usleep + 54
    frame #3: 0x00007fff8e3d117d AppKit`-[NSUIHeartBeat _heartBeatThread:] + 2132
    frame #4: 0x00007fff9368776b Foundation`__NSThread__main__ + 1318
    frame #5: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #7: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13
(lldb) detach
Process 88853 detached
(lldb) quit
```

Same crash but backtrace generated after starting the app in the debugger (instead of attaching to it):

```
* thread #1: tid = 0x1be8ca, 0x0000000101283430 QtGui`qt_mac_create_imagemask(pixmap=<unavailable>, sr=0x00007fff5fbfcbf0) + 752 at qpixmap_mac.cpp:1090, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x0000000101283430 QtGui`qt_mac_create_imagemask(pixmap=<unavailable>, sr=0x00007fff5fbfcbf0) + 752 at qpixmap_mac.cpp:1090
   1087     for(int y = sy, offset=0; y < sh; ++y) {
   1088         srow = sptr + (y * (sbpr / 4));
   1089         for(int x = sx; x < sw; ++x)
-> 1090             *(dptr+(offset++)) = (*(srow+x) & mask) ? 255 : 0;
   1091     }
   1092     QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0, dptr, nbytes, qt_mac_cgimage_data_free);
   1093     px->cg_mask = CGImageMaskCreate(sw, sh, 8, 8, nbytes / sh, provider, 0, 0);
[snip]
(lldb) bt all
* thread #1: tid = 0x1be8ca, 0x0000000101283430 QtGui`qt_mac_create_imagemask(pixmap=<unavailable>, sr=0x00007fff5fbfcbf0) + 752 at qpixmap_mac.cpp:1090, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x0000000101283430 QtGui`qt_mac_create_imagemask(pixmap=<unavailable>, sr=0x00007fff5fbfcbf0) + 752 at qpixmap_mac.cpp:1090
    frame #1: 0x000000010139dafb QtGui`qt_mac_draw_pattern(info=0x0000000105089e10, c=0x000000011232fd30) + 907 at qpaintengine_mac.cpp:494
    frame #2: 0x00007fff93e1ca6f CoreGraphics`CGPatternDelegateDrawPattern + 66
    frame #3: 0x00000001126d475a libPDFRIP.A.dylib`PDFPatternEmitDefinition + 1299
    frame #4: 0x00000001126d49c6 libPDFRIP.A.dylib`emitPatternDefinition + 14
    frame #5: 0x00007fff8b0d1382 CoreFoundation`__CFSetApplyFunction_block_invoke + 18
    frame #6: 0x00007fff8b0b58fc CoreFoundation`CFBasicHashApply + 124
    frame #7: 0x00007fff8b0d133d CoreFoundation`CFSetApplyFunction + 173
    frame #8: 0x00000001126d4993 libPDFRIP.A.dylib`PDFPatternSetEmitDefinitions + 71
    frame #9: 0x00000001126caa0c libPDFRIP.A.dylib`emit_page_resources(PDFDocument*) + 59
    frame #10: 0x00000001126ca9b0 libPDFRIP.A.dylib`PDFDocumentEndPage + 73
    frame #11: 0x00000001126c9570 libPDFRIP.A.dylib`pdf_EndPage + 17
    frame #12: 0x00007fff8f7e7ea3 PrintCore`pdfSpoolingEndPage(void*, void*) + 345
    frame #13: 0x00007fff8f7df835 PrintCore`PJCEndPage(OpaquePMPrintSession*) + 40
    frame #14: 0x00007fff8f7bd3b6 PrintCore`PMSessionEndPageNoDialog + 80
    frame #15: 0x00000001011812c7 QtGui`QMacPrintEngine::end() + 103
    frame #16: 0x00000001012dad0e QtGui`QPainter::end(this=<unavailable>) + 142 at qpainter.cpp:1963
    frame #17: 0x000000010d841159 libkatepartinterfaces.4.dylib`KatePrinter::print(doc=<unavailable>) + 17097 at kateprinter.cpp:669
    frame #18: 0x000000010d69533a libkatepartinterfaces.4.dylib`KateDocument::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) [inlined] KateDocument::print() + 1994 at katedocument.cpp:1855
    frame #19: 0x000000010d695332 libkatepartinterfaces.4.dylib`KateDocument::qt_static_metacall(_o=0x000000010508be40, _c=<unavailable>, _id=<unavailable>, _a=0x00007fff5fbfdd40) + 1986 at katedocument.moc:267
    frame #20: 0x000000010276b3fd QtCore`QMetaObject::activate(sender=0x00000001036d1b20, m=<unavailable>, local_signal_index=<unavailable>, argv=<unavailable>) + 1693 at qobject.cpp:3567
    frame #21: 0x00000001011bd419 QtGui`QAction::activate(QAction::ActionEvent) [inlined] QAction::triggered(this=0x00000001036d1b20, _t1=false) + 233 at moc_qaction.cpp:277
    frame #22: 0x00000001011bd3f1 QtGui`QAction::activate(this=0x00000001036d1b20, event=<unavailable>) + 193 at qaction.cpp:1257
    frame #23: 0x0000000101171c91 QtGui`-[QCocoaMenuLoader qtDispatcherToQAction:] + 65
    frame #24: 0x00007fff8e38b260 AppKit`-[NSApplication sendAction:to:from:] + 327
    frame #25: 0x00007fff8e3a61c8 AppKit`-[NSMenuItem _corePerformAction] + 394
    frame #26: 0x00007fff8e3a5f04 AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 117
    frame #27: 0x00007fff8e3a507c AppKit`-[NSMenu performKeyEquivalent:] + 289
    frame #28: 0x00007fff8e3a18e1 AppKit`-[NSApplication _handleKeyEquivalent:] + 822
    frame #29: 0x00007fff8e310acc AppKit`-[NSApplication sendEvent:] + 3293
    frame #30: 0x00000001011720fe QtGui`-[QNSApplication sendEvent:] + 78
    frame #31: 0x00007fff8e1609f9 AppKit`-[NSApplication run] + 646
    frame #32: 0x000000010117aba0 QtGui`QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 528
    frame #33: 0x00000001027508ad QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x00007fff00000024) + 9 at qglobal.h:2319
    frame #34: 0x00000001027508a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x00007fff00000024) at qglobal.h:2319
    frame #35: 0x00000001027508a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags<QEventLoop::ProcessEventsFlag>::operator|(this=<unavailable>, f=EventLoopExec) const + 59 at qeventloop.cpp:149
    frame #36: 0x0000000102750869 QtCore`QEventLoop::exec(this=0x00007fff5fbfe500, flags=(i = 0)) + 409 at qeventloop.cpp:204
    frame #37: 0x0000000102753ac7 QtCore`QCoreApplication::exec() + 199 at qcoreapplication.cpp:1225
    frame #38: 0x0000000100011693 libkdeinit4_kate.dylib`kdemain(argc=<unavailable>, argv=<unavailable>) + 13507 at katemain.cpp:381
    frame #39: 0x00007fff8d6075fd libdyld.dylib`start + 1
    frame #40: 0x00007fff8d6075fd libdyld.dylib`start + 1

  thread #2: tid = 0x1be8ee, 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff905a1421 libdispatch.dylib`_dispatch_mgr_invoke + 239
    frame #2: 0x00007fff905a1136 libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #3: tid = 0x1be8ef, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #4: tid = 0x1be8f0, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #5: tid = 0x1be8fe, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #6: tid = 0x1be909, 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10, name = 'com.apple.CFSocket.private'
    frame #0: 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10
    frame #1: 0x00007fff8b12fa03 CoreFoundation`__CFSocketManager + 867
    frame #2: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #3: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #4: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #7: tid = 0x1be915, 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff8cb80d18 libsystem_kernel.dylib`mach_msg + 64
    frame #2: 0x00007fff8b0e3f15 CoreFoundation`__CFRunLoopServiceMachPort + 181
    frame #3: 0x00007fff8b0e3539 CoreFoundation`__CFRunLoopRun + 1161
    frame #4: 0x00007fff8b0e2e75 CoreFoundation`CFRunLoopRunSpecific + 309
    frame #5: 0x00007fff8e30d05e AppKit`_NSEventThread + 144
    frame #6: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #7: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #8: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #8: tid = 0x1be963, 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #0: 0x00007fff8cb85e6a libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0x00007fff8f5d6f08 libsystem_pthread.dylib`_pthread_wqthread + 330
    frame #2: 0x00007fff8f5d9fb9 libsystem_pthread.dylib`start_wqthread + 13

  thread #9: tid = 0x1bea53, 0x00007fff8cb85a3a libsystem_kernel.dylib`__semwait_signal + 10, name = 'com.apple.appkit-heartbeat'
    frame #0: 0x00007fff8cb85a3a libsystem_kernel.dylib`__semwait_signal + 10
    frame #1: 0x00007fff88fbcdc0 libsystem_c.dylib`nanosleep + 200
    frame #2: 0x00007fff88fbccb2 libsystem_c.dylib`usleep + 54
    frame #3: 0x00007fff8e3d117d AppKit`-[NSUIHeartBeat _heartBeatThread:] + 2132
    frame #4: 0x00007fff9368776b Foundation`__NSThread__main__ + 1318
    frame #5: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #7: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13
```


Thanks,

René J.V. Bertin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-mac/attachments/20141130/cbaf6cef/attachment-0001.html>


More information about the kde-mac mailing list