Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MER]: This patch is not upstreamed as libsystrace is not widely in use, the impact of additional function calls into QtBase was undesired, and the general approach is not really generic to other types of tracing at this time. libsystrace is a very small initialized-on-load wrapper for Android systrace functionality, used so that data is written in order, regardless of how many different libraries are writing data to it at a given time. systrace is very useful for tracking system behavior, and for performance analysis and improvement. See also: https://developer.android.com/tools/debugging/systrace.html Some example uses of QSystraceEvent are also included in this patch. More are undoubtedly possible. Additional tracing (e.g. counting the number of ongoing HTTP requests and various other bits and pieces) are also easily accomplished. Change-Id: I70012f6ddaa084f5b08685ee40795d7fafcd9c96 Conflicts: configure src/corelib/global/global.pri src/dbus/qdbusintegrator.cpp
- Loading branch information
1 parent
aedf4d2
commit 1ca6e3c
Showing
18 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SOURCES = systrace.c | ||
|
||
CONFIG += link_pkgconfig | ||
PKGCONFIG_PRIVATE += systrace | ||
|
||
CONFIG -= qt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd, author: <robin.burchell@jollamobile.com> | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the config.tests of the Qt Toolkit. | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** 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 | ||
** a written agreement between you and Digia. For licensing terms and | ||
** conditions see http://qt.digia.com/licensing. For further information | ||
** use the contact form at http://qt.digia.com/contact-us. | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** In addition, as a special exception, Digia gives you certain additional | ||
** rights. These rights are described in the Digia Qt LGPL Exception | ||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
** | ||
** GNU General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU | ||
** General Public License version 3.0 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.GPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU General Public License version 3.0 requirements will be | ||
** met: http://www.gnu.org/copyleft/gpl.html. | ||
** | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include <systrace.h> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
SYSTRACE_BEGIN("config.tests", "systrace_main", "testing"); | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd, author: <robin.burchell@jollamobile.com> | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the QtCore module of the Qt Toolkit. | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** 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 | ||
** a written agreement between you and Digia. For licensing terms and | ||
** conditions see http://qt.digia.com/licensing. For further information | ||
** use the contact form at http://qt.digia.com/contact-us. | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** In addition, as a special exception, Digia gives you certain additional | ||
** rights. These rights are described in the Digia Qt LGPL Exception | ||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
** | ||
** GNU General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU | ||
** General Public License version 3.0 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.GPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU General Public License version 3.0 requirements will be | ||
** met: http://www.gnu.org/copyleft/gpl.html. | ||
** | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "qsystrace_p.h" | ||
|
||
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_DEBUG) && defined(QT_USE_LIBSYSTRACE) | ||
# include <systrace.h> | ||
#endif | ||
|
||
void QSystrace::begin(const char *module, const char *tracepoint, const char *message, ...) | ||
{ | ||
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_DEBUG) && defined(QT_USE_LIBSYSTRACE) | ||
char buffer[1024]; | ||
va_list args; | ||
va_start(args, message); | ||
vsprintf(buffer, message, args); | ||
va_end(args); | ||
SYSTRACE_BEGIN(module, tracepoint, buffer); | ||
#else | ||
Q_UNUSED(module) | ||
Q_UNUSED(tracepoint) | ||
Q_UNUSED(message) | ||
#endif | ||
} | ||
|
||
void QSystrace::end(const char *module, const char *tracepoint, const char *message, ...) | ||
{ | ||
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_DEBUG) && defined(QT_USE_LIBSYSTRACE) | ||
char buffer[1024]; | ||
va_list args; | ||
va_start(args, message); | ||
vsprintf(buffer, message, args); | ||
va_end(args); | ||
SYSTRACE_END(module, tracepoint, message); | ||
#else | ||
Q_UNUSED(module) | ||
Q_UNUSED(tracepoint) | ||
Q_UNUSED(message) | ||
#endif | ||
} | ||
|
||
void QSystrace::counter(const char *module, const char *tracepoint, const char *message, ...) | ||
{ | ||
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_NO_DEBUG) && defined(QT_USE_LIBSYSTRACE) | ||
char buffer[1024]; | ||
va_list args; | ||
va_start(args, message); | ||
vsprintf(buffer, message, args); | ||
va_end(args); | ||
SYSTRACE_COUNTER(module, tracepoint, message); | ||
#else | ||
Q_UNUSED(module) | ||
Q_UNUSED(tracepoint) | ||
Q_UNUSED(message) | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd, author: <robin.burchell@jollamobile.com> | ||
** Contact: http://www.qt-project.org/legal | ||
** | ||
** This file is part of the QtCore module of the Qt Toolkit. | ||
** | ||
** $QT_BEGIN_LICENSE:LGPL$ | ||
** 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 | ||
** a written agreement between you and Digia. For licensing terms and | ||
** conditions see http://qt.digia.com/licensing. For further information | ||
** use the contact form at http://qt.digia.com/contact-us. | ||
** | ||
** GNU Lesser General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU Lesser | ||
** General Public License version 2.1 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.LGPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU Lesser General Public License version 2.1 requirements | ||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
** | ||
** In addition, as a special exception, Digia gives you certain additional | ||
** rights. These rights are described in the Digia Qt LGPL Exception | ||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
** | ||
** GNU General Public License Usage | ||
** Alternatively, this file may be used under the terms of the GNU | ||
** General Public License version 3.0 as published by the Free Software | ||
** Foundation and appearing in the file LICENSE.GPL included in the | ||
** packaging of this file. Please review the following information to | ||
** ensure the GNU General Public License version 3.0 requirements will be | ||
** met: http://www.gnu.org/copyleft/gpl.html. | ||
** | ||
** | ||
** $QT_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef QSYSTRACE_P_H | ||
#define QSYSTRACE_P_H | ||
|
||
#include <qglobal.h> | ||
|
||
// | ||
// W A R N I N G | ||
// ------------- | ||
// | ||
// This file is not part of the Qt API. It exists purely as an | ||
// implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||
// | ||
// We mean it. | ||
// | ||
|
||
QT_BEGIN_NAMESPACE | ||
|
||
namespace QSystrace | ||
{ | ||
void Q_CORE_EXPORT begin(const char *module, const char *tracepoint, const char *message, ...); | ||
void Q_CORE_EXPORT end(const char *module, const char *tracepoint, const char *message, ...); | ||
void Q_CORE_EXPORT counter(const char *module, const char *tracepoint, const char *message, ...); | ||
}; | ||
|
||
// simple RAII wrapper we can use elsewhere in the codebase. must be inside Qt | ||
// so QT_NO_DEBUG (& our feature macro) can easily disable the functionality | ||
// while not littering the codebase with defines | ||
struct QSystraceEvent | ||
{ | ||
QSystraceEvent(const char *module, const char *tracepoint) | ||
: m_module(module) | ||
, m_tracepoint(tracepoint) | ||
{ | ||
QSystrace::begin(m_module, m_tracepoint, ""); | ||
} | ||
|
||
~QSystraceEvent() | ||
{ | ||
QSystrace::end(m_module, m_tracepoint, ""); | ||
} | ||
|
||
private: | ||
const char *m_module; | ||
const char *m_tracepoint; | ||
}; | ||
|
||
QT_END_NAMESPACE | ||
|
||
#endif // QSYSTRACE_P_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.