global/qlogging.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5__attribute__((__noreturn__)) -
6 -
7static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message); -
8static void qt_message_print(QtMsgType, const QMessageLogContext &context, const QString &message); -
9 -
10static bool isFatal(QtMsgType msgType) -
11{ -
12 if (msgType == QtFatalMsg)
partially evaluated: msgType == QtFatalMsg
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2146
0-2146
13 return true;
never executed: return true;
0
14 -
15 if (msgType == QtWarningMsg) {
evaluated: msgType == QtWarningMsg
TRUEFALSE
yes
Evaluation Count:910
yes
Evaluation Count:1236
910-1236
16 static bool fatalWarnings = qEnvironmentVariableIsSet("QT_FATAL_WARNINGS"); -
17 return fatalWarnings;
executed: return fatalWarnings;
Execution Count:910
910
18 } -
19 -
20 return false;
executed: return false;
Execution Count:1236
1236
21} -
22static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const char *s) -
23{ -
24 size_t len = qstrlen(s); -
25 if (len + 1 > space) {
never evaluated: len + 1 > space
0
26 const size_t skip = len - space + 4; -
27 s += skip; -
28 for (int i = 0; i < 3; ++i)
never evaluated: i < 3
0
29 *d++ = L'.';
never executed: *d++ = L'.';
0
30 }
never executed: }
0
31 while (*s)
never evaluated: *s
0
32 *d++ = *s++;
never executed: *d++ = *s++;
0
33 *d++ = 0; -
34}
never executed: }
0
35static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) -
36{ -
37 char emergency_buf[256] = { '\0' }; -
38 emergency_buf[sizeof emergency_buf - 1] = '\0'; -
39 -
40 -
41 -
42 -
43 -
44 if (msg)
never evaluated: msg
0
45 qvsnprintf(emergency_buf, sizeof emergency_buf - 1, msg, ap);
never executed: qvsnprintf(emergency_buf, sizeof emergency_buf - 1, msg, ap);
0
46 fprintf(stderr, "%s", emergency_buf); -
47 fflush(stderr); -
48 -
49 -
50 if (msgType == QtFatalMsg
never evaluated: msgType == QtFatalMsg
0
51 || (msgType == QtWarningMsg
never evaluated: msgType == QtWarningMsg
0
52 && qEnvironmentVariableIsSet("QT_FATAL_WARNINGS"))) {
never evaluated: qEnvironmentVariableIsSet("QT_FATAL_WARNINGS")
0
53 abort();
never executed: abort();
0
54 -
55 -
56 -
57 } -
58}
never executed: }
0
59 -
60 -
61 -
62 -
63 -
64static void qt_message(QtMsgType msgType, const QMessageLogContext &context, const char *msg, -
65 va_list ap, QString &buf) -
66{ -
67 -
68 if (std::uncaught_exception()) {
partially evaluated: std::uncaught_exception()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:935
0-935
69 qEmergencyOut(msgType, msg, ap); -
70 return;
never executed: return;
0
71 } -
72 -
73 if (msg) {
partially evaluated: msg
TRUEFALSE
yes
Evaluation Count:935
no
Evaluation Count:0
0-935
74 try { -
75 buf = QString().vsprintf(msg, ap); -
76 } catch (const std::bad_alloc &) {
executed: }
Execution Count:935
935
77 -
78 qEmergencyOut(msgType, msg, ap); -
79 -
80 return;
never executed: return;
0
81 -
82 } -
83 }
executed: }
Execution Count:935
935
84 qt_message_print(msgType, context, buf); -
85}
executed: }
Execution Count:935
935
86void QMessageLogger::debug(const char *msg, ...) const -
87{ -
88 QString message; -
89 -
90 va_list ap; -
91 __builtin_va_start(ap,msg); -
92 qt_message(QtDebugMsg, context, msg, ap, message); -
93 __builtin_va_end(ap); -
94 -
95 if (isFatal(QtDebugMsg))
partially evaluated: isFatal(QtDebugMsg)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
96 qt_message_fatal(QtDebugMsg, context, message);
never executed: qt_message_fatal(QtDebugMsg, context, message);
0
97}
executed: }
Execution Count:46
46
98QDebug QMessageLogger::debug() const -
99{ -
100 QDebug dbg = QDebug(QtDebugMsg); -
101 QMessageLogContext &ctxt = dbg.stream->context; -
102 ctxt.copy(context); -
103 return dbg;
executed: return dbg;
Execution Count:1188
1188
104} -
105QNoDebug QMessageLogger::noDebug() const -
106{ -
107 return QNoDebug();
never executed: return QNoDebug();
0
108} -
109void QMessageLogger::warning(const char *msg, ...) const -
110{ -
111 QString message; -
112 -
113 va_list ap; -
114 __builtin_va_start(ap,msg); -
115 qt_message(QtWarningMsg, context, msg, ap, message); -
116 __builtin_va_end(ap); -
117 -
118 if (isFatal(QtWarningMsg))
partially evaluated: isFatal(QtWarningMsg)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:884
0-884
119 qt_message_fatal(QtWarningMsg, context, message);
never executed: qt_message_fatal(QtWarningMsg, context, message);
0
120}
executed: }
Execution Count:884
884
121 -
122 -
123 -
124 -
125 -
126 -
127 -
128QDebug QMessageLogger::warning() const -
129{ -
130 QDebug dbg = QDebug(QtWarningMsg); -
131 QMessageLogContext &ctxt = dbg.stream->context; -
132 ctxt.copy(context); -
133 return dbg;
executed: return dbg;
Execution Count:25
25
134} -
135void QMessageLogger::critical(const char *msg, ...) const -
136{ -
137 QString message; -
138 -
139 va_list ap; -
140 __builtin_va_start(ap,msg); -
141 qt_message(QtCriticalMsg, context, msg, ap, message); -
142 __builtin_va_end(ap); -
143 -
144 if (isFatal(QtCriticalMsg))
never evaluated: isFatal(QtCriticalMsg)
0
145 qt_message_fatal(QtCriticalMsg, context, message);
never executed: qt_message_fatal(QtCriticalMsg, context, message);
0
146}
never executed: }
0
147 -
148 -
149 -
150 -
151 -
152 -
153 -
154QDebug QMessageLogger::critical() const -
155{ -
156 QDebug dbg = QDebug(QtCriticalMsg); -
157 QMessageLogContext &ctxt = dbg.stream->context; -
158 ctxt.copy(context); -
159 return dbg;
executed: return dbg;
Execution Count:1
1
160} -
161void QMessageLogger::fatal(const char *msg, ...) const -
162{ -
163 QString message; -
164 -
165 va_list ap; -
166 __builtin_va_start(ap,msg); -
167 do { try { qt_message(QtFatalMsg, context, msg, ap, message); } catch (...) { qTerminate(); } } while (0);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
executed: }
Execution Count:5
never executed: }
executed: }
Execution Count:5
0-5
168 __builtin_va_end(ap); -
169 -
170 qt_message_fatal(QtFatalMsg, context, message); -
171}
never executed: }
0
172 -
173 -
174 -
175 -
176 QByteArray qCleanupFuncinfo(QByteArray info) -
177{ -
178 -
179 -
180 -
181 -
182 if (info.isEmpty())
never evaluated: info.isEmpty()
0
183 return info;
never executed: return info;
0
184 -
185 int pos; -
186 -
187 -
188 pos = info.size() - 1; -
189 if (info.endsWith(']')) {
never evaluated: info.endsWith(']')
0
190 while (--pos) {
never evaluated: --pos
0
191 if (info.at(pos) == '[')
never evaluated: info.at(pos) == '['
0
192 info.truncate(pos);
never executed: info.truncate(pos);
0
193 }
never executed: }
0
194 }
never executed: }
0
195 -
196 -
197 static const char operator_call[] = "operator()"; -
198 static const char operator_lessThan[] = "operator<"; -
199 static const char operator_greaterThan[] = "operator>"; -
200 static const char operator_lessThanEqual[] = "operator<="; -
201 static const char operator_greaterThanEqual[] = "operator>="; -
202 -
203 -
204 info.replace("operator ", "operator"); -
205 -
206 -
207 for(;;) { -
208 int parencount = 0; -
209 pos = info.lastIndexOf(')'); -
210 if (pos == -1) {
never evaluated: pos == -1
0
211 -
212 return info;
never executed: return info;
0
213 } -
214 -
215 -
216 --pos; -
217 ++parencount; -
218 while (pos && parencount) {
never evaluated: pos
never evaluated: parencount
0
219 if (info.at(pos) == ')')
never evaluated: info.at(pos) == ')'
0
220 ++parencount;
never executed: ++parencount;
0
221 else if (info.at(pos) == '(')
never evaluated: info.at(pos) == '('
0
222 --parencount;
never executed: --parencount;
0
223 --pos; -
224 }
never executed: }
0
225 if (parencount != 0)
never evaluated: parencount != 0
0
226 return info;
never executed: return info;
0
227 -
228 info.truncate(++pos); -
229 -
230 if (info.at(pos - 1) == ')') {
never evaluated: info.at(pos - 1) == ')'
0
231 if (info.indexOf(operator_call) == pos - (int)strlen(operator_call))
never evaluated: info.indexOf(operator_call) == pos - (int)strlen(operator_call)
0
232 break;
never executed: break;
0
233 -
234 -
235 -
236 -
237 info.remove(0, info.indexOf('(')); -
238 info.chop(1); -
239 continue;
never executed: continue;
0
240 } else { -
241 break;
never executed: break;
0
242 } -
243 } -
244 -
245 -
246 int parencount = 0; -
247 int templatecount = 0; -
248 --pos; -
249 -
250 -
251 if (pos > -1) {
never evaluated: pos > -1
0
252 switch (info.at(pos)) { -
253 case ')': -
254 if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1)
never evaluated: info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1
0
255 pos -= 2;
never executed: pos -= 2;
0
256 break;
never executed: break;
0
257 case '<': -
258 if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1)
never evaluated: info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1
0
259 --pos;
never executed: --pos;
0
260 break;
never executed: break;
0
261 case '>': -
262 if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1)
never evaluated: info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1
0
263 --pos;
never executed: --pos;
0
264 break;
never executed: break;
0
265 case '=': { -
266 int operatorLength = (int)strlen(operator_lessThanEqual); -
267 if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1)
never evaluated: info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1
0
268 pos -= 2;
never executed: pos -= 2;
0
269 else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1)
never evaluated: info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1
0
270 pos -= 2;
never executed: pos -= 2;
0
271 break;
never executed: break;
0
272 } -
273 default: -
274 break;
never executed: break;
0
275 } -
276 }
never executed: }
0
277 -
278 while (pos > -1) {
never evaluated: pos > -1
0
279 if (parencount < 0 || templatecount < 0)
never evaluated: parencount < 0
never evaluated: templatecount < 0
0
280 return info;
never executed: return info;
0
281 -
282 char c = info.at(pos); -
283 if (c == ')')
never evaluated: c == ')'
0
284 ++parencount;
never executed: ++parencount;
0
285 else if (c == '(')
never evaluated: c == '('
0
286 --parencount;
never executed: --parencount;
0
287 else if (c == '>')
never evaluated: c == '>'
0
288 ++templatecount;
never executed: ++templatecount;
0
289 else if (c == '<')
never evaluated: c == '<'
0
290 --templatecount;
never executed: --templatecount;
0
291 else if (c == ' ' && templatecount == 0 && parencount == 0)
never evaluated: c == ' '
never evaluated: templatecount == 0
never evaluated: parencount == 0
0
292 break;
never executed: break;
0
293 -
294 --pos; -
295 }
never executed: }
0
296 info = info.mid(pos + 1); -
297 -
298 -
299 while ((info.at(0) == '*')
never evaluated: (info.at(0) == '*')
0
300 || (info.at(0) == '&'))
never evaluated: (info.at(0) == '&')
0
301 info = info.mid(1);
never executed: info = info.mid(1);
0
302 -
303 -
304 -
305 while ((pos = info.lastIndexOf('>')) != -1) {
never evaluated: (pos = info.lastIndexOf('>')) != -1
0
306 if (!info.contains('<'))
never evaluated: !info.contains('<')
0
307 break;
never executed: break;
0
308 -
309 -
310 int end = pos; -
311 templatecount = 1; -
312 --pos; -
313 while (pos && templatecount) {
never evaluated: pos
never evaluated: templatecount
0
314 register char c = info.at(pos); -
315 if (c == '>')
never evaluated: c == '>'
0
316 ++templatecount;
never executed: ++templatecount;
0
317 else if (c == '<')
never evaluated: c == '<'
0
318 --templatecount;
never executed: --templatecount;
0
319 --pos; -
320 }
never executed: }
0
321 ++pos; -
322 info.remove(pos, end - pos + 1); -
323 }
never executed: }
0
324 -
325 return info;
never executed: return info;
0
326} -
327 -
328 -
329static const char categoryTokenC[] = "%{category}"; -
330static const char typeTokenC[] = "%{type}"; -
331static const char messageTokenC[] = "%{message}"; -
332static const char fileTokenC[] = "%{file}"; -
333static const char lineTokenC[] = "%{line}"; -
334static const char functionTokenC[] = "%{function}"; -
335static const char pidTokenC[] = "%{pid}"; -
336static const char appnameTokenC[] = "%{appname}"; -
337static const char threadidTokenC[] = "%{threadid}"; -
338static const char emptyTokenC[] = ""; -
339 -
340static const char defaultPattern[] = "%{message}"; -
341 -
342 -
343struct QMessagePattern { -
344 QMessagePattern(); -
345 ~QMessagePattern(); -
346 -
347 void setPattern(const QString &pattern); -
348 -
349 -
350 const char **literals; -
351 const char **tokens; -
352 -
353 bool fromEnvironment; -
354 static QBasicMutex mutex; -
355}; -
356 -
357QBasicMutex QMessagePattern::mutex; -
358 -
359QMessagePattern::QMessagePattern() -
360 : literals(0) -
361 , tokens(0) -
362 , fromEnvironment(false) -
363{ -
364 const QString envPattern = QString::fromLocal8Bit(qgetenv("QT_MESSAGE_PATTERN")); -
365 if (envPattern.isEmpty()) {
never evaluated: envPattern.isEmpty()
0
366 setPattern(QLatin1String(defaultPattern)); -
367 } else {
never executed: }
0
368 setPattern(envPattern); -
369 fromEnvironment = true; -
370 }
never executed: }
0
371} -
372 -
373QMessagePattern::~QMessagePattern() -
374{ -
375 for (int i = 0; literals[i] != 0; ++i)
partially evaluated: literals[i] != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:185
0-185
376 delete [] literals[i];
never executed: delete [] literals[i];
0
377 delete [] literals; -
378 literals = 0; -
379 delete [] tokens; -
380 tokens = 0; -
381}
executed: }
Execution Count:185
185
382 -
383void QMessagePattern::setPattern(const QString &pattern) -
384{ -
385 delete [] tokens; -
386 delete [] literals; -
387 -
388 -
389 QList<QString> lexemes; -
390 QString lexeme; -
391 bool inPlaceholder = false; -
392 for (int i = 0; i < pattern.size(); ++i) {
never evaluated: i < pattern.size()
0
393 const QChar c = pattern.at(i); -
394 if ((c == QLatin1Char('%'))
never evaluated: (c == QLatin1Char('%'))
0
395 && !inPlaceholder) {
never evaluated: !inPlaceholder
0
396 if ((i + 1 < pattern.size())
never evaluated: (i + 1 < pattern.size())
0
397 && pattern.at(i + 1) == QLatin1Char('{')) {
never evaluated: pattern.at(i + 1) == QLatin1Char('{')
0
398 -
399 if (!lexeme.isEmpty()) {
never evaluated: !lexeme.isEmpty()
0
400 lexemes.append(lexeme); -
401 lexeme.clear(); -
402 }
never executed: }
0
403 inPlaceholder = true; -
404 }
never executed: }
0
405 }
never executed: }
0
406 -
407 lexeme.append(c); -
408 -
409 if ((c == QLatin1Char('}') && inPlaceholder)) {
never evaluated: c == QLatin1Char('}')
never evaluated: inPlaceholder
0
410 -
411 lexemes.append(lexeme); -
412 lexeme.clear(); -
413 inPlaceholder = false; -
414 }
never executed: }
0
415 }
never executed: }
0
416 if (!lexeme.isEmpty())
never evaluated: !lexeme.isEmpty()
0
417 lexemes.append(lexeme);
never executed: lexemes.append(lexeme);
0
418 -
419 -
420 QVarLengthArray<const char*> literalsVar; -
421 tokens = new const char*[lexemes.size() + 1]; -
422 tokens[lexemes.size()] = 0; -
423 -
424 for (int i = 0; i < lexemes.size(); ++i) {
never evaluated: i < lexemes.size()
0
425 const QString lexeme = lexemes.at(i); -
426 if (lexeme.startsWith(QLatin1String("%{"))
never evaluated: lexeme.startsWith(QLatin1String("%{"))
0
427 && lexeme.endsWith(QLatin1Char('}'))) {
never evaluated: lexeme.endsWith(QLatin1Char('}'))
0
428 -
429 if (lexeme == QLatin1String(typeTokenC)) {
never evaluated: lexeme == QLatin1String(typeTokenC)
0
430 tokens[i] = typeTokenC; -
431 } else if (lexeme == QLatin1String(categoryTokenC))
never evaluated: lexeme == QLatin1String(categoryTokenC)
never executed: }
0
432 tokens[i] = categoryTokenC;
never executed: tokens[i] = categoryTokenC;
0
433 else if (lexeme == QLatin1String(messageTokenC))
never evaluated: lexeme == QLatin1String(messageTokenC)
0
434 tokens[i] = messageTokenC;
never executed: tokens[i] = messageTokenC;
0
435 else if (lexeme == QLatin1String(fileTokenC))
never evaluated: lexeme == QLatin1String(fileTokenC)
0
436 tokens[i] = fileTokenC;
never executed: tokens[i] = fileTokenC;
0
437 else if (lexeme == QLatin1String(lineTokenC))
never evaluated: lexeme == QLatin1String(lineTokenC)
0
438 tokens[i] = lineTokenC;
never executed: tokens[i] = lineTokenC;
0
439 else if (lexeme == QLatin1String(functionTokenC))
never evaluated: lexeme == QLatin1String(functionTokenC)
0
440 tokens[i] = functionTokenC;
never executed: tokens[i] = functionTokenC;
0
441 else if (lexeme == QLatin1String(pidTokenC))
never evaluated: lexeme == QLatin1String(pidTokenC)
0
442 tokens[i] = pidTokenC;
never executed: tokens[i] = pidTokenC;
0
443 else if (lexeme == QLatin1String(appnameTokenC))
never evaluated: lexeme == QLatin1String(appnameTokenC)
0
444 tokens[i] = appnameTokenC;
never executed: tokens[i] = appnameTokenC;
0
445 else if (lexeme == QLatin1String(threadidTokenC))
never evaluated: lexeme == QLatin1String(threadidTokenC)
0
446 tokens[i] = threadidTokenC;
never executed: tokens[i] = threadidTokenC;
0
447 else { -
448 tokens[i] = emptyTokenC; -
449 -
450 QString error = QString::fromUtf8("" "QT_MESSAGE_PATTERN: Unknown placeholder %1\n" "", sizeof("QT_MESSAGE_PATTERN: Unknown placeholder %1\n") - 1) -
451 .arg(lexeme); -
452 fprintf(stderr, "%s", error.toLocal8Bit().constData()); -
453 fflush(stderr); -
454 }
never executed: }
0
455 } else { -
456 char *literal = new char[lexeme.size() + 1]; -
457 strncpy(literal, lexeme.toLatin1().constData(), lexeme.size()); -
458 literal[lexeme.size()] = '\0'; -
459 literalsVar.append(literal); -
460 tokens[i] = literal; -
461 }
never executed: }
0
462 } -
463 literals = new const char*[literalsVar.size() + 1]; -
464 literals[literalsVar.size()] = 0; -
465 memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); -
466}
never executed: }
0
467static QMessagePattern *qMessagePattern() { static QGlobalStatic<QMessagePattern > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QMessagePattern *x = new QMessagePattern; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QMessagePattern > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
0
468 -
469 -
470 -
471 -
472__attribute__((visibility("default"))) QString qMessageFormatString(QtMsgType type, const QMessageLogContext &context, -
473 const QString &str) -
474{ -
475 QString message; -
476 -
477 QMutexLocker lock(&QMessagePattern::mutex); -
478 -
479 QMessagePattern *pattern = qMessagePattern(); -
480 if (!pattern) {
never evaluated: !pattern
0
481 -
482 message.append(str); -
483 message.append(QLatin1Char('\n')); -
484 return message;
never executed: return message;
0
485 } -
486 -
487 -
488 if (pattern->tokens[0] == 0)
never evaluated: pattern->tokens[0] == 0
0
489 return message;
never executed: return message;
0
490 -
491 -
492 for (int i = 0; pattern->tokens[i] != 0; ++i) {
never evaluated: pattern->tokens[i] != 0
0
493 const char *token = pattern->tokens[i]; -
494 if (token == messageTokenC) {
never evaluated: token == messageTokenC
0
495 message.append(str); -
496 } else if (token == categoryTokenC) {
never evaluated: token == categoryTokenC
never executed: }
0
497 message.append(QLatin1String(context.category)); -
498 } else if (token == typeTokenC) {
never evaluated: token == typeTokenC
never executed: }
0
499 switch (type) { -
500 case QtDebugMsg: message.append(QLatin1String("debug")); break;
never executed: break;
0
501 case QtWarningMsg: message.append(QLatin1String("warning")); break;
never executed: break;
0
502 case QtCriticalMsg:message.append(QLatin1String("critical")); break;
never executed: break;
0
503 case QtFatalMsg: message.append(QLatin1String("fatal")); break;
never executed: break;
0
504 } -
505 } else if (token == fileTokenC) {
never evaluated: token == fileTokenC
never executed: }
0
506 if (context.file)
never evaluated: context.file
0
507 message.append(QLatin1String(context.file));
never executed: message.append(QLatin1String(context.file));
0
508 else -
509 message.append(QLatin1String("unknown"));
never executed: message.append(QLatin1String("unknown"));
0
510 } else if (token == lineTokenC) {
never evaluated: token == lineTokenC
0
511 message.append(QString::number(context.line)); -
512 } else if (token == functionTokenC) {
never executed: }
never evaluated: token == functionTokenC
0
513 if (context.function)
never evaluated: context.function
0
514 message.append(QString::fromLatin1(qCleanupFuncinfo(context.function)));
never executed: message.append(QString::fromLatin1(qCleanupFuncinfo(context.function)));
0
515 else -
516 message.append(QLatin1String("unknown"));
never executed: message.append(QLatin1String("unknown"));
0
517 -
518 } else if (token == pidTokenC) {
never evaluated: token == pidTokenC
0
519 message.append(QString::number(QCoreApplication::applicationPid())); -
520 } else if (token == appnameTokenC) {
never executed: }
never evaluated: token == appnameTokenC
0
521 message.append(QCoreApplication::applicationName()); -
522 } else if (token == threadidTokenC) {
never executed: }
never evaluated: token == threadidTokenC
0
523 message.append(QLatin1String("0x")); -
524 message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16)); -
525 -
526 } else {
never executed: }
0
527 message.append(QLatin1String(token)); -
528 }
never executed: }
0
529 } -
530 message.append(QLatin1Char('\n')); -
531 return message;
never executed: return message;
0
532} -
533 -
534 -
535 -
536typedef void (*QtMsgHandler)(QtMsgType, const char *); -
537__attribute__((visibility("default"))) QtMsgHandler qInstallMsgHandler(QtMsgHandler); -
538 -
539 -
540static QtMsgHandler msgHandler = 0; -
541static QtMessageHandler messageHandler = 0; -
542 -
543 -
544 -
545 -
546static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, -
547 const QString &buf) -
548{ -
549 QString logMessage = qMessageFormatString(type, context, buf); -
550 fprintf(stderr, "%s", logMessage.toLocal8Bit().constData()); -
551 fflush(stderr); -
552 -
553}
never executed: }
0
554 -
555 -
556 -
557 -
558static void qDefaultMsgHandler(QtMsgType type, const char *buf) -
559{ -
560 QMessageLogContext emptyContext; -
561 qDefaultMessageHandler(type, emptyContext, QLatin1String(buf)); -
562}
never executed: }
0
563 -
564static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message) -
565{ -
566 if (!msgHandler)
evaluated: !msgHandler
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2150
1-2150
567 msgHandler = qDefaultMsgHandler;
executed: msgHandler = qDefaultMsgHandler;
Execution Count:1
1
568 if (!messageHandler)
evaluated: !messageHandler
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:2088
63-2088
569 messageHandler = qDefaultMessageHandler;
executed: messageHandler = qDefaultMessageHandler;
Execution Count:63
63
570 -
571 -
572 if (msgHandler == qDefaultMsgHandler
evaluated: msgHandler == qDefaultMsgHandler
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2150
1-2150
573 || messageHandler != qDefaultMessageHandler) {
evaluated: messageHandler != qDefaultMessageHandler
TRUEFALSE
yes
Evaluation Count:154
yes
Evaluation Count:1996
154-1996
574 (*messageHandler)(msgType, context, message); -
575 } else {
executed: }
Execution Count:155
155
576 (*msgHandler)(msgType, message.toLocal8Bit().constData()); -
577 }
executed: }
Execution Count:1996
1996
578} -
579 -
580static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message) -
581{ -
582 (void)context;; -
583 (void)message;; -
584 -
585 -
586 -
587 abort();
executed: abort();
Execution Count:5
5
588 -
589 -
590 -
591} -
592 -
593 -
594 -
595 -
596 -
597void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, const QString &message) -
598{ -
599 qt_message_print(msgType, context, message); -
600 if (isFatal(msgType))
partially evaluated: isFatal(msgType)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1216
0-1216
601 qt_message_fatal(msgType, context, message);
never executed: qt_message_fatal(msgType, context, message);
0
602}
executed: }
Execution Count:1216
1216
603 -
604void qErrnoWarning(const char *msg, ...) -
605{ -
606 -
607 -
608 QString buf; -
609 va_list ap; -
610 __builtin_va_start(ap,msg); -
611 if (msg)
never evaluated: msg
0
612 buf.vsprintf(msg, ap);
never executed: buf.vsprintf(msg, ap);
0
613 __builtin_va_end(ap); -
614 -
615 buf += QLatin1String(" (") + qt_error_string(-1) + QLatin1Char(')'); -
616 QMessageLogContext context; -
617 qt_message_output(QtCriticalMsg, context, buf); -
618}
never executed: }
0
619 -
620void qErrnoWarning(int code, const char *msg, ...) -
621{ -
622 -
623 -
624 QString buf; -
625 va_list ap; -
626 __builtin_va_start(ap,msg); -
627 if (msg)
never evaluated: msg
0
628 buf.vsprintf(msg, ap);
never executed: buf.vsprintf(msg, ap);
0
629 __builtin_va_end(ap); -
630 -
631 buf += QLatin1String(" (") + qt_error_string(code) + QLatin1Char(')'); -
632 QMessageLogContext context; -
633 qt_message_output(QtCriticalMsg, context, buf); -
634}
never executed: }
0
635QtMessageHandler qInstallMessageHandler(QtMessageHandler h) -
636{ -
637 if (!messageHandler)
evaluated: !messageHandler
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:316
7-316
638 messageHandler = qDefaultMessageHandler;
executed: messageHandler = qDefaultMessageHandler;
Execution Count:7
7
639 QtMessageHandler old = messageHandler; -
640 messageHandler = h; -
641 return old;
executed: return old;
Execution Count:323
323
642} -
643 -
644QtMsgHandler qInstallMsgHandler(QtMsgHandler h) -
645{ -
646 -
647 -
648 if (!msgHandler)
evaluated: !msgHandler
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:589
214-589
649 msgHandler = qDefaultMsgHandler;
executed: msgHandler = qDefaultMsgHandler;
Execution Count:214
214
650 QtMsgHandler old = msgHandler; -
651 msgHandler = h; -
652 return old;
executed: return old;
Execution Count:803
803
653} -
654 -
655void qSetMessagePattern(const QString &pattern) -
656{ -
657 QMutexLocker lock(&QMessagePattern::mutex); -
658 -
659 if (!qMessagePattern()->fromEnvironment)
never evaluated: !qMessagePattern()->fromEnvironment
0
660 qMessagePattern()->setPattern(pattern);
never executed: qMessagePattern()->setPattern(pattern);
0
661}
never executed: }
0
662 -
663 -
664 -
665 -
666 -
667void QMessageLogContext::copy(const QMessageLogContext &logContext) -
668{ -
669 this->category = logContext.category; -
670 this->file = logContext.file; -
671 this->line = logContext.line; -
672 this->function = logContext.function; -
673}
executed: }
Execution Count:1214
1214
674 -
675 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial