<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/121213/">https://git.reviewboard.kde.org/r/121213/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On November 22nd, 2014, 11:20 nachm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/121213/diff/1/?file=329504#file329504line717" style="color: black; font-weight: bold; text-decoration: underline;">kdecore/io/kdebug.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">K_GLOBAL_STATIC(KDebugPrivate, kDebug_data)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">717</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">const</span> <span class="kt">int</span> <span class="n">mangledNameEnd</span> <span class="o">=</span> <span class="n">in</span><span class="p">.</span><span class="n">indexOf</span><span class="p">(</span><span class="s">" + "</span><span class="p">,</span> <span class="n">mangledNameStart</span> <span class="o">+</span> <span class="mi">2</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Why do you need to sharpen the match?</p></pre>
</blockquote>
<p>On November 22nd, 2014, 11:32 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Because otherwise the symbol to be demangled is left with a trailing space, which causes the demangle to fail. Wanna know how I know?</p></pre>
</blockquote>
<p>On November 22nd, 2014, 11:44 nachm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Don't know about the GCC behavior on trailing spaces, but one should probably have some "while (in.at(mangledNameEnd) == ' ') --mangledNameEnd;" loop?</p></pre>
</blockquote>
<p>On November 23rd, 2014, 12:20 vorm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">One could, but why? The start is found with a string, I don't see why the end wouldn't be, given that that loop of yours will always loop just once ...</p></pre>
</blockquote>
<p>On November 23rd, 2014, 12:31 vorm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">... or not at all or thrice - depending on how the mangler feels today.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">What I mean is that if untrimmed strings are a problem for demangling, one should seek to get rid of all the whitespace generically - i don't care about whether seeking for a string or char, this context is hardly performance critical.</p></pre>
</blockquote>
<p>On November 24th, 2014, 5:53 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">this particular bit of whitespace has nothing to do with the mangler or how it feels today. It's formatting done by the backtrace function, which clearly always puts a space-padded <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">+</code> rather than one without padding as under Linux.
Frankly, in general I'd agree with you, but here I don't see any reason to make the code more complex than it is.</p></pre>
</blockquote>
<p>On November 24th, 2014, 8:06 nachm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">backtrace() is provided by glibc resp. the apple (darwin) libc (i hope).
-> What provides /usr/include/execinfo.h on OSX?
That's what is needed to be detected (I assume this would affect <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">all</em> BSD variants?)</p>
<blockquote style="text-rendering: inherit;padding: 0 0 0 1em;border-left: 1px solid #bbb;white-space: normal;margin: 0 0 0 0.5em;line-height: inherit;">
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I don't see any reason to make the code more complex than it is.</p>
</blockquote>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">If we're dealing w/ unspecified output and need to sanitize it, we may have to do this generically if we must consider random toolchains aside gcc+glibc.
I know that you only care about OSX, but actually OSX is just a good testcase to see whether the code is "correct" or just happens to work.</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Do you compile with gcc or clang?</li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">Did you check whether the glibc backtrace() output is actually stripped?</li>
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">What if we compile glibc w/ llvm and glibc backtrace() fires padded " + " which llvm __cxa_demangle() cannot handle? (ok, rethorical question ;-)</li>
</ul></pre>
</blockquote>
<p>On November 24th, 2014, 9:41 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><blockquote style="text-rendering: inherit;padding: 0 0 0 1em;border-left: 1px solid #bbb;white-space: normal;margin: 0 0 0 0.5em;line-height: inherit;">
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">backtrace() is provided by glibc resp. the apple (darwin) libc (i hope).</p>
</blockquote>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Not that we have something called libc on OS X, but I think that just underlines my point. The C Library is more part of the system than it is of the C "package", so the only check on compiler that would make sense IMHO is on the system compiler, as far as that's possible (like the Apple-provided <strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">APPLE_CC</strong>).</p>
<blockquote style="text-rendering: inherit;padding: 0 0 0 1em;border-left: 1px solid #bbb;white-space: normal;margin: 0 0 0 0.5em;line-height: inherit;">
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">What provides /usr/include/execinfo.h on OSX?</p>
</blockquote>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">If you're talking about packages: either the standard install, or Xcode and/or "Command Line Tools".
One shouldn't take OS X as a guideline for any BSD variant, it might even have diverged too much to use BSD as a guideline for what ought to work on OS X.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I agree about the sanitising/generalising, which is why I pulled the suppression of trailing whitespace out of the end token search (and you'll notice I don't just suppress spaces). I just don't think it'd make any sense to have a os/toolchain-specific constant and then the actual search one-liner. Just put that search statement in the conditional block and be done with it.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This patch has currently been tested only on 10.9(.4), which means I can basically only test with clang. I can affirm though that the existing code doesn't demangle on 10.6 either, whether I use clang or gcc.</p>
<blockquote style="text-rendering: inherit;padding: 0 0 0 1em;border-left: 1px solid #bbb;white-space: normal;margin: 0 0 0 0.5em;line-height: inherit;">
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Did you check whether the glibc backtrace() output is actually stripped?</p>
</blockquote>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I don't understand the question?</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This is what unparsed output from backtrace_symbols looks like (even adding the counter: isn't required):</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #666666">0:</span> <span style="color: #BA2121">"0 libkdecore.5.dylib 0x0000000106656f71 _Z14kRealBacktracei + 81"</span>
<span style="color: #666666">1:</span> <span style="color: #BA2121">"1 kwindowtest 0x0000000105e322e1 _ZN10TestWindow8slotOpenEv + 2753"</span>
<span style="color: #666666">2:</span> <span style="color: #BA2121">"2 kwindowtest 0x0000000105e33d68 _ZN10TestWindow18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv + 184"</span>
<span style="color: #666666">3:</span> <span style="color: #BA2121">"3 QtCore 0x0000000106c8d3fd _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 1693"</span>
<span style="color: #666666">4:</span> <span style="color: #BA2121">"4 QtGui 0x0000000106faf419 _ZN7QAction8activateENS_11ActionEventE + 233"</span>
<span style="color: #666666">5:</span> <span style="color: #BA2121">"5 QtGui 0x00000001073141e4 _ZN22QAbstractButtonPrivate5clickEv + 84"</span>
<span style="color: #666666">6:</span> <span style="color: #BA2121">"6 QtGui 0x0000000107314fc8 _ZN15QAbstractButton17mouseReleaseEventEP11QMouseEvent + 88"</span>
<span style="color: #666666">7:</span> <span style="color: #BA2121">"7 QtGui 0x00000001073db67f _ZN11QToolButton17mouseReleaseEventEP11QMouseEvent + 15"</span>
<span style="color: #666666">8:</span> <span style="color: #BA2121">"8 QtGui 0x00000001070069bd _ZN7QWidget5eventEP6QEvent + 717"</span>
<span style="color: #666666">9:</span> <span style="color: #BA2121">"9 QtGui 0x0000000107314ed4 _ZN15QAbstractButton5eventEP6QEvent + 180"</span>
<span style="color: #666666">10:</span> <span style="color: #BA2121">"10 QtGui 0x00000001073dbb2a _ZN11QToolButton5eventEP6QEvent + 170"</span>
<span style="color: #666666">11:</span> <span style="color: #BA2121">"11 QtGui 0x0000000106fb840c _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent + 252"</span>
<span style="color: #666666">12:</span> <span style="color: #BA2121">"12 QtGui 0x0000000106fba357 _ZN12QApplication6notifyEP7QObjectP6QEvent + 2919"</span>
<span style="color: #666666">13:</span> <span style="color: #BA2121">"13 QtCore 0x0000000106c75516 _ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent + 118"</span>
<span style="color: #666666">14:</span> <span style="color: #BA2121">"14 QtGui 0x0000000106fb8df6 _ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Eb + 470"</span>
<span style="color: #666666">15:</span> <span style="color: #BA2121">"15 QtGui 0x0000000106f67a2a _Z23qt_mac_handleMouseEventP7NSEventN6QEvent4TypeEN2Qt11MouseButtonEP7QWidgetb + 922"</span>
<span style="color: #666666">16:</span> <span style="color: #BA2121">"16 AppKit 0x00007fff9491f145 -[NSWindow sendEvent:] + 781"</span>
<span style="color: #666666">17:</span> <span style="color: #BA2121">"17 QtGui 0x0000000106f5f2f1 -[QCocoaWindow sendEvent:] + 113"</span>
<span style="color: #666666">18:</span> <span style="color: #BA2121">"18 AppKit 0x00007fff948c05d4 -[NSApplication sendEvent:] + 2021"</span>
<span style="color: #666666">19:</span> <span style="color: #BA2121">"19 QtGui 0x0000000106f640fe -[QNSApplication sendEvent:] + 78"</span>
<span style="color: #666666">20:</span> <span style="color: #BA2121">"20 AppKit 0x00007fff947109f9 -[NSApplication run] + 646"</span>
<span style="color: #666666">21:</span> <span style="color: #BA2121">"21 QtGui 0x0000000106f6cba0 _ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE + 528"</span>
<span style="color: #666666">22:</span> <span style="color: #BA2121">"22 QtCore 0x0000000106c728ad _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE + 477"</span>
<span style="color: #666666">23:</span> <span style="color: #BA2121">"23 QtCore 0x0000000106c75ac7 _ZN16QCoreApplication4execEv + 199"</span>
<span style="color: #666666">24:</span> <span style="color: #BA2121">"24 kwindowtest 0x0000000105e33bdc main + 316"</span>
<span style="color: #666666">25:</span> <span style="color: #BA2121">"25 libdyld.dylib 0x00007fff93bb75fd start + 1"</span>
<span style="color: #666666">26:</span> <span style="color: #BA2121">"26 ??? 0x0000000000000002 0x0 + 2"</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">which is converted to:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #666666">0:</span> <span style="color: #666666">0</span> libkdecore<span style="color: #666666">.5</span>.dylib <span style="color: #666666">0x0000000106656f71</span> kRealBacktrace(<span style="color: #B00040">int</span>) <span style="color: #666666">+</span> <span style="color: #666666">81</span>
<span style="color: #666666">1:</span> <span style="color: #666666">1</span> kwindowtest <span style="color: #666666">0x0000000105e322e1</span> TestWindow<span style="color: #666666">::</span>slotOpen() <span style="color: #666666">+</span> <span style="color: #666666">2753</span>
<span style="color: #666666">2:</span> <span style="color: #666666">2</span> kwindowtest <span style="color: #666666">0x0000000105e33d68</span> TestWindow<span style="color: #666666">::</span>qt_static_metacall(QObject<span style="color: #666666">*</span>, QMetaObject<span style="color: #666666">::</span>Call, <span style="color: #B00040">int</span>, <span style="color: #B00040">void</span><span style="color: #666666">**</span>) <span style="color: #666666">+</span> <span style="color: #666666">184</span>
<span style="color: #666666">3:</span> <span style="color: #666666">3</span> QtCore <span style="color: #666666">0x0000000106c8d3fd</span> QMetaObject<span style="color: #666666">::</span>activate(QObject<span style="color: #666666">*</span>, QMetaObject <span style="color: #008000; font-weight: bold">const</span><span style="color: #666666">*</span>, <span style="color: #B00040">int</span>, <span style="color: #B00040">void</span><span style="color: #666666">**</span>) <span style="color: #666666">+</span> <span style="color: #666666">1693</span>
<span style="color: #666666">4:</span> <span style="color: #666666">4</span> QtGui <span style="color: #666666">0x0000000106faf419</span> QAction<span style="color: #666666">::</span>activate(QAction<span style="color: #666666">::</span>ActionEvent) <span style="color: #666666">+</span> <span style="color: #666666">233</span>
<span style="color: #666666">5:</span> <span style="color: #666666">5</span> QtGui <span style="color: #666666">0x00000001073141e4</span> QAbstractButtonPrivate<span style="color: #666666">::</span>click() <span style="color: #666666">+</span> <span style="color: #666666">84</span>
<span style="color: #666666">6:</span> <span style="color: #666666">6</span> QtGui <span style="color: #666666">0x0000000107314fc8</span> QAbstractButton<span style="color: #666666">::</span>mouseReleaseEvent(QMouseEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">88</span>
<span style="color: #666666">7:</span> <span style="color: #666666">7</span> QtGui <span style="color: #666666">0x00000001073db67f</span> QToolButton<span style="color: #666666">::</span>mouseReleaseEvent(QMouseEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">15</span>
<span style="color: #666666">8:</span> <span style="color: #666666">8</span> QtGui <span style="color: #666666">0x00000001070069bd</span> QWidget<span style="color: #666666">::</span>event(QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">717</span>
<span style="color: #666666">9:</span> <span style="color: #666666">9</span> QtGui <span style="color: #666666">0x0000000107314ed4</span> QAbstractButton<span style="color: #666666">::</span>event(QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">180</span>
<span style="color: #666666">10:</span> <span style="color: #666666">10</span> QtGui <span style="color: #666666">0x00000001073dbb2a</span> QToolButton<span style="color: #666666">::</span>event(QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">170</span>
<span style="color: #666666">11:</span> <span style="color: #666666">11</span> QtGui <span style="color: #666666">0x0000000106fb840c</span> QApplicationPrivate<span style="color: #666666">::</span>notify_helper(QObject<span style="color: #666666">*</span>, QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">252</span>
<span style="color: #666666">12:</span> <span style="color: #666666">12</span> QtGui <span style="color: #666666">0x0000000106fba357</span> QApplication<span style="color: #666666">::</span>notify(QObject<span style="color: #666666">*</span>, QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">2919</span>
<span style="color: #666666">13:</span> <span style="color: #666666">13</span> QtCore <span style="color: #666666">0x0000000106c75516</span> QCoreApplication<span style="color: #666666">::</span>notifyInternal(QObject<span style="color: #666666">*</span>, QEvent<span style="color: #666666">*</span>) <span style="color: #666666">+</span> <span style="color: #666666">118</span>
<span style="color: #666666">14:</span> <span style="color: #666666">14</span> QtGui <span style="color: #666666">0x0000000106fb8df6</span> QApplicationPrivate<span style="color: #666666">::</span>sendMouseEvent(QWidget<span style="color: #666666">*</span>, QMouseEvent<span style="color: #666666">*</span>, QWidget<span style="color: #666666">*</span>, QWidget<span style="color: #666666">*</span>, QWidget<span style="color: #666666">**</span>, QPointer<span style="color: #666666"><</span>QWidget<span style="color: #666666">>&</span>, <span style="color: #B00040">bool</span>) <span style="color: #666666">+</span> <span style="color: #666666">470</span>
<span style="color: #666666">15:</span> <span style="color: #666666">15</span> QtGui <span style="color: #666666">0x0000000106f67a2a</span> qt_mac_handleMouseEvent(NSEvent<span style="color: #666666">*</span>, QEvent<span style="color: #666666">::</span>Type, Qt<span style="color: #666666">::</span>MouseButton, QWidget<span style="color: #666666">*</span>, <span style="color: #B00040">bool</span>) <span style="color: #666666">+</span> <span style="color: #666666">922</span>
<span style="color: #666666">16:</span> <span style="color: #666666">16</span> AppKit <span style="color: #666666">0x00007fff9491f145</span> <span style="color: #666666">-</span>[NSWindow sendEvent<span style="color: #666666">:</span>] <span style="color: #666666">+</span> <span style="color: #666666">781</span>
<span style="color: #666666">17:</span> <span style="color: #666666">17</span> QtGui <span style="color: #666666">0x0000000106f5f2f1</span> <span style="color: #666666">-</span>[QCocoaWindow sendEvent<span style="color: #666666">:</span>] <span style="color: #666666">+</span> <span style="color: #666666">113</span>
<span style="color: #666666">18:</span> <span style="color: #666666">18</span> AppKit <span style="color: #666666">0x00007fff948c05d4</span> <span style="color: #666666">-</span>[NSApplication sendEvent<span style="color: #666666">:</span>] <span style="color: #666666">+</span> <span style="color: #666666">2021</span>
<span style="color: #666666">19:</span> <span style="color: #666666">19</span> QtGui <span style="color: #666666">0x0000000106f640fe</span> <span style="color: #666666">-</span>[QNSApplication sendEvent<span style="color: #666666">:</span>] <span style="color: #666666">+</span> <span style="color: #666666">78</span>
<span style="color: #666666">20:</span> <span style="color: #666666">20</span> AppKit <span style="color: #666666">0x00007fff947109f9</span> <span style="color: #666666">-</span>[NSApplication run] <span style="color: #666666">+</span> <span style="color: #666666">646</span>
<span style="color: #666666">21:</span> <span style="color: #666666">21</span> QtGui <span style="color: #666666">0x0000000106f6cba0</span> QEventDispatcherMac<span style="color: #666666">::</span>processEvents(QFlags<span style="color: #666666"><</span>QEventLoop<span style="color: #666666">::</span>ProcessEventsFlag<span style="color: #666666">></span>) <span style="color: #666666">+</span> <span style="color: #666666">528</span>
<span style="color: #666666">22:</span> <span style="color: #666666">22</span> QtCore <span style="color: #666666">0x0000000106c728ad</span> QEventLoop<span style="color: #666666">::</span>exec(QFlags<span style="color: #666666"><</span>QEventLoop<span style="color: #666666">::</span>ProcessEventsFlag<span style="color: #666666">></span>) <span style="color: #666666">+</span> <span style="color: #666666">477</span>
<span style="color: #666666">23:</span> <span style="color: #666666">23</span> QtCore <span style="color: #666666">0x0000000106c75ac7</span> QCoreApplication<span style="color: #666666">::</span>exec() <span style="color: #666666">+</span> <span style="color: #666666">199</span>
<span style="color: #666666">24:</span> <span style="color: #666666">24</span> kwindowtest <span style="color: #666666">0x0000000105e33bdc</span> main <span style="color: #666666">+</span> <span style="color: #666666">316</span>
<span style="color: #666666">25:</span> <span style="color: #666666">25</span> libdyld.dylib <span style="color: #666666">0x00007fff93bb75fd</span> start <span style="color: #666666">+</span> <span style="color: #666666">1</span>
<span style="color: #666666">26:</span> <span style="color: #666666">26</span> <span style="color: #666666">???</span> <span style="color: #666666">0x0000000000000002</span> <span style="color: #666666">0x0</span> <span style="color: #666666">+</span> <span style="color: #666666">2</span>
</pre></div>
</p></pre>
</blockquote>
<p>On November 25th, 2014, 2:11 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Using a very simple standalone test application I have compared the <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">backtrace_symbols</code> output under 10.9.4, using clang and gcc-4.8. Apparently this particular case is simple enough to avoid C++ runtime conflicts (there's main(), a <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">show_backtrace</code> function that mimicks <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">kRealBacktrace</code> and optionally a <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">maybeDemangledName</code> when building as C++).</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">In pure C, both compilers give</li>
</ul>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #666666">0</span> backtrace <span style="color: #666666">0x0000000104d57d9c</span> show_backtrace <span style="color: #666666">+</span> <span style="color: #666666">60</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">so the current parser would fail (but it's called from C++ so that's a moot point, or so I hope).</p>
<ul style="padding: 0;text-rendering: inherit;margin: 0 0 0 1em;line-height: inherit;white-space: normal;">
<li style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">In C++ mode, both compilers give</li>
</ul>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #666666">0</span> backtrace <span style="color: #666666">0x000000010656dbed</span> _Z14show_backtracev <span style="color: #666666">+</span> <span style="color: #666666">61</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I'll attach the code so that it can be tested on other platforms too.</p></pre>
</blockquote>
<p>On November 25th, 2014, 5:27 nachm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Very good - I already felt stupid.
The demangled is always nullptr here and the backtrace strings do not end w/ " + *" at all. No matter whether gcc, g++, clang or clang++</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">shrug</em></p></pre>
</blockquote>
<p>On November 25th, 2014, 5:59 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Yeah, on Linux I get</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #666666">0:</span> .<span style="color: #666666">/</span>backtrace() [<span style="color: #666666">0x400fa5</span>]
<span style="color: #666666">1:</span> .<span style="color: #666666">/</span>backtrace() [<span style="color: #666666">0x4011d2</span>]
<span style="color: #666666">2:</span> <span style="color: #666666">/</span>lib<span style="color: #666666">/</span>x86_64<span style="color: #666666">-</span>linux<span style="color: #666666">-</span>gnu<span style="color: #666666">/</span>libc.so<span style="color: #666666">.6</span>(__libc_start_main<span style="color: #666666">+0xf5</span>) [<span style="color: #666666">0x7fbc5e1f7ec5</span>]
<span style="color: #666666">3:</span> .<span style="color: #666666">/</span>backtrace() [<span style="color: #666666">0x400c49</span>]
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">is that comparable to what you're getting? If so, it would seem that backtrace or backtrace_symbols already do their own demangling...</p></pre>
</blockquote>
<p>On November 25th, 2014, 6:16 nachm. UTC, <b>Thomas Lübking</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Yupp.
This is of course nasty, because we cannot check "other" requirements - the entire demangling should be omitted on linux/glibc > v?.?
(I will argue that this is what I meant by "how the mangler feels today")</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Depending on your raw output, I'd btw. suggest to search for " _Z" - a simple " _" could (too) easily appear in the lib name?
For " + " ./. "+" + trimming, it becomes a coin flip between "future proof" and simplicitly - as demangling is apparently only relevant on eXoticOS™, <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">me</em> would now leave that choice to you.</p></pre>
</blockquote>
<p>On November 25th, 2014, 7:40 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I'll see if I still have that OpenIndiana VM, and what a BSD VM might teach me (but which flavour ...)</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Anyway, it seems that the function is rather aptly named ... it may demangle, and it may not, and if so that might be because the input was already demangled :).</p></pre>
</blockquote>
<p>On November 26th, 2014, 2:05 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">It's really getting weirder and weirder.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">When I copy the kdelib workhorse function into a KDE test application</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">QString <span style="color: #0000FF">RealBacktrace</span>(<span style="color: #B00040">int</span> levels)
{
QString s;
<span style="color: #B00040">void</span><span style="color: #666666">*</span> trace[<span style="color: #666666">256</span>];
<span style="color: #B00040">int</span> n <span style="color: #666666">=</span> backtrace(trace, <span style="color: #666666">256</span>);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>n)
<span style="color: #008000; font-weight: bold">return</span> s;
<span style="color: #B00040">char</span><span style="color: #666666">**</span> strings <span style="color: #666666">=</span> backtrace_symbols (trace, n);
<span style="color: #008000; font-weight: bold">if</span> ( levels <span style="color: #666666">!=</span> <span style="color: #666666">-1</span> )
n <span style="color: #666666">=</span> qMin( n, levels );
s <span style="color: #666666">=</span> QLatin1String(<span style="color: #BA2121">"[</span><span style="color: #BB6622; font-weight: bold">\n</span><span style="color: #BA2121">"</span>);
<span style="color: #008000; font-weight: bold">for</span> (<span style="color: #B00040">int</span> i <span style="color: #666666">=</span> <span style="color: #666666">0</span>; i <span style="color: #666666"><</span> n; <span style="color: #666666">++</span>i)
s <span style="color: #666666">+=</span> QString<span style="color: #666666">::</span>number(i) <span style="color: #666666">+</span> QLatin1String(<span style="color: #BA2121">": "</span>) <span style="color: #666666">+</span>
QLatin1String(strings[i]) <span style="color: #666666">+</span> QLatin1Char(<span style="color: #BA2121">'\n'</span>);
s <span style="color: #666666">+=</span> QLatin1String(<span style="color: #BA2121">"]</span><span style="color: #BB6622; font-weight: bold">\n</span><span style="color: #BA2121">"</span>);
<span style="color: #008000; font-weight: bold">if</span> (strings)
free (strings);
<span style="color: #008000; font-weight: bold">return</span> s;
}
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">and call it, I get this on Linux:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="border: 1px solid #FF0000">#</span> qDebug() <span style="color: #666666"><<</span> RealBacktrace(<span style="color: #666666">-1</span>);
<span style="color: #666666">0</span>: kdelibs4<span style="color: #666666">-4.14.0</span>/build/kdeui/tests/kwindowtest() <span style="border: 1px solid #FF0000">[</span><span style="color: #666666">0x40c349</span><span style="color: #BC7A00">]</span>
1: kdelibs4-4.14.0/build/kdeui/tests/kwindowtest() <span style="color: #BC7A00">[</span><span style="color: #666666">0x40c66a</span><span style="color: #BC7A00">]</span>
2: kdelibs4-4.14.0/build/kdeui/tests/kwindowtest() <span style="color: #BC7A00">[</span><span style="color: #666666">0x40dd4e</span><span style="color: #BC7A00">]</span>
3: /usr/lib/x86_64-linux-gnu/libQtCore.so.4(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0x2da) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93ac8b95a</span><span style="color: #BC7A00">]</span>
4: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN7QAction9triggeredEb+0x32) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc939d07312</span><span style="color: #BC7A00">]</span>
5: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN7QAction8activateENS_11ActionEventE+0x5f) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc939d08f3f</span><span style="color: #BC7A00">]</span>
6: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x5f8202) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93a13a202</span><span style="color: #BC7A00">]</span>
7: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(_ZN15QAbstractButton17mouseReleaseEventEP11QMouseEvent+0x6c) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93a13a32c</span><span style="color: #BC7A00">]</span>
<span style="color: #008000; font-weight: bold"><snip></span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">and when I call</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="border: 1px solid #FF0000">#</span> qDebug() <span style="color: #666666"><<</span> kBacktrace();
<span style="color: #666666">0</span>: kdelibs4<span style="color: #666666">-4.14.0</span>/build/lib/libkdecore.so.5(kRealBacktrace(int)<span style="color: #666666">+0x3f</span>) <span style="border: 1px solid #FF0000">[</span><span style="color: #666666">0x7fc93b3924cf</span><span style="color: #BC7A00">]</span>
1: kdelibs4-4.14.0/build/kdeui/tests/kwindowtest() <span style="color: #BC7A00">[</span><span style="color: #666666">0x40c72d</span><span style="color: #BC7A00">]</span>
2: kdelibs4-4.14.0/build/kdeui/tests/kwindowtest() <span style="color: #BC7A00">[</span><span style="color: #666666">0x40dd4e</span><span style="color: #BC7A00">]</span>
3: /usr/lib/x86_64-linux-gnu/libQtCore.so.4(QMetaObject::activate(QObject*, QMetaObject const*, int, void**)+0x2da) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93ac8b95a</span><span style="color: #BC7A00">]</span>
4: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::triggered(bool)+0x32) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc939d07312</span><span style="color: #BC7A00">]</span>
5: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::activate(QAction::ActionEvent)+0x5f) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc939d08f3f</span><span style="color: #BC7A00">]</span>
6: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x5f8202) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93a13a202</span><span style="color: #BC7A00">]</span>
7: /usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAbstractButton::mouseReleaseEvent(QMouseEvent*)+0x6c) <span style="color: #BC7A00">[</span><span style="color: #666666">0x7fc93a13a32c</span><span style="color: #BC7A00">]</span>
<span style="color: #008000; font-weight: bold"><snip></span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">In other words, in this case we get mangled symbols out of <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">backtrace_symbols</code> and maybeDemangledName gets to do its job...
It seems that backtrace/backtrace_symbols behave differently when called from a shared library than when called from a linked-in source module (which also contains main), but does that make any sense??</p></pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">http://www.gnu.org/software/libc/manual/html_node/Backtraces.html</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">tl;dr: you must link -rdynamic
g++ -rdynamic -o backtrace backtrace.c
clang++ -rdynamic -o backtrace backtrace.c
in order to get the symbols.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I can also confirm the format for glibc (same for g++ and clang++), ie. "(_Z" and NO whitespace around the '+'
The is also reflected by readelf -sw.</p></pre>
<br />
<p>- Thomas</p>
<br />
<p>On November 25th, 2014, 2:12 nachm. UTC, René J.V. Bertin wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for KDE Software on Mac OS X and kdelibs.</div>
<div>By René J.V. Bertin.</div>
<p style="color: grey;"><i>Updated Nov. 25, 2014, 2:12 nachm.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
kdelibs
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This patch adapts the parser in <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">maybeDemangledName</code> to the backtrace obtained in <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">kRealBacktrace</code> on OS X.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Works as expected on OS X 10.9.4 .</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>kdecore/io/kdebug.cpp <span style="color: grey">(872a05a)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/121213/diff/" style="margin-left: 3em;">View Diff</a></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">File Attachments </h1>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2014/11/25/e9d48fea-2506-493c-b068-26a8e7d12b6c__backtrace.c">minimal test for backtrace functionality and parsing; can be built as C and C++</a></li>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>