|
20 | 20 | #include <io.h>
|
21 | 21 | #include <psapi.h>
|
22 | 22 | #include <stdlib.h>
|
| 23 | +#include <TraceLoggingProvider.h> |
23 | 24 |
|
24 | 25 | #include "sanitizer_common.h"
|
25 | 26 | #include "sanitizer_file.h"
|
|
31 | 32 | #if defined(PSAPI_VERSION) && PSAPI_VERSION == 1
|
32 | 33 | #pragma comment(lib, "psapi")
|
33 | 34 | #endif
|
| 35 | +// Windows trace logging provider init |
| 36 | +#pragma comment(lib, "advapi32.lib") |
| 37 | +TRACELOGGING_DECLARE_PROVIDER(g_asan_provider); |
| 38 | +// GUID must be the same in utils/AddressSanitizerLoggingProvider.wprp |
| 39 | +TRACELOGGING_DEFINE_PROVIDER(g_asan_provider, "AddressSanitizerLoggingProvider", |
| 40 | + (0x6c6c766d, 0x3846, 0x4e6a, 0xa4, 0xfb, 0x5b, |
| 41 | + 0x53, 0x0b, 0xd0, 0xf3, 0xfa)); |
34 | 42 |
|
35 | 43 | // A macro to tell the compiler that this part of the code cannot be reached,
|
36 | 44 | // if the compiler supports this feature. Since we're using this in
|
@@ -652,6 +660,7 @@ int Atexit(void (*function)(void)) {
|
652 | 660 | }
|
653 | 661 |
|
654 | 662 | static int RunAtexit() {
|
| 663 | + TraceLoggingUnregister(g_asan_provider); |
655 | 664 | int ret = 0;
|
656 | 665 | for (uptr i = 0; i < atexit_functions.size(); ++i) {
|
657 | 666 | ret |= atexit(atexit_functions[i]);
|
@@ -749,6 +758,7 @@ uptr internal_sched_yield() {
|
749 | 758 | }
|
750 | 759 |
|
751 | 760 | void internal__exit(int exitcode) {
|
| 761 | + TraceLoggingUnregister(g_asan_provider); |
752 | 762 | // ExitProcess runs some finalizers, so use TerminateProcess to avoid that.
|
753 | 763 | // The debugger doesn't stop on TerminateProcess like it does on ExitProcess,
|
754 | 764 | // so add our own breakpoint here.
|
@@ -1070,6 +1080,30 @@ u32 GetNumberOfCPUs() {
|
1070 | 1080 | return sysinfo.dwNumberOfProcessors;
|
1071 | 1081 | }
|
1072 | 1082 |
|
| 1083 | +// TODO: Rename this project-wide to PlatformLogInit |
| 1084 | +void AndroidLogInit(void) { |
| 1085 | + HRESULT hr = TraceLoggingRegister(g_asan_provider); |
| 1086 | + if (!SUCCEEDED(hr)) |
| 1087 | + return; |
| 1088 | +} |
| 1089 | + |
| 1090 | +void SetAbortMessage(const char *) {} |
| 1091 | + |
| 1092 | +void LogFullErrorReport(const char *buffer) { |
| 1093 | + if (common_flags()->log_to_syslog) { |
| 1094 | + InternalMmapVector<wchar_t> filename; |
| 1095 | + DWORD filename_length = 0; |
| 1096 | + do { |
| 1097 | + filename.resize(filename.size() + 0x100); |
| 1098 | + filename_length = |
| 1099 | + GetModuleFileName(NULL, filename.begin(), filename.size()); |
| 1100 | + } while (filename_length >= filename.size()); |
| 1101 | + TraceLoggingWrite(g_asan_provider, "AsanReportEvent", |
| 1102 | + TraceLoggingValue(filename.begin(), "ExecutableName"), |
| 1103 | + TraceLoggingValue(buffer, "AsanReportContents")); |
| 1104 | + } |
| 1105 | +} |
| 1106 | + |
1073 | 1107 | } // namespace __sanitizer
|
1074 | 1108 |
|
1075 | 1109 | #endif // _WIN32
|
0 commit comments