|
220 | 220 | #include <client/crashpad_client.h> |
221 | 221 | #include <client/prune_crash_reports.h> |
222 | 222 | #include <client/settings.h> |
| 223 | +#include <client/annotation.h> |
223 | 224 |
|
224 | 225 | #include <fmt/format.h> |
225 | 226 |
|
226 | 227 | #include "llnotificationsutil.h" |
227 | 228 | #include "llversioninfo.h" |
| 229 | + |
| 230 | + |
| 231 | +template <size_t SIZE, crashpad::Annotation::Type T = crashpad::Annotation::Type::kString> |
| 232 | +struct crashpad_annotation : public crashpad::Annotation { |
| 233 | + std::array<char, SIZE> buffer; |
| 234 | + crashpad_annotation(const char* name) : crashpad::Annotation(T, name, buffer.data()) |
| 235 | + {} |
| 236 | + void set(const std::string& src) { |
| 237 | + LL_INFOS() << name() << ": " << src.c_str() << LL_ENDL; |
| 238 | + const size_t min_size = llmin(SIZE, src.size()); |
| 239 | + memcpy(buffer.data(), src.data(), min_size); |
| 240 | + buffer.data()[SIZE - 1] = '\0'; |
| 241 | + SetSize(min_size); |
| 242 | + } |
| 243 | +}; |
| 244 | +#define DEFINE_CRASHPAD_ANNOTATION(name, len) \ |
| 245 | +static crashpad_annotation<len> g_crashpad_annotation_##name##_buffer(#name); |
| 246 | +#define SET_CRASHPAD_ANNOTATION_VALUE(name, value) \ |
| 247 | +g_crashpad_annotation_##name##_buffer.set(value); |
| 248 | +#else |
| 249 | +#define SET_CRASHPAD_ANNOTATION_VALUE(name, value) |
| 250 | +#define DEFINE_CRASHPAD_ANNOTATION(name, len) |
228 | 251 | #endif |
229 | 252 |
|
| 253 | +DEFINE_CRASHPAD_ANNOTATION(fatal_message, 512); |
| 254 | +DEFINE_CRASHPAD_ANNOTATION(grid_name, 64); |
| 255 | +DEFINE_CRASHPAD_ANNOTATION(cpu_string, 128); |
| 256 | +DEFINE_CRASHPAD_ANNOTATION(startup_state, 32); |
230 | 257 |
|
231 | 258 | ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor |
232 | 259 | // |
@@ -770,8 +797,18 @@ bool LLAppViewer::init() |
770 | 797 | initCrashReporting(); |
771 | 798 | #endif |
772 | 799 |
|
| 800 | + writeDebugInfo(); |
| 801 | + |
773 | 802 | setupErrorHandling(); |
774 | 803 |
|
| 804 | + { |
| 805 | + auto fn = boost::bind<bool>([](const LLSD& stateInfo) -> bool { |
| 806 | + SET_CRASHPAD_ANNOTATION_VALUE(startup_state, stateInfo["str"].asString()); |
| 807 | + return false; |
| 808 | + }, _1); |
| 809 | + LLStartUp::getStateEventPump().listen<::LLEventListener>("LLAppViewer", fn); |
| 810 | + } |
| 811 | + |
775 | 812 | // |
776 | 813 | // Start of the application |
777 | 814 | // |
@@ -2741,6 +2778,10 @@ void LLAppViewer::writeDebugInfo(bool isStatic) |
2741 | 2778 |
|
2742 | 2779 | isStatic ? LLSDSerialize::toPrettyXML(gDebugInfo, out_file) |
2743 | 2780 | : LLSDSerialize::toPrettyXML(gDebugInfo["Dynamic"], out_file); |
| 2781 | +#else |
| 2782 | + SET_CRASHPAD_ANNOTATION_VALUE(fatal_message, gDebugInfo["FatalMessage"].asString()); |
| 2783 | + SET_CRASHPAD_ANNOTATION_VALUE(grid_name, gDebugInfo["GridName"].asString()); |
| 2784 | + SET_CRASHPAD_ANNOTATION_VALUE(cpu_string, gDebugInfo["CPUInfo"]["CPUString"].asString()); |
2744 | 2785 | #endif |
2745 | 2786 | } |
2746 | 2787 |
|
|
0 commit comments