[PATCH] D58552: [compiler-rt] Windows Trace Logging for error reports.
Matthew G McGovern via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 12:56:22 PST 2019
mcgov updated this revision to Diff 188245.
mcgov added a comment.
Updated to use common_flags->log_to_syslog
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58552/new/
https://reviews.llvm.org/D58552
Files:
lib/sanitizer_common/sanitizer_common.h
lib/sanitizer_common/sanitizer_win.cc
utils/AddressSanitizerLoggingProvider.wprp
Index: utils/AddressSanitizerLoggingProvider.wprp
===================================================================
--- /dev/null
+++ utils/AddressSanitizerLoggingProvider.wprp
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WindowsPerformanceRecorder Version="1.0" Author="Microsoft Corporation" Company="Microsoft Corporation">
+ <Profiles>
+ <EventCollector Id="EventCollector_AddressSanitizerLoggingProvider" Name="AddressSanitizerLoggingProvider">
+ <BufferSize Value="64" />
+ <Buffers Value="4" />
+ </EventCollector>
+ <EventProvider Id="EventProvider_AddressSanitizerLoggingProvider" Name="6c6c766d-3846-4e6a-a4fb-5b530bd0f3fa" />
+ <Profile Id="AddressSanitizerLoggingProvider.Verbose.File" Name="AddressSanitizerLoggingProvider" Description="AddressSanitizerLoggingProvider" LoggingMode="File" DetailLevel="Verbose">
+ <Collectors>
+ <EventCollectorId Value="EventCollector_AddressSanitizerLoggingProvider">
+ <EventProviders>
+ <EventProviderId Value="EventProvider_AddressSanitizerLoggingProvider" />
+ </EventProviders>
+ </EventCollectorId>
+ </Collectors>
+ </Profile>
+ <Profile Id="AddressSanitizerLoggingProvider.Light.File" Name="AddressSanitizerLoggingProvider" Description="AddressSanitizerLoggingProvider" Base="AddressSanitizerLoggingProvider.Verbose.File" LoggingMode="File" DetailLevel="Light" />
+ <Profile Id="AddressSanitizerLoggingProvider.Verbose.Memory" Name="AddressSanitizerLoggingProvider" Description="AddressSanitizerLoggingProvider" Base="AddressSanitizerLoggingProvider.Verbose.File" LoggingMode="Memory" DetailLevel="Verbose" />
+ <Profile Id="AddressSanitizerLoggingProvider.Light.Memory" Name="AddressSanitizerLoggingProvider" Description="AddressSanitizerLoggingProvider" Base="AddressSanitizerLoggingProvider.Verbose.File" LoggingMode="Memory" DetailLevel="Light" />
+ </Profiles>
+</WindowsPerformanceRecorder>
\ No newline at end of file
Index: lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- lib/sanitizer_common/sanitizer_win.cc
+++ lib/sanitizer_common/sanitizer_win.cc
@@ -20,6 +20,7 @@
#include <io.h>
#include <psapi.h>
#include <stdlib.h>
+#include <TraceLoggingProvider.h>
#include "sanitizer_common.h"
#include "sanitizer_file.h"
@@ -31,6 +32,8 @@
#if defined(PSAPI_VERSION) && PSAPI_VERSION == 1
#pragma comment(lib, "psapi")
#endif
+#pragma comment(lib, "advapi32.lib")
+// advapi32 needed for win10 tracelogging.
// A macro to tell the compiler that this part of the code cannot be reached,
// if the compiler supports this feature. Since we're using this in
@@ -1063,6 +1066,25 @@
return sysinfo.dwNumberOfProcessors;
}
+TRACELOGGING_DECLARE_PROVIDER(g_hAsanProvider);
+TRACELOGGING_DEFINE_PROVIDER(g_hAsanProvider, "AddressSanitizerLoggingProvider",
+ (0x6c6c766d, 0x3846, 0x4e6a, 0xa4, 0xfb, 0x5b,
+ 0x53, 0x0b, 0xd0, 0xf3, 0xfa));
+
+void LogFullErrorReport(const char *buffer) {
+ if (common_flags()->log_to_syslog){
+ char Filename[MAX_PATH + 1] = {0};
+ GetModuleFileNameA(NULL, Filename, MAX_PATH);
+ HRESULT hr = TraceLoggingRegister(g_hAsanProvider);
+ if (!SUCCEEDED(hr))
+ return;
+ TraceLoggingWrite(g_hAsanProvider, "AsanReportEvent",
+ TraceLoggingString(Filename, "Process"),
+ TraceLoggingString(buffer, "Message"));
+ TraceLoggingUnregister(g_hAsanProvider);
+ }
+}
+
} // namespace __sanitizer
#endif // _WIN32
Index: lib/sanitizer_common/sanitizer_common.h
===================================================================
--- lib/sanitizer_common/sanitizer_common.h
+++ lib/sanitizer_common/sanitizer_common.h
@@ -803,7 +803,7 @@
void WriteToSyslog(const char *buffer);
-#if SANITIZER_MAC
+#if SANITIZER_MAC || SANITIZER_WINDOWS
void LogFullErrorReport(const char *buffer);
#else
INLINE void LogFullErrorReport(const char *buffer) {}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58552.188245.patch
Type: text/x-patch
Size: 4038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190225/955f7943/attachment.bin>
More information about the llvm-commits
mailing list