PSA: Enable KCrash for you application
Amber Schenck
ambersck at hotmail.com
Mon Oct 14 21:08:01 BST 2024
On 8/8/24 07:34, Magno Lomardo wrote:
> Hi!
>
> Would be possible to put this info into the docs, if it isn't already there?
>
> I believe this is really important and deserves a spotlight on the docs.
> Thoughts on that?
Yes please! I've searched through the docs for exactly these details in
the past. Specifically what is needed: `find_package( KF5 Crash )`,
`target_link_libraries( <target> KF5::Crash )`, and
`KCrash::initialize()` after AboutData along with which parts of
AboutData matter. A lot of "best practices" are missing, and using other
applications as examples can be flaky because they may be way out of
date too.
Thanks,
-Amber
>
> Regards,
> Magno Lomardo
>
>
> On Thu, Aug 8, 2024 at 11:24 AM Nicolas Fella <nicolas.fella at gmx.de
> <mailto:nicolas.fella at gmx.de>> wrote:
>
> Hi,
>
> TL;DR: Call KCrash::initialize() after setting up KAboutData
>
> crash reporting via DrKonqi to Bugzilla and Sentry is powered by the
> KCrash framework, which acts as the crash handler inside the
> application.
>
> To install the crash handler you need to call KCrash::initialize() in
> your application's main function. Since the crash handler relies on
> information from KAboutData you should do it after the call to
> KAboutData::setApplicationData(). For best results make sure to include
> the application version in the about data.
>
> You can verify that it is working correctly by doing "killall -SEGV
> myapp" and checking that DrKonqi appears and lets you submit a report.
>
> Why am I sending this now? Some background:
>
> In KF5 linking against KF5::Crash would automatically install the crash
> handler for your application even without the explicity
> KCrash::initalize(). This approach had some caveats:
>
> - It doesn't work when linking with -as-needed, which is the default in
> some distributions
>
> - Similarly it won't work with static builds
>
> - It can result in the crash handler being installed for non-KDE apps
> that happen to load KF5::Crash, e.g. via out platform plugins
>
> For these reasons for KF6 we dropped this approach (see
> https://invent.kde.org/frameworks/kcrash/-/merge_requests/51
> <https://invent.kde.org/frameworks/kcrash/-/merge_requests/51>), meaning
> one must explicitly opt into our crash handling. A large number of our
> applications does that already, but there's also a significant number
> that doesn't. Please check your applications for that.
>
> Cheers
>
> Nico
>
--
Attached is my PGP public key.
Primary key fingerprint: 4407 5FB3 3665 0970 3B75 CD31 7DA1 7F4D AC46 7943
If you have a PGP key (and a minute to spare)
please send it in reply to this email.
If you have no idea what PGP is, feel free
to ignore all this gobbledegook.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x7DA17F4DAC467943.asc
Type: application/pgp-keys
Size: 4483 bytes
Desc: OpenPGP public key
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20241014/5842f3c5/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20241014/5842f3c5/attachment.sig>
More information about the kde-devel
mailing list