Commit 1fc8ad94 authored by vegorov@chromium.org's avatar vegorov@chromium.org

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=
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/177413006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19688 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 285f253a
...@@ -662,15 +662,15 @@ static bool HasConsole() { ...@@ -662,15 +662,15 @@ static bool HasConsole() {
static void VPrintHelper(FILE* stream, const char* format, va_list args) { static void VPrintHelper(FILE* stream, const char* format, va_list args) {
if (HasConsole()) { if ((stream == stdout || stream == stderr) && !HasConsole()) {
vfprintf(stream, format, args);
} else {
// It is important to use safe print here in order to avoid // It is important to use safe print here in order to avoid
// overflowing the buffer. We might truncate the output, but this // overflowing the buffer. We might truncate the output, but this
// does not crash. // does not crash.
EmbeddedVector<char, 4096> buffer; EmbeddedVector<char, 4096> buffer;
OS::VSNPrintF(buffer, format, args); OS::VSNPrintF(buffer, format, args);
OutputDebugStringA(buffer.start()); OutputDebugStringA(buffer.start());
} else {
vfprintf(stream, format, args);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment