2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2012-02-09 16:04:43 +00:00
|
|
|
|
|
|
|
#ifndef QMLPROFILERAPPLICATION_H
|
|
|
|
#define QMLPROFILERAPPLICATION_H
|
|
|
|
|
2012-03-08 15:50:14 +00:00
|
|
|
#include "qmlprofilerclient.h"
|
|
|
|
#include "qmlprofilerdata.h"
|
2012-02-09 16:04:43 +00:00
|
|
|
|
2015-09-16 14:28:24 +00:00
|
|
|
#include <private/qqmldebugconnection_p.h>
|
|
|
|
|
|
|
|
#include <QtCore/qcoreapplication.h>
|
|
|
|
#include <QtCore/qprocess.h>
|
|
|
|
#include <QtCore/qtimer.h>
|
|
|
|
#include <QtNetwork/qabstractsocket.h>
|
|
|
|
|
2015-05-21 15:13:03 +00:00
|
|
|
enum PendingRequest {
|
|
|
|
REQUEST_QUIT,
|
|
|
|
REQUEST_FLUSH_FILE,
|
|
|
|
REQUEST_FLUSH,
|
|
|
|
REQUEST_OUTPUT_FILE,
|
|
|
|
REQUEST_TOGGLE_RECORDING,
|
|
|
|
REQUEST_NONE
|
|
|
|
};
|
|
|
|
|
2012-02-09 16:04:43 +00:00
|
|
|
class QmlProfilerApplication : public QCoreApplication
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QmlProfilerApplication(int &argc, char **argv);
|
|
|
|
~QmlProfilerApplication();
|
|
|
|
|
2015-05-18 15:43:25 +00:00
|
|
|
void parseArguments();
|
2012-02-09 16:04:43 +00:00
|
|
|
int exec();
|
2015-05-19 13:54:16 +00:00
|
|
|
bool isInteractive() const;
|
2012-02-09 16:04:43 +00:00
|
|
|
void userCommand(const QString &command);
|
2015-05-19 12:50:06 +00:00
|
|
|
void notifyTraceStarted();
|
2015-05-21 13:37:52 +00:00
|
|
|
void outputData();
|
2012-02-09 16:04:43 +00:00
|
|
|
|
2016-07-20 13:35:50 +00:00
|
|
|
signals:
|
|
|
|
void readyForCommand();
|
|
|
|
|
|
|
|
private:
|
2012-02-09 16:04:43 +00:00
|
|
|
void run();
|
|
|
|
void tryToConnect();
|
|
|
|
void connected();
|
2018-02-02 12:24:44 +00:00
|
|
|
void disconnected();
|
2012-02-09 16:04:43 +00:00
|
|
|
void processHasOutput();
|
|
|
|
void processFinished();
|
|
|
|
|
2015-09-15 13:14:40 +00:00
|
|
|
void traceClientEnabledChanged(bool enabled);
|
2012-02-09 16:04:43 +00:00
|
|
|
void traceFinished();
|
|
|
|
|
2015-05-21 15:13:03 +00:00
|
|
|
void prompt(const QString &line = QString(), bool ready = true);
|
2012-02-09 16:04:43 +00:00
|
|
|
void logError(const QString &error);
|
2021-02-17 12:53:22 +00:00
|
|
|
void logWarning(const QString &warning);
|
2012-02-09 16:04:43 +00:00
|
|
|
void logStatus(const QString &status);
|
|
|
|
|
2015-05-21 08:35:42 +00:00
|
|
|
quint64 parseFeatures(const QStringList &featureList, const QString &values, bool exclude);
|
2015-05-21 15:13:03 +00:00
|
|
|
bool checkOutputFile(PendingRequest pending);
|
|
|
|
void flush();
|
|
|
|
void output();
|
2012-02-09 16:04:43 +00:00
|
|
|
|
|
|
|
enum ApplicationMode {
|
|
|
|
LaunchMode,
|
|
|
|
AttachMode
|
|
|
|
} m_runMode;
|
|
|
|
|
|
|
|
// LaunchMode
|
2018-11-14 08:53:21 +00:00
|
|
|
QString m_executablePath;
|
|
|
|
QStringList m_arguments;
|
2012-02-09 16:04:43 +00:00
|
|
|
QProcess *m_process;
|
|
|
|
|
2015-09-16 16:00:18 +00:00
|
|
|
QString m_socketFile;
|
2012-02-09 16:04:43 +00:00
|
|
|
QString m_hostName;
|
|
|
|
quint16 m_port;
|
2015-05-21 15:13:03 +00:00
|
|
|
QString m_outputFile;
|
|
|
|
QString m_interactiveOutputFile;
|
|
|
|
|
|
|
|
PendingRequest m_pendingRequest;
|
2012-02-09 16:04:43 +00:00
|
|
|
bool m_verbose;
|
2015-05-19 12:50:06 +00:00
|
|
|
bool m_recording;
|
2015-05-19 13:54:16 +00:00
|
|
|
bool m_interactive;
|
2012-02-09 16:04:43 +00:00
|
|
|
|
2017-12-14 19:06:57 +00:00
|
|
|
QScopedPointer<QQmlDebugConnection> m_connection;
|
|
|
|
QScopedPointer<QmlProfilerClient> m_qmlProfilerClient;
|
|
|
|
QScopedPointer<QmlProfilerData> m_profilerData;
|
2012-02-09 16:04:43 +00:00
|
|
|
QTimer m_connectTimer;
|
|
|
|
uint m_connectionAttempts;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QMLPROFILERAPPLICATION_H
|