1 /* 2 SPDX-FileCopyrightText: 2009 George Kiagiadakis <gkiagia@users.sourceforge.net> 3 SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org> 4 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 #ifndef CRASHEDAPPLICATION_H 8 #define CRASHEDAPPLICATION_H 9 10 #include <QDateTime> 11 #include <QFileInfo> 12 #include <QObject> 13 14 #include "bugreportaddress.h" 15 16 class KCrashBackend; 17 18 class CrashedApplication : public QObject 19 { 20 Q_OBJECT 21 public: 22 CrashedApplication(int pid, 23 int thread, 24 int signalNumber, 25 const QFileInfo &executable, 26 const QString &version, 27 const BugReportAddress &reportAddress, 28 const QString &name = QString(), 29 const QString &productName = QString(), 30 const QDateTime &datetime = QDateTime::currentDateTime(), 31 bool restarted = false, 32 bool hasDeletedFiles = false, 33 const QString &fakeBaseName = QString(), 34 QObject *parent = nullptr); 35 36 ~CrashedApplication() override; 37 38 /** Returns the crashed program's name, possibly translated (ex. "The KDE Crash Handler") */ 39 QString name() const; 40 41 /** Returns a QFileInfo with information about the executable that crashed */ 42 QFileInfo executable() const; 43 44 /** When an application is run via kdeinit, the executable() method returns kdeinit4, but 45 * we still need a way to know which is the application that was loaded by kdeinit. So, 46 * this method returns the base name of the executable that would have been launched if 47 * the app had not been loaded by kdeinit (ex. "plasma-desktop"). If the application was 48 * not launched via kdeinit, this method returns executable().baseName(); 49 */ 50 QString fakeExecutableBaseName() const; 51 52 /** Returns the version of the crashed program */ 53 QString version() const; 54 55 /** Returns the address where the bug report for this application should go */ 56 BugReportAddress bugReportAddress() const; 57 58 /** Bugzialla product name, if the crashed application has explicitly specified that. */ 59 QString productName() const; 60 61 /** Returns the pid of the crashed program */ 62 int pid() const; 63 64 /** Returns the signal number that the crashed program received */ 65 int signalNumber() const; 66 67 /** Returns the name of the signal (ex. SIGSEGV) */ 68 QString signalName() const; 69 70 bool hasBeenRestarted() const; 71 72 int thread() const; 73 74 const QDateTime &datetime() const; 75 76 /** @returns whether mmap'd files have been deleted, e.g. updated since start of app */ 77 bool hasDeletedFiles() const; 78 79 public Q_SLOTS: 80 void restart(); 81 82 Q_SIGNALS: 83 void restarted(bool success); 84 85 protected: 86 int m_pid; 87 int m_signalNumber; 88 QString m_name; 89 QFileInfo m_executable; 90 QString m_fakeBaseName; 91 QString m_version; 92 BugReportAddress m_reportAddress; 93 QString m_productName; 94 bool m_restarted; 95 int m_thread; 96 QDateTime m_datetime; 97 bool m_hasDeletedFiles; 98 99 public: 100 // Only set for the 'coredumpd' backend. Path to on-disk core dump. 101 QString m_coreFile; 102 }; 103 104 QString getSuggestedKCrashFilename(const CrashedApplication *app); 105 106 #endif // CRASHEDAPPLICATION_H 107