Backed out changeset d7d447cac91b (bug 969762) for tp5 regression.

This commit is contained in:
Masatoshi Kimura 2014-02-12 06:01:29 +09:00
parent 3674e63b9e
commit 0a3d8da618
8 changed files with 124 additions and 101 deletions

View File

@ -29,7 +29,6 @@
#include "nsIDOMClassInfo.h"
#include "nsIDOMFile.h"
#include "xpcpublic.h"
#include "mozilla/Debug.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/StructuredCloneUtils.h"
#include "JavaScriptChild.h"
@ -38,6 +37,9 @@
#include "nsPrintfCString.h"
#include <algorithm>
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef XP_WIN
#include <windows.h>
# if defined(SendMessage)
@ -721,7 +723,16 @@ nsFrameMessageManager::GetChildAt(uint32_t aIndex,
NS_IMETHODIMP
nsFrameMessageManager::Dump(const nsAString& aStr)
{
PrintToDebugger(aStr, stdout);
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", NS_ConvertUTF16toUTF8(aStr).get());
#endif
#ifdef XP_WIN
if (IsDebuggerPresent()) {
OutputDebugStringW(PromiseFlatString(aStr).get());
}
#endif
fputs(NS_ConvertUTF16toUTF8(aStr).get(), stdout);
fflush(stdout);
return NS_OK;
}

View File

@ -232,6 +232,10 @@ class nsIScriptTimeoutHandler;
#endif // check
#include "AccessCheck.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef PR_LOGGING
static PRLogModuleInfo* gDOMLeakPRLog;
#endif
@ -5809,7 +5813,31 @@ nsGlobalWindow::Dump(const nsAString& aStr)
return NS_OK;
}
PrintToDebugger(aStr, gDumpFile ? gDumpFile : stdout);
char *cstr = ToNewUTF8String(aStr);
#if defined(XP_MACOSX)
// have to convert \r to \n so that printing to the console works
char *c = cstr, *cEnd = cstr + strlen(cstr);
while (c < cEnd) {
if (*c == '\r')
*c = '\n';
c++;
}
#endif
if (cstr) {
#ifdef XP_WIN
PrintToDebugger(cstr);
#endif
#ifdef ANDROID
__android_log_write(ANDROID_LOG_INFO, "GeckoDump", cstr);
#endif
FILE *fp = gDumpFile ? gDumpFile : stdout;
fputs(cstr, fp);
fflush(fp);
nsMemory::Free(cstr);
}
return NS_OK;
}

View File

@ -7,11 +7,14 @@
#include "WorkerScope.h"
#include "jsapi.h"
#include "mozilla/Debug.h"
#include "mozilla/dom/FunctionBinding.h"
#include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h"
#include "mozilla/dom/SharedWorkerGlobalScopeBinding.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#include "Console.h"
#include "Location.h"
#include "Navigator.h"
@ -258,8 +261,13 @@ WorkerGlobalScope::Dump(const Optional<nsAString>& aString) const
return;
}
PrintToDebugger(aString.Value(), stdout, kPrintToStream
| kPrintInfoLog);
NS_ConvertUTF16toUTF8 str(aString.Value());
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", str.get());
#endif
fputs(str.get(), stdout);
fflush(stdout);
}
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate)

View File

@ -13,12 +13,17 @@
#include <cstdarg>
#include "prlog.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef XP_WIN
#include <windows.h>
#endif
#include "jsapi.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsIComponentManager.h"
#include "mozilla/Debug.h"
#include "mozilla/Module.h"
#include "nsIFile.h"
#include "mozJSComponentLoader.h"
@ -113,9 +118,18 @@ Dump(JSContext *cx, unsigned argc, Value *vp)
if (!chars)
return false;
nsDependentSubstring ustr(reinterpret_cast<const char16_t*>(chars),
length);
PrintToDebugger(ustr, stdout);
NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast<const char16_t*>(chars),
length);
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get());
#endif
#ifdef XP_WIN
if (IsDebuggerPresent()) {
OutputDebugStringW(reinterpret_cast<const wchar_t*>(chars));
}
#endif
fputs(utf8str.get(), stdout);
fflush(stdout);
return true;
}

View File

@ -8,7 +8,6 @@
#include "jsfriendapi.h"
#include "jsprf.h"
#include "js/OldDebugAPI.h"
#include "mozilla/Debug.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsIXPConnect.h"
@ -33,6 +32,10 @@
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef XP_WIN
#include <windows.h>
#endif
@ -297,9 +300,18 @@ Dump(JSContext *cx, unsigned argc, jsval *vp)
if (!chars)
return false;
nsDependentSubstring ustr(reinterpret_cast<const char16_t*>(chars),
length);
PrintToDebugger(ustr, gOutFile);
NS_ConvertUTF16toUTF8 utf8str(reinterpret_cast<const char16_t*>(chars),
length);
#ifdef ANDROID
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", utf8str.get());
#endif
#ifdef XP_WIN
if (IsDebuggerPresent()) {
OutputDebugStringW(reinterpret_cast<const wchar_t*>(chars));
}
#endif
fputs(utf8str.get(), gOutFile);
fflush(gOutFile);
return true;
}

View File

@ -6,61 +6,16 @@
#include "mozilla/Debug.h"
#ifdef XP_WIN
#include <io.h>
#include <windows.h>
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
void mozilla::PrintToDebugger(const nsAString& aStr, FILE* aStream,
LogOptions aOptions)
{
nsString msg(aStr);
if (aOptions & kPrintNewLine) {
msg.AppendLiteral("\n");
}
#ifdef XP_WIN
if ((aOptions & kPrintToDebugger) && ::IsDebuggerPresent()) {
::OutputDebugStringW(msg.get());
}
if (!(aOptions & kPrintToStream)) {
return;
void mozilla::PrintToDebugger(const char* aStr)
{
if (::IsDebuggerPresent()) {
::OutputDebugStringA(aStr);
}
int fd = _fileno(aStream);
if (_isatty(fd)) {
fflush(aStream);
DWORD writtenCount;
WriteConsoleW(reinterpret_cast<HANDLE>(_get_osfhandle(fd)),
msg.BeginReading(), msg.Length(),
&writtenCount, nullptr);
return;
}
#endif
NS_ConvertUTF16toUTF8 cstr(msg);
#ifdef ANDROID
if (aOptions & (kPrintInfoLog | kPrintErrorLog)) {
__android_log_write(aOptions & kPrintErrorLog ? ANDROID_LOG_ERROR
: ANDROID_LOG_INFO,
"GeckoDump", cstr.get());
}
#endif
#ifndef XP_WIN
if (!(aOptions & kPrintToStream)) {
return;
}
#endif
#if defined(XP_MACOSX)
// have to convert \r to \n so that printing to the console works
cstr.ReplaceChar('\r', '\n');
#endif
fputs(cstr.get(), aStream);
fflush(aStream);
}
#endif

View File

@ -3,40 +3,18 @@
* 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/. */
#ifndef mozilla_Debug_h
#define mozilla_Debug_h
#include "nsString.h"
#include <stdio.h>
#ifndef mozilla_Debug_h__
#define mozilla_Debug_h__
namespace mozilla {
typedef uint32_t LogOptions;
// Print a message to the specified stream.
const LogOptions kPrintToStream = 1 << 0;
// Print a message to a debugger if the debugger is attached.
// At the moment, only meaningful on Windows.
const LogOptions kPrintToDebugger = 1 << 1;
// Print an info-level message to the log.
// At the moment, only meaningful on Andriod.
const LogOptions kPrintInfoLog = 1 << 2;
// Print an error-level message to the log.
// At the moment, only meaningful on Andriod.
const LogOptions kPrintErrorLog = 1 << 3;
// Print a new line after the message.
const LogOptions kPrintNewLine = 1 << 4;
#ifdef XP_WIN
// Print aStr to a debugger if the debugger is attached.
void PrintToDebugger(const nsAString& aStr, FILE* aStream,
LogOptions aOptions = kPrintToStream
| kPrintToDebugger
| kPrintInfoLog);
void PrintToDebugger(const char* aStr);
#endif
} // namespace mozilla
#endif // mozilla_Debug_h
#endif // mozilla_Debug_h__

View File

@ -20,9 +20,15 @@
#include "nsIConsoleListener.h"
#include "nsPrintfCString.h"
#include "mozilla/Debug.h"
#include "mozilla/Preferences.h"
#if defined(ANDROID)
#include <android/log.h>
#endif
#ifdef XP_WIN
#include <windows.h>
#endif
using namespace mozilla;
NS_IMPL_ADDREF(nsConsoleService)
@ -185,13 +191,24 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
{
MutexAutoLock lock(mLock);
nsString msg;
message->GetMessageMoz(getter_Copies(msg));
LogOptions options = kPrintToDebugger | kPrintNewLine;
if (outputMode == OutputToLog) {
options |= kPrintErrorLog;
#if defined(ANDROID)
if (outputMode == OutputToLog)
{
nsXPIDLString msg;
message->GetMessageMoz(getter_Copies(msg));
__android_log_print(ANDROID_LOG_ERROR, "GeckoConsole",
"%s",
NS_LossyConvertUTF16toASCII(msg).get());
}
PrintToDebugger(msg, nullptr, options);
#endif
#ifdef XP_WIN
if (IsDebuggerPresent()) {
nsString msg;
message->GetMessageMoz(getter_Copies(msg));
msg.AppendLiteral("\n");
OutputDebugStringW(msg.get());
}
#endif
/*
* If there's already a message in the slot we're about to replace,