mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
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>
This commit is contained in:
parent
bdff3fa4e7
commit
7cfcbc3775
2 changed files with 6 additions and 4 deletions
|
@ -58,7 +58,7 @@ static const int s_signals[] = {
|
||||||
void KCrash::setFlags(KCrash::CrashFlags flags)
|
void KCrash::setFlags(KCrash::CrashFlags flags)
|
||||||
{
|
{
|
||||||
s_flags = flags;
|
s_flags = flags;
|
||||||
if (s_flags & KCrash::AutoRestart || s_flags & KCrash::DrKonqi) {
|
if (s_flags & KCrash::AutoRestart || s_flags & KCrash::DrKonqi || s_flags & KCrash::Backtrace) {
|
||||||
// Default crash handler is required for the flags to work but one may be set already
|
// Default crash handler is required for the flags to work but one may be set already
|
||||||
if (!s_crashHandler) {
|
if (!s_crashHandler) {
|
||||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde");
|
||||||
|
@ -166,7 +166,7 @@ void KCrash::defaultCrashHandler(int sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
::system(systemargs.constData());
|
::system(systemargs.constData());
|
||||||
} else {
|
} else if (s_flags & KCrash::Backtrace) {
|
||||||
// NOTE: if HAVE_BACKTRACE is not defined kBacktrace() will return empty string
|
// NOTE: if HAVE_BACKTRACE is not defined kBacktrace() will return empty string
|
||||||
#ifdef HAVE_BACKTRACE
|
#ifdef HAVE_BACKTRACE
|
||||||
kError() << QCoreApplication::applicationName() << "crashed:\n" << kBacktrace();
|
kError() << QCoreApplication::applicationName() << "crashed:\n" << kBacktrace();
|
||||||
|
|
|
@ -84,12 +84,14 @@ namespace KCrash
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options to determine how the default crash handler should behave.
|
* Options to determine how the default crash handler should behave.
|
||||||
* @note AutoRestart takes priority over the other options even if they are set
|
* @note Options are prioritised in their numerical order, i.e. if
|
||||||
|
* AutoRestart is set all other options are ignored.
|
||||||
*/
|
*/
|
||||||
enum CrashFlag {
|
enum CrashFlag {
|
||||||
AutoRestart = 1, ///< autorestart this application. Only sensible for KUniqueApplications. @since 4.1.
|
AutoRestart = 1, ///< autorestart this application. Only sensible for KUniqueApplications. @since 4.1.
|
||||||
DrKonqi = 2, ///< launchers DrKonqi. @since 4.23.
|
DrKonqi = 2, ///< launchers DrKonqi. @since 4.23.
|
||||||
NoRestart = 4 ///< tell DrKonqi not to restart the program. @since 4.23.
|
NoRestart = 4, ///< tell DrKonqi not to restart the program. @since 4.23.
|
||||||
|
Backtrace = 8 ///< log backtrace if the program crashes. @since 4.23.
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CrashFlags, CrashFlag)
|
Q_DECLARE_FLAGS(CrashFlags, CrashFlag)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue