Reviewers: Yang,

Message:
Please take a look.

This fixes --redirect-code-traces on Windows when used from inside the Chrome.
Without this fix output is silently dropped to the floor unless console is
attached to it (e.g. by patching its PE header).

Description:
Fix VPrintHelper used on Windows.

VPrintHelper would silently ignore the stream given to it if application is in
GUI mode (no console is attached) and redirect output to the debugger via
OutputDebugString.

Such redirection makes sense only if passed stream is either stderr or stdout.
Don't redirect any other stream to the debugger.

Reorder clauses in VPrintHelper to make condition more readable.

BUG=

Please review this at https://codereview.chromium.org/177413006/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+3, -3 lines):
  M src/platform-win32.cc


Index: src/platform-win32.cc
diff --git a/src/platform-win32.cc b/src/platform-win32.cc
index 56261735b871ee2166498f877ced615baf4efa7f..930795602a9ac7e313598754dbf2f8061f7e0e41 100644
--- a/src/platform-win32.cc
+++ b/src/platform-win32.cc
@@ -662,15 +662,15 @@ static bool HasConsole() {


 static void VPrintHelper(FILE* stream, const char* format, va_list args) {
-  if (HasConsole()) {
-    vfprintf(stream, format, args);
-  } else {
+  if ((stream == stdout || stream == stderr) && !HasConsole()) {
     // It is important to use safe print here in order to avoid
     // overflowing the buffer. We might truncate the output, but this
     // does not crash.
     EmbeddedVector<char, 4096> buffer;
     OS::VSNPrintF(buffer, format, args);
     OutputDebugStringA(buffer.start());
+  } else {
+    vfprintf(stream, format, args);
   }
 }



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to