Katana libraries
Revision | 7cfcbc37756b999d4a312c640814da8c5a4965e0 (tree) |
---|---|
Time | 2022-12-09 19:28:21 |
Author | Ivailo Monev <xakepa10@gmai...> |
Commiter | Ivailo Monev |
kdeui: new KCrash::Backtrace to log backtraces
for programs that cannot call drkonqi to show backtrace (such as
ksmserver or any non-GUI D-Bus service)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
@@ -58,7 +58,7 @@ static const int s_signals[] = { | ||
58 | 58 | void KCrash::setFlags(KCrash::CrashFlags flags) |
59 | 59 | { |
60 | 60 | s_flags = flags; |
61 | - if (s_flags & KCrash::AutoRestart || s_flags & KCrash::DrKonqi) { | |
61 | + if (s_flags & KCrash::AutoRestart || s_flags & KCrash::DrKonqi || s_flags & KCrash::Backtrace) { | |
62 | 62 | // Default crash handler is required for the flags to work but one may be set already |
63 | 63 | if (!s_crashHandler) { |
64 | 64 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde"); |
@@ -166,7 +166,7 @@ void KCrash::defaultCrashHandler(int sig) | ||
166 | 166 | } |
167 | 167 | |
168 | 168 | ::system(systemargs.constData()); |
169 | - } else { | |
169 | + } else if (s_flags & KCrash::Backtrace) { | |
170 | 170 | // NOTE: if HAVE_BACKTRACE is not defined kBacktrace() will return empty string |
171 | 171 | #ifdef HAVE_BACKTRACE |
172 | 172 | kError() << QCoreApplication::applicationName() << "crashed:\n" << kBacktrace(); |
@@ -84,12 +84,14 @@ namespace KCrash | ||
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Options to determine how the default crash handler should behave. |
87 | - * @note AutoRestart takes priority over the other options even if they are set | |
87 | + * @note Options are prioritised in their numerical order, i.e. if | |
88 | + * AutoRestart is set all other options are ignored. | |
88 | 89 | */ |
89 | 90 | enum CrashFlag { |
90 | 91 | AutoRestart = 1, ///< autorestart this application. Only sensible for KUniqueApplications. @since 4.1. |
91 | 92 | DrKonqi = 2, ///< launchers DrKonqi. @since 4.23. |
92 | - NoRestart = 4 ///< tell DrKonqi not to restart the program. @since 4.23. | |
93 | + NoRestart = 4, ///< tell DrKonqi not to restart the program. @since 4.23. | |
94 | + Backtrace = 8 ///< log backtrace if the program crashes. @since 4.23. | |
93 | 95 | }; |
94 | 96 | Q_DECLARE_FLAGS(CrashFlags, CrashFlag) |
95 | 97 |