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
This commit is contained in:
vegorov@chromium.org 2014-03-06 11:55:47 +00:00
parent 285f253af1
commit 1fc8ad9486

View File

@ -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);
}
}