Bug 1530531: Add a command line option to the launcher process that forces it to log errors to the Windows event log; r=mhowell
authorAaron Klotz <aklotz@mozilla.com>
Mon, 25 Feb 2019 23:11:20 +0000
changeset 518895 faec87a80ed1e4f50a7961b4dd652a682ef339ce
parent 518894 2e92db777acff0551795391d97e05a57e051ec9c
child 518901 7c89a561baee4bf8a5b726a30032d40a5986180f
child 518902 d69f9928a349d8b6c8bdccb2f689f3171ed293d5
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1530531
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530531: Add a command line option to the launcher process that forces it to log errors to the Windows event log; r=mhowell Differential Revision: https://phabricator.services.mozilla.com/D21099
browser/app/winlauncher/ErrorHandler.cpp
browser/app/winlauncher/ErrorHandler.h
browser/app/winlauncher/LauncherProcessWin.cpp
--- a/browser/app/winlauncher/ErrorHandler.cpp
+++ b/browser/app/winlauncher/ErrorHandler.cpp
@@ -52,16 +52,17 @@
 #define TELEMETRY_LAUNCHER_PING_DOCTYPE L"/launcher-process-failure"
 #define TELEMETRY_LAUNCHER_PING_VERSION L"/1"
 
 static const wchar_t kUrl[] = TELEMETRY_BASE_URL TELEMETRY_NAMESPACE
     TELEMETRY_LAUNCHER_PING_DOCTYPE TELEMETRY_LAUNCHER_PING_VERSION L"/";
 static const uint32_t kGuidCharLenWithNul = 39;
 static const uint32_t kGuidCharLenNoBracesNoNul = 36;
 static const mozilla::StaticXREAppData* gAppData;
+static bool gForceEventLog = false;
 
 namespace {
 
 struct EventSourceDeleter {
   using pointer = HANDLE;
 
   void operator()(pointer aEvtSrc) { ::DeregisterEventSource(aEvtSrc); }
 };
@@ -665,17 +666,17 @@ static bool DoSendPing(const PingThreadC
 
   return true;
 }
 
 static unsigned __stdcall SendPingThread(void* aContext) {
   mozilla::UniquePtr<PingThreadContext> context(
       reinterpret_cast<PingThreadContext*>(aContext));
 
-  if (!DoSendPing(*context)) {
+  if (!DoSendPing(*context) || gForceEventLog) {
     PostErrorToLog(context->mLauncherError);
   }
 
   return 0;
 }
 
 #endif  // defined(MOZ_TELEMETRY_REPORTING)
 
@@ -719,20 +720,24 @@ static bool SendPing(const mozilla::Laun
 namespace mozilla {
 
 void HandleLauncherError(const LauncherError& aError) {
 #if defined(MOZ_LAUNCHER_PROCESS)
   LauncherRegistryInfo regInfo;
   Unused << regInfo.DisableDueToFailure();
 #endif  // defined(MOZ_LAUNCHER_PROCESS)
 
-  if (SendPing(aError)) {
+  if (SendPing(aError) && !gForceEventLog) {
     return;
   }
 
   PostErrorToLog(aError);
 }
 
 void SetLauncherErrorAppData(const StaticXREAppData& aAppData) {
   gAppData = &aAppData;
 }
 
+void SetLauncherErrorForceEventLog() {
+  gForceEventLog = true;
+}
+
 }  // namespace mozilla
--- a/browser/app/winlauncher/ErrorHandler.h
+++ b/browser/app/winlauncher/ErrorHandler.h
@@ -39,11 +39,13 @@ inline void HandleLauncherError(
   HandleLauncherError(r);
 }
 
 // Forward declaration
 struct StaticXREAppData;
 
 void SetLauncherErrorAppData(const StaticXREAppData& aAppData);
 
+void SetLauncherErrorForceEventLog();
+
 }  // namespace mozilla
 
 #endif  //  mozilla_ErrorHandler_h
--- a/browser/app/winlauncher/LauncherProcessWin.cpp
+++ b/browser/app/winlauncher/LauncherProcessWin.cpp
@@ -211,16 +211,22 @@ static mozilla::Maybe<bool> RunAsLaunche
 }
 
 namespace mozilla {
 
 Maybe<int> LauncherMain(int& argc, wchar_t* argv[],
                         const StaticXREAppData& aAppData) {
   SetLauncherErrorAppData(aAppData);
 
+  if (CheckArg(argc, argv, L"log-launcher-error",
+               static_cast<const wchar_t**>(nullptr),
+               mozilla::CheckArgFlag::RemoveArg) == ARG_FOUND) {
+    SetLauncherErrorForceEventLog();
+  }
+
   Maybe<bool> runAsLauncher = RunAsLauncherProcess(argc, argv);
   if (!runAsLauncher || !runAsLauncher.value()) {
     return Nothing();
   }
 
   // Make sure that the launcher process itself has image load policies set
   if (IsWin10AnniversaryUpdateOrLater()) {
     const DynamicallyLinkedFunctionPtr<decltype(&SetProcessMitigationPolicy)>