File indexing completed on 2024-04-28 04:38:34

0001 /*
0002     SPDX-FileCopyrightText: 2006 Vladimir Prus <ghost@cs.msu.su>
0003     SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org>
0004     SPDX-FileCopyrightText: 2009 Andreas Pakulat <apaku@gmx.de>
0005     SPDX-FileCopyrightText: 2016 Aetf <aetf@unlimitedcodeworks.xyz>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef MIDEBUGJOBS_H
0011 #define MIDEBUGJOBS_H
0012 
0013 #include <outputview/outputjob.h>
0014 
0015 #include <QPointer>
0016 
0017 class IExecutePlugin;
0018 namespace KDevelop
0019 {
0020 class OutputModel;
0021 class ILaunchConfiguration;
0022 }
0023 
0024 namespace KDevMI {
0025 
0026 class MIDebuggerPlugin;
0027 class MIDebugSession;
0028 
0029 template<class JobBase>
0030 class MIDebugJobBase : public JobBase
0031 {
0032 public:
0033     explicit MIDebugJobBase(MIDebuggerPlugin* plugin, QObject* parent);
0034     ~MIDebugJobBase() override;
0035 
0036 protected:
0037     void done();
0038     bool doKill() override;
0039 
0040     QPointer<MIDebugSession> m_session;
0041 };
0042 
0043 class MIDebugJob : public MIDebugJobBase<KDevelop::OutputJob>
0044 {
0045     Q_OBJECT
0046 public:
0047     enum {
0048         // Add a "random" number to KJob::UserDefinedError and hopefully avoid clashes with OutputJob's error codes.
0049         InvalidExecutable = UserDefinedError + 231,
0050         ExecutableIsNotExecutable,
0051         InvalidArguments
0052     };
0053 
0054     MIDebugJob(MIDebuggerPlugin* p, KDevelop::ILaunchConfiguration* launchcfg, IExecutePlugin* plugin,
0055              QObject* parent = nullptr);
0056     void start() override;
0057 
0058 private Q_SLOTS:
0059     void stdoutReceived(const QStringList&);
0060     void stderrReceived(const QStringList&);
0061 
0062 private:
0063     void finishWithError(int errorCode, const QString& errorText);
0064     KDevelop::OutputModel* model();
0065 
0066     KDevelop::ILaunchConfiguration* m_launchcfg;
0067     IExecutePlugin* m_execute;
0068 };
0069 
0070 class MIExamineCoreJob : public MIDebugJobBase<KJob>
0071 {
0072     Q_OBJECT
0073 public:
0074     explicit MIExamineCoreJob(MIDebuggerPlugin *plugin, QObject *parent = nullptr);
0075 
0076     void start() override;
0077 };
0078 
0079 class MIAttachProcessJob : public MIDebugJobBase<KJob>
0080 {
0081     Q_OBJECT
0082 public:
0083     MIAttachProcessJob(MIDebuggerPlugin *plugin, int pid, QObject *parent = nullptr);
0084 
0085     void start() override;
0086 
0087 private:
0088     int m_pid;
0089 };
0090 
0091 } // end of namespace KDevMI
0092 
0093 #endif // MIDEBUGJOBS_H