1/*
2 Copyright (C) 2009 George Kiagiadakis <gkiagia@users.sourceforge.net>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#ifndef DRKONQIBACKENDS_H
18#define DRKONQIBACKENDS_H
19
20#include <QtCore/QObject>
21
22class CrashedApplication;
23class DebuggerManager;
24
25class AbstractDrKonqiBackend
26{
27public:
28 virtual ~AbstractDrKonqiBackend();
29 virtual bool init();
30
31 inline CrashedApplication *crashedApplication() const {
32 return m_crashedApplication;
33 }
34
35 inline DebuggerManager *debuggerManager() const {
36 return m_debuggerManager;
37 }
38
39protected:
40 virtual CrashedApplication *constructCrashedApplication() = 0;
41 virtual DebuggerManager *constructDebuggerManager() = 0;
42
43private:
44 CrashedApplication *m_crashedApplication;
45 DebuggerManager *m_debuggerManager;
46};
47
48class KCrashBackend : public QObject, public AbstractDrKonqiBackend
49{
50 Q_OBJECT
51public:
52 KCrashBackend();
53 virtual ~KCrashBackend();
54 virtual bool init();
55
56protected:
57 virtual CrashedApplication *constructCrashedApplication();
58 virtual DebuggerManager *constructDebuggerManager();
59
60private slots:
61 void stopAttachedProcess();
62 void continueAttachedProcess();
63 void onDebuggerStarting();
64 void onDebuggerFinished();
65
66private:
67 static void emergencySaveFunction(int signal);
68 static qint64 s_pid; //for use by the emergencySaveFunction
69
70 enum State { ProcessRunning, ProcessStopped, DebuggerRunning };
71 State m_state;
72};
73
74#endif // DRKONQIBACKENDS_H
75