Bug 1060419 - make XPC_Log_print use VsprintfLiteral, r?froydnj
MozReview-Commit-ID: 9ruECevHqfs
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -3653,66 +3653,66 @@ XPCJSContext::AfterProcessTask(uint32_t
/***************************************************************************/
void
XPCJSContext::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth--;
- XPC_LOG_ALWAYS(("XPCJSContext @ %x", this));
+ XPC_LOG_ALWAYS(("XPCJSContext @ %p", this));
XPC_LOG_INDENT();
- XPC_LOG_ALWAYS(("mJSContext @ %x", Context()));
-
- XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %x with %d wrapperclasses(s)",
+ XPC_LOG_ALWAYS(("mJSContext @ %p", Context()));
+
+ XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %p with %d wrapperclasses(s)",
mWrappedJSClassMap, mWrappedJSClassMap->Count()));
// iterate wrappersclasses...
if (depth && mWrappedJSClassMap->Count()) {
XPC_LOG_INDENT();
for (auto i = mWrappedJSClassMap->Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<IID2WrappedJSClassMap::Entry*>(i.Get());
entry->value->DebugDump(depth);
}
XPC_LOG_OUTDENT();
}
// iterate wrappers...
- XPC_LOG_ALWAYS(("mWrappedJSMap @ %x with %d wrappers(s)",
+ XPC_LOG_ALWAYS(("mWrappedJSMap @ %p with %d wrappers(s)",
mWrappedJSMap, mWrappedJSMap->Count()));
if (depth && mWrappedJSMap->Count()) {
XPC_LOG_INDENT();
mWrappedJSMap->Dump(depth);
XPC_LOG_OUTDENT();
}
- XPC_LOG_ALWAYS(("mIID2NativeInterfaceMap @ %x with %d interface(s)",
+ XPC_LOG_ALWAYS(("mIID2NativeInterfaceMap @ %p with %d interface(s)",
mIID2NativeInterfaceMap,
mIID2NativeInterfaceMap->Count()));
- XPC_LOG_ALWAYS(("mClassInfo2NativeSetMap @ %x with %d sets(s)",
+ XPC_LOG_ALWAYS(("mClassInfo2NativeSetMap @ %p with %d sets(s)",
mClassInfo2NativeSetMap,
mClassInfo2NativeSetMap->Count()));
- XPC_LOG_ALWAYS(("mThisTranslatorMap @ %x with %d translator(s)",
+ XPC_LOG_ALWAYS(("mThisTranslatorMap @ %p with %d translator(s)",
mThisTranslatorMap, mThisTranslatorMap->Count()));
- XPC_LOG_ALWAYS(("mNativeSetMap @ %x with %d sets(s)",
+ XPC_LOG_ALWAYS(("mNativeSetMap @ %p with %d sets(s)",
mNativeSetMap, mNativeSetMap->Count()));
// iterate sets...
if (depth && mNativeSetMap->Count()) {
XPC_LOG_INDENT();
for (auto i = mNativeSetMap->Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<NativeSetMap::Entry*>(i.Get());
entry->key_value->DebugDump(depth);
}
XPC_LOG_OUTDENT();
}
- XPC_LOG_ALWAYS(("mPendingResult of %x", mPendingResult));
+ XPC_LOG_ALWAYS(("mPendingResult of %" PRIx32, static_cast<uint32_t>(mPendingResult)));
XPC_LOG_OUTDENT();
#endif
}
/***************************************************************************/
void
--- a/js/xpconnect/src/XPCLog.cpp
+++ b/js/xpconnect/src/XPCLog.cpp
@@ -3,17 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
/* Debug Logging support. */
#include "XPCLog.h"
#include "mozilla/Logging.h"
-#include "prprf.h"
+#include "mozilla/Sprintf.h"
#include "mozilla/mozalloc.h"
#include <string.h>
#include <stdarg.h>
// this all only works for DEBUG...
#ifdef DEBUG
#define SPACE_COUNT 200
@@ -52,17 +52,17 @@ XPC_Log_Finish()
void
XPC_Log_print(const char* fmt, ...)
{
va_list ap;
char line[LINE_LEN];
va_start(ap, fmt);
- PR_vsnprintf(line, sizeof(line)-1, fmt, ap);
+ VsprintfLiteral(line, fmt, ap);
va_end(ap);
if (g_Indent)
PR_LogPrint("%s%s",g_Spaces+SPACE_COUNT-(INDENT_FACTOR*g_Indent),line);
else
PR_LogPrint("%s",line);
}
bool
--- a/js/xpconnect/src/XPCLog.h
+++ b/js/xpconnect/src/XPCLog.h
@@ -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/. */
/* Debug Logging support. */
#ifndef xpclog_h___
#define xpclog_h___
+#include "mozilla/Attributes.h"
#include "mozilla/Logging.h"
/*
* This uses mozilla/Logging.h. The module name used here is 'xpclog'.
* These environment settings should work...
*
* SET MOZ_LOG=xpclog:5
* SET MOZ_LOG_FILE=logfile.txt
@@ -34,17 +35,17 @@
#define XPC_LOG_FLUSH() PR_LogFlush()
#define XPC_LOG_INDENT() XPC_Log_Indent()
#define XPC_LOG_OUTDENT() XPC_Log_Outdent()
#define XPC_LOG_CLEAR_INDENT() XPC_Log_Clear_Indent()
#define XPC_LOG_FINISH() XPC_Log_Finish()
extern "C" {
-void XPC_Log_print(const char* fmt, ...);
+void XPC_Log_print(const char* fmt, ...) MOZ_FORMAT_PRINTF(1, 2);
bool XPC_Log_Check(int i);
void XPC_Log_Indent();
void XPC_Log_Outdent();
void XPC_Log_Clear_Indent();
void XPC_Log_Finish();
} // extern "C"
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -692,31 +692,31 @@ nsXPCWrappedJS::GetProperty(const nsAStr
}
/***************************************************************************/
NS_IMETHODIMP
nsXPCWrappedJS::DebugDump(int16_t depth)
{
#ifdef DEBUG
- XPC_LOG_ALWAYS(("nsXPCWrappedJS @ %x with mRefCnt = %d", this, mRefCnt.get()));
+ XPC_LOG_ALWAYS(("nsXPCWrappedJS @ %p with mRefCnt = %" PRIuPTR, this, mRefCnt.get()));
XPC_LOG_INDENT();
- XPC_LOG_ALWAYS(("%s wrapper around JSObject @ %x", \
+ XPC_LOG_ALWAYS(("%s wrapper around JSObject @ %p", \
IsRootWrapper() ? "ROOT":"non-root", mJSObj.get()));
char* name;
GetClass()->GetInterfaceInfo()->GetName(&name);
XPC_LOG_ALWAYS(("interface name is %s", name));
if (name)
free(name);
char * iid = GetClass()->GetIID().ToString();
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
if (iid)
free(iid);
- XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x", mClass.get()));
+ XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %p", mClass.get()));
if (!IsRootWrapper())
XPC_LOG_OUTDENT();
if (mNext) {
if (IsRootWrapper()) {
XPC_LOG_ALWAYS(("Additional wrappers for this object..."));
XPC_LOG_INDENT();
}
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1409,43 +1409,43 @@ xpc::NewOutObject(JSContext* cx)
}
NS_IMETHODIMP
nsXPCWrappedJSClass::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth-- ;
- XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x with mRefCnt = %d", this, mRefCnt.get()));
+ XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %p with mRefCnt = %" PRIuPTR, this, mRefCnt.get()));
XPC_LOG_INDENT();
char* name;
mInfo->GetName(&name);
XPC_LOG_ALWAYS(("interface name is %s", name));
if (name)
free(name);
char * iid = mIID.ToString();
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
if (iid)
free(iid);
- XPC_LOG_ALWAYS(("InterfaceInfo @ %x", mInfo.get()));
+ XPC_LOG_ALWAYS(("InterfaceInfo @ %p", mInfo.get()));
uint16_t methodCount = 0;
if (depth) {
uint16_t i;
nsCOMPtr<nsIInterfaceInfo> parent;
XPC_LOG_INDENT();
mInfo->GetParent(getter_AddRefs(parent));
- XPC_LOG_ALWAYS(("parent @ %x", parent.get()));
+ XPC_LOG_ALWAYS(("parent @ %p", parent.get()));
mInfo->GetMethodCount(&methodCount);
XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
mInfo->GetConstantCount(&i);
XPC_LOG_ALWAYS(("ConstantCount = %d", i));
XPC_LOG_OUTDENT();
}
- XPC_LOG_ALWAYS(("mContext @ %x", mContext));
- XPC_LOG_ALWAYS(("mDescriptors @ %x count = %d", mDescriptors, methodCount));
+ XPC_LOG_ALWAYS(("mContext @ %p", mContext));
+ XPC_LOG_ALWAYS(("mDescriptors @ %p count = %d", mDescriptors, methodCount));
if (depth && mDescriptors && methodCount) {
depth--;
XPC_LOG_INDENT();
for (uint16_t i = 0; i < methodCount; i++) {
XPC_LOG_ALWAYS(("Method %d is %s%s", \
i, IsReflectable(i) ? "":" NOT ","reflectable"));
}
XPC_LOG_OUTDENT();
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -2089,41 +2089,41 @@ XPCWrappedNative::HasNativeMember(Handle
uint16_t ignored;
return GetSet()->FindMember(name, &member, &ignored) && !!member;
}
NS_IMETHODIMP XPCWrappedNative::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth-- ;
- XPC_LOG_ALWAYS(("XPCWrappedNative @ %x with mRefCnt = %d", this, mRefCnt.get()));
+ XPC_LOG_ALWAYS(("XPCWrappedNative @ %p with mRefCnt = %" PRIuPTR, this, mRefCnt.get()));
XPC_LOG_INDENT();
if (HasProto()) {
XPCWrappedNativeProto* proto = GetProto();
if (depth && proto)
proto->DebugDump(depth);
else
- XPC_LOG_ALWAYS(("mMaybeProto @ %x", proto));
+ XPC_LOG_ALWAYS(("mMaybeProto @ %p", proto));
} else
- XPC_LOG_ALWAYS(("Scope @ %x", GetScope()));
+ XPC_LOG_ALWAYS(("Scope @ %p", GetScope()));
if (depth && mSet)
mSet->DebugDump(depth);
else
- XPC_LOG_ALWAYS(("mSet @ %x", mSet.get()));
+ XPC_LOG_ALWAYS(("mSet @ %p", mSet.get()));
- XPC_LOG_ALWAYS(("mFlatJSObject of %x", mFlatJSObject.unbarrieredGetPtr()));
- XPC_LOG_ALWAYS(("mIdentity of %x", mIdentity.get()));
- XPC_LOG_ALWAYS(("mScriptable @ %x", mScriptable.get()));
+ XPC_LOG_ALWAYS(("mFlatJSObject of %p", mFlatJSObject.unbarrieredGetPtr()));
+ XPC_LOG_ALWAYS(("mIdentity of %p", mIdentity.get()));
+ XPC_LOG_ALWAYS(("mScriptable @ %p", mScriptable.get()));
if (depth && mScriptable) {
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("mFlags of %x", mScriptable->GetScriptableFlags()));
- XPC_LOG_ALWAYS(("mJSClass @ %x", mScriptable->GetJSClass()));
+ XPC_LOG_ALWAYS(("mJSClass @ %p", mScriptable->GetJSClass()));
XPC_LOG_OUTDENT();
}
XPC_LOG_OUTDENT();
#endif
return NS_OK;
}
/***************************************************************************/
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -409,21 +409,21 @@ XPCNativeInterface::SizeOfIncludingThis(
return mallocSizeOf(this);
}
void
XPCNativeInterface::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth--;
- XPC_LOG_ALWAYS(("XPCNativeInterface @ %x", this));
+ XPC_LOG_ALWAYS(("XPCNativeInterface @ %p", this));
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("name is %s", GetNameString()));
XPC_LOG_ALWAYS(("mMemberCount is %d", mMemberCount));
- XPC_LOG_ALWAYS(("mInfo @ %x", mInfo.get()));
+ XPC_LOG_ALWAYS(("mInfo @ %p", mInfo.get()));
XPC_LOG_OUTDENT();
#endif
}
/***************************************************************************/
// XPCNativeSetKey
static PLDHashNumber
@@ -782,17 +782,17 @@ XPCNativeSet::SizeOfIncludingThis(Malloc
return mallocSizeOf(this);
}
void
XPCNativeSet::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth--;
- XPC_LOG_ALWAYS(("XPCNativeSet @ %x", this));
+ XPC_LOG_ALWAYS(("XPCNativeSet @ %p", this));
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("mInterfaceCount of %d", mInterfaceCount));
if (depth) {
for (uint16_t i = 0; i < mInterfaceCount; i++)
mInterfaces[i]->DebugDump(depth);
}
XPC_LOG_ALWAYS(("mMemberCount of %d", mMemberCount));
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -168,26 +168,26 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCW
return proto;
}
void
XPCWrappedNativeProto::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth-- ;
- XPC_LOG_ALWAYS(("XPCWrappedNativeProto @ %x", this));
+ XPC_LOG_ALWAYS(("XPCWrappedNativeProto @ %p", this));
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("gDEBUG_LiveProtoCount is %d", gDEBUG_LiveProtoCount));
- XPC_LOG_ALWAYS(("mScope @ %x", mScope));
- XPC_LOG_ALWAYS(("mJSProtoObject @ %x", mJSProtoObject.get()));
- XPC_LOG_ALWAYS(("mSet @ %x", mSet.get()));
- XPC_LOG_ALWAYS(("mScriptable @ %x", mScriptable.get()));
+ XPC_LOG_ALWAYS(("mScope @ %p", mScope));
+ XPC_LOG_ALWAYS(("mJSProtoObject @ %p", mJSProtoObject.get()));
+ XPC_LOG_ALWAYS(("mSet @ %p", mSet.get()));
+ XPC_LOG_ALWAYS(("mScriptable @ %p", mScriptable.get()));
if (depth && mScriptable) {
XPC_LOG_INDENT();
XPC_LOG_ALWAYS(("mFlags of %x", mScriptable->GetScriptableFlags()));
- XPC_LOG_ALWAYS(("mJSClass @ %x", mScriptable->GetJSClass()));
+ XPC_LOG_ALWAYS(("mJSClass @ %p", mScriptable->GetJSClass()));
XPC_LOG_OUTDENT();
}
XPC_LOG_OUTDENT();
#endif
}
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -854,48 +854,48 @@ XPCWrappedNativeScope::DebugDumpAllScope
// get scope count.
int count = 0;
XPCWrappedNativeScope* cur;
for (cur = gScopes; cur; cur = cur->mNext)
count++ ;
XPC_LOG_ALWAYS(("chain of %d XPCWrappedNativeScope(s)", count));
XPC_LOG_INDENT();
- XPC_LOG_ALWAYS(("gDyingScopes @ %x", gDyingScopes));
+ XPC_LOG_ALWAYS(("gDyingScopes @ %p", gDyingScopes));
if (depth)
for (cur = gScopes; cur; cur = cur->mNext)
cur->DebugDump(depth);
XPC_LOG_OUTDENT();
#endif
}
void
XPCWrappedNativeScope::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth-- ;
- XPC_LOG_ALWAYS(("XPCWrappedNativeScope @ %x", this));
+ XPC_LOG_ALWAYS(("XPCWrappedNativeScope @ %p", this));
XPC_LOG_INDENT();
- XPC_LOG_ALWAYS(("mNext @ %x", mNext));
- XPC_LOG_ALWAYS(("mComponents @ %x", mComponents.get()));
- XPC_LOG_ALWAYS(("mGlobalJSObject @ %x", mGlobalJSObject.get()));
+ XPC_LOG_ALWAYS(("mNext @ %p", mNext));
+ XPC_LOG_ALWAYS(("mComponents @ %p", mComponents.get()));
+ XPC_LOG_ALWAYS(("mGlobalJSObject @ %p", mGlobalJSObject.get()));
- XPC_LOG_ALWAYS(("mWrappedNativeMap @ %x with %d wrappers(s)",
+ XPC_LOG_ALWAYS(("mWrappedNativeMap @ %p with %d wrappers(s)",
mWrappedNativeMap, mWrappedNativeMap->Count()));
// iterate contexts...
if (depth && mWrappedNativeMap->Count()) {
XPC_LOG_INDENT();
for (auto i = mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
entry->value->DebugDump(depth);
}
XPC_LOG_OUTDENT();
}
- XPC_LOG_ALWAYS(("mWrappedNativeProtoMap @ %x with %d protos(s)",
+ XPC_LOG_ALWAYS(("mWrappedNativeProtoMap @ %p with %d protos(s)",
mWrappedNativeProtoMap,
mWrappedNativeProtoMap->Count()));
// iterate contexts...
if (depth && mWrappedNativeProtoMap->Count()) {
XPC_LOG_INDENT();
for (auto i = mWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get());
entry->value->DebugDump(depth);
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -927,25 +927,25 @@ nsXPConnect::GetWrappedNativePrototype(J
return NS_OK;
}
NS_IMETHODIMP
nsXPConnect::DebugDump(int16_t depth)
{
#ifdef DEBUG
depth-- ;
- XPC_LOG_ALWAYS(("nsXPConnect @ %x with mRefCnt = %d", this, mRefCnt.get()));
+ XPC_LOG_ALWAYS(("nsXPConnect @ %p with mRefCnt = %" PRIuPTR, this, mRefCnt.get()));
XPC_LOG_INDENT();
- XPC_LOG_ALWAYS(("gSelf @ %x", gSelf));
+ XPC_LOG_ALWAYS(("gSelf @ %p", gSelf));
XPC_LOG_ALWAYS(("gOnceAliveNowDead is %d", (int)gOnceAliveNowDead));
if (mContext) {
if (depth)
mContext->DebugDump(depth);
else
- XPC_LOG_ALWAYS(("XPCJSContext @ %x", mContext));
+ XPC_LOG_ALWAYS(("XPCJSContext @ %p", mContext));
} else
XPC_LOG_ALWAYS(("mContext is null"));
XPCWrappedNativeScope::DebugDumpAllScopes(depth);
XPC_LOG_OUTDENT();
#endif
return NS_OK;
}
@@ -977,17 +977,17 @@ nsXPConnect::DebugDumpObject(nsISupports
getter_AddRefs(wn)))) {
XPC_LOG_ALWAYS(("Dumping a nsIXPConnectWrappedNative..."));
wn->DebugDump(depth);
} else if (NS_SUCCEEDED(p->QueryInterface(NS_GET_IID(nsIXPConnectWrappedJS),
getter_AddRefs(wjs)))) {
XPC_LOG_ALWAYS(("Dumping a nsIXPConnectWrappedJS..."));
wjs->DebugDump(depth);
} else {
- XPC_LOG_ALWAYS(("*** Could not dump the nsISupports @ %x", p));
+ XPC_LOG_ALWAYS(("*** Could not dump the nsISupports @ %p", p));
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsXPConnect::DebugDumpJSStack(bool showArgs,
bool showLocals,