diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:30:27 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:35:48 +0100 |
commit | 4a8273a6fc2e741e811cf5dabc9a3c240306cf7f (patch) | |
tree | 2148abc88f8543eecdc0b97b2dd92594836af9b2 /src/corelib/doc/snippets/qtracer/ftracer.cpp | |
parent | 036c5db468164297d213764c59a4b59daa76d90a (diff) | |
parent | 1c2be58fecaff1de5f2849192eb712984ebd59bd (diff) |
Merge remote-tracking branch 'origin/stable' into dev
For the conflicts in msvc_nmake.cpp the ifdefs are extended since we
need to support windows phone in the target branch while it is not there
in the current stable branch (as of Qt 5.2).
Conflicts:
configure
qmake/generators/win32/msvc_nmake.cpp
src/3rdparty/angle/src/libEGL/Surface.cpp
src/angle/src/common/common.pri
src/corelib/global/qglobal.h
src/corelib/io/qstandardpaths.cpp
src/plugins/platforms/qnx/qqnxintegration.cpp
src/plugins/platforms/qnx/qqnxscreeneventhandler.h
src/plugins/platforms/xcb/qglxintegration.h
src/widgets/kernel/win.pri
tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
tools/configure/configureapp.cpp
Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
Diffstat (limited to 'src/corelib/doc/snippets/qtracer/ftracer.cpp')
-rw-r--r-- | src/corelib/doc/snippets/qtracer/ftracer.cpp | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/src/corelib/doc/snippets/qtracer/ftracer.cpp b/src/corelib/doc/snippets/qtracer/ftracer.cpp deleted file mode 100644 index b12e3ed9c3..0000000000 --- a/src/corelib/doc/snippets/qtracer/ftracer.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> - -#include <QCoreApplication> -#include <QLoggingCategory> - - -//![1] -QLoggingCategory theFooArea("foo"); -QLoggingCategory theBarArea("bar"); -QLoggingCategory theBazArea("baz"); -//![1] - -// Note: These locations are Ubuntu specific. - -// Note: To make the example work with user permissions, make sure -// the files are user-writable and the path leading there accessible. - -const char traceSwitch[] = "/sys/kernel/debug/tracing/tracing_on"; -const char traceSink[] = "/sys/kernel/debug/tracing/trace_marker"; - -// The base class only serves as a facility to share code -// between the "single line" data logging aspect and the -// scoped "measuring" aspect. - -// Both aspects and the base class could be combined into -// a single tracer serving both purposes, but are split -// here for clarity. - -// Error handling is left as an exercise. - -//![2] -class MyTracerBase : public QTracer -{ -public: - MyTracerBase() { - enable = ::open(traceSwitch, O_WRONLY); - marker = ::open(traceSink, O_WRONLY); - } - - ~MyTracerBase() { - ::close(enable); - ::close(marker); - } - -protected: - int enable; - int marker; -}; -//![2] - - -//![2] -class MyTracer : public MyTracerBase -{ -public: - void start() { ::write(marker, "B", 1); } - void end() { ::write(marker, "E", 1); } -}; -//![2] - - -//![3] -class MyDataLogger : public MyTracerBase -{ -public: - MyDataLogger() { - buf[0] = 0; - pos = 0; - } - - void record(int i) { pos += sprintf(buf + pos, "%d", i); } - void record(const char *msg) { pos += sprintf(buf + pos, "%s", msg); } - void end() { ::write(marker, buf, pos); pos = 0; } - -private: - char buf[100]; - int pos; -}; -//![3] - -// Simplest possible example for "measuring". -//![4] -int foo(int i) -{ - qCTraceGuard(theFooArea); - // Here could be some lengthy code. - return i * i; -} -//![4] - -// We can switch on/off tracing dynamically. -// The tracer will be temporarily switched off at the third call -// and re-enabled at the eighth. -//![5] -int bar(int i) -{ - static int n = 0; - ++n; - if (n == 3) - theBarArea.setEnabled(QtTraceMsg, false); - if (n == 8) - theBarArea.setEnabled(QtTraceMsg, true); - - qCTraceGuard(theBarArea); - return i * i; -} -//![5] - -// An example to create "complex" log messages. -//![6] -int baz(int i) -{ - qCTrace(theBazArea) << 32 << "some stuff"; - - return i * i; -} -//![6] - - - -//![7] -namespace { -static struct Init -{ - Init() { - tracer.addToCategory(theFooArea); - tracer.addToCategory(theBarArea); - logger.addToCategory(theBazArea); - } - - MyTracer tracer; - MyDataLogger logger; - -} initializer; -} -//![7] |