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 DEBUGGER_H
18#define DEBUGGER_H
19
20#include <QtCore/QString>
21
22#include <KSharedConfig>
23
24class Debugger
25{
26public:
27 static QList<Debugger> availableInternalDebuggers(const QString & backend);
28 static QList<Debugger> availableExternalDebuggers(const QString & backend);
29
30 /** Returns true if this Debugger instance is valid, or false otherwise.
31 * Debugger instances are valid only if they have been constructed from
32 * availableInternalDebuggers() or availableExternalDebuggers(). If they
33 * have been constructed directly using the Debugger constructor, they are invalid.
34 */
35 bool isValid() const;
36
37 /** Returns true if this debugger is installed. This is determined by
38 * looking for the executable that tryExec() returns. If it is in $PATH,
39 * this method returns true.
40 */
41 bool isInstalled() const;
42
43 /** Returns the translatable name of the debugger (eg. "GDB") */
44 QString name() const;
45
46 /** Returns the code name of the debugger (eg. "gdb"). */
47 QString codeName() const;
48
49 /** Returns the executable name that drkonqi should check if it exists
50 * to determine whether the debugger is installed
51 */
52 QString tryExec() const;
53
54 /** Returns a list with the drkonqi backends that this debugger supports */
55 QStringList supportedBackends() const;
56
57 /** Sets the backend to be used. This function must be called before using
58 * command(), backtraceBatchCommands() or runInTerminal().
59 */
60 void setUsedBackend(const QString & backendName);
61
62 /** Returns the command that should be run to use the debugger */
63 QString command() const;
64
65 /** Returns the commands that should be given to the debugger when
66 * run in batch mode in order to generate a backtrace
67 */
68 QString backtraceBatchCommands() const;
69
70 /** If this is an external debugger, it returns whether it should be run in a terminal or not */
71 bool runInTerminal() const;
72
73
74 enum ExpandStringUsage {
75 ExpansionUsagePlainText,
76 ExpansionUsageShell
77 };
78
79 static void expandString(QString & str, ExpandStringUsage usage = ExpansionUsagePlainText,
80 const QString & tempFile = QString());
81
82private:
83 static QList<Debugger> availableDebuggers(const char *regexp, const QString & backend);
84 KSharedConfig::Ptr m_config;
85 QString m_backend;
86};
87
88#endif
89