File indexing completed on 2024-04-21 04:35:59

0001 /* This file is part of KDevelop
0002    Copyright 2006-2008 Hamish Rodda <rodda@kde.org>
0003    Copyright 2002 Harald Fernengel <harry@kdevelop.org>
0004    Copyright 2011 Mathieu Lornac <mathieu.lornac@gmail.com>
0005    Copyright 2011 Damien Coppel <damien.coppel@gmail.com>
0006    Copyright 2011 Lionel Duc <lionel.data@gmail.com>
0007    Copyright 2016-2017 Anton Anikin <anton@anikin.xyz>
0008 
0009    This program is free software; you can redistribute it and/or
0010    modify it under the terms of the GNU General Public
0011    License as published by the Free Software Foundation; either
0012    version 2 of the License, or (at your option) any later version.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0017    General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program; see the file COPYING.  If not, write to
0021    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0022    Boston, MA 02110-1301, USA.
0023 */
0024 
0025 #pragma once
0026 
0027 #include <interfaces/istatus.h>
0028 #include <outputview/outputexecutejob.h>
0029 
0030 #include <KConfigGroup>
0031 
0032 class QWidget;
0033 
0034 namespace KDevelop { class ILaunchConfiguration; }
0035 
0036 namespace Valgrind
0037 {
0038 
0039 class Tool;
0040 
0041 class Job : public KDevelop::OutputExecuteJob, public KDevelop::IStatus
0042 {
0043     Q_OBJECT
0044     Q_INTERFACES(KDevelop::IStatus)
0045 
0046 public:
0047     Job(const Tool* tool, KDevelop::ILaunchConfiguration* launchConfig);
0048     ~Job() override = default;
0049 
0050     void start() override;
0051     using KDevelop::OutputExecuteJob::doKill;
0052 
0053     const Tool* tool() const;
0054     virtual QWidget* createView() = 0;
0055 
0056     QString statusName() const override;
0057 
0058 Q_SIGNALS:
0059     void clearMessage(KDevelop::IStatus*) override;
0060     void hideProgress(KDevelop::IStatus*) override;
0061     void showErrorMessage(const QString& message, int timeout = 0) override;
0062     void showMessage(KDevelop::IStatus*, const QString& message, int timeout = 0) override;
0063     void showProgress(KDevelop::IStatus*, int minimum, int maximum, int value) override;
0064 
0065 protected:
0066     void postProcessStderr(const QStringList& lines) override;
0067     virtual void processValgrindOutput(const QStringList& lines);
0068 
0069     void childProcessExited(int exitCode, QProcess::ExitStatus exitStatus) override;
0070     void childProcessError(QProcess::ProcessError processError) override;
0071 
0072     virtual bool processEnded();
0073 
0074     virtual void addLoggingArgs(QStringList& args) const;
0075     virtual void addToolArgs(QStringList& args) const = 0;
0076 
0077     int executeProcess(const QString& executable, const QStringList& args, QByteArray& processOutput);
0078 
0079     QStringList buildCommandLine() const;
0080 
0081     const Tool* m_tool;
0082 
0083     KConfigGroup m_configGroup;
0084 
0085     QString m_analyzedExecutable;
0086     QStringList m_analyzedExecutableArguments;
0087 
0088     QStringList m_valgrindOutput;
0089 
0090     quint16 m_tcpServerPort;
0091 };
0092 
0093 }