OSDN Git Service

496753bc25f25ba4bbcef1f68bfe9e53bb05eece
[qt-creator-jp/qt-creator-jp.git] / src / libs / valgrind / valgrindprocess.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
8 **
9 ** Contact: Nokia Corporation (qt-info@nokia.com)
10 **
11 ** No Commercial Usage
12 **
13 ** This file contains pre-release code and may not be distributed.
14 ** You may use this file in accordance with the terms and conditions
15 ** contained in the Technology Preview License Agreement accompanying
16 ** this package.
17 **
18 ** GNU Lesser General Public License Usage
19 **
20 ** Alternatively, this file may be used under the terms of the GNU Lesser
21 ** General Public License version 2.1 as published by the Free Software
22 ** Foundation and appearing in the file LICENSE.LGPL included in the
23 ** packaging of this file.  Please review the following information to
24 ** ensure the GNU Lesser General Public License version 2.1 requirements
25 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 **
27 ** In addition, as a special exception, Nokia gives you certain additional
28 ** rights.  These rights are described in the Nokia Qt LGPL Exception
29 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30 **
31 ** If you have questions regarding the use of this file, please contact
32 ** Nokia at qt-info@nokia.com.
33 **
34 **************************************************************************/
35
36 #ifndef VALGRIND_RUNNER_P_H
37 #define VALGRIND_RUNNER_P_H
38
39 #include <utils/qtcprocess.h>
40
41 namespace Valgrind {
42 namespace Internal {
43
44 /**
45  * Abstract process that can be subclassed to supply local and remote valgrind runs
46  */
47 class ValgrindProcess : public QObject
48 {
49     Q_OBJECT
50 public:
51     explicit ValgrindProcess(QObject *parent = 0);
52     virtual ~ValgrindProcess();
53
54     virtual bool isRunning() const = 0;
55
56     virtual void run(const QString &valgrindExecutable, const QStringList &valgrindArguments,
57                      const QString &debuggeeExecutable, const QString &debuggeeArguments) = 0;
58     virtual void close() = 0;
59
60     virtual QString errorString() const = 0;
61     virtual QProcess::ProcessError error() const = 0;
62
63     virtual void setProcessChannelMode(QProcess::ProcessChannelMode mode) = 0;
64     virtual void setWorkingDirectory(const QString &path) = 0;
65     virtual void setEnvironment(const Utils::Environment &environment) = 0;
66
67 signals:
68     void started();
69     void finished(int, QProcess::ExitStatus);
70     void error(QProcess::ProcessError);
71     void standardOutputReceived(const QByteArray &);
72     void standardErrorReceived(const QByteArray &);
73 };
74
75 /**
76  * Run valgrind on the local machine
77  */
78 class LocalValgrindProcess : public ValgrindProcess
79 {
80     Q_OBJECT
81
82 public:
83     explicit LocalValgrindProcess(QObject *parent = 0);
84     virtual ~LocalValgrindProcess();
85
86     virtual bool isRunning() const;
87
88     virtual void run(const QString &valgrindExecutable, const QStringList &valgrindArguments,
89                      const QString &debuggeeExecutable, const QString &debuggeeArguments);
90     virtual void close();
91
92     virtual QString errorString() const;
93     QProcess::ProcessError error() const;
94
95     virtual void setProcessChannelMode(QProcess::ProcessChannelMode mode);
96     virtual void setWorkingDirectory(const QString &path);
97     virtual void setEnvironment(const Utils::Environment &environment);
98
99     Q_PID pid() const;
100
101 private slots:
102     void readyReadStandardError();
103     void readyReadStandardOutput();
104
105 private:
106     Utils::QtcProcess m_process;
107 };
108
109 // remote support will be supplied later
110
111 }
112 }
113
114 #endif // VALGRIND_RUNNER_P_H