| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qlogging.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | static long qt_gettid() | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | return syscall(186); | - | ||||||||||||||||||
| 12 | } | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | __attribute__((__noreturn__)) | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message); | - | ||||||||||||||||||
| 24 | static void qt_message_print(QtMsgType, const QMessageLogContext &context, const QString &message); | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | static bool isFatal(QtMsgType msgType) | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | if (msgType == QtFatalMsg) | - | ||||||||||||||||||
| 29 | return true; | - | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | if (msgType == QtCriticalMsg) { | - | ||||||||||||||||||
| 32 | static bool fatalCriticals = !qEnvironmentVariableIsEmpty("QT_FATAL_CRITICALS"); | - | ||||||||||||||||||
| 33 | return fatalCriticals; | - | ||||||||||||||||||
| 34 | } | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | if (msgType == QtWarningMsg || msgType == QtCriticalMsg) { | - | ||||||||||||||||||
| 37 | static bool fatalWarnings = !qEnvironmentVariableIsEmpty("QT_FATAL_WARNINGS"); | - | ||||||||||||||||||
| 38 | return fatalWarnings; | - | ||||||||||||||||||
| 39 | } | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | return false; | - | ||||||||||||||||||
| 42 | } | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | static bool willLogToConsole() | - | ||||||||||||||||||
| 45 | { | - | ||||||||||||||||||
| 46 | bool ok = true; | - | ||||||||||||||||||
| 47 | uint envcontrol = qgetenv("QT_LOGGING_TO_CONSOLE").toUInt(&ok); | - | ||||||||||||||||||
| 48 | if (ok) | - | ||||||||||||||||||
| 49 | return envcontrol; | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | int devtty = qt_safe_open("/dev/tty", 00); | - | ||||||||||||||||||
| 56 | if (devtty == -1 && ((*__errno_location ()) == 2 || (*__errno_location ()) == 1)) { | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | return isatty(2); | - | ||||||||||||||||||
| 59 | } else if (devtty != -1) { | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | qt_safe_close(devtty); | - | ||||||||||||||||||
| 62 | return true; | - | ||||||||||||||||||
| 63 | } | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | return false; | - | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | } | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | __attribute__((visibility("default"))) bool qt_logging_to_console() | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | static const bool logToConsole = willLogToConsole(); | - | ||||||||||||||||||
| 76 | return logToConsole; | - | ||||||||||||||||||
| 77 | } | - | ||||||||||||||||||
| 78 | __attribute__((noinline)) | - | ||||||||||||||||||
| 79 | static QString qt_message(QtMsgType msgType, const QMessageLogContext &context, const char *msg, va_list ap) | - | ||||||||||||||||||
| 80 | { | - | ||||||||||||||||||
| 81 | QString buf = QString::vasprintf(msg, ap); | - | ||||||||||||||||||
| 82 | qt_message_print(msgType, context, buf); | - | ||||||||||||||||||
| 83 | return buf; | - | ||||||||||||||||||
| 84 | } | - | ||||||||||||||||||
| 85 | void QMessageLogger::debug(const char *msg, ...) const | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | va_list ap; | - | ||||||||||||||||||
| 88 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 89 | const QString message = qt_message(QtDebugMsg, context, msg, ap); | - | ||||||||||||||||||
| 90 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | if (isFatal(QtDebugMsg)) | - | ||||||||||||||||||
| 93 | qt_message_fatal(QtDebugMsg, context, message); | - | ||||||||||||||||||
| 94 | } | - | ||||||||||||||||||
| 95 | void QMessageLogger::info(const char *msg, ...) const | - | ||||||||||||||||||
| 96 | { | - | ||||||||||||||||||
| 97 | va_list ap; | - | ||||||||||||||||||
| 98 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 99 | const QString message = qt_message(QtInfoMsg, context, msg, ap); | - | ||||||||||||||||||
| 100 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | if (isFatal(QtInfoMsg)) | - | ||||||||||||||||||
| 103 | qt_message_fatal(QtInfoMsg, context, message); | - | ||||||||||||||||||
| 104 | } | - | ||||||||||||||||||
| 105 | void QMessageLogger::debug(const QLoggingCategory &cat, const char *msg, ...) const | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | if (!cat.isDebugEnabled()) | - | ||||||||||||||||||
| 108 | return; | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 111 | ctxt.copy(context); | - | ||||||||||||||||||
| 112 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | va_list ap; | - | ||||||||||||||||||
| 115 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 116 | const QString message = qt_message(QtDebugMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 117 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | if (isFatal(QtDebugMsg)) | - | ||||||||||||||||||
| 120 | qt_message_fatal(QtDebugMsg, ctxt, message); | - | ||||||||||||||||||
| 121 | } | - | ||||||||||||||||||
| 122 | void QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc, | - | ||||||||||||||||||
| 123 | const char *msg, ...) const | - | ||||||||||||||||||
| 124 | { | - | ||||||||||||||||||
| 125 | const QLoggingCategory &cat = (*catFunc)(); | - | ||||||||||||||||||
| 126 | if (!cat.isDebugEnabled()) | - | ||||||||||||||||||
| 127 | return; | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 130 | ctxt.copy(context); | - | ||||||||||||||||||
| 131 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | va_list ap; | - | ||||||||||||||||||
| 134 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 135 | const QString message = qt_message(QtDebugMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 136 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | if (isFatal(QtDebugMsg)) | - | ||||||||||||||||||
| 139 | qt_message_fatal(QtDebugMsg, ctxt, message); | - | ||||||||||||||||||
| 140 | } | - | ||||||||||||||||||
| 141 | QDebug QMessageLogger::debug() const | - | ||||||||||||||||||
| 142 | { | - | ||||||||||||||||||
| 143 | QDebug dbg = QDebug(QtDebugMsg); | - | ||||||||||||||||||
| 144 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 145 | ctxt.copy(context); | - | ||||||||||||||||||
| 146 | return dbg; | - | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | QDebug QMessageLogger::debug(const QLoggingCategory &cat) const | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | QDebug dbg = QDebug(QtDebugMsg); | - | ||||||||||||||||||
| 158 | if (!cat.isDebugEnabled()) | - | ||||||||||||||||||
| 159 | dbg.stream->message_output = false; | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 162 | ctxt.copy(context); | - | ||||||||||||||||||
| 163 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | return dbg; | - | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const | - | ||||||||||||||||||
| 175 | { | - | ||||||||||||||||||
| 176 | return debug((*catFunc)()); | - | ||||||||||||||||||
| 177 | } | - | ||||||||||||||||||
| 178 | QNoDebug QMessageLogger::noDebug() const noexcept | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | return never executed: QNoDebug();return QNoDebug();never executed: return QNoDebug(); | 0 | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 182 | void QMessageLogger::info(const QLoggingCategory &cat, const char *msg, ...) const | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | if (!cat.isInfoEnabled()) | - | ||||||||||||||||||
| 185 | return; | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 188 | ctxt.copy(context); | - | ||||||||||||||||||
| 189 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | va_list ap; | - | ||||||||||||||||||
| 192 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 193 | const QString message = qt_message(QtInfoMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 194 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | if (isFatal(QtInfoMsg)) | - | ||||||||||||||||||
| 197 | qt_message_fatal(QtInfoMsg, ctxt, message); | - | ||||||||||||||||||
| 198 | } | - | ||||||||||||||||||
| 199 | void QMessageLogger::info(QMessageLogger::CategoryFunction catFunc, | - | ||||||||||||||||||
| 200 | const char *msg, ...) const | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | const QLoggingCategory &cat = (*catFunc)(); | - | ||||||||||||||||||
| 203 | if (!cat.isInfoEnabled()) | - | ||||||||||||||||||
| 204 | return; | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 207 | ctxt.copy(context); | - | ||||||||||||||||||
| 208 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | va_list ap; | - | ||||||||||||||||||
| 211 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 212 | const QString message = qt_message(QtInfoMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 213 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | if (isFatal(QtInfoMsg)) | - | ||||||||||||||||||
| 216 | qt_message_fatal(QtInfoMsg, ctxt, message); | - | ||||||||||||||||||
| 217 | } | - | ||||||||||||||||||
| 218 | QDebug QMessageLogger::info() const | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | QDebug dbg = QDebug(QtInfoMsg); | - | ||||||||||||||||||
| 221 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 222 | ctxt.copy(context); | - | ||||||||||||||||||
| 223 | return dbg; | - | ||||||||||||||||||
| 224 | } | - | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | QDebug QMessageLogger::info(const QLoggingCategory &cat) const | - | ||||||||||||||||||
| 233 | { | - | ||||||||||||||||||
| 234 | QDebug dbg = QDebug(QtInfoMsg); | - | ||||||||||||||||||
| 235 | if (!cat.isInfoEnabled()) | - | ||||||||||||||||||
| 236 | dbg.stream->message_output = false; | - | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 239 | ctxt.copy(context); | - | ||||||||||||||||||
| 240 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | return dbg; | - | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | QDebug QMessageLogger::info(QMessageLogger::CategoryFunction catFunc) const | - | ||||||||||||||||||
| 252 | { | - | ||||||||||||||||||
| 253 | return info((*catFunc)()); | - | ||||||||||||||||||
| 254 | } | - | ||||||||||||||||||
| 255 | void QMessageLogger::warning(const char *msg, ...) const | - | ||||||||||||||||||
| 256 | { | - | ||||||||||||||||||
| 257 | va_list ap; | - | ||||||||||||||||||
| 258 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 259 | const QString message = qt_message(QtWarningMsg, context, msg, ap); | - | ||||||||||||||||||
| 260 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | if (isFatal(QtWarningMsg)) | - | ||||||||||||||||||
| 263 | qt_message_fatal(QtWarningMsg, context, message); | - | ||||||||||||||||||
| 264 | } | - | ||||||||||||||||||
| 265 | void QMessageLogger::warning(const QLoggingCategory &cat, const char *msg, ...) const | - | ||||||||||||||||||
| 266 | { | - | ||||||||||||||||||
| 267 | if (!cat.isWarningEnabled()) | - | ||||||||||||||||||
| 268 | return; | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 271 | ctxt.copy(context); | - | ||||||||||||||||||
| 272 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | va_list ap; | - | ||||||||||||||||||
| 275 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 276 | const QString message = qt_message(QtWarningMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 277 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | if (isFatal(QtWarningMsg)) | - | ||||||||||||||||||
| 280 | qt_message_fatal(QtWarningMsg, ctxt, message); | - | ||||||||||||||||||
| 281 | } | - | ||||||||||||||||||
| 282 | void QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc, | - | ||||||||||||||||||
| 283 | const char *msg, ...) const | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | const QLoggingCategory &cat = (*catFunc)(); | - | ||||||||||||||||||
| 286 | if (!cat.isWarningEnabled()) | - | ||||||||||||||||||
| 287 | return; | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 290 | ctxt.copy(context); | - | ||||||||||||||||||
| 291 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | va_list ap; | - | ||||||||||||||||||
| 294 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 295 | const QString message = qt_message(QtWarningMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 296 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | if (isFatal(QtWarningMsg)) | - | ||||||||||||||||||
| 299 | qt_message_fatal(QtWarningMsg, ctxt, message); | - | ||||||||||||||||||
| 300 | } | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | QDebug QMessageLogger::warning() const | - | ||||||||||||||||||
| 309 | { | - | ||||||||||||||||||
| 310 | QDebug dbg = QDebug(QtWarningMsg); | - | ||||||||||||||||||
| 311 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 312 | ctxt.copy(context); | - | ||||||||||||||||||
| 313 | return dbg; | - | ||||||||||||||||||
| 314 | } | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | - | |||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | QDebug QMessageLogger::warning(const QLoggingCategory &cat) const | - | ||||||||||||||||||
| 322 | { | - | ||||||||||||||||||
| 323 | QDebug dbg = QDebug(QtWarningMsg); | - | ||||||||||||||||||
| 324 | if (!cat.isWarningEnabled()) | - | ||||||||||||||||||
| 325 | dbg.stream->message_output = false; | - | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 328 | ctxt.copy(context); | - | ||||||||||||||||||
| 329 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | return dbg; | - | ||||||||||||||||||
| 332 | } | - | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | QDebug QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc) const | - | ||||||||||||||||||
| 341 | { | - | ||||||||||||||||||
| 342 | return warning((*catFunc)()); | - | ||||||||||||||||||
| 343 | } | - | ||||||||||||||||||
| 344 | void QMessageLogger::critical(const char *msg, ...) const | - | ||||||||||||||||||
| 345 | { | - | ||||||||||||||||||
| 346 | va_list ap; | - | ||||||||||||||||||
| 347 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 348 | const QString message = qt_message(QtCriticalMsg, context, msg, ap); | - | ||||||||||||||||||
| 349 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | if (isFatal(QtCriticalMsg)) | - | ||||||||||||||||||
| 352 | qt_message_fatal(QtCriticalMsg, context, message); | - | ||||||||||||||||||
| 353 | } | - | ||||||||||||||||||
| 354 | void QMessageLogger::critical(const QLoggingCategory &cat, const char *msg, ...) const | - | ||||||||||||||||||
| 355 | { | - | ||||||||||||||||||
| 356 | if (!cat.isCriticalEnabled()) | - | ||||||||||||||||||
| 357 | return; | - | ||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 360 | ctxt.copy(context); | - | ||||||||||||||||||
| 361 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | va_list ap; | - | ||||||||||||||||||
| 364 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 365 | const QString message = qt_message(QtCriticalMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 366 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | if (isFatal(QtCriticalMsg)) | - | ||||||||||||||||||
| 369 | qt_message_fatal(QtCriticalMsg, ctxt, message); | - | ||||||||||||||||||
| 370 | } | - | ||||||||||||||||||
| 371 | void QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc, | - | ||||||||||||||||||
| 372 | const char *msg, ...) const | - | ||||||||||||||||||
| 373 | { | - | ||||||||||||||||||
| 374 | const QLoggingCategory &cat = (*catFunc)(); | - | ||||||||||||||||||
| 375 | if (!cat.isCriticalEnabled()) | - | ||||||||||||||||||
| 376 | return; | - | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | QMessageLogContext ctxt; | - | ||||||||||||||||||
| 379 | ctxt.copy(context); | - | ||||||||||||||||||
| 380 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | va_list ap; | - | ||||||||||||||||||
| 383 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 384 | const QString message = qt_message(QtCriticalMsg, ctxt, msg, ap); | - | ||||||||||||||||||
| 385 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | if (isFatal(QtCriticalMsg)) | - | ||||||||||||||||||
| 388 | qt_message_fatal(QtCriticalMsg, ctxt, message); | - | ||||||||||||||||||
| 389 | } | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | QDebug QMessageLogger::critical() const | - | ||||||||||||||||||
| 398 | { | - | ||||||||||||||||||
| 399 | QDebug dbg = QDebug(QtCriticalMsg); | - | ||||||||||||||||||
| 400 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 401 | ctxt.copy(context); | - | ||||||||||||||||||
| 402 | return dbg; | - | ||||||||||||||||||
| 403 | } | - | ||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | QDebug QMessageLogger::critical(const QLoggingCategory &cat) const | - | ||||||||||||||||||
| 412 | { | - | ||||||||||||||||||
| 413 | QDebug dbg = QDebug(QtCriticalMsg); | - | ||||||||||||||||||
| 414 | if (!cat.isCriticalEnabled()) | - | ||||||||||||||||||
| 415 | dbg.stream->message_output = false; | - | ||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 | QMessageLogContext &ctxt = dbg.stream->context; | - | ||||||||||||||||||
| 418 | ctxt.copy(context); | - | ||||||||||||||||||
| 419 | ctxt.category = cat.categoryName(); | - | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | return dbg; | - | ||||||||||||||||||
| 422 | } | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | - | |||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const | - | ||||||||||||||||||
| 431 | { | - | ||||||||||||||||||
| 432 | return critical((*catFunc)()); | - | ||||||||||||||||||
| 433 | } | - | ||||||||||||||||||
| 434 | void QMessageLogger::fatal(const char *msg, ...) const noexcept | - | ||||||||||||||||||
| 435 | { | - | ||||||||||||||||||
| 436 | QString message; | - | ||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | va_list ap; | - | ||||||||||||||||||
| 439 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 440 | do { message = qt_message(QtFatalMsg, context, msg, ap); } while (0); | - | ||||||||||||||||||
| 441 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | qt_message_fatal(QtFatalMsg, context, message); | - | ||||||||||||||||||
| 444 | } never executed: end of block | 0 | ||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | __attribute__((visibility("default"))) QByteArray qCleanupFuncinfo(QByteArray info) | - | ||||||||||||||||||
| 450 | { | - | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | - | |||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | if (info.isEmpty()) | - | ||||||||||||||||||
| 456 | return info; | - | ||||||||||||||||||
| 457 | - | |||||||||||||||||||
| 458 | int pos; | - | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | pos = info.size() - 1; | - | ||||||||||||||||||
| 463 | if (info.endsWith(']') && !(info.startsWith('+') || info.startsWith('-'))) { | - | ||||||||||||||||||
| 464 | while (--pos) { | - | ||||||||||||||||||
| 465 | if (info.at(pos) == '[') | - | ||||||||||||||||||
| 466 | info.truncate(pos); | - | ||||||||||||||||||
| 467 | } | - | ||||||||||||||||||
| 468 | } | - | ||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | static const char operator_call[] = "operator()"; | - | ||||||||||||||||||
| 472 | static const char operator_lessThan[] = "operator<"; | - | ||||||||||||||||||
| 473 | static const char operator_greaterThan[] = "operator>"; | - | ||||||||||||||||||
| 474 | static const char operator_lessThanEqual[] = "operator<="; | - | ||||||||||||||||||
| 475 | static const char operator_greaterThanEqual[] = "operator>="; | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | info.replace("operator ", "operator"); | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | for(;;) { | - | ||||||||||||||||||
| 482 | int parencount = 0; | - | ||||||||||||||||||
| 483 | pos = info.lastIndexOf(')'); | - | ||||||||||||||||||
| 484 | if (pos == -1) { | - | ||||||||||||||||||
| 485 | - | |||||||||||||||||||
| 486 | return info; | - | ||||||||||||||||||
| 487 | } | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | --pos; | - | ||||||||||||||||||
| 491 | ++parencount; | - | ||||||||||||||||||
| 492 | while (pos && parencount) { | - | ||||||||||||||||||
| 493 | if (info.at(pos) == ')') | - | ||||||||||||||||||
| 494 | ++parencount; | - | ||||||||||||||||||
| 495 | else if (info.at(pos) == '(') | - | ||||||||||||||||||
| 496 | --parencount; | - | ||||||||||||||||||
| 497 | --pos; | - | ||||||||||||||||||
| 498 | } | - | ||||||||||||||||||
| 499 | if (parencount != 0) | - | ||||||||||||||||||
| 500 | return info; | - | ||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | info.truncate(++pos); | - | ||||||||||||||||||
| 503 | - | |||||||||||||||||||
| 504 | if (info.at(pos - 1) == ')') { | - | ||||||||||||||||||
| 505 | if (info.indexOf(operator_call) == pos - (int)strlen(operator_call)) | - | ||||||||||||||||||
| 506 | break; | - | ||||||||||||||||||
| 507 | - | |||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | info.remove(0, info.indexOf('(')); | - | ||||||||||||||||||
| 512 | info.chop(1); | - | ||||||||||||||||||
| 513 | continue; | - | ||||||||||||||||||
| 514 | } else { | - | ||||||||||||||||||
| 515 | break; | - | ||||||||||||||||||
| 516 | } | - | ||||||||||||||||||
| 517 | } | - | ||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | int parencount = 0; | - | ||||||||||||||||||
| 521 | int templatecount = 0; | - | ||||||||||||||||||
| 522 | --pos; | - | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | if (pos > -1) { | - | ||||||||||||||||||
| 526 | switch (info.at(pos)) { | - | ||||||||||||||||||
| 527 | case ')': | - | ||||||||||||||||||
| 528 | if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1) | - | ||||||||||||||||||
| 529 | pos -= 2; | - | ||||||||||||||||||
| 530 | break; | - | ||||||||||||||||||
| 531 | case '<': | - | ||||||||||||||||||
| 532 | if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1) | - | ||||||||||||||||||
| 533 | --pos; | - | ||||||||||||||||||
| 534 | break; | - | ||||||||||||||||||
| 535 | case '>': | - | ||||||||||||||||||
| 536 | if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1) | - | ||||||||||||||||||
| 537 | --pos; | - | ||||||||||||||||||
| 538 | break; | - | ||||||||||||||||||
| 539 | case '=': { | - | ||||||||||||||||||
| 540 | int operatorLength = (int)strlen(operator_lessThanEqual); | - | ||||||||||||||||||
| 541 | if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1) | - | ||||||||||||||||||
| 542 | pos -= 2; | - | ||||||||||||||||||
| 543 | else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1) | - | ||||||||||||||||||
| 544 | pos -= 2; | - | ||||||||||||||||||
| 545 | break; | - | ||||||||||||||||||
| 546 | } | - | ||||||||||||||||||
| 547 | default: | - | ||||||||||||||||||
| 548 | break; | - | ||||||||||||||||||
| 549 | } | - | ||||||||||||||||||
| 550 | } | - | ||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | while (pos > -1) { | - | ||||||||||||||||||
| 553 | if (parencount < 0 || templatecount < 0) | - | ||||||||||||||||||
| 554 | return info; | - | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | char c = info.at(pos); | - | ||||||||||||||||||
| 557 | if (c == ')') | - | ||||||||||||||||||
| 558 | ++parencount; | - | ||||||||||||||||||
| 559 | else if (c == '(') | - | ||||||||||||||||||
| 560 | --parencount; | - | ||||||||||||||||||
| 561 | else if (c == '>') | - | ||||||||||||||||||
| 562 | ++templatecount; | - | ||||||||||||||||||
| 563 | else if (c == '<') | - | ||||||||||||||||||
| 564 | --templatecount; | - | ||||||||||||||||||
| 565 | else if (c == ' ' && templatecount == 0 && parencount == 0) | - | ||||||||||||||||||
| 566 | break; | - | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | --pos; | - | ||||||||||||||||||
| 569 | } | - | ||||||||||||||||||
| 570 | info = info.mid(pos + 1); | - | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | - | |||||||||||||||||||
| 573 | while ((info.at(0) == '*') | - | ||||||||||||||||||
| 574 | || (info.at(0) == '&')) | - | ||||||||||||||||||
| 575 | info = info.mid(1); | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | while ((pos = info.lastIndexOf('>')) != -1) { | - | ||||||||||||||||||
| 580 | if (!info.contains('<')) | - | ||||||||||||||||||
| 581 | break; | - | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | - | |||||||||||||||||||
| 584 | int end = pos; | - | ||||||||||||||||||
| 585 | templatecount = 1; | - | ||||||||||||||||||
| 586 | --pos; | - | ||||||||||||||||||
| 587 | while (pos && templatecount) { | - | ||||||||||||||||||
| 588 | char c = info.at(pos); | - | ||||||||||||||||||
| 589 | if (c == '>') | - | ||||||||||||||||||
| 590 | ++templatecount; | - | ||||||||||||||||||
| 591 | else if (c == '<') | - | ||||||||||||||||||
| 592 | --templatecount; | - | ||||||||||||||||||
| 593 | --pos; | - | ||||||||||||||||||
| 594 | } | - | ||||||||||||||||||
| 595 | ++pos; | - | ||||||||||||||||||
| 596 | info.remove(pos, end - pos + 1); | - | ||||||||||||||||||
| 597 | } | - | ||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | return info; | - | ||||||||||||||||||
| 600 | } | - | ||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | static const char categoryTokenC[] = "%{category}"; | - | ||||||||||||||||||
| 604 | static const char typeTokenC[] = "%{type}"; | - | ||||||||||||||||||
| 605 | static const char messageTokenC[] = "%{message}"; | - | ||||||||||||||||||
| 606 | static const char fileTokenC[] = "%{file}"; | - | ||||||||||||||||||
| 607 | static const char lineTokenC[] = "%{line}"; | - | ||||||||||||||||||
| 608 | static const char functionTokenC[] = "%{function}"; | - | ||||||||||||||||||
| 609 | static const char pidTokenC[] = "%{pid}"; | - | ||||||||||||||||||
| 610 | static const char appnameTokenC[] = "%{appname}"; | - | ||||||||||||||||||
| 611 | static const char threadidTokenC[] = "%{threadid}"; | - | ||||||||||||||||||
| 612 | static const char qthreadptrTokenC[] = "%{qthreadptr}"; | - | ||||||||||||||||||
| 613 | static const char timeTokenC[] = "%{time"; | - | ||||||||||||||||||
| 614 | static const char backtraceTokenC[] = "%{backtrace"; | - | ||||||||||||||||||
| 615 | static const char ifCategoryTokenC[] = "%{if-category}"; | - | ||||||||||||||||||
| 616 | static const char ifDebugTokenC[] = "%{if-debug}"; | - | ||||||||||||||||||
| 617 | static const char ifInfoTokenC[] = "%{if-info}"; | - | ||||||||||||||||||
| 618 | static const char ifWarningTokenC[] = "%{if-warning}"; | - | ||||||||||||||||||
| 619 | static const char ifCriticalTokenC[] = "%{if-critical}"; | - | ||||||||||||||||||
| 620 | static const char ifFatalTokenC[] = "%{if-fatal}"; | - | ||||||||||||||||||
| 621 | static const char endifTokenC[] = "%{endif}"; | - | ||||||||||||||||||
| 622 | static const char emptyTokenC[] = ""; | - | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}"; | - | ||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 | - | |||||||||||||||||||
| 627 | struct QMessagePattern { | - | ||||||||||||||||||
| 628 | QMessagePattern(); | - | ||||||||||||||||||
| 629 | ~QMessagePattern(); | - | ||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | void setPattern(const QString &pattern); | - | ||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | const char **literals; | - | ||||||||||||||||||
| 635 | const char **tokens; | - | ||||||||||||||||||
| 636 | QList<QString> timeArgs; | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | QElapsedTimer timer; | - | ||||||||||||||||||
| 639 | - | |||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | struct BacktraceParams { | - | ||||||||||||||||||
| 642 | QString backtraceSeparator; | - | ||||||||||||||||||
| 643 | int backtraceDepth; | - | ||||||||||||||||||
| 644 | }; | - | ||||||||||||||||||
| 645 | QVector<BacktraceParams> backtraceArgs; | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | bool fromEnvironment; | - | ||||||||||||||||||
| 649 | static QBasicMutex mutex; | - | ||||||||||||||||||
| 650 | }; | - | ||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 | template<> class QTypeInfo<QMessagePattern::BacktraceParams > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QMessagePattern::BacktraceParams)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QMessagePattern::BacktraceParams >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QMessagePattern::BacktraceParams) }; static inline const char *name() { return "QMessagePattern::BacktraceParams"; } }; | - | ||||||||||||||||||
| 653 | - | |||||||||||||||||||
| 654 | - | |||||||||||||||||||
| 655 | QBasicMutex QMessagePattern::mutex; | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | QMessagePattern::QMessagePattern() | - | ||||||||||||||||||
| 658 | : literals(0) | - | ||||||||||||||||||
| 659 | , tokens(0) | - | ||||||||||||||||||
| 660 | , fromEnvironment(false) | - | ||||||||||||||||||
| 661 | { | - | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | timer.start(); | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | const QString envPattern = QString::fromLocal8Bit(qgetenv("QT_MESSAGE_PATTERN")); | - | ||||||||||||||||||
| 666 | if (envPattern.isEmpty()) { | - | ||||||||||||||||||
| 667 | setPattern(QLatin1String(defaultPattern)); | - | ||||||||||||||||||
| 668 | } else { | - | ||||||||||||||||||
| 669 | setPattern(envPattern); | - | ||||||||||||||||||
| 670 | fromEnvironment = true; | - | ||||||||||||||||||
| 671 | } | - | ||||||||||||||||||
| 672 | } | - | ||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | QMessagePattern::~QMessagePattern() | - | ||||||||||||||||||
| 675 | { | - | ||||||||||||||||||
| 676 | for (int i = 0; literals[i]; ++i) | - | ||||||||||||||||||
| 677 | delete [] literals[i]; | - | ||||||||||||||||||
| 678 | delete [] literals; | - | ||||||||||||||||||
| 679 | literals = 0; | - | ||||||||||||||||||
| 680 | delete [] tokens; | - | ||||||||||||||||||
| 681 | tokens = 0; | - | ||||||||||||||||||
| 682 | } | - | ||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | void QMessagePattern::setPattern(const QString &pattern) | - | ||||||||||||||||||
| 685 | { | - | ||||||||||||||||||
| 686 | if (literals
| 9-448 | ||||||||||||||||||
| 687 | for (int i = 0; literals[i]
| 9-48 | ||||||||||||||||||
| 688 | delete [] literals[i]; executed 48 times by 2 tests: delete [] literals[i];Executed by:
| 48 | ||||||||||||||||||
| 689 | delete [] literals; | - | ||||||||||||||||||
| 690 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||
| 691 | delete [] tokens; | - | ||||||||||||||||||
| 692 | timeArgs.clear(); | - | ||||||||||||||||||
| 693 | - | |||||||||||||||||||
| 694 | backtraceArgs.clear(); | - | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | - | |||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | QList<QString> lexemes; | - | ||||||||||||||||||
| 699 | QString lexeme; | - | ||||||||||||||||||
| 700 | bool inPlaceholder = false; | - | ||||||||||||||||||
| 701 | for (int i = 0; i < pattern.size()
| 457-21226 | ||||||||||||||||||
| 702 | const QChar c = pattern.at(i); | - | ||||||||||||||||||
| 703 | if ((
| 1880-19346 | ||||||||||||||||||
| 704 | && !inPlaceholder
| 0-1880 | ||||||||||||||||||
| 705 | if ((
| 0-1880 | ||||||||||||||||||
| 706 | && pattern.at(i + 1) == QLatin1Char('{')
| 0-1880 | ||||||||||||||||||
| 707 | - | |||||||||||||||||||
| 708 | if (!lexeme.isEmpty()
| 528-1352 | ||||||||||||||||||
| 709 | lexemes.append(lexeme); | - | ||||||||||||||||||
| 710 | lexeme.clear(); | - | ||||||||||||||||||
| 711 | } executed 528 times by 106 tests: end of blockExecuted by:
| 528 | ||||||||||||||||||
| 712 | inPlaceholder = true; | - | ||||||||||||||||||
| 713 | } executed 1880 times by 106 tests: end of blockExecuted by:
| 1880 | ||||||||||||||||||
| 714 | } executed 1880 times by 106 tests: end of blockExecuted by:
| 1880 | ||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | lexeme.append(c); | - | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | if ((c == QLatin1Char('}')
| 0-19346 | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | lexemes.append(lexeme); | - | ||||||||||||||||||
| 721 | lexeme.clear(); | - | ||||||||||||||||||
| 722 | inPlaceholder = false; | - | ||||||||||||||||||
| 723 | } executed 1880 times by 106 tests: end of blockExecuted by:
| 1880 | ||||||||||||||||||
| 724 | } executed 21226 times by 106 tests: end of blockExecuted by:
| 21226 | ||||||||||||||||||
| 725 | if (!lexeme.isEmpty()
| 13-444 | ||||||||||||||||||
| 726 | lexemes.append(lexeme); executed 13 times by 1 test: lexemes.append(lexeme);Executed by:
| 13 | ||||||||||||||||||
| 727 | - | |||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | QVarLengthArray<const char*> literalsVar; | - | ||||||||||||||||||
| 730 | tokens = new const char*[lexemes.size() + 1]; | - | ||||||||||||||||||
| 731 | tokens[lexemes.size()] = 0; | - | ||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | bool nestedIfError = false; | - | ||||||||||||||||||
| 734 | bool inIf = false; | - | ||||||||||||||||||
| 735 | QString error; | - | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | for (int i = 0; i < lexemes.size()
| 457-2421 | ||||||||||||||||||
| 738 | const QString lexeme = lexemes.at(i); | - | ||||||||||||||||||
| 739 | if (lexeme.startsWith(QLatin1String("%{"))
| 541-1880 | ||||||||||||||||||
| 740 | && lexeme.endsWith(QLatin1Char('}'))
| 0-1880 | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | if (lexeme == QLatin1String(typeTokenC)
| 3-1877 | ||||||||||||||||||
| 743 | tokens[i] = typeTokenC; | - | ||||||||||||||||||
| 744 | } executed 3 times by 2 tests: else if (lexeme == QLatin1String(categoryTokenC)end of blockExecuted by:
| 3-1435 | ||||||||||||||||||
| 745 | tokens[i] = categoryTokenC; executed 442 times by 106 tests: tokens[i] = categoryTokenC;Executed by:
| 442 | ||||||||||||||||||
| 746 | else if (lexeme == QLatin1String(messageTokenC)
| 455-980 | ||||||||||||||||||
| 747 | tokens[i] = messageTokenC; executed 455 times by 106 tests: tokens[i] = messageTokenC;Executed by:
| 455 | ||||||||||||||||||
| 748 | else if (lexeme == QLatin1String(fileTokenC)
| 1-979 | ||||||||||||||||||
| 749 | tokens[i] = fileTokenC; executed 1 time by 1 test: tokens[i] = fileTokenC;Executed by:
| 1 | ||||||||||||||||||
| 750 | else if (lexeme == QLatin1String(lineTokenC)
| 2-977 | ||||||||||||||||||
| 751 | tokens[i] = lineTokenC; executed 2 times by 2 tests: tokens[i] = lineTokenC;Executed by:
| 2 | ||||||||||||||||||
| 752 | else if (lexeme == QLatin1String(functionTokenC)
| 2-975 | ||||||||||||||||||
| 753 | tokens[i] = functionTokenC; executed 2 times by 2 tests: tokens[i] = functionTokenC;Executed by:
| 2 | ||||||||||||||||||
| 754 | else if (lexeme == QLatin1String(pidTokenC)
| 1-974 | ||||||||||||||||||
| 755 | tokens[i] = pidTokenC; executed 1 time by 1 test: tokens[i] = pidTokenC;Executed by:
| 1 | ||||||||||||||||||
| 756 | else if (lexeme == QLatin1String(appnameTokenC)
| 1-973 | ||||||||||||||||||
| 757 | tokens[i] = appnameTokenC; executed 1 time by 1 test: tokens[i] = appnameTokenC;Executed by:
| 1 | ||||||||||||||||||
| 758 | else if (lexeme == QLatin1String(threadidTokenC)
| 1-972 | ||||||||||||||||||
| 759 | tokens[i] = threadidTokenC; executed 1 time by 1 test: tokens[i] = threadidTokenC;Executed by:
| 1 | ||||||||||||||||||
| 760 | else if (lexeme == QLatin1String(qthreadptrTokenC)
| 1-971 | ||||||||||||||||||
| 761 | tokens[i] = qthreadptrTokenC; executed 1 time by 1 test: tokens[i] = qthreadptrTokenC;Executed by:
| 1 | ||||||||||||||||||
| 762 | else if (lexeme.startsWith(QLatin1String(timeTokenC))
| 6-965 | ||||||||||||||||||
| 763 | tokens[i] = timeTokenC; | - | ||||||||||||||||||
| 764 | int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' ')); | - | ||||||||||||||||||
| 765 | if (spaceIdx > 0
| 0-6 | ||||||||||||||||||
| 766 | timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2)); executed 6 times by 1 test: timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2));Executed by:
| 6 | ||||||||||||||||||
| 767 | else | - | ||||||||||||||||||
| 768 | timeArgs.append(QString()); never executed: timeArgs.append(QString()); | 0 | ||||||||||||||||||
| 769 | } else if (lexeme.startsWith(QLatin1String(backtraceTokenC))
| 2-963 | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | tokens[i] = backtraceTokenC; | - | ||||||||||||||||||
| 772 | QString backtraceSeparator = ([]() -> QString { enum { Size = sizeof(u"" "|")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "|" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||||||||
| 773 | int backtraceDepth = 5; | - | ||||||||||||||||||
| 774 | QRegularExpression depthRx(([]() -> QString { enum { Size = sizeof(u"" " depth=(?|\"([^\"]*)\"|([^ }]*))")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" " depth=(?|\"([^\"]*)\"|([^ }]*))" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 2 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 2 | ||||||||||||||||||
| 775 | QRegularExpression separatorRx(([]() -> QString { enum { Size = sizeof(u"" " separator=(?|\"([^\"]*)\"|([^ }]*))")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" " separator=(?|\"([^\"]*)\"|([^ }]*))" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 2 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 2 | ||||||||||||||||||
| 776 | QRegularExpressionMatch m = depthRx.match(lexeme); | - | ||||||||||||||||||
| 777 | if (m.hasMatch()
| 1 | ||||||||||||||||||
| 778 | int depth = m.capturedRef(1).toInt(); | - | ||||||||||||||||||
| 779 | if (depth <= 0
| 0-1 | ||||||||||||||||||
| 780 | error += ([]() -> QString { enum { Size = sizeof(u"" "QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeofQLatin1String(QStringData) }, u"" "QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"}; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); never executed: error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"); | 0 | ||||||||||||||||||
| 781 | return qstring_literal_temp; }());else | - | ||||||||||||||||||
| 782 | backtraceDepth = depth; executed 1 time by 1 test: backtraceDepth = depth;Executed by:
| 1 | ||||||||||||||||||
| 783 | } | - | ||||||||||||||||||
| 784 | m = separatorRx.match(lexeme); | - | ||||||||||||||||||
| 785 | if (m.hasMatch()
| 1 | ||||||||||||||||||
| 786 | backtraceSeparator = m.captured(1); executed 1 time by 1 test: backtraceSeparator = m.captured(1);Executed by:
| 1 | ||||||||||||||||||
| 787 | BacktraceParams backtraceParams; | - | ||||||||||||||||||
| 788 | backtraceParams.backtraceDepth = backtraceDepth; | - | ||||||||||||||||||
| 789 | backtraceParams.backtraceSeparator = backtraceSeparator; | - | ||||||||||||||||||
| 790 | backtraceArgs.append(backtraceParams); | - | ||||||||||||||||||
| 791 | - | |||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | - | |||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 796 | else if (lexeme == QLatin1String(ifCategoryTokenC)
never executed: tokens[i] = ifCategoryTokenC; inIf = true; }nestedIfError = true;executed 442 times by 106 tests: end of blockExecuted by:
| 0-521 | ||||||||||||||||||
| 797 | else if (lexeme == QLatin1String(ifDebugTokenC)
never executed: tokens[i] = ifDebugTokenC; inIf = true; }nestedIfError = true;executed 9 times by 2 tests: end of blockExecuted by:
| 0-512 | ||||||||||||||||||
| 798 | else if (lexeme == QLatin1String(ifInfoTokenC)
never executed: tokens[i] = ifInfoTokenC; inIf = true; }nestedIfError = true;executed 6 times by 1 test: end of blockExecuted by:
| 0-506 | ||||||||||||||||||
| 799 | else if (lexeme == QLatin1String(ifWarningTokenC)
executed 1 time by 1 test: tokens[i] = ifWarningTokenC; inIf = true; }nestedIfError = true;Executed by:
executed 10 times by 2 tests: end of blockExecuted by:
| 1-496 | ||||||||||||||||||
| 800 | else if (lexeme == QLatin1String(ifCriticalTokenC)
never executed: tokens[i] = ifCriticalTokenC; inIf = true; }nestedIfError = true;executed 7 times by 2 tests: end of blockExecuted by:
| 0-489 | ||||||||||||||||||
| 801 | else if (lexeme == QLatin1String(ifFatalTokenC)
never executed: tokens[i] = ifFatalTokenC; inIf = true; }nestedIfError = true;executed 7 times by 2 tests: end of blockExecuted by:
| 0-482 | ||||||||||||||||||
| 802 | - | |||||||||||||||||||
| 803 | else if (lexeme == QLatin1String(endifTokenC)
| 2-480 | ||||||||||||||||||
| 804 | tokens[i] = endifTokenC; | - | ||||||||||||||||||
| 805 | if (!inIf
| 0-479 | ||||||||||||||||||
| 806 | error += ([]() -> QString { enum { Size = sizeof(u"" "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeofQLatin1String(QStringData) }, u"" "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"}; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); executed 1 time by 1 test: error += QLatin1String("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n");Executed by:
| 1 | ||||||||||||||||||
| 807 | return qstring_literal_temp; }());inIf = false; | - | ||||||||||||||||||
| 808 | } executed 480 times by 106 tests: else {end of blockExecuted by:
| 480 | ||||||||||||||||||
| 809 | tokens[i] = emptyTokenC; | - | ||||||||||||||||||
| 810 | error += ([]() -> QString { enum { Size = sizeof(u"" "QT_MESSAGE_PATTERN: Unknown placeholder %1\n")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QT_MESSAGE_PATTERN: Unknown placeholder %1\n" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 2 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 2 times by 1 test: }())return qstring_literal_temp;Executed by:
| 2 | ||||||||||||||||||
| 811 | .arg(lexeme); | - | ||||||||||||||||||
| 812 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 813 | } else { | - | ||||||||||||||||||
| 814 | char *literal = new char[lexeme.size() + 1]; | - | ||||||||||||||||||
| 815 | strncpy(literal, lexeme.toLatin1().constData(), lexeme.size()); | - | ||||||||||||||||||
| 816 | literal[lexeme.size()] = '\0'; | - | ||||||||||||||||||
| 817 | literalsVar.append(literal); | - | ||||||||||||||||||
| 818 | tokens[i] = literal; | - | ||||||||||||||||||
| 819 | } executed 541 times by 106 tests: end of blockExecuted by:
| 541 | ||||||||||||||||||
| 820 | } | - | ||||||||||||||||||
| 821 | if (nestedIfError
| 1-456 | ||||||||||||||||||
| 822 | error += ([]() -> QString { enum { Size = sizeofQLatin1String(u"" "QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"); executed 1 time by 1 test: error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");Executed by:
| 1 | ||||||||||||||||||
| 823 | else if (inIf
| 1-455 | ||||||||||||||||||
| 824 | error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n"); executed 1 time by 1 test: error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");Executed by:
| 1 | ||||||||||||||||||
| 825 | if (!error.isEmpty()
| 3-454 | ||||||||||||||||||
| 826 | { | - | ||||||||||||||||||
| 827 | fprintf(stderr, "%s", error.toLocal8Bit().constData()); | - | ||||||||||||||||||
| 828 | fflush(stderr); | - | ||||||||||||||||||
| 829 | } | - | ||||||||||||||||||
| 830 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 831 | literals = new const char*[literalsVar.size() + 1]; | - | ||||||||||||||||||
| 832 | literals[literalsVar.size()] = 0; | - | ||||||||||||||||||
| 833 | memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); | - | ||||||||||||||||||
| 834 | } executed 457 times by 106 tests: end of blockExecuted by:
| 457 | ||||||||||||||||||
| 835 | static QStringList backtraceFramesForLogMessage(int frameCount) | - | ||||||||||||||||||
| 836 | { | - | ||||||||||||||||||
| 837 | QStringList result; | - | ||||||||||||||||||
| 838 | if (frameCount == 0
| 0-16 | ||||||||||||||||||
| 839 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | - | |||||||||||||||||||
| 842 | - | |||||||||||||||||||
| 843 | - | |||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | static QRegularExpression rx(([]() -> QString { enum { Size = sizeof(u"" "^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QT_MESSAGE_PATTERN: %{if-*} cannot be"^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) nested\n"\\[[a-f0-9x]*\\]$" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());}()), | - | ||||||||||||||||||
| 847 | QRegularExpression::OptimizeOnFirstUsageOption); | - | ||||||||||||||||||
| 848 | - | |||||||||||||||||||
| 849 | QVarLengthArray<void*, 32> buffer(7 + frameCount); | - | ||||||||||||||||||
| 850 | int n = backtrace(buffer.data(), buffer.size()); | - | ||||||||||||||||||
| 851 | if (n > 0
| 0-16 | ||||||||||||||||||
| 852 | int numberPrinted = 0; | - | ||||||||||||||||||
| 853 | for (int i = 0; i < n
| 0-156 | ||||||||||||||||||
| 854 | QScopedPointer<char*, QScopedPointerPodDeleter> strings(backtrace_symbols(buffer.data() + i, 1)); | - | ||||||||||||||||||
| 855 | QString trace = QString::fromLatin1(strings.data()[0]); | - | ||||||||||||||||||
| 856 | QRegularExpressionMatch m = rx.match(trace); | - | ||||||||||||||||||
| 857 | if (m.hasMatch()
| 0-156 | ||||||||||||||||||
| 858 | QString library = m.captured(1); | - | ||||||||||||||||||
| 859 | QString function = m.captured(2); | - | ||||||||||||||||||
| 860 | - | |||||||||||||||||||
| 861 | - | |||||||||||||||||||
| 862 | if (!numberPrinted
| 16-128 | ||||||||||||||||||
| 863 | && (function.isEmpty()
| 4-76 | ||||||||||||||||||
| 864 | || function.contains(QLatin1String("QDebug"))
| 0-4 | ||||||||||||||||||
| 865 | continue; executed 112 times by 1 test: continue;Executed by:
| 112 | ||||||||||||||||||
| 866 | } | - | ||||||||||||||||||
| 867 | - | |||||||||||||||||||
| 868 | if (function.startsWith(QLatin1String("_Z"))
| 8-36 | ||||||||||||||||||
| 869 | QScopedPointer<char, QScopedPointerPodDeleter> demangled( | - | ||||||||||||||||||
| 870 | abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); | - | ||||||||||||||||||
| 871 | if (demangled
| 0-8 | ||||||||||||||||||
| 872 | function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); executed 8 times by 1 test: function = QString::fromUtf8(qCleanupFuncinfo(demangled.data()));Executed by:
| 8 | ||||||||||||||||||
| 873 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 874 | - | |||||||||||||||||||
| 875 | if (function.isEmpty()
| 10-34 | ||||||||||||||||||
| 876 | result.append(QLatin1Char('?') + library + QLatin1Char('?')); | - | ||||||||||||||||||
| 877 | } executed 10 times by 1 test: else {end of blockExecuted by:
| 10 | ||||||||||||||||||
| 878 | result.append(function); | - | ||||||||||||||||||
| 879 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||||||||||||||
| 880 | } else { | - | ||||||||||||||||||
| 881 | if (inIfnumberPrinted == 0
| 0 | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 884 | } | - | ||||||||||||||||||
| 885 | result.append(([]() -> QString { enum { Size = sizeof(u"" "QT_MESSAGE_PATTERN: missing %{endif}\n""???")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QT_MESSAGE_PATTERN: missing %{endif}\n""???" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }());}()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 886 | } never executed: end of block | 0 | ||||||||||||||||||
| 887 | numberPrinted++; | - | ||||||||||||||||||
| 888 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||
| 889 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 890 | return executed 16 times by 1 test: result;return result;Executed by:
executed 16 times by 1 test: return result;Executed by:
| 16 | ||||||||||||||||||
| 891 | } | - | ||||||||||||||||||
| 892 | - | |||||||||||||||||||
| 893 | static QString formatBacktraceForLogMessage(const QMessagePattern::BacktraceParams backtraceParams, | - | ||||||||||||||||||
| 894 | const char *function) | - | ||||||||||||||||||
| 895 | { | - | ||||||||||||||||||
| 896 | QString backtraceSeparator = backtraceParams.backtraceSeparator; | - | ||||||||||||||||||
| 897 | int backtraceDepth = backtraceParams.backtraceDepth; | - | ||||||||||||||||||
| 898 | - | |||||||||||||||||||
| 899 | QStringList frames = backtraceFramesForLogMessage(backtraceDepth); | - | ||||||||||||||||||
| 900 | if (!error(frames
| 0-16 | ||||||||||||||||||
| 901 | { | 0 | ||||||||||||||||||
| { | ||||||||||||||||||||
| fprintfreturn never executed: return QString();never executed: QString();return QString();never executed: return QString(); | ||||||||||||||||||||
| 902 | - | |||||||||||||||||||
| 903 | - | |||||||||||||||||||
| 904 | if (stderr, "%s", errorfunction
| 0-16 | ||||||||||||||||||
fflush
| ||||||||||||||||||||
}
| ||||||||||||||||||||
}
| ||||||||||||||||||||
literals = new const char*[literalsVar.size() + 1];
| ||||||||||||||||||||
literals
| ||||||||||||||||||||
| 905 | frames never executed: frames[0] = QString::fromUtf8(qCleanupFuncinfo(function));never executed: [literalsVar.size()] =0;frames[0] = QString::fromUtf8(qCleanupFuncinfo(function));never executed: frames[0] = QString::fromUtf8(qCleanupFuncinfo(function)); | 0 | ||||||||||||||||||
| memcpy never executed: frames[0] = QString::fromUtf8(qCleanupFuncinfo(function));never executed: ] = QString::fromUtf8(literals, literalsVar.constData(), literalsVarqCleanupFuncinfo(function));frames[0] = QString::fromUtf8(qCleanupFuncinfo(function));never executed: frames[0] = QString::fromUtf8(qCleanupFuncinfo(function)); | ||||||||||||||||||||
| 906 | - | |||||||||||||||||||
| 907 | return executed 16 times by 1 test: framesreturn frames.join(backtraceSeparator);Executed by:
executed 16 times by 1 test: return frames.join(backtraceSeparator);Executed by:
executed 16 times by 1 test: .size() * sizeofjoin(const char*));backtraceSeparator);return frames.join(backtraceSeparator);Executed by:
executed 16 times by 1 test: return frames.join(backtraceSeparator);Executed by:
| 16 | ||||||||||||||||||
| 908 | } | - | ||||||||||||||||||
| 909 | namespace { namespace Q_QGS_qMessagePattern { typedef QMessagePattern Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QMessagePattern, Q_QGS_qMessagePattern::innerFunction, Q_QGS_qMessagePattern::guard> qMessagePattern; | - | ||||||||||||||||||
| 910 | QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, const QString &str) | - | ||||||||||||||||||
| 911 | { | - | ||||||||||||||||||
| 912 | QString message; | - | ||||||||||||||||||
| 913 | - | |||||||||||||||||||
| 914 | QMutexLocker lock(&QMessagePattern::mutex); | - | ||||||||||||||||||
| 915 | - | |||||||||||||||||||
| 916 | QMessagePattern *pattern = qMessagePattern(); | - | ||||||||||||||||||
| 917 | if (!pattern
| 0-254286 | ||||||||||||||||||
| 918 | - | |||||||||||||||||||
| 919 | message.append(str); | - | ||||||||||||||||||
| 920 | return never executed: message;return message;never executed: return message; | 0 | ||||||||||||||||||
| 921 | } | - | ||||||||||||||||||
| 922 | - | |||||||||||||||||||
| 923 | bool skip = false; | - | ||||||||||||||||||
| 924 | - | |||||||||||||||||||
| 925 | - | |||||||||||||||||||
| 926 | int timeArgsIdx = 0; | - | ||||||||||||||||||
| 927 | - | |||||||||||||||||||
| 928 | int backtraceArgsIdx = 0; | - | ||||||||||||||||||
| 929 | - | |||||||||||||||||||
| 930 | - | |||||||||||||||||||
| 931 | - | |||||||||||||||||||
| 932 | - | |||||||||||||||||||
| 933 | for (int i = 0; pattern->tokens[i] != 0
| 254286-1271809 | ||||||||||||||||||
| 934 | const char *token = pattern->tokens[i]; | - | ||||||||||||||||||
| 935 | if (token == endifTokenC
| 254276-1017533 | ||||||||||||||||||
| 936 | skip = false; | - | ||||||||||||||||||
| 937 | } executed 254276 times by 106 tests: else if (skipend of blockExecuted by:
| 254276-509094 | ||||||||||||||||||
| 938 | - | |||||||||||||||||||
| 939 | - | |||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | if (token == timeTokenC
| 10-508429 | ||||||||||||||||||
| 942 | timeArgsIdx++; executed 10 times by 1 test: timeArgsIdx++;Executed by:
| 10 | ||||||||||||||||||
| 943 | - | |||||||||||||||||||
| 944 | else if (token == backtraceTokenC
| 0-508429 | ||||||||||||||||||
| 945 | backtraceArgsIdx++; never executed: backtraceArgsIdx++; | 0 | ||||||||||||||||||
| 946 | - | |||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | } executed 508439 times by 106 tests: else if (token == messageTokenCend of blockExecuted by:
| 254276-508439 | ||||||||||||||||||
| 949 | message.append(str); | - | ||||||||||||||||||
| 950 | } executed 254276 times by 106 tests: else if (token == categoryTokenCend of blockExecuted by:
| 3-254815 | ||||||||||||||||||
| 951 | message.append(QLatin1String(context.category)); | - | ||||||||||||||||||
| 952 | } executed 3 times by 3 tests: else if (token == typeTokenCend of blockExecuted by:
| 3-254801 | ||||||||||||||||||
| 953 | switch (type) { | - | ||||||||||||||||||
| 954 | case executed 6 times by 2 tests: QtDebugMsg:case QtDebugMsg:Executed by:
executed 6 times by 2 tests: message.append(QLatin1String("debug")); break;case QtDebugMsg:Executed by:
executed 6 times by 2 tests: break;Executed by:
| 6 | ||||||||||||||||||
| 955 | case executed 2 times by 1 test: QtInfoMsg:case QtInfoMsg:Executed by:
executed 2 times by 1 test: message.append(QLatin1String("info")); break;case QtInfoMsg:Executed by:
executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||
| 956 | case executed 4 times by 1 test: QtWarningMsg:case QtWarningMsg:Executed by:
executed 4 times by 1 test: message.append(QLatin1String("warning")); break;case QtWarningMsg:Executed by:
executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||
| 957 | case executed 2 times by 1 test: QtCriticalMsg:case QtCriticalMsg:Executed by:
executed 2 times by 1 test: message.append(QLatin1String("critical")); break;case QtCriticalMsg:Executed by:
executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||
| 958 | case never executed: QtFatalMsg:case QtFatalMsg:never executed: message.append(QLatin1String("fatal")); break;case QtFatalMsg:never executed: break; | 0 | ||||||||||||||||||
| 959 | } | - | ||||||||||||||||||
| 960 | } executed 14 times by 2 tests: else if (token == fileTokenCend of blockExecuted by:
| 1-254800 | ||||||||||||||||||
| 961 | if (context.file
| 0-1 | ||||||||||||||||||
| 962 | message.append(QLatin1String(context.file)); executed 1 time by 1 test: message.append(QLatin1String(context.file));Executed by:
| 1 | ||||||||||||||||||
| 963 | else | - | ||||||||||||||||||
| 964 | message.append(QLatin1String("unknown")); never executed: message.append(QLatin1String("unknown")); | 0 | ||||||||||||||||||
| 965 | } else if (token == lineTokenC
| 9-254791 | ||||||||||||||||||
| 966 | message.append(QString::number(context.line)); | - | ||||||||||||||||||
| 967 | } executed 9 times by 2 tests: else if (token == functionTokenCend of blockExecuted by:
| 9-254782 | ||||||||||||||||||
| 968 | if (context.function
| 0-9 | ||||||||||||||||||
| 969 | message.append(QString::fromLatin1(qCleanupFuncinfo(context.function))); executed 9 times by 2 tests: message.append(QString::fromLatin1(qCleanupFuncinfo(context.function)));Executed by:
| 9 | ||||||||||||||||||
| 970 | else | - | ||||||||||||||||||
| 971 | message.append(QLatin1String("unknown")); never executed: message.append(QLatin1String("unknown")); | 0 | ||||||||||||||||||
| 972 | - | |||||||||||||||||||
| 973 | } else if (token == pidTokenC
| 8-254774 | ||||||||||||||||||
| 974 | message.append(QString::number(QCoreApplication::applicationPid())); | - | ||||||||||||||||||
| 975 | } executed 8 times by 1 test: else if (token == appnameTokenCend of blockExecuted by:
| 8-254766 | ||||||||||||||||||
| 976 | message.append(QCoreApplication::applicationName()); | - | ||||||||||||||||||
| 977 | } executed 8 times by 1 test: else if (token == threadidTokenCend of blockExecuted by:
| 8-254758 | ||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 | message.append(QString::number(qt_gettid())); | - | ||||||||||||||||||
| 980 | } executed 8 times by 1 test: else if (token == qthreadptrTokenCend of blockExecuted by:
| 8-254750 | ||||||||||||||||||
| 981 | message.append(QLatin1String("0x")); | - | ||||||||||||||||||
| 982 | message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16)); | - | ||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | } executed 8 times by 1 test: else if (token == backtraceTokenCend of blockExecuted by:
| 8-254734 | ||||||||||||||||||
| 985 | QMessagePattern::BacktraceParams backtraceParams = pattern->backtraceArgs.at(backtraceArgsIdx); | - | ||||||||||||||||||
| 986 | QString backtraceSeparator = backtraceParams.backtraceSeparator; | - | ||||||||||||||||||
| int backtraceDepth = backtraceParams.backtraceDepth;backtraceArgsIdx++; | ||||||||||||||||||||
| 987 | QVarLengthArray<void*, 32> buffer(7 + backtraceDepth); | - | ||||||||||||||||||
| int n = backtrace(buffer.data(), buffer.size()); | ||||||||||||||||||||
| if (n > 0) { | ||||||||||||||||||||
| int numberPrinted = 0; | ||||||||||||||||||||
| for (int i = 0; i < n && numberPrinted < backtraceDepth; ++i) { | ||||||||||||||||||||
| QScopedPointer<char*, QScopedPointerPodDeleter> strings(backtrace_symbols(buffer.data() + i, 1)); | ||||||||||||||||||||
| QString trace = QString::fromLatin1(strings.data()[0]); | ||||||||||||||||||||
| static QRegularExpression rx(([]() -> QString { enum { Size = sizeof(u"" "^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()), | ||||||||||||||||||||
| QRegularExpression::OptimizeOnFirstUsageOption); | ||||||||||||||||||||
| QRegularExpressionMatch m = rx.match(trace); | ||||||||||||||||||||
| if (m.hasMatch()) { | ||||||||||||||||||||
| QString library = m.captured(1); | ||||||||||||||||||||
| QString function = m.captured(2); | ||||||||||||||||||||
| if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) | ||||||||||||||||||||
| && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) | ||||||||||||||||||||
| || function.contains(QLatin1String("QDebug")))) { | ||||||||||||||||||||
| continue; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (function.startsWith(QLatin1String("_Z"))) { | ||||||||||||||||||||
| QScopedPointer<char, QScopedPointerPodDeleter> demangled( | ||||||||||||||||||||
| abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); | ||||||||||||||||||||
| if (demangled) | ||||||||||||||||||||
| function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (numberPrinted > 0)message.append(backtraceSeparator); | ||||||||||||||||||||
| if (function.isEmpty()) { | ||||||||||||||||||||
| if (numberPrinted == 0 && context.function) | ||||||||||||||||||||
| message += QString::fromUtf8(qCleanupFuncinfoformatBacktraceForLogMessage(backtraceParams, context.function));else | ||||||||||||||||||||
| message += QLatin1Char('?') + library + QLatin1Char('?'); | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| message += function; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| if (numberPrinted == 0) | ||||||||||||||||||||
| continue; | ||||||||||||||||||||
| message += backtraceSeparator + QLatin1String("???"); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| numberPrinted++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| 988 | - | |||||||||||||||||||
| 989 | } executed 16 times by 1 test: else if (token == timeTokenCend of blockExecuted by:
| 16-254696 | ||||||||||||||||||
| 990 | QString timeFormat = pattern->timeArgs.at(timeArgsIdx); | - | ||||||||||||||||||
| 991 | timeArgsIdx++; | - | ||||||||||||||||||
| 992 | if (timeFormat == QLatin1String("process")
| 8-30 | ||||||||||||||||||
| 993 | quint64 ms = pattern->timer.elapsed(); | - | ||||||||||||||||||
| 994 | message.append(QString::asprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); | - | ||||||||||||||||||
| 995 | } executed 8 times by 1 test: else if (timeFormat == QLatin1String("boot")end of blockExecuted by:
| 0-30 | ||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | - | |||||||||||||||||||
| 998 | QElapsedTimer now; | - | ||||||||||||||||||
| 999 | now.start(); | - | ||||||||||||||||||
| 1000 | uint ms = now.msecsSinceReference(); | - | ||||||||||||||||||
| 1001 | message.append(QString::asprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); | - | ||||||||||||||||||
| 1002 | } never executed: else if (timeFormat.isEmpty()end of block
| 0-30 | ||||||||||||||||||
| 1003 | message.append(QDateTime::currentDateTime().toString(Qt::ISODate)); | - | ||||||||||||||||||
| 1004 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 1005 | message.append(QDateTime::currentDateTime().toString(timeFormat)); | - | ||||||||||||||||||
| 1006 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||
| 1007 | - | |||||||||||||||||||
| 1008 | } else if (token == ifCategoryTokenC
| 514-254182 | ||||||||||||||||||
| 1009 | if (!context.category
| 3-254177 | ||||||||||||||||||
| 1010 | skip = true; executed 254179 times by 106 tests: skip = true;Executed by:
| 254179 | ||||||||||||||||||
| 1011 | - | |||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | - | |||||||||||||||||||
| 1014 | } executed 254182 times by 106 tests: else if (token == ifDebugTokenCend of blockExecuted by:
| 30-254182 | ||||||||||||||||||
| 1015 | } executed 30 times by 2 tests: else if (token == ifInfoTokenCend of blockExecuted by:
| 6-478 | ||||||||||||||||||
| 1016 | } executed 6 times by 1 test: else if (token == ifWarningTokenCend of blockExecuted by:
| 6-444 | ||||||||||||||||||
| 1017 | } executed 34 times by 2 tests: else if (token == ifCriticalTokenCend of blockExecuted by:
| 14-430 | ||||||||||||||||||
| 1018 | } executed 14 times by 2 tests: else if (token == ifFatalTokenCend of blockExecuted by:
| 14-416 | ||||||||||||||||||
| 1019 | - | |||||||||||||||||||
| 1020 | } executed 14 times by 2 tests: else {end of blockExecuted by:
| 14 | ||||||||||||||||||
| 1021 | message.append(QLatin1String(token)); | - | ||||||||||||||||||
| 1022 | } executed 416 times by 3 tests: end of blockExecuted by:
| 416 | ||||||||||||||||||
| 1023 | } | - | ||||||||||||||||||
| 1024 | return executed 254286 times by 106 tests: message;return message;Executed by:
executed 254286 times by 106 tests: return message;Executed by:
| 254286 | ||||||||||||||||||
| 1025 | } | - | ||||||||||||||||||
| 1026 | - | |||||||||||||||||||
| 1027 | - | |||||||||||||||||||
| 1028 | - | |||||||||||||||||||
| 1029 | typedef void (*QtMsgHandler)(QtMsgType, const char *); | - | ||||||||||||||||||
| 1030 | __attribute__((visibility("default"))) QtMsgHandler qInstallMsgHandler(QtMsgHandler); | - | ||||||||||||||||||
| 1031 | - | |||||||||||||||||||
| 1032 | - | |||||||||||||||||||
| 1033 | static void qDefaultMsgHandler(QtMsgType type, const char *buf); | - | ||||||||||||||||||
| 1034 | static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf); | - | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 | - | |||||||||||||||||||
| 1037 | static QBasicAtomicPointer<void (QtMsgType, const char*)> msgHandler = { qDefaultMsgHandler }; | - | ||||||||||||||||||
| 1038 | - | |||||||||||||||||||
| 1039 | static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = { qDefaultMessageHandler }; | - | ||||||||||||||||||
| 1040 | static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, | - | ||||||||||||||||||
| 1041 | const QString &buf) | - | ||||||||||||||||||
| 1042 | { | - | ||||||||||||||||||
| 1043 | QString logMessage = qFormatLogMessage(type, context, buf); | - | ||||||||||||||||||
| 1044 | - | |||||||||||||||||||
| 1045 | - | |||||||||||||||||||
| 1046 | - | |||||||||||||||||||
| 1047 | if (logMessage.isNull()) | - | ||||||||||||||||||
| 1048 | return; | - | ||||||||||||||||||
| 1049 | - | |||||||||||||||||||
| 1050 | if (!qt_logging_to_console()) { | - | ||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||
| 1052 | fprintf(stderr, "%s\n", logMessage.toLocal8Bit().constData()); | - | ||||||||||||||||||
| 1053 | fflush(stderr); | - | ||||||||||||||||||
| 1054 | } | - | ||||||||||||||||||
| 1055 | - | |||||||||||||||||||
| 1056 | - | |||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | - | |||||||||||||||||||
| 1059 | static void qDefaultMsgHandler(QtMsgType type, const char *buf) | - | ||||||||||||||||||
| 1060 | { | - | ||||||||||||||||||
| 1061 | QMessageLogContext emptyContext; | - | ||||||||||||||||||
| 1062 | qDefaultMessageHandler(type, emptyContext, QString::fromLocal8Bit(buf)); | - | ||||||||||||||||||
| 1063 | } | - | ||||||||||||||||||
| 1064 | - | |||||||||||||||||||
| 1065 | - | |||||||||||||||||||
| 1066 | - | |||||||||||||||||||
| 1067 | static thread_local bool msgHandlerGrabbed = false; | - | ||||||||||||||||||
| 1068 | - | |||||||||||||||||||
| 1069 | static bool grabMessageHandler() | - | ||||||||||||||||||
| 1070 | { | - | ||||||||||||||||||
| 1071 | if (msgHandlerGrabbed) | - | ||||||||||||||||||
| 1072 | return false; | - | ||||||||||||||||||
| 1073 | - | |||||||||||||||||||
| 1074 | msgHandlerGrabbed = true; | - | ||||||||||||||||||
| 1075 | return true; | - | ||||||||||||||||||
| 1076 | } | - | ||||||||||||||||||
| 1077 | - | |||||||||||||||||||
| 1078 | static void ungrabMessageHandler() | - | ||||||||||||||||||
| 1079 | { | - | ||||||||||||||||||
| 1080 | msgHandlerGrabbed = false; | - | ||||||||||||||||||
| 1081 | } | - | ||||||||||||||||||
| 1082 | - | |||||||||||||||||||
| 1083 | - | |||||||||||||||||||
| 1084 | - | |||||||||||||||||||
| 1085 | - | |||||||||||||||||||
| 1086 | - | |||||||||||||||||||
| 1087 | - | |||||||||||||||||||
| 1088 | static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message) | - | ||||||||||||||||||
| 1089 | { | - | ||||||||||||||||||
| 1090 | - | |||||||||||||||||||
| 1091 | - | |||||||||||||||||||
| 1092 | if (!context.category || (strcmp(context.category, "default") == 0)) { | - | ||||||||||||||||||
| 1093 | if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) { | - | ||||||||||||||||||
| 1094 | if (!defaultCategory->isEnabled(msgType)) | - | ||||||||||||||||||
| 1095 | return; | - | ||||||||||||||||||
| 1096 | } | - | ||||||||||||||||||
| 1097 | } | - | ||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | - | |||||||||||||||||||
| 1101 | - | |||||||||||||||||||
| 1102 | if (grabMessageHandler()) { | - | ||||||||||||||||||
| 1103 | - | |||||||||||||||||||
| 1104 | if (msgHandler.load() == qDefaultMsgHandler | - | ||||||||||||||||||
| 1105 | || messageHandler.load() != qDefaultMessageHandler) { | - | ||||||||||||||||||
| 1106 | (*messageHandler.load())(msgType, context, message); | - | ||||||||||||||||||
| 1107 | } else { | - | ||||||||||||||||||
| 1108 | (*msgHandler.load())(msgType, message.toLocal8Bit().constData()); | - | ||||||||||||||||||
| 1109 | } | - | ||||||||||||||||||
| 1110 | ungrabMessageHandler(); | - | ||||||||||||||||||
| 1111 | } else { | - | ||||||||||||||||||
| 1112 | fprintf(stderr, "%s\n", message.toLocal8Bit().constData()); | - | ||||||||||||||||||
| 1113 | } | - | ||||||||||||||||||
| 1114 | } | - | ||||||||||||||||||
| 1115 | - | |||||||||||||||||||
| 1116 | static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message) | - | ||||||||||||||||||
| 1117 | { | - | ||||||||||||||||||
| 1118 | (void)context;; | - | ||||||||||||||||||
| 1119 | (void)message;; | - | ||||||||||||||||||
| 1120 | - | |||||||||||||||||||
| 1121 | - | |||||||||||||||||||
| 1122 | - | |||||||||||||||||||
| 1123 | abort(); | - | ||||||||||||||||||
| 1124 | - | |||||||||||||||||||
| 1125 | - | |||||||||||||||||||
| 1126 | - | |||||||||||||||||||
| 1127 | } | - | ||||||||||||||||||
| 1128 | - | |||||||||||||||||||
| 1129 | - | |||||||||||||||||||
| 1130 | - | |||||||||||||||||||
| 1131 | - | |||||||||||||||||||
| 1132 | - | |||||||||||||||||||
| 1133 | void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, const QString &message) | - | ||||||||||||||||||
| 1134 | { | - | ||||||||||||||||||
| 1135 | qt_message_print(msgType, context, message); | - | ||||||||||||||||||
| 1136 | if (isFatal(msgType)) | - | ||||||||||||||||||
| 1137 | qt_message_fatal(msgType, context, message); | - | ||||||||||||||||||
| 1138 | } | - | ||||||||||||||||||
| 1139 | - | |||||||||||||||||||
| 1140 | void qErrnoWarning(const char *msg, ...) | - | ||||||||||||||||||
| 1141 | { | - | ||||||||||||||||||
| 1142 | - | |||||||||||||||||||
| 1143 | - | |||||||||||||||||||
| 1144 | va_list ap; | - | ||||||||||||||||||
| 1145 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 1146 | QString buf = QString::vasprintf(msg, ap); | - | ||||||||||||||||||
| 1147 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 1148 | - | |||||||||||||||||||
| 1149 | buf += QLatin1String(" (") + qt_error_string(-1) + QLatin1Char(')'); | - | ||||||||||||||||||
| 1150 | QMessageLogContext context; | - | ||||||||||||||||||
| 1151 | qt_message_output(QtCriticalMsg, context, buf); | - | ||||||||||||||||||
| 1152 | } | - | ||||||||||||||||||
| 1153 | - | |||||||||||||||||||
| 1154 | void qErrnoWarning(int code, const char *msg, ...) | - | ||||||||||||||||||
| 1155 | { | - | ||||||||||||||||||
| 1156 | - | |||||||||||||||||||
| 1157 | - | |||||||||||||||||||
| 1158 | va_list ap; | - | ||||||||||||||||||
| 1159 | __builtin_va_start(ap,msg); | - | ||||||||||||||||||
| 1160 | QString buf = QString::vasprintf(msg, ap); | - | ||||||||||||||||||
| 1161 | __builtin_va_end(ap); | - | ||||||||||||||||||
| 1162 | - | |||||||||||||||||||
| 1163 | buf += QLatin1String(" (") + qt_error_string(code) + QLatin1Char(')'); | - | ||||||||||||||||||
| 1164 | QMessageLogContext context; | - | ||||||||||||||||||
| 1165 | qt_message_output(QtCriticalMsg, context, buf); | - | ||||||||||||||||||
| 1166 | } | - | ||||||||||||||||||
| 1167 | QtMessageHandler qInstallMessageHandler(QtMessageHandler h) | - | ||||||||||||||||||
| 1168 | { | - | ||||||||||||||||||
| 1169 | if (!h) | - | ||||||||||||||||||
| 1170 | h = qDefaultMessageHandler; | - | ||||||||||||||||||
| 1171 | - | |||||||||||||||||||
| 1172 | return messageHandler.fetchAndStoreRelaxed(h); | - | ||||||||||||||||||
| 1173 | } | - | ||||||||||||||||||
| 1174 | - | |||||||||||||||||||
| 1175 | QtMsgHandler qInstallMsgHandler(QtMsgHandler h) | - | ||||||||||||||||||
| 1176 | { | - | ||||||||||||||||||
| 1177 | if (!h) | - | ||||||||||||||||||
| 1178 | h = qDefaultMsgHandler; | - | ||||||||||||||||||
| 1179 | - | |||||||||||||||||||
| 1180 | return msgHandler.fetchAndStoreRelaxed(h); | - | ||||||||||||||||||
| 1181 | } | - | ||||||||||||||||||
| 1182 | - | |||||||||||||||||||
| 1183 | void qSetMessagePattern(const QString &pattern) | - | ||||||||||||||||||
| 1184 | { | - | ||||||||||||||||||
| 1185 | QMutexLocker lock(&QMessagePattern::mutex); | - | ||||||||||||||||||
| 1186 | - | |||||||||||||||||||
| 1187 | if (!qMessagePattern()->fromEnvironment) | - | ||||||||||||||||||
| 1188 | qMessagePattern()->setPattern(pattern); | - | ||||||||||||||||||
| 1189 | } | - | ||||||||||||||||||
| 1190 | - | |||||||||||||||||||
| 1191 | - | |||||||||||||||||||
| 1192 | - | |||||||||||||||||||
| 1193 | - | |||||||||||||||||||
| 1194 | - | |||||||||||||||||||
| 1195 | - | |||||||||||||||||||
| 1196 | void QMessageLogContext::copy(const QMessageLogContext &logContext) | - | ||||||||||||||||||
| 1197 | { | - | ||||||||||||||||||
| 1198 | this->category = logContext.category; | - | ||||||||||||||||||
| 1199 | this->file = logContext.file; | - | ||||||||||||||||||
| 1200 | this->line = logContext.line; | - | ||||||||||||||||||
| 1201 | this->function = logContext.function; | - | ||||||||||||||||||
| 1202 | } | - | ||||||||||||||||||
| 1203 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |