Bug 1500215 - PID suffix ION_SPEW_FILENAME for logs in multiprocess context r=sfink
authorMatthew Gaudet <mgaudet@mozilla.com>
Wed, 24 Oct 2018 14:31:55 +0000
changeset 491158 1a0b7f5e0282052c0bd67a98143cdcd2c4cb39fa
parent 491157 486615f18dd75bebea50fbbb1154b67d8b915426
child 491159 481aad44be651f02ef3c7596802011ccd40631c1
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerssfink
bugs1500215
milestone65.0a1
Bug 1500215 - PID suffix ION_SPEW_FILENAME for logs in multiprocess context r=sfink Differential Revision: https://phabricator.services.mozilla.com/D9133
js/src/jit/JitSpewer.cpp
--- a/js/src/jit/JitSpewer.cpp
+++ b/js/src/jit/JitSpewer.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifdef JS_JITSPEW
 
 #include "jit/JitSpewer.h"
 
 #include "mozilla/Atomics.h"
+#include "mozilla/Sprintf.h"
 
 #ifdef XP_WIN
 #include <process.h>
 #define getpid _getpid
 #else
 #include <unistd.h>
 #endif
 #include "jit/Ion.h"
@@ -619,17 +620,19 @@ jit::CheckLogging()
         EnableChannel(JitSpew_BaselineOSR);
         EnableChannel(JitSpew_BaselineBailouts);
         EnableChannel(JitSpew_BaselineDebugModeOSR);
     }
 
     FILE* spewfh = stderr;
     const char* filename = getenv("ION_SPEW_FILENAME");
     if (filename && *filename) {
-        spewfh = fopen(filename, "w");
+        char actual_filename[2048] = {0};
+        SprintfLiteral(actual_filename, "%s.%d", filename, getpid());
+        spewfh = fopen(actual_filename, "w");
         MOZ_RELEASE_ASSERT(spewfh);
         setbuf(spewfh, nullptr); // Make unbuffered
     }
     JitSpewPrinter().init(spewfh);
 }
 
 JitSpewIndent::JitSpewIndent(JitSpewChannel channel)
   : channel_(channel)