2017-12-11 18:45:29 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-11 18:45:29 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-11 18:45:29 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace CrashReports {
|
|
|
|
|
2017-12-13 00:15:58 +04:00
|
|
|
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
|
|
|
|
2017-12-11 18:45:29 +04:00
|
|
|
struct dump {
|
|
|
|
~dump();
|
|
|
|
};
|
|
|
|
const dump &operator<<(const dump &stream, const char *str);
|
|
|
|
const dump &operator<<(const dump &stream, const wchar_t *str);
|
|
|
|
const dump &operator<<(const dump &stream, int num);
|
|
|
|
const dump &operator<<(const dump &stream, unsigned int num);
|
|
|
|
const dump &operator<<(const dump &stream, unsigned long num);
|
|
|
|
const dump &operator<<(const dump &stream, unsigned long long num);
|
|
|
|
const dump &operator<<(const dump &stream, double num);
|
|
|
|
|
2017-12-13 00:15:58 +04:00
|
|
|
#endif // TDESKTOP_DISABLE_CRASH_REPORTS
|
|
|
|
|
2017-12-11 18:45:29 +04:00
|
|
|
enum Status {
|
|
|
|
CantOpen,
|
|
|
|
LastCrashed,
|
|
|
|
Started
|
|
|
|
};
|
|
|
|
Status Start();
|
|
|
|
Status Restart(); // can be only CantOpen or Started
|
|
|
|
void Finish();
|
|
|
|
|
|
|
|
void SetAnnotation(const std::string &key, const QString &value);
|
2018-01-18 14:04:25 +03:00
|
|
|
void SetAnnotationHex(const std::string &key, const QString &value);
|
2017-12-11 18:45:29 +04:00
|
|
|
inline void ClearAnnotation(const std::string &key) {
|
|
|
|
SetAnnotation(key, QString());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remembers value pointer and tries to add the value to the crash report.
|
|
|
|
// Attention! You should call clearCrashAnnotationRef(key) before destroying value.
|
|
|
|
void SetAnnotationRef(const std::string &key, const QString *valuePtr);
|
|
|
|
inline void ClearAnnotationRef(const std::string &key) {
|
|
|
|
SetAnnotationRef(key, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartCatching();
|
|
|
|
void FinishCatching();
|
|
|
|
|
|
|
|
} // namespace CrashReports
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
namespace assertion {
|
|
|
|
|
|
|
|
inline void log(const char *message, const char *file, int line) {
|
|
|
|
const auto info = QStringLiteral("%1 %2:%3"
|
|
|
|
).arg(message
|
|
|
|
).arg(file
|
|
|
|
).arg(line
|
|
|
|
);
|
|
|
|
const auto entry = QStringLiteral("Assertion Failed! ") + info;
|
|
|
|
|
|
|
|
#ifdef LOG
|
|
|
|
LOG((entry));
|
|
|
|
#endif // LOG
|
|
|
|
|
|
|
|
CrashReports::SetAnnotation("Assertion", info);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace assertion
|
|
|
|
} // namespace base
|