Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/debugger/qqmlmemoryprofiler.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | #include "qqmlmemoryprofiler_p.h" | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | QQmlMemoryScope::LibraryState QQmlMemoryScope::state = QQmlMemoryScope::Unloaded; | - | ||||||||||||||||||||||||
46 | - | |||||||||||||||||||||||||
47 | typedef void (qmlmemprofile_stats)(int *allocCount, int *bytesAllocated); | - | ||||||||||||||||||||||||
48 | typedef void (qmlmemprofile_clear)(); | - | ||||||||||||||||||||||||
49 | typedef void (qmlmemprofile_enable)(); | - | ||||||||||||||||||||||||
50 | typedef void (qmlmemprofile_disable)(); | - | ||||||||||||||||||||||||
51 | typedef void (qmlmemprofile_push_location)(const char *filename, int lineNumber); | - | ||||||||||||||||||||||||
52 | typedef void (qmlmemprofile_pop_location)(); | - | ||||||||||||||||||||||||
53 | typedef void (qmlmemprofile_save)(const char *filename); | - | ||||||||||||||||||||||||
54 | typedef int (qmlmemprofile_is_enabled)(); | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | static qmlmemprofile_stats *memprofile_stats; | - | ||||||||||||||||||||||||
57 | static qmlmemprofile_clear *memprofile_clear; | - | ||||||||||||||||||||||||
58 | static qmlmemprofile_enable *memprofile_enable; | - | ||||||||||||||||||||||||
59 | static qmlmemprofile_disable *memprofile_disable; | - | ||||||||||||||||||||||||
60 | static qmlmemprofile_push_location *memprofile_push_location; | - | ||||||||||||||||||||||||
61 | static qmlmemprofile_pop_location *memprofile_pop_location; | - | ||||||||||||||||||||||||
62 | static qmlmemprofile_save *memprofile_save; | - | ||||||||||||||||||||||||
63 | static qmlmemprofile_is_enabled *memprofile_is_enabled; | - | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | #if QT_CONFIG(library) | - | ||||||||||||||||||||||||
66 | extern QFunctionPointer qt_linux_find_symbol_sys(const char *symbol); | - | ||||||||||||||||||||||||
67 | #endif | - | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | bool QQmlMemoryScope::doOpenLibrary() | - | ||||||||||||||||||||||||
70 | { | - | ||||||||||||||||||||||||
71 | #if defined(Q_OS_LINUX) && QT_CONFIG(library) | - | ||||||||||||||||||||||||
72 | if (state == Unloaded) {
| 0-336 | ||||||||||||||||||||||||
73 | memprofile_stats = (qmlmemprofile_stats *) qt_linux_find_symbol_sys("qmlmemprofile_stats"); | - | ||||||||||||||||||||||||
74 | memprofile_clear = (qmlmemprofile_clear *) qt_linux_find_symbol_sys("qmlmemprofile_clear"); | - | ||||||||||||||||||||||||
75 | memprofile_enable = (qmlmemprofile_enable *) qt_linux_find_symbol_sys("qmlmemprofile_enable"); | - | ||||||||||||||||||||||||
76 | memprofile_disable = (qmlmemprofile_disable *) qt_linux_find_symbol_sys("qmlmemprofile_disable"); | - | ||||||||||||||||||||||||
77 | memprofile_push_location = (qmlmemprofile_push_location *) qt_linux_find_symbol_sys("qmlmemprofile_push_location"); | - | ||||||||||||||||||||||||
78 | memprofile_pop_location = (qmlmemprofile_pop_location *) qt_linux_find_symbol_sys("qmlmemprofile_pop_location"); | - | ||||||||||||||||||||||||
79 | memprofile_save = (qmlmemprofile_save *) qt_linux_find_symbol_sys("qmlmemprofile_save"); | - | ||||||||||||||||||||||||
80 | memprofile_is_enabled = (qmlmemprofile_is_enabled *) qt_linux_find_symbol_sys("qmlmemprofile_is_enabled"); | - | ||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | if (memprofile_stats && memprofile_clear && memprofile_enable && memprofile_disable &&
| 0-336 | ||||||||||||||||||||||||
83 | memprofile_push_location && memprofile_pop_location && memprofile_save && memprofile_is_enabled)
| 0 | ||||||||||||||||||||||||
84 | state = Loaded; never executed: state = Loaded; | 0 | ||||||||||||||||||||||||
85 | else | - | ||||||||||||||||||||||||
86 | state = Failed; executed 336 times by 152 tests: state = Failed; Executed by:
| 336 | ||||||||||||||||||||||||
87 | } | - | ||||||||||||||||||||||||
88 | #endif // Q_OS_LINUX | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | return state == Loaded; executed 336 times by 152 tests: return state == Loaded; Executed by:
| 336 | ||||||||||||||||||||||||
91 | } | - | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | void QQmlMemoryScope::init(const char *string) | - | ||||||||||||||||||||||||
94 | { | - | ||||||||||||||||||||||||
95 | if (memprofile_is_enabled()) {
| 0 | ||||||||||||||||||||||||
96 | memprofile_push_location(string, 0); | - | ||||||||||||||||||||||||
97 | pushed = true; | - | ||||||||||||||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||
101 | void QQmlMemoryScope::done() | - | ||||||||||||||||||||||||
102 | { | - | ||||||||||||||||||||||||
103 | memprofile_pop_location(); | - | ||||||||||||||||||||||||
104 | } never executed: end of block | 0 | ||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | bool QQmlMemoryProfiler::isEnabled() | - | ||||||||||||||||||||||||
107 | { | - | ||||||||||||||||||||||||
108 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
109 | return memprofile_is_enabled(); never executed: return memprofile_is_enabled(); | 0 | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
112 | } | - | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | void QQmlMemoryProfiler::enable() | - | ||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||
116 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
117 | memprofile_enable(); never executed: memprofile_enable(); | 0 | ||||||||||||||||||||||||
118 | } never executed: end of block | 0 | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | void QQmlMemoryProfiler::disable() | - | ||||||||||||||||||||||||
121 | { | - | ||||||||||||||||||||||||
122 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
123 | memprofile_disable(); never executed: memprofile_disable(); | 0 | ||||||||||||||||||||||||
124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | void QQmlMemoryProfiler::clear() | - | ||||||||||||||||||||||||
127 | { | - | ||||||||||||||||||||||||
128 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
129 | memprofile_clear(); never executed: memprofile_clear(); | 0 | ||||||||||||||||||||||||
130 | } never executed: end of block | 0 | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | void QQmlMemoryProfiler::stats(int *allocCount, int *bytesAllocated) | - | ||||||||||||||||||||||||
133 | { | - | ||||||||||||||||||||||||
134 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
135 | memprofile_stats(allocCount, bytesAllocated); never executed: memprofile_stats(allocCount, bytesAllocated); | 0 | ||||||||||||||||||||||||
136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | void QQmlMemoryProfiler::save(const char *filename) | - | ||||||||||||||||||||||||
139 | { | - | ||||||||||||||||||||||||
140 | if (QQmlMemoryScope::openLibrary())
| 0 | ||||||||||||||||||||||||
141 | memprofile_save(filename); never executed: memprofile_save(filename); | 0 | ||||||||||||||||||||||||
142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |