2012-02-09 16:04:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-02-09 16:04:43 +00:00
|
|
|
**
|
2012-02-16 04:43:03 +00:00
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
2012-02-09 16:04:43 +00:00
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-20 05:21:40 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 11:23:05 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-20 05:21:40 +00:00
|
|
|
**
|
2016-01-19 11:23:05 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-02-09 16:04:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#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);
|
|
|
|
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
|