mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Bug 995730 - Fix style violations in xpcom/base/. r=froydnj,continuation
This commit is contained in:
parent
a772659b8d
commit
fb371cca99
@ -84,13 +84,15 @@ namespace {
|
||||
|
||||
#endif
|
||||
|
||||
void safe_write(const char *a)
|
||||
void
|
||||
safe_write(const char* aStr)
|
||||
{
|
||||
// Well, puts isn't exactly "safe", but at least it doesn't call malloc...
|
||||
fputs(a, stdout);
|
||||
fputs(aStr, stdout);
|
||||
}
|
||||
|
||||
void safe_write(uint64_t x)
|
||||
void
|
||||
safe_write(uint64_t aNum)
|
||||
{
|
||||
// 2^64 is 20 decimal digits.
|
||||
const unsigned int max_len = 21;
|
||||
@ -98,10 +100,9 @@ void safe_write(uint64_t x)
|
||||
buf[max_len - 1] = '\0';
|
||||
|
||||
uint32_t i;
|
||||
for (i = max_len - 2; i < max_len && x > 0; i--)
|
||||
{
|
||||
buf[i] = "0123456789"[x % 10];
|
||||
x /= 10;
|
||||
for (i = max_len - 2; i < max_len && aNum > 0; i--) {
|
||||
buf[i] = "0123456789"[aNum % 10];
|
||||
aNum /= 10;
|
||||
}
|
||||
|
||||
safe_write(&buf[i + 1]);
|
||||
@ -148,24 +149,25 @@ volatile PRIntervalTime sLastLowMemoryNotificationTime;
|
||||
|
||||
// These are function pointers to the functions we wrap in Init().
|
||||
|
||||
void* (WINAPI *sVirtualAllocOrig)
|
||||
void* (WINAPI* sVirtualAllocOrig)
|
||||
(LPVOID aAddress, SIZE_T aSize, DWORD aAllocationType, DWORD aProtect);
|
||||
|
||||
void* (WINAPI *sMapViewOfFileOrig)
|
||||
void* (WINAPI* sMapViewOfFileOrig)
|
||||
(HANDLE aFileMappingObject, DWORD aDesiredAccess,
|
||||
DWORD aFileOffsetHigh, DWORD aFileOffsetLow,
|
||||
SIZE_T aNumBytesToMap);
|
||||
|
||||
HBITMAP (WINAPI *sCreateDIBSectionOrig)
|
||||
(HDC aDC, const BITMAPINFO *aBitmapInfo,
|
||||
UINT aUsage, VOID **aBits,
|
||||
HBITMAP (WINAPI* sCreateDIBSectionOrig)
|
||||
(HDC aDC, const BITMAPINFO* aBitmapInfo,
|
||||
UINT aUsage, VOID** aBits,
|
||||
HANDLE aSection, DWORD aOffset);
|
||||
|
||||
/**
|
||||
* Fire a memory pressure event if it's been long enough since the last one we
|
||||
* fired.
|
||||
*/
|
||||
bool MaybeScheduleMemoryPressureEvent()
|
||||
bool
|
||||
MaybeScheduleMemoryPressureEvent()
|
||||
{
|
||||
// If this interval rolls over, we may fire an extra memory pressure
|
||||
// event, but that's not a big deal.
|
||||
@ -192,7 +194,8 @@ bool MaybeScheduleMemoryPressureEvent()
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckMemAvailable()
|
||||
void
|
||||
CheckMemAvailable()
|
||||
{
|
||||
if (!sHooksActive) {
|
||||
return;
|
||||
@ -204,8 +207,7 @@ void CheckMemAvailable()
|
||||
|
||||
DEBUG_WARN_IF_FALSE(success, "GlobalMemoryStatusEx failed.");
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (success) {
|
||||
// sLowVirtualMemoryThreshold is in MB, but ullAvailVirtual is in bytes.
|
||||
if (stat.ullAvailVirtual < sLowVirtualMemoryThreshold * 1024 * 1024) {
|
||||
// If we're running low on virtual memory, unconditionally schedule the
|
||||
@ -214,14 +216,12 @@ void CheckMemAvailable()
|
||||
LOG("Detected low virtual memory.");
|
||||
++sNumLowVirtualMemEvents;
|
||||
NS_DispatchEventualMemoryPressure(MemPressure_New);
|
||||
}
|
||||
else if (stat.ullAvailPageFile < sLowCommitSpaceThreshold * 1024 * 1024) {
|
||||
} else if (stat.ullAvailPageFile < sLowCommitSpaceThreshold * 1024 * 1024) {
|
||||
LOG("Detected low available page file space.");
|
||||
if (MaybeScheduleMemoryPressureEvent()) {
|
||||
++sNumLowCommitSpaceEvents;
|
||||
}
|
||||
}
|
||||
else if (stat.ullAvailPhys < sLowPhysicalMemoryThreshold * 1024 * 1024) {
|
||||
} else if (stat.ullAvailPhys < sLowPhysicalMemoryThreshold * 1024 * 1024) {
|
||||
LOG("Detected low physical memory.");
|
||||
if (MaybeScheduleMemoryPressureEvent()) {
|
||||
++sNumLowPhysicalMemEvents;
|
||||
@ -278,9 +278,9 @@ MapViewOfFileHook(HANDLE aFileMappingObject,
|
||||
|
||||
HBITMAP WINAPI
|
||||
CreateDIBSectionHook(HDC aDC,
|
||||
const BITMAPINFO *aBitmapInfo,
|
||||
const BITMAPINFO* aBitmapInfo,
|
||||
UINT aUsage,
|
||||
VOID **aBits,
|
||||
VOID** aBits,
|
||||
HANDLE aSection,
|
||||
DWORD aOffset)
|
||||
{
|
||||
@ -304,8 +304,9 @@ CreateDIBSectionHook(HDC aDC,
|
||||
// absolute value.
|
||||
int64_t size = bitCount * aBitmapInfo->bmiHeader.biWidth *
|
||||
aBitmapInfo->bmiHeader.biHeight;
|
||||
if (size < 0)
|
||||
if (size < 0) {
|
||||
size *= -1;
|
||||
}
|
||||
|
||||
// If we're allocating more than 1MB, check how much memory is left after
|
||||
// the allocation.
|
||||
@ -458,10 +459,10 @@ nsMemoryPressureWatcher::Init()
|
||||
* free dirty pages held by jemalloc.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsMemoryPressureWatcher::Observe(nsISupports *subject, const char *topic,
|
||||
const char16_t *data)
|
||||
nsMemoryPressureWatcher::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
MOZ_ASSERT(!strcmp(topic, "memory-pressure"), "Unknown topic");
|
||||
MOZ_ASSERT(!strcmp(aTopic, "memory-pressure"), "Unknown topic");
|
||||
|
||||
if (sFreeDirtyPages) {
|
||||
nsRefPtr<nsIRunnable> runnable = new nsJemallocFreeDirtyPagesRunnable();
|
||||
@ -477,7 +478,8 @@ nsMemoryPressureWatcher::Observe(nsISupports *subject, const char *topic,
|
||||
namespace mozilla {
|
||||
namespace AvailableMemoryTracker {
|
||||
|
||||
void Activate()
|
||||
void
|
||||
Activate()
|
||||
{
|
||||
#if defined(_M_IX86) && defined(XP_WIN)
|
||||
MOZ_ASSERT(sInitialized);
|
||||
@ -487,8 +489,7 @@ void Activate()
|
||||
// we're not going to run out of virtual memory!
|
||||
if (sizeof(void*) > 4) {
|
||||
sLowVirtualMemoryThreshold = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Preferences::AddUintVarCache(&sLowVirtualMemoryThreshold,
|
||||
"memory.low_virtual_mem_threshold_mb", 128);
|
||||
}
|
||||
@ -501,8 +502,10 @@ void Activate()
|
||||
"memory.low_memory_notification_interval_ms", 10000);
|
||||
|
||||
RegisterStrongMemoryReporter(new LowEventsReporter());
|
||||
RegisterLowMemoryEventsVirtualDistinguishedAmount(LowMemoryEventsVirtualDistinguishedAmount);
|
||||
RegisterLowMemoryEventsPhysicalDistinguishedAmount(LowMemoryEventsPhysicalDistinguishedAmount);
|
||||
RegisterLowMemoryEventsVirtualDistinguishedAmount(
|
||||
LowMemoryEventsVirtualDistinguishedAmount);
|
||||
RegisterLowMemoryEventsPhysicalDistinguishedAmount(
|
||||
LowMemoryEventsPhysicalDistinguishedAmount);
|
||||
sHooksActive = true;
|
||||
#endif
|
||||
|
||||
@ -511,7 +514,8 @@ void Activate()
|
||||
watcher->Init();
|
||||
}
|
||||
|
||||
void Init()
|
||||
void
|
||||
Init()
|
||||
{
|
||||
// Do nothing on x86-64, because nsWindowsDllInterceptor is not thread-safe
|
||||
// on 64-bit. (On 32-bit, it's probably thread-safe.) Even if we run Init()
|
||||
@ -531,15 +535,15 @@ void Init()
|
||||
sKernel32Intercept.Init("Kernel32.dll");
|
||||
sKernel32Intercept.AddHook("VirtualAlloc",
|
||||
reinterpret_cast<intptr_t>(VirtualAllocHook),
|
||||
(void**) &sVirtualAllocOrig);
|
||||
reinterpret_cast<void**>(&sVirtualAllocOrig));
|
||||
sKernel32Intercept.AddHook("MapViewOfFile",
|
||||
reinterpret_cast<intptr_t>(MapViewOfFileHook),
|
||||
(void**) &sMapViewOfFileOrig);
|
||||
reinterpret_cast<void**>(&sMapViewOfFileOrig));
|
||||
|
||||
sGdi32Intercept.Init("Gdi32.dll");
|
||||
sGdi32Intercept.AddHook("CreateDIBSection",
|
||||
reinterpret_cast<intptr_t>(CreateDIBSectionHook),
|
||||
(void**) &sCreateDIBSectionOrig);
|
||||
reinterpret_cast<void**>(&sCreateDIBSectionOrig));
|
||||
}
|
||||
|
||||
sInitialized = true;
|
||||
|
@ -11,7 +11,7 @@ namespace mozilla {
|
||||
namespace ClearOnShutdown_Internal {
|
||||
|
||||
bool sHasShutDown = false;
|
||||
StaticAutoPtr<LinkedList<ShutdownObserver> > sShutdownObservers;
|
||||
StaticAutoPtr<LinkedList<ShutdownObserver>> sShutdownObservers;
|
||||
|
||||
} // namespace ClearOnShutdown_Internal
|
||||
} // namespace mozilla
|
||||
|
@ -42,16 +42,19 @@ class ShutdownObserver : public LinkedListElement<ShutdownObserver>
|
||||
{
|
||||
public:
|
||||
virtual void Shutdown() = 0;
|
||||
virtual ~ShutdownObserver() {}
|
||||
virtual ~ShutdownObserver()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class SmartPtr>
|
||||
class PointerClearer : public ShutdownObserver
|
||||
{
|
||||
public:
|
||||
PointerClearer(SmartPtr *aPtr)
|
||||
PointerClearer(SmartPtr* aPtr)
|
||||
: mPtr(aPtr)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Shutdown()
|
||||
{
|
||||
@ -61,16 +64,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SmartPtr *mPtr;
|
||||
SmartPtr* mPtr;
|
||||
};
|
||||
|
||||
extern bool sHasShutDown;
|
||||
extern StaticAutoPtr<LinkedList<ShutdownObserver> > sShutdownObservers;
|
||||
extern StaticAutoPtr<LinkedList<ShutdownObserver>> sShutdownObservers;
|
||||
|
||||
} // namespace ClearOnShutdown_Internal
|
||||
|
||||
template<class SmartPtr>
|
||||
inline void ClearOnShutdown(SmartPtr *aPtr)
|
||||
inline void
|
||||
ClearOnShutdown(SmartPtr* aPtr)
|
||||
{
|
||||
using namespace ClearOnShutdown_Internal;
|
||||
|
||||
@ -85,15 +89,15 @@ inline void ClearOnShutdown(SmartPtr *aPtr)
|
||||
|
||||
// Called when XPCOM is shutting down, after all shutdown notifications have
|
||||
// been sent and after all threads' event loops have been purged.
|
||||
inline void KillClearOnShutdown()
|
||||
inline void
|
||||
KillClearOnShutdown()
|
||||
{
|
||||
using namespace ClearOnShutdown_Internal;
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (sShutdownObservers) {
|
||||
ShutdownObserver *observer;
|
||||
while ((observer = sShutdownObservers->popFirst())) {
|
||||
while (ShutdownObserver* observer = sShutdownObservers->popFirst()) {
|
||||
observer->Shutdown();
|
||||
delete observer;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace mozilla {
|
||||
struct DeferredFinalizeFunctionHolder
|
||||
{
|
||||
DeferredFinalizeFunction run;
|
||||
void *data;
|
||||
void* data;
|
||||
};
|
||||
|
||||
class IncrementalFinalizeRunnable : public nsRunnable
|
||||
@ -100,7 +100,7 @@ class IncrementalFinalizeRunnable : public nsRunnable
|
||||
|
||||
public:
|
||||
IncrementalFinalizeRunnable(CycleCollectedJSRuntime* aRt,
|
||||
nsTArray<nsISupports*>& mSupports,
|
||||
nsTArray<nsISupports*>& aMSupports,
|
||||
DeferredFinalizerTable& aFinalizerTable);
|
||||
virtual ~IncrementalFinalizeRunnable();
|
||||
|
||||
@ -112,18 +112,19 @@ public:
|
||||
} // namespace mozilla
|
||||
|
||||
inline bool
|
||||
AddToCCKind(JSGCTraceKind kind)
|
||||
AddToCCKind(JSGCTraceKind aKind)
|
||||
{
|
||||
return kind == JSTRACE_OBJECT || kind == JSTRACE_SCRIPT;
|
||||
return aKind == JSTRACE_OBJECT || aKind == JSTRACE_SCRIPT;
|
||||
}
|
||||
|
||||
static void
|
||||
TraceWeakMappingChild(JSTracer* trc, void** thingp, JSGCTraceKind kind);
|
||||
TraceWeakMappingChild(JSTracer* aTrc, void** aThingp, JSGCTraceKind aKind);
|
||||
|
||||
struct NoteWeakMapChildrenTracer : public JSTracer
|
||||
{
|
||||
NoteWeakMapChildrenTracer(JSRuntime *rt, nsCycleCollectionNoteRootCallback& cb)
|
||||
: JSTracer(rt, TraceWeakMappingChild), mCb(cb)
|
||||
NoteWeakMapChildrenTracer(JSRuntime* aRt,
|
||||
nsCycleCollectionNoteRootCallback& aCb)
|
||||
: JSTracer(aRt, TraceWeakMappingChild), mCb(aCb)
|
||||
{
|
||||
}
|
||||
nsCycleCollectionNoteRootCallback& mCb;
|
||||
@ -134,14 +135,14 @@ struct NoteWeakMapChildrenTracer : public JSTracer
|
||||
};
|
||||
|
||||
static void
|
||||
TraceWeakMappingChild(JSTracer* trc, void** thingp, JSGCTraceKind kind)
|
||||
TraceWeakMappingChild(JSTracer* aTrc, void** aThingp, JSGCTraceKind aKind)
|
||||
{
|
||||
MOZ_ASSERT(trc->callback == TraceWeakMappingChild);
|
||||
void* thing = *thingp;
|
||||
MOZ_ASSERT(aTrc->callback == TraceWeakMappingChild);
|
||||
void* thing = *aThingp;
|
||||
NoteWeakMapChildrenTracer* tracer =
|
||||
static_cast<NoteWeakMapChildrenTracer*>(trc);
|
||||
static_cast<NoteWeakMapChildrenTracer*>(aTrc);
|
||||
|
||||
if (kind == JSTRACE_STRING) {
|
||||
if (aKind == JSTRACE_STRING) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,19 +150,19 @@ TraceWeakMappingChild(JSTracer* trc, void** thingp, JSGCTraceKind kind)
|
||||
return;
|
||||
}
|
||||
|
||||
if (AddToCCKind(kind)) {
|
||||
if (AddToCCKind(aKind)) {
|
||||
tracer->mCb.NoteWeakMapping(tracer->mMap, tracer->mKey, tracer->mKeyDelegate, thing);
|
||||
tracer->mTracedAny = true;
|
||||
} else {
|
||||
JS_TraceChildren(trc, thing, kind);
|
||||
JS_TraceChildren(aTrc, thing, aKind);
|
||||
}
|
||||
}
|
||||
|
||||
struct NoteWeakMapsTracer : public js::WeakMapTracer
|
||||
{
|
||||
NoteWeakMapsTracer(JSRuntime* rt, js::WeakMapTraceCallback cb,
|
||||
nsCycleCollectionNoteRootCallback& cccb)
|
||||
: js::WeakMapTracer(rt, cb), mCb(cccb), mChildTracer(rt, cccb)
|
||||
NoteWeakMapsTracer(JSRuntime* aRt, js::WeakMapTraceCallback aCb,
|
||||
nsCycleCollectionNoteRootCallback& aCccb)
|
||||
: js::WeakMapTracer(aRt, aCb), mCb(aCccb), mChildTracer(aRt, aCccb)
|
||||
{
|
||||
}
|
||||
nsCycleCollectionNoteRootCallback& mCb;
|
||||
@ -169,16 +170,18 @@ struct NoteWeakMapsTracer : public js::WeakMapTracer
|
||||
};
|
||||
|
||||
static void
|
||||
TraceWeakMapping(js::WeakMapTracer* trc, JSObject* m,
|
||||
void* k, JSGCTraceKind kkind,
|
||||
void* v, JSGCTraceKind vkind)
|
||||
TraceWeakMapping(js::WeakMapTracer* aTrc, JSObject* aMap,
|
||||
void* aKey, JSGCTraceKind aKeyKind,
|
||||
void* aValue, JSGCTraceKind aValueKind)
|
||||
{
|
||||
MOZ_ASSERT(trc->callback == TraceWeakMapping);
|
||||
NoteWeakMapsTracer* tracer = static_cast<NoteWeakMapsTracer* >(trc);
|
||||
MOZ_ASSERT(aTrc->callback == TraceWeakMapping);
|
||||
NoteWeakMapsTracer* tracer = static_cast<NoteWeakMapsTracer*>(aTrc);
|
||||
|
||||
// If nothing that could be held alive by this entry is marked gray, return.
|
||||
if ((!k || !xpc_IsGrayGCThing(k)) && MOZ_LIKELY(!tracer->mCb.WantAllTraces())) {
|
||||
if (!v || !xpc_IsGrayGCThing(v) || vkind == JSTRACE_STRING) {
|
||||
if ((!aKey || !xpc_IsGrayGCThing(aKey)) &&
|
||||
MOZ_LIKELY(!tracer->mCb.WantAllTraces())) {
|
||||
if (!aValue || !xpc_IsGrayGCThing(aValue) ||
|
||||
aValueKind == JSTRACE_STRING) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -187,37 +190,38 @@ TraceWeakMapping(js::WeakMapTracer* trc, JSObject* m,
|
||||
// reason about the liveness of their keys, which in turn requires that
|
||||
// the key can be represented in the cycle collector graph. All existing
|
||||
// uses of weak maps use either objects or scripts as keys, which are okay.
|
||||
MOZ_ASSERT(AddToCCKind(kkind));
|
||||
MOZ_ASSERT(AddToCCKind(aKeyKind));
|
||||
|
||||
// As an emergency fallback for non-debug builds, if the key is not
|
||||
// representable in the cycle collector graph, we treat it as marked. This
|
||||
// can cause leaks, but is preferable to ignoring the binding, which could
|
||||
// cause the cycle collector to free live objects.
|
||||
if (!AddToCCKind(kkind)) {
|
||||
k = nullptr;
|
||||
if (!AddToCCKind(aKeyKind)) {
|
||||
aKey = nullptr;
|
||||
}
|
||||
|
||||
JSObject* kdelegate = nullptr;
|
||||
if (k && kkind == JSTRACE_OBJECT) {
|
||||
kdelegate = js::GetWeakmapKeyDelegate((JSObject*)k);
|
||||
if (aKey && aKeyKind == JSTRACE_OBJECT) {
|
||||
kdelegate = js::GetWeakmapKeyDelegate((JSObject*)aKey);
|
||||
}
|
||||
|
||||
if (AddToCCKind(vkind)) {
|
||||
tracer->mCb.NoteWeakMapping(m, k, kdelegate, v);
|
||||
if (AddToCCKind(aValueKind)) {
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey, kdelegate, aValue);
|
||||
} else {
|
||||
tracer->mChildTracer.mTracedAny = false;
|
||||
tracer->mChildTracer.mMap = m;
|
||||
tracer->mChildTracer.mKey = k;
|
||||
tracer->mChildTracer.mMap = aMap;
|
||||
tracer->mChildTracer.mKey = aKey;
|
||||
tracer->mChildTracer.mKeyDelegate = kdelegate;
|
||||
|
||||
if (v && vkind != JSTRACE_STRING) {
|
||||
JS_TraceChildren(&tracer->mChildTracer, v, vkind);
|
||||
if (aValue && aValueKind != JSTRACE_STRING) {
|
||||
JS_TraceChildren(&tracer->mChildTracer, aValue, aValueKind);
|
||||
}
|
||||
|
||||
// The delegate could hold alive the key, so report something to the CC
|
||||
// if we haven't already.
|
||||
if (!tracer->mChildTracer.mTracedAny && k && xpc_IsGrayGCThing(k) && kdelegate) {
|
||||
tracer->mCb.NoteWeakMapping(m, k, kdelegate, nullptr);
|
||||
if (!tracer->mChildTracer.mTracedAny &&
|
||||
aKey && xpc_IsGrayGCThing(aKey) && kdelegate) {
|
||||
tracer->mCb.NoteWeakMapping(aMap, aKey, kdelegate, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,9 +229,10 @@ TraceWeakMapping(js::WeakMapTracer* trc, JSObject* m,
|
||||
// This is based on the logic in TraceWeakMapping.
|
||||
struct FixWeakMappingGrayBitsTracer : public js::WeakMapTracer
|
||||
{
|
||||
FixWeakMappingGrayBitsTracer(JSRuntime* rt)
|
||||
: js::WeakMapTracer(rt, FixWeakMappingGrayBits)
|
||||
{}
|
||||
FixWeakMappingGrayBitsTracer(JSRuntime* aRt)
|
||||
: js::WeakMapTracer(aRt, FixWeakMappingGrayBits)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FixAll()
|
||||
@ -241,40 +246,42 @@ struct FixWeakMappingGrayBitsTracer : public js::WeakMapTracer
|
||||
private:
|
||||
|
||||
static void
|
||||
FixWeakMappingGrayBits(js::WeakMapTracer* trc, JSObject* m,
|
||||
void* k, JSGCTraceKind kkind,
|
||||
void* v, JSGCTraceKind vkind)
|
||||
FixWeakMappingGrayBits(js::WeakMapTracer* aTrc, JSObject* aMap,
|
||||
void* aKey, JSGCTraceKind aKeyKind,
|
||||
void* aValue, JSGCTraceKind aValueKind)
|
||||
{
|
||||
MOZ_ASSERT(!JS::IsIncrementalGCInProgress(trc->runtime),
|
||||
MOZ_ASSERT(!JS::IsIncrementalGCInProgress(aTrc->runtime),
|
||||
"Don't call FixWeakMappingGrayBits during a GC.");
|
||||
|
||||
FixWeakMappingGrayBitsTracer* tracer = static_cast<FixWeakMappingGrayBitsTracer*>(trc);
|
||||
FixWeakMappingGrayBitsTracer* tracer =
|
||||
static_cast<FixWeakMappingGrayBitsTracer*>(aTrc);
|
||||
|
||||
// If nothing that could be held alive by this entry is marked gray, return.
|
||||
bool delegateMightNeedMarking = k && xpc_IsGrayGCThing(k);
|
||||
bool valueMightNeedMarking = v && xpc_IsGrayGCThing(v) && vkind != JSTRACE_STRING;
|
||||
bool delegateMightNeedMarking = aKey && xpc_IsGrayGCThing(aKey);
|
||||
bool valueMightNeedMarking = aValue && xpc_IsGrayGCThing(aValue) &&
|
||||
aValueKind != JSTRACE_STRING;
|
||||
if (!delegateMightNeedMarking && !valueMightNeedMarking) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AddToCCKind(kkind)) {
|
||||
k = nullptr;
|
||||
if (!AddToCCKind(aKeyKind)) {
|
||||
aKey = nullptr;
|
||||
}
|
||||
|
||||
if (delegateMightNeedMarking && kkind == JSTRACE_OBJECT) {
|
||||
JSObject* kdelegate = js::GetWeakmapKeyDelegate((JSObject*)k);
|
||||
if (delegateMightNeedMarking && aKeyKind == JSTRACE_OBJECT) {
|
||||
JSObject* kdelegate = js::GetWeakmapKeyDelegate((JSObject*)aKey);
|
||||
if (kdelegate && !xpc_IsGrayGCThing(kdelegate)) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(k, JSTRACE_OBJECT)) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aKey, JSTRACE_OBJECT)) {
|
||||
tracer->mAnyMarked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v && xpc_IsGrayGCThing(v) &&
|
||||
(!k || !xpc_IsGrayGCThing(k)) &&
|
||||
(!m || !xpc_IsGrayGCThing(m)) &&
|
||||
vkind != JSTRACE_SHAPE) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(v, vkind)) {
|
||||
if (aValue && xpc_IsGrayGCThing(aValue) &&
|
||||
(!aKey || !xpc_IsGrayGCThing(aKey)) &&
|
||||
(!aMap || !xpc_IsGrayGCThing(aMap)) &&
|
||||
aValueKind != JSTRACE_SHAPE) {
|
||||
if (JS::UnmarkGrayGCThingRecursively(aValue, aValueKind)) {
|
||||
tracer->mAnyMarked = true;
|
||||
}
|
||||
}
|
||||
@ -304,42 +311,44 @@ CheckParticipatesInCycleCollection(void* aThing, const char* aName, void* aClosu
|
||||
}
|
||||
|
||||
if (AddToCCKind(js::GCThingTraceKind(aThing)) &&
|
||||
xpc_IsGrayGCThing(aThing))
|
||||
{
|
||||
xpc_IsGrayGCThing(aThing)) {
|
||||
closure->mCycleCollectionEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
NoteJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
|
||||
NoteJSHolder(void* aHolder, nsScriptObjectTracer*& aTracer, void* aArg)
|
||||
{
|
||||
Closure *closure = static_cast<Closure*>(arg);
|
||||
Closure* closure = static_cast<Closure*>(aArg);
|
||||
|
||||
bool noteRoot;
|
||||
if (MOZ_UNLIKELY(closure->mCb->WantAllTraces())) {
|
||||
noteRoot = true;
|
||||
} else {
|
||||
closure->mCycleCollectionEnabled = false;
|
||||
tracer->Trace(holder, TraceCallbackFunc(CheckParticipatesInCycleCollection), closure);
|
||||
aTracer->Trace(aHolder,
|
||||
TraceCallbackFunc(CheckParticipatesInCycleCollection),
|
||||
closure);
|
||||
noteRoot = closure->mCycleCollectionEnabled;
|
||||
}
|
||||
|
||||
if (noteRoot) {
|
||||
closure->mCb->NoteNativeRoot(holder, tracer);
|
||||
closure->mCb->NoteNativeRoot(aHolder, aTracer);
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
JSGCThingParticipant::Traverse(void* p, nsCycleCollectionTraversalCallback& cb)
|
||||
JSGCThingParticipant::Traverse(void* aPtr,
|
||||
nsCycleCollectionTraversalCallback& aCb)
|
||||
{
|
||||
CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*>
|
||||
(reinterpret_cast<char*>(this) -
|
||||
offsetof(CycleCollectedJSRuntime, mGCThingCycleCollectorGlobal));
|
||||
|
||||
runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL,
|
||||
p, js::GCThingTraceKind(p), cb);
|
||||
aPtr, js::GCThingTraceKind(aPtr), aCb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -348,16 +357,16 @@ JSGCThingParticipant::Traverse(void* p, nsCycleCollectionTraversalCallback& cb)
|
||||
static JSGCThingParticipant sGCThingCycleCollectorGlobal;
|
||||
|
||||
NS_IMETHODIMP
|
||||
JSZoneParticipant::Traverse(void* p, nsCycleCollectionTraversalCallback& cb)
|
||||
JSZoneParticipant::Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb)
|
||||
{
|
||||
CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*>
|
||||
(reinterpret_cast<char*>(this) -
|
||||
offsetof(CycleCollectedJSRuntime, mJSZoneCycleCollectorGlobal));
|
||||
|
||||
MOZ_ASSERT(!cb.WantAllTraces());
|
||||
JS::Zone* zone = static_cast<JS::Zone*>(p);
|
||||
MOZ_ASSERT(!aCb.WantAllTraces());
|
||||
JS::Zone* zone = static_cast<JS::Zone*>(aPtr);
|
||||
|
||||
runtime->TraverseZone(zone, cb);
|
||||
runtime->TraverseZone(zone, aCb);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -366,8 +375,8 @@ NoteJSChildTracerShim(JSTracer* aTrc, void** aThingp, JSGCTraceKind aTraceKind);
|
||||
|
||||
struct TraversalTracer : public JSTracer
|
||||
{
|
||||
TraversalTracer(JSRuntime *rt, nsCycleCollectionTraversalCallback& aCb)
|
||||
: JSTracer(rt, NoteJSChildTracerShim, DoNotTraceWeakMaps), mCb(aCb)
|
||||
TraversalTracer(JSRuntime* aRt, nsCycleCollectionTraversalCallback& aCb)
|
||||
: JSTracer(aRt, NoteJSChildTracerShim, DoNotTraceWeakMaps), mCb(aCb)
|
||||
{
|
||||
}
|
||||
nsCycleCollectionTraversalCallback& mCb;
|
||||
@ -401,7 +410,7 @@ NoteJSChild(JSTracer* aTrc, void* aThing, JSGCTraceKind aTraceKind)
|
||||
} else if (tracer->debugPrintIndex() != (size_t)-1) {
|
||||
char buffer[200];
|
||||
JS_snprintf(buffer, sizeof(buffer), "%s[%lu]",
|
||||
static_cast<const char *>(tracer->debugPrintArg()),
|
||||
static_cast<const char*>(tracer->debugPrintArg()),
|
||||
tracer->debugPrintIndex());
|
||||
tracer->mCb.NoteNextEdgeName(buffer);
|
||||
} else {
|
||||
@ -457,10 +466,10 @@ static const JSZoneParticipant sJSZoneCycleCollectorGlobal;
|
||||
CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSRuntime* aParentRuntime,
|
||||
uint32_t aMaxbytes,
|
||||
JSUseHelperThreads aUseHelperThreads)
|
||||
: mGCThingCycleCollectorGlobal(sGCThingCycleCollectorGlobal),
|
||||
mJSZoneCycleCollectorGlobal(sJSZoneCycleCollectorGlobal),
|
||||
mJSRuntime(nullptr),
|
||||
mJSHolders(512)
|
||||
: mGCThingCycleCollectorGlobal(sGCThingCycleCollectorGlobal)
|
||||
, mJSZoneCycleCollectorGlobal(sJSZoneCycleCollectorGlobal)
|
||||
, mJSRuntime(nullptr)
|
||||
, mJSHolders(512)
|
||||
{
|
||||
mozilla::dom::InitScriptSettings();
|
||||
|
||||
@ -510,9 +519,9 @@ CycleCollectedJSRuntime::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
UnmarkJSHolder(void* holder, nsScriptObjectTracer*& tracer, void* arg)
|
||||
UnmarkJSHolder(void* aHolder, nsScriptObjectTracer*& aTracer, void* aArg)
|
||||
{
|
||||
tracer->CanSkip(holder, true);
|
||||
aTracer->CanSkip(aHolder, true);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
@ -647,7 +656,8 @@ CycleCollectedJSRuntime::TraverseGCThing(TraverseSelect aTs, void* aThing,
|
||||
}
|
||||
}
|
||||
|
||||
struct TraverseObjectShimClosure {
|
||||
struct TraverseObjectShimClosure
|
||||
{
|
||||
nsCycleCollectionTraversalCallback& cb;
|
||||
CycleCollectedJSRuntime* self;
|
||||
};
|
||||
@ -752,26 +762,40 @@ CycleCollectedJSRuntime::ContextCallback(JSContext* aContext,
|
||||
|
||||
struct JsGcTracer : public TraceCallbacks
|
||||
{
|
||||
virtual void Trace(JS::Heap<JS::Value> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapValueTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<JS::Value>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapValueTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::Heap<jsid> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapIdTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<jsid>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapIdTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSObject *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapObjectTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapObjectTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::TenuredHeap<JSObject *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallTenuredObjectTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::TenuredHeap<JSObject*>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallTenuredObjectTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSString *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapStringTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<JSString*>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapStringTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSScript *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapScriptTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<JSScript*>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapScriptTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSFunction *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapFunctionTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
virtual void Trace(JS::Heap<JSFunction*>* aPtr, const char* aName,
|
||||
void* aClosure) const MOZ_OVERRIDE
|
||||
{
|
||||
JS_CallHeapFunctionTracer(static_cast<JSTracer*>(aClosure), aPtr, aName);
|
||||
}
|
||||
};
|
||||
|
||||
@ -897,7 +921,7 @@ CycleCollectedJSRuntime::ZoneParticipant()
|
||||
}
|
||||
|
||||
nsresult
|
||||
CycleCollectedJSRuntime::TraverseRoots(nsCycleCollectionNoteRootCallback &aCb)
|
||||
CycleCollectedJSRuntime::TraverseRoots(nsCycleCollectionNoteRootCallback& aCb)
|
||||
{
|
||||
TraverseNativeRoots(aCb);
|
||||
|
||||
@ -985,9 +1009,9 @@ CycleCollectedJSRuntime::DeferredFinalize(nsISupports* aSupports)
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSRuntime::DumpJSHeap(FILE* file)
|
||||
CycleCollectedJSRuntime::DumpJSHeap(FILE* aFile)
|
||||
{
|
||||
js::DumpHeapComplete(Runtime(), file, js::CollectNurseryBeforeDump);
|
||||
js::DumpHeapComplete(Runtime(), aFile, js::CollectNurseryBeforeDump);
|
||||
}
|
||||
|
||||
|
||||
@ -1028,8 +1052,8 @@ IncrementalFinalizeRunnable::DeferredFinalizerEnumerator(DeferredFinalizeFunctio
|
||||
IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSRuntime* aRt,
|
||||
nsTArray<nsISupports*>& aSupports,
|
||||
DeferredFinalizerTable& aFinalizers)
|
||||
: mRuntime(aRt),
|
||||
mFinalizeFunctionToRun(0)
|
||||
: mRuntime(aRt)
|
||||
, mFinalizeFunctionToRun(0)
|
||||
{
|
||||
this->mSupports.SwapElements(aSupports);
|
||||
DeferredFinalizeFunctionHolder* function = mDeferredFinalizeFunctions.AppendElement();
|
||||
@ -1058,7 +1082,7 @@ IncrementalFinalizeRunnable::ReleaseNow(bool aLimited)
|
||||
TimeStamp started = TimeStamp::Now();
|
||||
bool timeout = false;
|
||||
do {
|
||||
const DeferredFinalizeFunctionHolder &function =
|
||||
const DeferredFinalizeFunctionHolder& function =
|
||||
mDeferredFinalizeFunctions[mFinalizeFunctionToRun];
|
||||
if (aLimited) {
|
||||
bool done = false;
|
||||
@ -1139,8 +1163,7 @@ CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
|
||||
case JSGC_BEGIN:
|
||||
nsCycleCollector_prepareForGarbageCollection();
|
||||
break;
|
||||
case JSGC_END:
|
||||
{
|
||||
case JSGC_END: {
|
||||
/*
|
||||
* If the previous GC created a runnable to finalize objects
|
||||
* incrementally, and if it hasn't finished yet, finish it now. We
|
||||
|
@ -28,47 +28,49 @@ namespace mozilla {
|
||||
class JSGCThingParticipant: public nsCycleCollectionParticipant
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD_(void) Root(void *n)
|
||||
NS_IMETHOD_(void) Root(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) Unlink(void *n)
|
||||
NS_IMETHOD_(void) Unlink(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) Unroot(void *n)
|
||||
NS_IMETHOD_(void) Unroot(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) DeleteCycleCollectable(void *n)
|
||||
NS_IMETHOD_(void) DeleteCycleCollectable(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Traverse(void *n, nsCycleCollectionTraversalCallback &cb);
|
||||
NS_IMETHOD Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb);
|
||||
};
|
||||
|
||||
class JSZoneParticipant : public nsCycleCollectionParticipant
|
||||
{
|
||||
public:
|
||||
MOZ_CONSTEXPR JSZoneParticipant(): nsCycleCollectionParticipant() {}
|
||||
|
||||
NS_IMETHOD_(void) Root(void *p)
|
||||
MOZ_CONSTEXPR JSZoneParticipant(): nsCycleCollectionParticipant()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) Unlink(void *p)
|
||||
NS_IMETHOD_(void) Root(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) Unroot(void *p)
|
||||
NS_IMETHOD_(void) Unlink(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD_(void) DeleteCycleCollectable(void *n)
|
||||
NS_IMETHOD_(void) Unroot(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Traverse(void *p, nsCycleCollectionTraversalCallback &cb);
|
||||
NS_IMETHOD_(void) DeleteCycleCollectable(void* aPtr)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb);
|
||||
};
|
||||
|
||||
class IncrementalFinalizeRunnable;
|
||||
@ -119,10 +121,16 @@ protected:
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
void UnmarkSkippableJSHolders();
|
||||
|
||||
virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb) {}
|
||||
virtual void TraceAdditionalNativeGrayRoots(JSTracer* aTracer) {}
|
||||
virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb)
|
||||
{
|
||||
}
|
||||
virtual void TraceAdditionalNativeGrayRoots(JSTracer* aTracer)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void CustomGCCallback(JSGCStatus aStatus) {}
|
||||
virtual void CustomGCCallback(JSGCStatus aStatus)
|
||||
{
|
||||
}
|
||||
virtual bool CustomContextCallback(JSContext* aCx, unsigned aOperation)
|
||||
{
|
||||
return true; // Don't block context creation.
|
||||
@ -206,11 +214,11 @@ public:
|
||||
nsCycleCollectionParticipant* GCThingParticipant();
|
||||
nsCycleCollectionParticipant* ZoneParticipant();
|
||||
|
||||
nsresult TraverseRoots(nsCycleCollectionNoteRootCallback &aCb);
|
||||
nsresult TraverseRoots(nsCycleCollectionNoteRootCallback& aCb);
|
||||
bool UsefulToMergeZones() const;
|
||||
void FixWeakMappingGrayBits() const;
|
||||
bool AreGCGrayBitsValid() const;
|
||||
void GarbageCollect(uint32_t reason) const;
|
||||
void GarbageCollect(uint32_t aReason) const;
|
||||
|
||||
void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
|
||||
DeferredFinalizeFunction aFunc,
|
||||
@ -221,7 +229,7 @@ public:
|
||||
|
||||
virtual void PrepareForForgetSkippable() = 0;
|
||||
virtual void BeginCycleCollectionCallback() = 0;
|
||||
virtual void EndCycleCollectionCallback(CycleCollectorResults &aResults) = 0;
|
||||
virtual void EndCycleCollectionCallback(CycleCollectorResults& aResults) = 0;
|
||||
virtual void DispatchDeferredDeletion(bool aContinuation) = 0;
|
||||
|
||||
JSRuntime* Runtime() const
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
||||
void mozilla::PrintToDebugger(const char* aStr)
|
||||
void
|
||||
mozilla::PrintToDebugger(const char* aStr)
|
||||
{
|
||||
if (::IsDebuggerPresent()) {
|
||||
::OutputDebugStringA(aStr);
|
||||
|
@ -15,8 +15,8 @@ namespace mozilla {
|
||||
|
||||
nsresult
|
||||
FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, void **bp,
|
||||
void *stackEnd);
|
||||
uint32_t aMaxFrames, void* aClosure, void** aBp,
|
||||
void* aStackEnd);
|
||||
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,11 @@ private:
|
||||
// this constructor always, the compiler wouldn't generate a trivial
|
||||
// default constructor for us in non-debug mode.
|
||||
#ifdef DEBUG
|
||||
StaticMutex(StaticMutex &other);
|
||||
StaticMutex(StaticMutex& other);
|
||||
#endif
|
||||
|
||||
// Disallow these operators.
|
||||
StaticMutex& operator=(StaticMutex* rhs);
|
||||
StaticMutex& operator=(StaticMutex* aRhs);
|
||||
static void* operator new(size_t) CPP_THROW_NEW;
|
||||
static void operator delete(void*);
|
||||
};
|
||||
|
@ -48,9 +48,9 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
StaticAutoPtr<T>& operator=(T* rhs)
|
||||
StaticAutoPtr<T>& operator=(T* aRhs)
|
||||
{
|
||||
Assign(rhs);
|
||||
Assign(aRhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -81,14 +81,14 @@ private:
|
||||
// this constructor always, the compiler wouldn't generate a trivial
|
||||
// default constructor for us in non-debug mode.
|
||||
#ifdef DEBUG
|
||||
StaticAutoPtr(StaticAutoPtr<T> &other);
|
||||
StaticAutoPtr(StaticAutoPtr<T>& other);
|
||||
#endif
|
||||
|
||||
void Assign(T* newPtr)
|
||||
void Assign(T* aNewPtr)
|
||||
{
|
||||
MOZ_ASSERT(!newPtr || mRawPtr != newPtr);
|
||||
MOZ_ASSERT(!aNewPtr || mRawPtr != aNewPtr);
|
||||
T* oldPtr = mRawPtr;
|
||||
mRawPtr = newPtr;
|
||||
mRawPtr = aNewPtr;
|
||||
delete oldPtr;
|
||||
}
|
||||
|
||||
@ -109,15 +109,15 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
StaticRefPtr<T>& operator=(T* rhs)
|
||||
StaticRefPtr<T>& operator=(T* aRhs)
|
||||
{
|
||||
AssignWithAddref(rhs);
|
||||
AssignWithAddref(aRhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
StaticRefPtr<T>& operator=(const StaticRefPtr<T>& rhs)
|
||||
StaticRefPtr<T>& operator=(const StaticRefPtr<T>& aRhs)
|
||||
{
|
||||
return (this = rhs.mRawPtr);
|
||||
return (this = aRhs.mRawPtr);
|
||||
}
|
||||
|
||||
T* get() const
|
||||
@ -142,18 +142,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void AssignWithAddref(T* newPtr)
|
||||
void AssignWithAddref(T* aNewPtr)
|
||||
{
|
||||
if (newPtr) {
|
||||
newPtr->AddRef();
|
||||
if (aNewPtr) {
|
||||
aNewPtr->AddRef();
|
||||
}
|
||||
AssignAssumingAddRef(newPtr);
|
||||
AssignAssumingAddRef(aNewPtr);
|
||||
}
|
||||
|
||||
void AssignAssumingAddRef(T* newPtr)
|
||||
void AssignAssumingAddRef(T* aNewPtr)
|
||||
{
|
||||
T* oldPtr = mRawPtr;
|
||||
mRawPtr = newPtr;
|
||||
mRawPtr = aNewPtr;
|
||||
if (oldPtr) {
|
||||
oldPtr->Release();
|
||||
}
|
||||
@ -199,16 +199,16 @@ class Zero;
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const StaticAutoPtr<T>& lhs, const StaticAutoPtr<U>& rhs)
|
||||
operator==(const StaticAutoPtr<T>& aLhs, const StaticAutoPtr<U>& aRhs)
|
||||
{
|
||||
return lhs.get() == rhs.get();
|
||||
return aLhs.get() == aRhs.get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const StaticAutoPtr<T>& lhs, const StaticAutoPtr<U>& rhs)
|
||||
operator!=(const StaticAutoPtr<T>& aLhs, const StaticAutoPtr<U>& aRhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
return !(aLhs == aRhs);
|
||||
}
|
||||
|
||||
REFLEXIVE_EQUALITY_OPERATORS(const StaticAutoPtr<T>&, const U*,
|
||||
@ -225,16 +225,16 @@ REFLEXIVE_EQUALITY_OPERATORS(const StaticAutoPtr<T>&, StaticPtr_internal::Zero*,
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const StaticRefPtr<T>& lhs, const StaticRefPtr<U>& rhs)
|
||||
operator==(const StaticRefPtr<T>& aLhs, const StaticRefPtr<U>& aRhs)
|
||||
{
|
||||
return lhs.get() == rhs.get();
|
||||
return aLhs.get() == aRhs.get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const StaticRefPtr<T>& lhs, const StaticRefPtr<U>& rhs)
|
||||
operator!=(const StaticRefPtr<T>& aLhs, const StaticRefPtr<U>& aRhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
return !(aLhs == aRhs);
|
||||
}
|
||||
|
||||
REFLEXIVE_EQUALITY_OPERATORS(const StaticRefPtr<T>&, const U*,
|
||||
|
@ -84,14 +84,14 @@ GetBasename(const nsCString& aPath, nsACString& aOut)
|
||||
}
|
||||
|
||||
static bool
|
||||
IsNumeric(const char* s)
|
||||
IsNumeric(const char* aStr)
|
||||
{
|
||||
MOZ_ASSERT(*s); // shouldn't see empty strings
|
||||
while (*s) {
|
||||
if (!isdigit(*s)) {
|
||||
MOZ_ASSERT(*aStr); // shouldn't see empty strings
|
||||
while (*aStr) {
|
||||
if (!isdigit(*aStr)) {
|
||||
return false;
|
||||
}
|
||||
s++;
|
||||
++aStr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -190,7 +190,10 @@ private:
|
||||
// These are the cross-cutting measurements across all processes.
|
||||
struct ProcessSizes
|
||||
{
|
||||
ProcessSizes() { memset(this, 0, sizeof(*this)); }
|
||||
ProcessSizes()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
}
|
||||
|
||||
size_t mSizes[ProcessSizeKindLimit];
|
||||
};
|
||||
@ -271,8 +274,9 @@ private:
|
||||
while (true) {
|
||||
nsresult rv = ParseMapping(f, processName, aHandleReport, aData,
|
||||
&processSizes, aTotalPss);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
@ -361,8 +365,9 @@ private:
|
||||
size_t pss = 0;
|
||||
nsresult rv = ParseMapBody(aFile, aProcessName, name, description,
|
||||
aHandleReport, aData, &pss);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Increment the appropriate aProcessSizes values, and the total.
|
||||
aProcessSizes->mSizes[kind] += pss;
|
||||
@ -827,7 +832,8 @@ const char* SystemReporter::kindPathSuffixes[] = {
|
||||
"vdso"
|
||||
};
|
||||
|
||||
void Init()
|
||||
void
|
||||
Init()
|
||||
{
|
||||
RegisterStrongMemoryReporter(new SystemReporter());
|
||||
}
|
||||
|
@ -14,9 +14,13 @@ namespace SystemMemoryReporter {
|
||||
// empty functions on other platforms.
|
||||
|
||||
#if defined(XP_LINUX)
|
||||
void Init();
|
||||
void
|
||||
Init();
|
||||
#else
|
||||
void Init() {}
|
||||
void
|
||||
Init()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace SystemMemoryReporter
|
||||
|
@ -12,17 +12,18 @@
|
||||
#include "plstr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla { namespace eventtracer {
|
||||
namespace mozilla {
|
||||
namespace eventtracer {
|
||||
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
|
||||
namespace {
|
||||
|
||||
const uint32_t kBatchSize = 256;
|
||||
const char kTypeChars[eventtracer::eLast] = {' ','N','S','W','E','D'};
|
||||
const char kTypeChars[eventtracer::eLast] = {' ', 'N', 'S', 'W', 'E', 'D'};
|
||||
|
||||
// Flushing thread and records queue monitor
|
||||
mozilla::Monitor * gMonitor = nullptr;
|
||||
mozilla::Monitor* gMonitor = nullptr;
|
||||
|
||||
// gInitialized and gCapture can be accessed from multiple threads
|
||||
// simultaneously without any locking. However, since they are only ever
|
||||
@ -34,14 +35,15 @@ bool gInitialized;
|
||||
bool gCapture;
|
||||
|
||||
// Time stamp of the epoch we have started to capture
|
||||
mozilla::TimeStamp * gProfilerStart;
|
||||
mozilla::TimeStamp* gProfilerStart;
|
||||
|
||||
// Duration of the log to keep up to
|
||||
mozilla::TimeDuration * gMaxBacklogTime;
|
||||
mozilla::TimeDuration* gMaxBacklogTime;
|
||||
|
||||
|
||||
// Record of a single event
|
||||
class Record {
|
||||
class Record
|
||||
{
|
||||
public:
|
||||
Record()
|
||||
: mType(::mozilla::eventtracer::eNone)
|
||||
@ -52,7 +54,7 @@ public:
|
||||
MOZ_COUNT_CTOR(Record);
|
||||
}
|
||||
|
||||
Record& operator=(const Record & aOther)
|
||||
Record& operator=(const Record& aOther)
|
||||
{
|
||||
mType = aOther.mType;
|
||||
mTime = aOther.mTime;
|
||||
@ -71,20 +73,22 @@ public:
|
||||
|
||||
uint32_t mType;
|
||||
TimeStamp mTime;
|
||||
void * mItem;
|
||||
char * mText;
|
||||
char * mText2;
|
||||
void* mItem;
|
||||
char* mText;
|
||||
char* mText2;
|
||||
};
|
||||
|
||||
char * DupCurrentThreadName()
|
||||
char* DupCurrentThreadName()
|
||||
{
|
||||
if (NS_IsMainThread())
|
||||
if (NS_IsMainThread()) {
|
||||
return PL_strdup("Main Thread");
|
||||
}
|
||||
|
||||
PRThread * currentThread = PR_GetCurrentThread();
|
||||
const char * name = PR_GetThreadName(currentThread);
|
||||
if (name)
|
||||
PRThread* currentThread = PR_GetCurrentThread();
|
||||
const char* name = PR_GetThreadName(currentThread);
|
||||
if (name) {
|
||||
return PL_strdup(name);
|
||||
}
|
||||
|
||||
char buffer[128];
|
||||
PR_snprintf(buffer, 127, "Nameless %p", currentThread);
|
||||
@ -93,10 +97,11 @@ char * DupCurrentThreadName()
|
||||
}
|
||||
|
||||
// An array of events, each thread keeps its own private instance
|
||||
class RecordBatch {
|
||||
class RecordBatch
|
||||
{
|
||||
public:
|
||||
RecordBatch(size_t aLength = kBatchSize,
|
||||
char * aThreadName = DupCurrentThreadName())
|
||||
char* aThreadName = DupCurrentThreadName())
|
||||
: mRecordsHead(new Record[aLength])
|
||||
, mRecordsTail(mRecordsHead + aLength)
|
||||
, mNextRecord(mRecordsHead)
|
||||
@ -114,52 +119,61 @@ public:
|
||||
MOZ_COUNT_DTOR(RecordBatch);
|
||||
}
|
||||
|
||||
void Close() { mClosed = true; }
|
||||
void Close()
|
||||
{
|
||||
mClosed = true;
|
||||
}
|
||||
|
||||
size_t Length() const { return mNextRecord - mRecordsHead; }
|
||||
size_t Length() const
|
||||
{
|
||||
return mNextRecord - mRecordsHead;
|
||||
}
|
||||
bool CanBeDeleted(const TimeStamp& aUntil) const;
|
||||
|
||||
static RecordBatch * Register();
|
||||
static void Close(void * data); // Registered on freeing thread data
|
||||
static RecordBatch * Clone(RecordBatch * aLog, const TimeStamp& aSince);
|
||||
static void Delete(RecordBatch * aLog);
|
||||
static RecordBatch* Register();
|
||||
static void Close(void* data); // Registered on freeing thread data
|
||||
static RecordBatch* Clone(RecordBatch* aLog, const TimeStamp& aSince);
|
||||
static void Delete(RecordBatch* aLog);
|
||||
|
||||
static RecordBatch * CloneLog();
|
||||
static RecordBatch* CloneLog();
|
||||
static void GCLog(const TimeStamp& aUntil);
|
||||
static void DeleteLog();
|
||||
|
||||
Record * mRecordsHead;
|
||||
Record * mRecordsTail;
|
||||
Record * mNextRecord;
|
||||
Record* mRecordsHead;
|
||||
Record* mRecordsTail;
|
||||
Record* mNextRecord;
|
||||
|
||||
RecordBatch * mNextBatch;
|
||||
char * mThreadNameCopy;
|
||||
RecordBatch* mNextBatch;
|
||||
char* mThreadNameCopy;
|
||||
bool mClosed;
|
||||
};
|
||||
|
||||
// Protected by gMonitor, accessed concurently
|
||||
// Linked list of batches threads want to flush on disk
|
||||
RecordBatch * gLogHead = nullptr;
|
||||
RecordBatch * gLogTail = nullptr;
|
||||
RecordBatch* gLogHead = nullptr;
|
||||
RecordBatch* gLogTail = nullptr;
|
||||
|
||||
// Registers the batch in the linked list
|
||||
// static
|
||||
RecordBatch *
|
||||
RecordBatch*
|
||||
RecordBatch::Register()
|
||||
{
|
||||
MonitorAutoLock mon(*gMonitor);
|
||||
|
||||
if (!gInitialized)
|
||||
if (!gInitialized) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (gLogHead)
|
||||
if (gLogHead) {
|
||||
RecordBatch::GCLog(TimeStamp::Now() - *gMaxBacklogTime);
|
||||
}
|
||||
|
||||
RecordBatch * batch = new RecordBatch();
|
||||
if (!gLogHead)
|
||||
RecordBatch* batch = new RecordBatch();
|
||||
if (!gLogHead) {
|
||||
gLogHead = batch;
|
||||
else // gLogTail is non-null
|
||||
} else { // gLogTail is non-null
|
||||
gLogTail->mNextBatch = batch;
|
||||
}
|
||||
gLogTail = batch;
|
||||
|
||||
mon.Notify();
|
||||
@ -167,23 +181,24 @@ RecordBatch::Register()
|
||||
}
|
||||
|
||||
void
|
||||
RecordBatch::Close(void * data)
|
||||
RecordBatch::Close(void* data)
|
||||
{
|
||||
RecordBatch * batch = static_cast<RecordBatch*>(data);
|
||||
RecordBatch* batch = static_cast<RecordBatch*>(data);
|
||||
batch->Close();
|
||||
}
|
||||
|
||||
// static
|
||||
RecordBatch *
|
||||
RecordBatch::Clone(RecordBatch * aOther, const TimeStamp& aSince)
|
||||
RecordBatch*
|
||||
RecordBatch::Clone(RecordBatch* aOther, const TimeStamp& aSince)
|
||||
{
|
||||
if (!aOther)
|
||||
if (!aOther) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t length = aOther->Length();
|
||||
size_t min = 0;
|
||||
size_t max = length;
|
||||
Record * record = nullptr;
|
||||
Record* record = nullptr;
|
||||
|
||||
// Binary search for record with time >= aSince
|
||||
size_t i;
|
||||
@ -191,20 +206,22 @@ RecordBatch::Clone(RecordBatch * aOther, const TimeStamp& aSince)
|
||||
i = (max + min) / 2;
|
||||
|
||||
record = aOther->mRecordsHead + i;
|
||||
if (record->mTime >= aSince)
|
||||
if (record->mTime >= aSince) {
|
||||
max = i;
|
||||
else
|
||||
min = i+1;
|
||||
} else {
|
||||
min = i + 1;
|
||||
}
|
||||
}
|
||||
i = (max + min) / 2;
|
||||
|
||||
// How many Record's to copy?
|
||||
size_t toCopy = length - i;
|
||||
if (!toCopy)
|
||||
if (!toCopy) {
|
||||
return RecordBatch::Clone(aOther->mNextBatch, aSince);
|
||||
}
|
||||
|
||||
// Clone
|
||||
RecordBatch * clone = new RecordBatch(toCopy, PL_strdup(aOther->mThreadNameCopy));
|
||||
RecordBatch* clone = new RecordBatch(toCopy, PL_strdup(aOther->mThreadNameCopy));
|
||||
for (; i < length; ++i) {
|
||||
record = aOther->mRecordsHead + i;
|
||||
*clone->mNextRecord = *record;
|
||||
@ -217,17 +234,17 @@ RecordBatch::Clone(RecordBatch * aOther, const TimeStamp& aSince)
|
||||
|
||||
// static
|
||||
void
|
||||
RecordBatch::Delete(RecordBatch * aLog)
|
||||
RecordBatch::Delete(RecordBatch* aLog)
|
||||
{
|
||||
while (aLog) {
|
||||
RecordBatch * batch = aLog;
|
||||
RecordBatch* batch = aLog;
|
||||
aLog = aLog->mNextBatch;
|
||||
delete batch;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
RecordBatch *
|
||||
RecordBatch*
|
||||
RecordBatch::CloneLog()
|
||||
{
|
||||
TimeStamp startEpoch = *gProfilerStart;
|
||||
@ -247,10 +264,10 @@ RecordBatch::GCLog(const TimeStamp& aUntil)
|
||||
// Garbage collect all unreferenced and old batches
|
||||
gMonitor->AssertCurrentThreadOwns();
|
||||
|
||||
RecordBatch *volatile * referer = &gLogHead;
|
||||
RecordBatch* volatile* referer = &gLogHead;
|
||||
gLogTail = nullptr;
|
||||
|
||||
RecordBatch * batch = *referer;
|
||||
RecordBatch* batch = *referer;
|
||||
while (batch) {
|
||||
if (batch->CanBeDeleted(aUntil)) {
|
||||
// The batch is completed and thus unreferenced by the thread
|
||||
@ -259,8 +276,7 @@ RecordBatch::GCLog(const TimeStamp& aUntil)
|
||||
*referer = batch->mNextBatch;
|
||||
delete batch;
|
||||
batch = *referer;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// We walk the whole list, so this will end up filled with
|
||||
// the very last valid element of it.
|
||||
gLogTail = batch;
|
||||
@ -277,7 +293,7 @@ RecordBatch::GCLog(const TimeStamp& aUntil)
|
||||
void
|
||||
RecordBatch::DeleteLog()
|
||||
{
|
||||
RecordBatch * batch;
|
||||
RecordBatch* batch;
|
||||
{
|
||||
MonitorAutoLock mon(*gMonitor);
|
||||
batch = gLogHead;
|
||||
@ -302,7 +318,7 @@ RecordBatch::CanBeDeleted(const TimeStamp& aUntil) const
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((mNextRecord-1)->mTime <= aUntil) {
|
||||
if ((mNextRecord - 1)->mTime <= aUntil) {
|
||||
// Is the last record older then the time we demand records
|
||||
// for? If not, this batch has expired.
|
||||
return true;
|
||||
@ -317,8 +333,8 @@ RecordBatch::CanBeDeleted(const TimeStamp& aUntil) const
|
||||
class EventFilter
|
||||
{
|
||||
public:
|
||||
static EventFilter * Build(const char * filterVar);
|
||||
bool EventPasses(const char * eventName);
|
||||
static EventFilter* Build(const char* filterVar);
|
||||
bool EventPasses(const char* eventName);
|
||||
|
||||
~EventFilter()
|
||||
{
|
||||
@ -328,23 +344,24 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
EventFilter(const char * eventName, EventFilter * next)
|
||||
EventFilter(const char* eventName, EventFilter* next)
|
||||
: mFilter(PL_strdup(eventName))
|
||||
, mNext(next)
|
||||
{
|
||||
MOZ_COUNT_CTOR(EventFilter);
|
||||
}
|
||||
|
||||
char * mFilter;
|
||||
EventFilter * mNext;
|
||||
char* mFilter;
|
||||
EventFilter* mNext;
|
||||
};
|
||||
|
||||
// static
|
||||
EventFilter *
|
||||
EventFilter::Build(const char * filterVar)
|
||||
EventFilter*
|
||||
EventFilter::Build(const char* filterVar)
|
||||
{
|
||||
if (!filterVar || !*filterVar)
|
||||
if (!filterVar || !*filterVar) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Reads a comma serpatated list of events.
|
||||
|
||||
@ -354,15 +371,17 @@ EventFilter::Build(const char * filterVar)
|
||||
|
||||
// Read up to a comma or EOF -> get name of an event first in the list
|
||||
count = sscanf(filterVar, "%63[^,]%n", eventName, &delta);
|
||||
if (count == 0)
|
||||
if (count == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pos = delta;
|
||||
|
||||
// Skip a comma, if present, accept spaces around it
|
||||
count = sscanf(filterVar + pos, " , %n", &delta);
|
||||
if (count != EOF)
|
||||
if (count != EOF) {
|
||||
pos += delta;
|
||||
}
|
||||
|
||||
// eventName contains name of the first event in the list
|
||||
// second argument recursively parses the rest of the list string and
|
||||
@ -371,30 +390,34 @@ EventFilter::Build(const char * filterVar)
|
||||
}
|
||||
|
||||
bool
|
||||
EventFilter::EventPasses(const char * eventName)
|
||||
EventFilter::EventPasses(const char* eventName)
|
||||
{
|
||||
if (!strcmp(eventName, mFilter))
|
||||
if (!strcmp(eventName, mFilter)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mNext)
|
||||
if (mNext) {
|
||||
return mNext->EventPasses(eventName);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// State and control variables, initialized in Init() method, after it
|
||||
// immutable and read concurently.
|
||||
EventFilter * gEventFilter = nullptr;
|
||||
EventFilter* gEventFilter = nullptr;
|
||||
unsigned gThreadPrivateIndex;
|
||||
|
||||
// static
|
||||
bool CheckEventFilters(uint32_t aType, void * aItem, const char * aText)
|
||||
bool CheckEventFilters(uint32_t aType, void* aItem, const char* aText)
|
||||
{
|
||||
if (!gEventFilter)
|
||||
if (!gEventFilter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aType == eName)
|
||||
if (aType == eName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return gEventFilter->EventPasses(aText);
|
||||
}
|
||||
@ -404,20 +427,24 @@ bool CheckEventFilters(uint32_t aType, void * aItem, const char * aText)
|
||||
#endif //MOZ_VISUAL_EVENT_TRACER
|
||||
|
||||
// static
|
||||
void Init()
|
||||
void
|
||||
Init()
|
||||
{
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
const char * logEvents = PR_GetEnv("MOZ_PROFILING_EVENTS");
|
||||
if (logEvents && *logEvents)
|
||||
const char* logEvents = PR_GetEnv("MOZ_PROFILING_EVENTS");
|
||||
if (logEvents && *logEvents) {
|
||||
gEventFilter = EventFilter::Build(logEvents);
|
||||
}
|
||||
|
||||
PRStatus status = PR_NewThreadPrivateIndex(&gThreadPrivateIndex, &RecordBatch::Close);
|
||||
if (status != PR_SUCCESS)
|
||||
if (status != PR_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
gMonitor = new mozilla::Monitor("Profiler");
|
||||
if (!gMonitor)
|
||||
if (!gMonitor) {
|
||||
return;
|
||||
}
|
||||
|
||||
gProfilerStart = new mozilla::TimeStamp();
|
||||
gMaxBacklogTime = new mozilla::TimeDuration();
|
||||
@ -427,7 +454,8 @@ void Init()
|
||||
}
|
||||
|
||||
// static
|
||||
void Shutdown()
|
||||
void
|
||||
Shutdown()
|
||||
{
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
gCapture = false;
|
||||
@ -458,29 +486,34 @@ void Shutdown()
|
||||
}
|
||||
|
||||
// static
|
||||
void Mark(uint32_t aType, void * aItem, const char * aText, const char * aText2)
|
||||
void
|
||||
Mark(uint32_t aType, void* aItem, const char* aText, const char* aText2)
|
||||
{
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
if (!gInitialized || !gCapture)
|
||||
if (!gInitialized || !gCapture) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aType == eNone)
|
||||
if (aType == eNone) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckEventFilters(aType, aItem, aText)) // Events use just aText
|
||||
if (!CheckEventFilters(aType, aItem, aText)) { // Events use just aText
|
||||
return;
|
||||
}
|
||||
|
||||
RecordBatch * threadLogPrivate = static_cast<RecordBatch *>(
|
||||
RecordBatch* threadLogPrivate = static_cast<RecordBatch*>(
|
||||
PR_GetThreadPrivate(gThreadPrivateIndex));
|
||||
if (!threadLogPrivate) {
|
||||
threadLogPrivate = RecordBatch::Register();
|
||||
if (!threadLogPrivate)
|
||||
if (!threadLogPrivate) {
|
||||
return;
|
||||
}
|
||||
|
||||
PR_SetThreadPrivate(gThreadPrivateIndex, threadLogPrivate);
|
||||
}
|
||||
|
||||
Record * record = threadLogPrivate->mNextRecord;
|
||||
Record* record = threadLogPrivate->mNextRecord;
|
||||
record->mType = aType;
|
||||
record->mTime = mozilla::TimeStamp::Now();
|
||||
record->mItem = aItem;
|
||||
@ -509,12 +542,13 @@ class VisualEventTracerLog : public nsIVisualEventTracerLog
|
||||
VisualEventTracerLog(RecordBatch* aBatch)
|
||||
: mBatch(aBatch)
|
||||
, mProfilerStart(*gProfilerStart)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~VisualEventTracerLog();
|
||||
|
||||
protected:
|
||||
RecordBatch * mBatch;
|
||||
RecordBatch* mBatch;
|
||||
TimeStamp mProfilerStart;
|
||||
};
|
||||
|
||||
@ -526,13 +560,13 @@ VisualEventTracerLog::~VisualEventTracerLog()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
VisualEventTracerLog::GetJSONString(nsACString & _retval)
|
||||
VisualEventTracerLog::GetJSONString(nsACString& _retval)
|
||||
{
|
||||
nsCString buffer;
|
||||
|
||||
buffer.Assign(NS_LITERAL_CSTRING("{\n\"version\": 1,\n\"records\":[\n"));
|
||||
|
||||
RecordBatch * batch = mBatch;
|
||||
RecordBatch* batch = mBatch;
|
||||
while (batch) {
|
||||
if (batch != mBatch) {
|
||||
// This is not the first batch we are writting, add comma
|
||||
@ -546,7 +580,7 @@ VisualEventTracerLog::GetJSONString(nsACString & _retval)
|
||||
static const int kBufferSize = 2048;
|
||||
char buf[kBufferSize];
|
||||
|
||||
for (Record * record = batch->mRecordsHead;
|
||||
for (Record* record = batch->mRecordsHead;
|
||||
record < batch->mNextRecord;
|
||||
++record) {
|
||||
|
||||
@ -570,7 +604,7 @@ VisualEventTracerLog::GetJSONString(nsACString & _retval)
|
||||
|
||||
buffer.Append(NS_LITERAL_CSTRING("]}\n"));
|
||||
|
||||
RecordBatch * next = batch->mNextBatch;
|
||||
RecordBatch* next = batch->mNextBatch;
|
||||
batch = next;
|
||||
}
|
||||
|
||||
@ -612,8 +646,9 @@ NS_IMPL_ISUPPORTS(VisualEventTracer, nsIVisualEventTracer)
|
||||
NS_IMETHODIMP
|
||||
VisualEventTracer::Start(const uint32_t aMaxBacklogSeconds)
|
||||
{
|
||||
if (!gInitialized)
|
||||
if (!gInitialized) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (gCapture) {
|
||||
NS_WARNING("VisualEventTracer has already been started");
|
||||
@ -637,8 +672,9 @@ VisualEventTracer::Start(const uint32_t aMaxBacklogSeconds)
|
||||
NS_IMETHODIMP
|
||||
VisualEventTracer::Stop()
|
||||
{
|
||||
if (!gInitialized)
|
||||
if (!gInitialized) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!gCapture) {
|
||||
NS_WARNING("VisualEventTracer is not runing");
|
||||
@ -662,12 +698,13 @@ VisualEventTracer::Stop()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
VisualEventTracer::Snapshot(nsIVisualEventTracerLog ** _result)
|
||||
VisualEventTracer::Snapshot(nsIVisualEventTracerLog** _result)
|
||||
{
|
||||
if (!gInitialized)
|
||||
if (!gInitialized) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
RecordBatch * batch = RecordBatch::CloneLog();
|
||||
RecordBatch* batch = RecordBatch::CloneLog();
|
||||
|
||||
nsRefPtr<VisualEventTracerLog> log = new VisualEventTracerLog(batch);
|
||||
log.forget(_result);
|
||||
|
@ -159,8 +159,8 @@ enum MarkType {
|
||||
// @param aText2
|
||||
// Optional second part of the instnace name, or event name.
|
||||
// Event filtering does apply only to the first part (aText).
|
||||
void Mark(uint32_t aType, void * aItem,
|
||||
const char * aText, const char * aText2 = 0);
|
||||
void Mark(uint32_t aType, void* aItem,
|
||||
const char* aText, const char* aText2 = 0);
|
||||
|
||||
|
||||
// Helper guard object. Use to mark an event in the constructor and a different
|
||||
@ -176,11 +176,11 @@ void Mark(uint32_t aType, void * aItem,
|
||||
class MOZ_STACK_CLASS AutoEventTracer
|
||||
{
|
||||
public:
|
||||
AutoEventTracer(void * aInstance,
|
||||
AutoEventTracer(void* aInstance,
|
||||
uint32_t aTypeOn, // MarkType marked in constructor
|
||||
uint32_t aTypeOff, // MarkType marked in destructor
|
||||
const char * aName,
|
||||
const char * aName2 = 0
|
||||
const char* aName,
|
||||
const char* aName2 = 0
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mInstance(aInstance)
|
||||
, mName(aName)
|
||||
@ -199,9 +199,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void * mInstance;
|
||||
const char * mName;
|
||||
const char * mName2;
|
||||
void* mInstance;
|
||||
const char* mName;
|
||||
const char* mName2;
|
||||
uint32_t mTypeOn;
|
||||
uint32_t mTypeOff;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -251,8 +251,9 @@ public:
|
||||
}
|
||||
ThisClass& operator=(const ThisClass& aRefToCopy)
|
||||
{
|
||||
if (this == &aRefToCopy)
|
||||
if (this == &aRefToCopy) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
this->SafeRelease();
|
||||
SimpleRef::operator=(aRefToCopy);
|
||||
@ -291,8 +292,9 @@ protected:
|
||||
// Increase the reference count if there is a resource.
|
||||
void SafeAddRef()
|
||||
{
|
||||
if (this->HaveResource())
|
||||
if (this->HaveResource()) {
|
||||
this->AddRef(this->get());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -467,7 +469,10 @@ public:
|
||||
// The handle is a pointer to T.
|
||||
typedef T* RawRef;
|
||||
// A nullptr does not have a resource.
|
||||
static RawRef Void() { return nullptr; }
|
||||
static RawRef Void()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -658,8 +663,9 @@ protected:
|
||||
// Release a resource if there is one.
|
||||
void SafeRelease()
|
||||
{
|
||||
if (this->HaveResource())
|
||||
if (this->HaveResource()) {
|
||||
this->Release(this->get());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -14,27 +14,27 @@
|
||||
NS_IMPL_ISUPPORTS(nsConsoleMessage, nsIConsoleMessage)
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage()
|
||||
: mTimeStamp(0),
|
||||
mMessage()
|
||||
: mTimeStamp(0)
|
||||
, mMessage()
|
||||
{
|
||||
}
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage(const char16_t *message)
|
||||
nsConsoleMessage::nsConsoleMessage(const char16_t* aMessage)
|
||||
{
|
||||
mTimeStamp = JS_Now() / 1000;
|
||||
mMessage.Assign(message);
|
||||
mMessage.Assign(aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetMessageMoz(char16_t **result)
|
||||
nsConsoleMessage::GetMessageMoz(char16_t** aResult)
|
||||
{
|
||||
*result = ToNewUnicode(mMessage);
|
||||
*aResult = ToNewUnicode(mMessage);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetTimeStamp(int64_t *aTimeStamp)
|
||||
nsConsoleMessage::GetTimeStamp(int64_t* aTimeStamp)
|
||||
{
|
||||
*aTimeStamp = mTimeStamp;
|
||||
return NS_OK;
|
||||
|
@ -12,16 +12,19 @@
|
||||
#include "nsIConsoleMessage.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsConsoleMessage MOZ_FINAL : public nsIConsoleMessage {
|
||||
class nsConsoleMessage MOZ_FINAL : public nsIConsoleMessage
|
||||
{
|
||||
public:
|
||||
nsConsoleMessage();
|
||||
nsConsoleMessage(const char16_t *message);
|
||||
nsConsoleMessage(const char16_t* aMessage);
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICONSOLEMESSAGE
|
||||
|
||||
private:
|
||||
~nsConsoleMessage() {}
|
||||
~nsConsoleMessage()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t mTimeStamp;
|
||||
nsString mMessage;
|
||||
|
@ -62,14 +62,17 @@ nsConsoleService::~nsConsoleService()
|
||||
i++;
|
||||
}
|
||||
|
||||
if (mMessages)
|
||||
if (mMessages) {
|
||||
nsMemory::Free(mMessages);
|
||||
}
|
||||
}
|
||||
|
||||
class AddConsolePrefWatchers : public nsRunnable
|
||||
{
|
||||
public:
|
||||
AddConsolePrefWatchers(nsConsoleService* aConsole) : mConsole(aConsole) {}
|
||||
AddConsolePrefWatchers(nsConsoleService* aConsole) : mConsole(aConsole)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
@ -88,13 +91,14 @@ private:
|
||||
nsresult
|
||||
nsConsoleService::Init()
|
||||
{
|
||||
mMessages = (nsIConsoleMessage **)
|
||||
nsMemory::Alloc(mBufferSize * sizeof(nsIConsoleMessage *));
|
||||
if (!mMessages)
|
||||
mMessages = (nsIConsoleMessage**)
|
||||
nsMemory::Alloc(mBufferSize * sizeof(nsIConsoleMessage*));
|
||||
if (!mMessages) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Array elements should be 0 initially for circular buffer algorithm.
|
||||
memset(mMessages, 0, mBufferSize * sizeof(nsIConsoleMessage *));
|
||||
memset(mMessages, 0, mBufferSize * sizeof(nsIConsoleMessage*));
|
||||
|
||||
NS_DispatchToMainThread(new AddConsolePrefWatchers(this));
|
||||
|
||||
@ -106,9 +110,9 @@ namespace {
|
||||
class LogMessageRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
LogMessageRunnable(nsIConsoleMessage* message, nsConsoleService* service)
|
||||
: mMessage(message)
|
||||
, mService(service)
|
||||
LogMessageRunnable(nsIConsoleMessage* aMessage, nsConsoleService* aService)
|
||||
: mMessage(aMessage)
|
||||
, mService(aService)
|
||||
{ }
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
@ -122,9 +126,9 @@ typedef nsCOMArray<nsIConsoleListener> ListenerArrayType;
|
||||
|
||||
PLDHashOperator
|
||||
CollectCurrentListeners(nsISupports* aKey, nsIConsoleListener* aValue,
|
||||
void* closure)
|
||||
void* aClosure)
|
||||
{
|
||||
ListenerArrayType* listeners = static_cast<ListenerArrayType*>(closure);
|
||||
ListenerArrayType* listeners = static_cast<ListenerArrayType*>(aClosure);
|
||||
listeners->AppendObject(aValue);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
@ -141,8 +145,9 @@ LogMessageRunnable::Run()
|
||||
|
||||
mService->SetIsDelivering();
|
||||
|
||||
for (int32_t i = 0; i < listeners.Count(); ++i)
|
||||
for (int32_t i = 0; i < listeners.Count(); ++i) {
|
||||
listeners[i]->Observe(mMessage);
|
||||
}
|
||||
|
||||
mService->SetDoneDelivering();
|
||||
|
||||
@ -153,16 +158,18 @@ LogMessageRunnable::Run()
|
||||
|
||||
// nsIConsoleService methods
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::LogMessage(nsIConsoleMessage *message)
|
||||
nsConsoleService::LogMessage(nsIConsoleMessage* aMessage)
|
||||
{
|
||||
return LogMessageWithMode(message, OutputToLog);
|
||||
return LogMessageWithMode(aMessage, OutputToLog);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleService::OutputMode outputMode)
|
||||
nsConsoleService::LogMessageWithMode(nsIConsoleMessage* aMessage,
|
||||
nsConsoleService::OutputMode aOutputMode)
|
||||
{
|
||||
if (message == nullptr)
|
||||
if (!aMessage) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!sLoggingEnabled) {
|
||||
return NS_OK;
|
||||
@ -170,7 +177,7 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
|
||||
if (NS_IsMainThread() && mDeliveringMessage) {
|
||||
nsCString msg;
|
||||
message->ToString(msg);
|
||||
aMessage->ToString(msg);
|
||||
NS_WARNING(nsPrintfCString("Reentrancy error: some client attempted "
|
||||
"to display a message to the console while in a console listener. "
|
||||
"The following message was discarded: \"%s\"", msg.get()).get());
|
||||
@ -178,10 +185,10 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
}
|
||||
|
||||
nsRefPtr<LogMessageRunnable> r;
|
||||
nsIConsoleMessage *retiredMessage;
|
||||
nsIConsoleMessage* retiredMessage;
|
||||
|
||||
if (sLoggingBuffered) {
|
||||
NS_ADDREF(message); // early, in case it's same as replaced below.
|
||||
NS_ADDREF(aMessage); // early, in case it's same as replaced below.
|
||||
}
|
||||
|
||||
/*
|
||||
@ -192,10 +199,9 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
#if defined(ANDROID)
|
||||
if (outputMode == OutputToLog)
|
||||
{
|
||||
if (aOutputMode == OutputToLog) {
|
||||
nsCString msg;
|
||||
message->ToString(msg);
|
||||
aMessage->ToString(msg);
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoConsole",
|
||||
"%s", msg.get());
|
||||
}
|
||||
@ -203,7 +209,7 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
#ifdef XP_WIN
|
||||
if (IsDebuggerPresent()) {
|
||||
nsString msg;
|
||||
message->GetMessageMoz(getter_Copies(msg));
|
||||
aMessage->GetMessageMoz(getter_Copies(msg));
|
||||
msg.AppendLiteral("\n");
|
||||
OutputDebugStringW(msg.get());
|
||||
}
|
||||
@ -217,7 +223,7 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
retiredMessage = mMessages[mCurrent];
|
||||
|
||||
if (sLoggingBuffered) {
|
||||
mMessages[mCurrent++] = message;
|
||||
mMessages[mCurrent++] = aMessage;
|
||||
if (mCurrent == mBufferSize) {
|
||||
mCurrent = 0; // wrap around.
|
||||
mFull = true;
|
||||
@ -225,15 +231,17 @@ nsConsoleService::LogMessageWithMode(nsIConsoleMessage *message, nsConsoleServic
|
||||
}
|
||||
|
||||
if (mListeners.Count() > 0) {
|
||||
r = new LogMessageRunnable(message, this);
|
||||
r = new LogMessageRunnable(aMessage, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (retiredMessage != nullptr)
|
||||
if (retiredMessage) {
|
||||
NS_RELEASE(retiredMessage);
|
||||
}
|
||||
|
||||
if (r)
|
||||
if (r) {
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -247,20 +255,20 @@ nsConsoleService::EnumerateListeners(ListenerHash::EnumReadFunction aFunction,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::LogStringMessage(const char16_t *message)
|
||||
nsConsoleService::LogStringMessage(const char16_t* aMessage)
|
||||
{
|
||||
if (!sLoggingEnabled) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsConsoleMessage> msg(new nsConsoleMessage(message));
|
||||
nsRefPtr<nsConsoleMessage> msg(new nsConsoleMessage(aMessage));
|
||||
return this->LogMessage(msg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::GetMessageArray(uint32_t *count, nsIConsoleMessage ***messages)
|
||||
nsConsoleService::GetMessageArray(uint32_t* aCount, nsIConsoleMessage*** aMessages)
|
||||
{
|
||||
nsIConsoleMessage **messageArray;
|
||||
nsIConsoleMessage** messageArray;
|
||||
|
||||
/*
|
||||
* Lock the whole method, as we don't want anyone mucking with mCurrent or
|
||||
@ -274,23 +282,23 @@ nsConsoleService::GetMessageArray(uint32_t *count, nsIConsoleMessage ***messages
|
||||
* and return a count of 0. This should result in a 0-length
|
||||
* array object when called from script.
|
||||
*/
|
||||
messageArray = (nsIConsoleMessage **)
|
||||
nsMemory::Alloc(sizeof (nsIConsoleMessage *));
|
||||
messageArray = (nsIConsoleMessage**)
|
||||
nsMemory::Alloc(sizeof(nsIConsoleMessage*));
|
||||
*messageArray = nullptr;
|
||||
*messages = messageArray;
|
||||
*count = 0;
|
||||
*aMessages = messageArray;
|
||||
*aCount = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t resultSize = mFull ? mBufferSize : mCurrent;
|
||||
messageArray =
|
||||
(nsIConsoleMessage **)nsMemory::Alloc((sizeof (nsIConsoleMessage *))
|
||||
* resultSize);
|
||||
(nsIConsoleMessage**)nsMemory::Alloc((sizeof(nsIConsoleMessage*))
|
||||
* resultSize);
|
||||
|
||||
if (messageArray == nullptr) {
|
||||
*messages = nullptr;
|
||||
*count = 0;
|
||||
if (!messageArray) {
|
||||
*aMessages = nullptr;
|
||||
*aCount = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -308,40 +316,40 @@ nsConsoleService::GetMessageArray(uint32_t *count, nsIConsoleMessage ***messages
|
||||
NS_ADDREF(messageArray[i]);
|
||||
}
|
||||
}
|
||||
*count = resultSize;
|
||||
*messages = messageArray;
|
||||
*aCount = resultSize;
|
||||
*aMessages = messageArray;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::RegisterListener(nsIConsoleListener *listener)
|
||||
nsConsoleService::RegisterListener(nsIConsoleListener* aListener)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_ERROR("nsConsoleService::RegisterListener is main thread only.");
|
||||
return NS_ERROR_NOT_SAME_THREAD;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(listener);
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(aListener);
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
if (mListeners.GetWeak(canonical)) {
|
||||
// Reregistering a listener isn't good
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mListeners.Put(canonical, listener);
|
||||
mListeners.Put(canonical, aListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::UnregisterListener(nsIConsoleListener *listener)
|
||||
nsConsoleService::UnregisterListener(nsIConsoleListener* aListener)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_ERROR("nsConsoleService::UnregisterListener is main thread only.");
|
||||
return NS_ERROR_NOT_SAME_THREAD;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(listener);
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(aListener);
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
@ -367,8 +375,9 @@ nsConsoleService::Reset()
|
||||
/*
|
||||
* Free all messages stored so far (cf. destructor)
|
||||
*/
|
||||
for (uint32_t i = 0; i < mBufferSize && mMessages[i] != nullptr; i++)
|
||||
for (uint32_t i = 0; i < mBufferSize && mMessages[i]; i++) {
|
||||
NS_RELEASE(mMessages[i]);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -28,13 +28,15 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICONSOLESERVICE
|
||||
|
||||
void SetIsDelivering() {
|
||||
void SetIsDelivering()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mDeliveringMessage);
|
||||
mDeliveringMessage = true;
|
||||
}
|
||||
|
||||
void SetDoneDelivering() {
|
||||
void SetDoneDelivering()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mDeliveringMessage);
|
||||
mDeliveringMessage = false;
|
||||
@ -48,7 +50,8 @@ public:
|
||||
SuppressLog,
|
||||
OutputToLog
|
||||
};
|
||||
virtual nsresult LogMessageWithMode(nsIConsoleMessage *message, OutputMode outputMode);
|
||||
virtual nsresult LogMessageWithMode(nsIConsoleMessage* aMessage,
|
||||
OutputMode aOutputMode);
|
||||
|
||||
typedef nsInterfaceHashtable<nsISupportsHashKey, nsIConsoleListener> ListenerHash;
|
||||
void EnumerateListeners(ListenerHash::EnumReadFunction aFunction, void* aClosure);
|
||||
@ -57,7 +60,7 @@ private:
|
||||
~nsConsoleService();
|
||||
|
||||
// Circular buffer of saved messages
|
||||
nsIConsoleMessage **mMessages;
|
||||
nsIConsoleMessage** mMessages;
|
||||
|
||||
// How big?
|
||||
uint32_t mBufferSize;
|
||||
|
@ -14,23 +14,25 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static int ReportException(EXCEPTION_POINTERS *aExceptionInfo)
|
||||
static int
|
||||
ReportException(EXCEPTION_POINTERS* aExceptionInfo)
|
||||
{
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
nsCOMPtr<nsICrashReporter> cr =
|
||||
do_GetService("@mozilla.org/toolkit/crash-reporter;1");
|
||||
if (cr)
|
||||
if (cr) {
|
||||
cr->WriteMinidumpForException(aExceptionInfo);
|
||||
}
|
||||
#endif
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
XPCOM_API(LRESULT)
|
||||
CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
CallWindowProcCrashProtected(WNDPROC aWndProc, HWND aHWnd, UINT aMsg,
|
||||
WPARAM aWParam, LPARAM aLParam)
|
||||
{
|
||||
MOZ_SEH_TRY {
|
||||
return wndProc(hWnd, msg, wParam, lParam);
|
||||
return aWndProc(aHWnd, aMsg, aWParam, aLParam);
|
||||
}
|
||||
MOZ_SEH_EXCEPT(ReportException(GetExceptionInformation())) {
|
||||
::TerminateProcess(::GetCurrentProcess(), 253);
|
||||
|
@ -14,8 +14,9 @@ namespace mozilla {
|
||||
|
||||
// Call a given window procedure, and catch any Win32 exceptions raised from it,
|
||||
// and report them as crashes.
|
||||
XPCOM_API(LRESULT) CallWindowProcCrashProtected(WNDPROC wndProc, HWND hWnd, UINT msg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
XPCOM_API(LRESULT) CallWindowProcCrashProtected(WNDPROC aWndProc, HWND aHWnd,
|
||||
UINT aMsg, WPARAM aWParam,
|
||||
LPARAM aLParam);
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@ void nsCycleCollector_finishAnyCurrentCollection();
|
||||
void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false);
|
||||
bool nsCycleCollector_doDeferredDeletion();
|
||||
|
||||
void nsCycleCollector_collect(nsICycleCollectorListener *aManualListener);
|
||||
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
|
||||
|
||||
// If aSliceTime is negative, the CC will run to completion. Otherwise,
|
||||
// aSliceTime will be used as the time budget for the slice, in ms.
|
||||
@ -57,7 +57,7 @@ uint32_t nsCycleCollector_suspectedCount();
|
||||
void nsCycleCollector_shutdown();
|
||||
|
||||
// Helpers for interacting with JS
|
||||
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime *aRt);
|
||||
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime* aRt);
|
||||
void nsCycleCollector_forgetJSRuntime();
|
||||
|
||||
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
|
||||
@ -65,9 +65,9 @@ void nsCycleCollector_forgetJSRuntime();
|
||||
{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
|
||||
|
||||
extern nsresult
|
||||
nsCycleCollectorLoggerConstructor(nsISupports* outer,
|
||||
nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void* *aInstancePtr);
|
||||
void** aInstancePtr);
|
||||
|
||||
namespace mozilla {
|
||||
namespace cyclecollector {
|
||||
|
@ -54,13 +54,13 @@
|
||||
#include "mozilla/mozalloc_abort.h"
|
||||
|
||||
static void
|
||||
Abort(const char *aMsg);
|
||||
Abort(const char* aMsg);
|
||||
|
||||
static void
|
||||
RealBreak();
|
||||
|
||||
static void
|
||||
Break(const char *aMsg);
|
||||
Break(const char* aMsg);
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
@ -72,7 +72,7 @@ Break(const char *aMsg);
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static const char *sMultiprocessDescription = nullptr;
|
||||
static const char* sMultiprocessDescription = nullptr;
|
||||
|
||||
static Atomic<int32_t> gAssertionCount;
|
||||
|
||||
@ -91,29 +91,29 @@ nsDebugImpl::Release()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDebugImpl::Assertion(const char *aStr, const char *aExpr,
|
||||
const char *aFile, int32_t aLine)
|
||||
nsDebugImpl::Assertion(const char* aStr, const char* aExpr,
|
||||
const char* aFile, int32_t aLine)
|
||||
{
|
||||
NS_DebugBreak(NS_DEBUG_ASSERTION, aStr, aExpr, aFile, aLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDebugImpl::Warning(const char *aStr, const char *aFile, int32_t aLine)
|
||||
nsDebugImpl::Warning(const char* aStr, const char* aFile, int32_t aLine)
|
||||
{
|
||||
NS_DebugBreak(NS_DEBUG_WARNING, aStr, nullptr, aFile, aLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDebugImpl::Break(const char *aFile, int32_t aLine)
|
||||
nsDebugImpl::Break(const char* aFile, int32_t aLine)
|
||||
{
|
||||
NS_DebugBreak(NS_DEBUG_BREAK, nullptr, nullptr, aFile, aLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDebugImpl::Abort(const char *aFile, int32_t aLine)
|
||||
nsDebugImpl::Abort(const char* aFile, int32_t aLine)
|
||||
{
|
||||
NS_DebugBreak(NS_DEBUG_ABORT, nullptr, nullptr, aFile, aLine);
|
||||
return NS_OK;
|
||||
@ -172,7 +172,7 @@ nsDebugImpl::GetIsDebuggerAttached(bool* aResult)
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsDebugImpl::SetMultiprocessMode(const char *aDesc)
|
||||
nsDebugImpl::SetMultiprocessMode(const char* aDesc)
|
||||
{
|
||||
sMultiprocessDescription = aDesc;
|
||||
}
|
||||
@ -184,7 +184,8 @@ nsDebugImpl::SetMultiprocessMode(const char *aDesc)
|
||||
*/
|
||||
static PRLogModuleInfo* gDebugLog;
|
||||
|
||||
static void InitLog(void)
|
||||
static void
|
||||
InitLog()
|
||||
{
|
||||
if (0 == gDebugLog) {
|
||||
gDebugLog = PR_NewLogModule("nsDebug");
|
||||
@ -201,44 +202,48 @@ enum nsAssertBehavior {
|
||||
NS_ASSERT_STACK_AND_ABORT
|
||||
};
|
||||
|
||||
static nsAssertBehavior GetAssertBehavior()
|
||||
static nsAssertBehavior
|
||||
GetAssertBehavior()
|
||||
{
|
||||
static nsAssertBehavior gAssertBehavior = NS_ASSERT_UNINITIALIZED;
|
||||
if (gAssertBehavior != NS_ASSERT_UNINITIALIZED)
|
||||
if (gAssertBehavior != NS_ASSERT_UNINITIALIZED) {
|
||||
return gAssertBehavior;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) && defined(MOZ_METRO)
|
||||
if (IsRunningInWindowsMetro())
|
||||
if (IsRunningInWindowsMetro()) {
|
||||
gAssertBehavior = NS_ASSERT_WARN;
|
||||
else
|
||||
} else {
|
||||
gAssertBehavior = NS_ASSERT_TRAP;
|
||||
}
|
||||
#elif defined(XP_WIN)
|
||||
gAssertBehavior = NS_ASSERT_TRAP;
|
||||
#else
|
||||
gAssertBehavior = NS_ASSERT_WARN;
|
||||
#endif
|
||||
|
||||
const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
|
||||
if (!assertString || !*assertString)
|
||||
const char* assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
|
||||
if (!assertString || !*assertString) {
|
||||
return gAssertBehavior;
|
||||
|
||||
if (!strcmp(assertString, "warn"))
|
||||
}
|
||||
if (!strcmp(assertString, "warn")) {
|
||||
return gAssertBehavior = NS_ASSERT_WARN;
|
||||
|
||||
if (!strcmp(assertString, "suspend"))
|
||||
}
|
||||
if (!strcmp(assertString, "suspend")) {
|
||||
return gAssertBehavior = NS_ASSERT_SUSPEND;
|
||||
|
||||
if (!strcmp(assertString, "stack"))
|
||||
}
|
||||
if (!strcmp(assertString, "stack")) {
|
||||
return gAssertBehavior = NS_ASSERT_STACK;
|
||||
|
||||
if (!strcmp(assertString, "abort"))
|
||||
}
|
||||
if (!strcmp(assertString, "abort")) {
|
||||
return gAssertBehavior = NS_ASSERT_ABORT;
|
||||
|
||||
if (!strcmp(assertString, "trap") || !strcmp(assertString, "break"))
|
||||
}
|
||||
if (!strcmp(assertString, "trap") || !strcmp(assertString, "break")) {
|
||||
return gAssertBehavior = NS_ASSERT_TRAP;
|
||||
|
||||
if (!strcmp(assertString, "stack-and-abort"))
|
||||
}
|
||||
if (!strcmp(assertString, "stack-and-abort")) {
|
||||
return gAssertBehavior = NS_ASSERT_STACK_AND_ABORT;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Unrecognized value of XPCOM_DEBUG_BREAK\n");
|
||||
return gAssertBehavior;
|
||||
@ -246,45 +251,51 @@ static nsAssertBehavior GetAssertBehavior()
|
||||
|
||||
struct FixedBuffer
|
||||
{
|
||||
FixedBuffer() : curlen(0) { buffer[0] = '\0'; }
|
||||
FixedBuffer() : curlen(0)
|
||||
{
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
char buffer[1000];
|
||||
uint32_t curlen;
|
||||
};
|
||||
|
||||
static int
|
||||
StuffFixedBuffer(void *closure, const char *buf, uint32_t len)
|
||||
StuffFixedBuffer(void* aClosure, const char* aBuf, uint32_t aLen)
|
||||
{
|
||||
if (!len)
|
||||
if (!aLen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FixedBuffer *fb = (FixedBuffer*) closure;
|
||||
FixedBuffer* fb = (FixedBuffer*)aClosure;
|
||||
|
||||
// strip the trailing null, we add it again later
|
||||
if (buf[len - 1] == '\0')
|
||||
--len;
|
||||
if (aBuf[aLen - 1] == '\0') {
|
||||
--aLen;
|
||||
}
|
||||
|
||||
if (fb->curlen + len >= sizeof(fb->buffer))
|
||||
len = sizeof(fb->buffer) - fb->curlen - 1;
|
||||
if (fb->curlen + aLen >= sizeof(fb->buffer)) {
|
||||
aLen = sizeof(fb->buffer) - fb->curlen - 1;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
memcpy(fb->buffer + fb->curlen, buf, len);
|
||||
fb->curlen += len;
|
||||
if (aLen) {
|
||||
memcpy(fb->buffer + fb->curlen, aBuf, aLen);
|
||||
fb->curlen += aLen;
|
||||
fb->buffer[fb->curlen] = '\0';
|
||||
}
|
||||
|
||||
return len;
|
||||
return aLen;
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(void)
|
||||
NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
|
||||
const char *aFile, int32_t aLine)
|
||||
NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
|
||||
const char* aFile, int32_t aLine)
|
||||
{
|
||||
InitLog();
|
||||
|
||||
FixedBuffer buf;
|
||||
PRLogModuleLevel ll = PR_LOG_WARNING;
|
||||
const char *sevString = "WARNING";
|
||||
const char* sevString = "WARNING";
|
||||
|
||||
switch (aSeverity) {
|
||||
case NS_DEBUG_ASSERTION:
|
||||
@ -317,17 +328,18 @@ NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
|
||||
|
||||
PrintToBuffer("%s: ", sevString);
|
||||
|
||||
if (aStr)
|
||||
if (aStr) {
|
||||
PrintToBuffer("%s: ", aStr);
|
||||
|
||||
if (aExpr)
|
||||
}
|
||||
if (aExpr) {
|
||||
PrintToBuffer("'%s', ", aExpr);
|
||||
|
||||
if (aFile)
|
||||
}
|
||||
if (aFile) {
|
||||
PrintToBuffer("file %s, ", aFile);
|
||||
|
||||
if (aLine != -1)
|
||||
}
|
||||
if (aLine != -1) {
|
||||
PrintToBuffer("line %d", aLine);
|
||||
}
|
||||
|
||||
# undef PrintToBuffer
|
||||
|
||||
@ -337,8 +349,9 @@ NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
|
||||
|
||||
// errors on platforms without a debugdlg ring a bell on stderr
|
||||
#if !defined(XP_WIN)
|
||||
if (ll != PR_LOG_WARNING)
|
||||
if (ll != PR_LOG_WARNING) {
|
||||
fprintf(stderr, "\07");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
@ -417,7 +430,7 @@ NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
|
||||
}
|
||||
|
||||
static void
|
||||
Abort(const char *aMsg)
|
||||
Abort(const char* aMsg)
|
||||
{
|
||||
mozalloc_abort(aMsg);
|
||||
}
|
||||
@ -455,12 +468,12 @@ RealBreak()
|
||||
|
||||
// Abort() calls this function, don't call it!
|
||||
static void
|
||||
Break(const char *aMsg)
|
||||
Break(const char* aMsg)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
static int ignoreDebugger;
|
||||
if (!ignoreDebugger) {
|
||||
const char *shouldIgnoreDebugger = getenv("XPCOM_DEBUG_DLG");
|
||||
const char* shouldIgnoreDebugger = getenv("XPCOM_DEBUG_DLG");
|
||||
ignoreDebugger = 1 + (shouldIgnoreDebugger && !strcmp(shouldIgnoreDebugger, "1"));
|
||||
}
|
||||
if ((ignoreDebugger == 2) || !::IsDebuggerPresent()) {
|
||||
@ -483,12 +496,12 @@ Break(const char *aMsg)
|
||||
si.wShowWindow = SW_SHOW;
|
||||
|
||||
// 2nd arg of CreateProcess is in/out
|
||||
wchar_t *msgCopy = (wchar_t*) _alloca((strlen(aMsg) + 1)*sizeof(wchar_t));
|
||||
wchar_t* msgCopy = (wchar_t*)_alloca((strlen(aMsg) + 1) * sizeof(wchar_t));
|
||||
wcscpy(msgCopy, NS_ConvertUTF8toUTF16(aMsg).get());
|
||||
|
||||
if(GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), executable, MAX_PATH) &&
|
||||
nullptr != (pName = wcsrchr(executable, '\\')) &&
|
||||
nullptr != wcscpy(pName + 1, L"windbgdlg.exe") &&
|
||||
if (GetModuleFileNameW(GetModuleHandleW(L"xpcom.dll"), executable, MAX_PATH) &&
|
||||
(pName = wcsrchr(executable, '\\')) != nullptr &&
|
||||
wcscpy(pName + 1, L"windbgdlg.exe") &&
|
||||
CreateProcessW(executable, msgCopy, nullptr, nullptr,
|
||||
false, DETACHED_PROCESS | NORMAL_PRIORITY_CLASS,
|
||||
nullptr, nullptr, &si, &pi)) {
|
||||
@ -498,7 +511,7 @@ Break(const char *aMsg)
|
||||
CloseHandle(pi.hThread);
|
||||
}
|
||||
|
||||
switch(code) {
|
||||
switch (code) {
|
||||
case IDABORT:
|
||||
//This should exit us
|
||||
raise(SIGABRT);
|
||||
@ -531,10 +544,11 @@ Break(const char *aMsg)
|
||||
static const nsDebugImpl kImpl;
|
||||
|
||||
nsresult
|
||||
nsDebugImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
nsDebugImpl::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NS_WARN_IF(outer))
|
||||
if (NS_WARN_IF(aOuter)) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
|
||||
return const_cast<nsDebugImpl*>(&kImpl)->
|
||||
QueryInterface(aIID, aInstancePtr);
|
||||
@ -566,10 +580,10 @@ NS_ErrorAccordingToNSPR()
|
||||
}
|
||||
|
||||
void
|
||||
NS_ABORT_OOM(size_t size)
|
||||
NS_ABORT_OOM(size_t aSize)
|
||||
{
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
CrashReporter::AnnotateOOMAllocationSize(size);
|
||||
CrashReporter::AnnotateOOMAllocationSize(aSize);
|
||||
#endif
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
@ -13,12 +13,15 @@
|
||||
class nsDebugImpl : public nsIDebug2
|
||||
{
|
||||
public:
|
||||
nsDebugImpl() {}
|
||||
nsDebugImpl()
|
||||
{
|
||||
}
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDEBUG
|
||||
NS_DECL_NSIDEBUG2
|
||||
|
||||
static nsresult Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
static nsresult Create(nsISupports* aOuter, const nsIID& aIID,
|
||||
void** aInstancePtr);
|
||||
|
||||
/*
|
||||
* Inform nsDebugImpl that we're in multiprocess mode.
|
||||
@ -26,7 +29,7 @@ public:
|
||||
* If aDesc is not nullptr, the string it points to must be
|
||||
* statically-allocated (i.e., it must be a string literal).
|
||||
*/
|
||||
static void SetMultiprocessMode(const char *aDesc);
|
||||
static void SetMultiprocessMode(const char* aDesc);
|
||||
};
|
||||
|
||||
|
||||
|
@ -65,7 +65,8 @@ DumpSignalHandler(int aSignum)
|
||||
|
||||
NS_IMPL_ISUPPORTS(FdWatcher, nsIObserver);
|
||||
|
||||
void FdWatcher::Init()
|
||||
void
|
||||
FdWatcher::Init()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -80,7 +81,8 @@ void FdWatcher::Init()
|
||||
// Implementations may call this function multiple times if they ensure that
|
||||
// it's safe to call OpenFd() multiple times and they call StopWatching()
|
||||
// first.
|
||||
void FdWatcher::StartWatching()
|
||||
void
|
||||
FdWatcher::StartWatching()
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
MOZ_ASSERT(mFd == -1);
|
||||
@ -99,7 +101,8 @@ void FdWatcher::StartWatching()
|
||||
|
||||
// Since implementations can call StartWatching() multiple times, they can of
|
||||
// course call StopWatching() multiple times.
|
||||
void FdWatcher::StopWatching()
|
||||
void
|
||||
FdWatcher::StopWatching()
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
|
||||
@ -129,8 +132,7 @@ SignalPipeWatcher::RegisterCallback(uint8_t aSignal,
|
||||
{
|
||||
MutexAutoLock lock(mSignalInfoLock);
|
||||
|
||||
for (SignalInfoArray::index_type i = 0; i < mSignalInfo.Length(); i++)
|
||||
{
|
||||
for (SignalInfoArray::index_type i = 0; i < mSignalInfo.Length(); ++i) {
|
||||
if (mSignalInfo[i].mSignal == aSignal) {
|
||||
LOG("Register Signal(%d) callback failed! (DUPLICATE)", aSignal);
|
||||
return;
|
||||
@ -171,7 +173,8 @@ SignalPipeWatcher::~SignalPipeWatcher()
|
||||
}
|
||||
}
|
||||
|
||||
int SignalPipeWatcher::OpenFd()
|
||||
int
|
||||
SignalPipeWatcher::OpenFd()
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
|
||||
@ -194,7 +197,8 @@ int SignalPipeWatcher::OpenFd()
|
||||
return readFd;
|
||||
}
|
||||
|
||||
void SignalPipeWatcher::StopWatching()
|
||||
void
|
||||
SignalPipeWatcher::StopWatching()
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
|
||||
@ -211,7 +215,8 @@ void SignalPipeWatcher::StopWatching()
|
||||
FdWatcher::StopWatching();
|
||||
}
|
||||
|
||||
void SignalPipeWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
void
|
||||
SignalPipeWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
|
||||
@ -226,7 +231,7 @@ void SignalPipeWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
{
|
||||
MutexAutoLock lock(mSignalInfoLock);
|
||||
for (SignalInfoArray::index_type i = 0; i < mSignalInfo.Length(); i++) {
|
||||
if(signum == mSignalInfo[i].mSignal) {
|
||||
if (signum == mSignalInfo[i].mSignal) {
|
||||
mSignalInfo[i].mCallback(signum);
|
||||
return;
|
||||
}
|
||||
@ -279,8 +284,7 @@ FifoWatcher::RegisterCallback(const nsCString& aCommand, FifoCallback aCallback)
|
||||
{
|
||||
MutexAutoLock lock(mFifoInfoLock);
|
||||
|
||||
for (FifoInfoArray::index_type i = 0; i < mFifoInfo.Length(); i++)
|
||||
{
|
||||
for (FifoInfoArray::index_type i = 0; i < mFifoInfo.Length(); ++i) {
|
||||
if (mFifoInfo[i].mCommand.Equals(aCommand)) {
|
||||
LOG("Register command(%s) callback failed! (DUPLICATE)", aCommand.get());
|
||||
return;
|
||||
@ -294,7 +298,8 @@ FifoWatcher::~FifoWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
int FifoWatcher::OpenFd()
|
||||
int
|
||||
FifoWatcher::OpenFd()
|
||||
{
|
||||
// If the memory_info_dumper.directory pref is specified, put the fifo
|
||||
// there. Otherwise, put it into the system's tmp directory.
|
||||
@ -310,18 +315,21 @@ int FifoWatcher::OpenFd()
|
||||
}
|
||||
} else {
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rv = file->AppendNative(NS_LITERAL_CSTRING("debug_info_trigger"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsAutoCString path;
|
||||
rv = file->GetNativePath(path);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// unlink might fail because the file doesn't exist, or for other reasons.
|
||||
// But we don't care it fails; any problems will be detected later, when we
|
||||
@ -365,7 +373,8 @@ int FifoWatcher::OpenFd()
|
||||
return fd;
|
||||
}
|
||||
|
||||
void FifoWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
void
|
||||
FifoWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
{
|
||||
MOZ_ASSERT(XRE_GetIOMessageLoop() == MessageLoopForIO::current());
|
||||
|
||||
@ -374,7 +383,7 @@ void FifoWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
do {
|
||||
// sizeof(buf) - 1 to leave space for the null-terminator.
|
||||
nread = read(aFd, buf, sizeof(buf));
|
||||
} while(nread == -1 && errno == EINTR);
|
||||
} while (nread == -1 && errno == EINTR);
|
||||
|
||||
if (nread == -1) {
|
||||
// We want to avoid getting into a situation where
|
||||
@ -409,7 +418,7 @@ void FifoWatcher::OnFileCanReadWithoutBlocking(int aFd)
|
||||
|
||||
for (FifoInfoArray::index_type i = 0; i < mFifoInfo.Length(); i++) {
|
||||
const nsCString commandStr = mFifoInfo[i].mCommand;
|
||||
if(inputStr == commandStr.get()) {
|
||||
if (inputStr == commandStr.get()) {
|
||||
mFifoInfo[i].mCallback(inputStr);
|
||||
return;
|
||||
}
|
||||
@ -431,7 +440,7 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
// For Android, first try the downloads directory which is world-readable
|
||||
// rather than the temp directory which is not.
|
||||
if (!*aFile) {
|
||||
char *env = PR_GetEnv("DOWNLOADS_DIRECTORY");
|
||||
char* env = PR_GetEnv("DOWNLOADS_DIRECTORY");
|
||||
if (env) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile);
|
||||
}
|
||||
@ -440,8 +449,9 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
nsresult rv;
|
||||
if (!*aFile) {
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
@ -451,8 +461,9 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
// subdirectory of the temp directory and chmod 777 that directory.
|
||||
if (aFoldername != EmptyCString()) {
|
||||
rv = (*aFile)->AppendNative(aFoldername);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// It's OK if this fails; that probably just means that the directory already
|
||||
// exists.
|
||||
@ -460,22 +471,27 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
|
||||
nsAutoCString dirPath;
|
||||
rv = (*aFile)->GetNativePath(dirPath);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR) {}
|
||||
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIFile> file(*aFile);
|
||||
|
||||
rv = file->AppendNative(aFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0666);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// Make this file world-read/writable; the permissions passed to the
|
||||
@ -483,10 +499,13 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
|
||||
// umask.
|
||||
nsAutoCString path;
|
||||
rv = file->GetNativePath(path);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
while (chmod(path.get(), 0666) == -1 && errno == EINTR) {}
|
||||
while (chmod(path.get(), 0666) == -1 && errno == EINTR)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
@ -34,8 +34,9 @@ using namespace mozilla;
|
||||
* Abstract base class for something which watches an fd and takes action when
|
||||
* we can read from it without blocking.
|
||||
*/
|
||||
class FdWatcher : public MessageLoopForIO::Watcher
|
||||
, public nsIObserver
|
||||
class FdWatcher
|
||||
: public MessageLoopForIO::Watcher
|
||||
, public nsIObserver
|
||||
{
|
||||
protected:
|
||||
MessageLoopForIO::FileDescriptorWatcher mReadWatcher;
|
||||
@ -99,7 +100,8 @@ public:
|
||||
};
|
||||
|
||||
typedef void (* FifoCallback)(const nsCString& inputStr);
|
||||
struct FifoInfo {
|
||||
struct FifoInfo
|
||||
{
|
||||
nsCString mCommand;
|
||||
FifoCallback mCallback;
|
||||
};
|
||||
@ -133,14 +135,16 @@ private:
|
||||
FifoWatcher(nsCString aPath)
|
||||
: mDirPath(aPath)
|
||||
, mFifoInfoLock("FifoWatcher.mFifoInfoLock")
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
mozilla::Mutex mFifoInfoLock; // protects mFifoInfo
|
||||
FifoInfoArray mFifoInfo;
|
||||
};
|
||||
|
||||
typedef void (* PipeCallback)(const uint8_t recvSig);
|
||||
struct SignalInfo {
|
||||
struct SignalInfo
|
||||
{
|
||||
uint8_t mSignal;
|
||||
PipeCallback mCallback;
|
||||
};
|
||||
|
@ -178,8 +178,10 @@
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline uint32_t NS_FAILED_impl(nsresult _nsresult) {
|
||||
return static_cast<uint32_t>(_nsresult) & 0x80000000;
|
||||
inline uint32_t
|
||||
NS_FAILED_impl(nsresult aErr)
|
||||
{
|
||||
return static_cast<uint32_t>(aErr) & 0x80000000;
|
||||
}
|
||||
#define NS_FAILED(_nsresult) ((bool)MOZ_UNLIKELY(NS_FAILED_impl(_nsresult)))
|
||||
#define NS_SUCCEEDED(_nsresult) ((bool)MOZ_LIKELY(!NS_FAILED_impl(_nsresult)))
|
||||
@ -227,14 +229,20 @@ NS_ErrorAccordingToNSPR();
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline uint16_t NS_ERROR_GET_CODE(nsresult err) {
|
||||
return uint32_t(err) & 0xffff;
|
||||
inline uint16_t
|
||||
NS_ERROR_GET_CODE(nsresult aErr)
|
||||
{
|
||||
return uint32_t(aErr) & 0xffff;
|
||||
}
|
||||
inline uint16_t NS_ERROR_GET_MODULE(nsresult err) {
|
||||
return ((uint32_t(err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff;
|
||||
inline uint16_t
|
||||
NS_ERROR_GET_MODULE(nsresult aErr)
|
||||
{
|
||||
return ((uint32_t(aErr) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff;
|
||||
}
|
||||
inline bool NS_ERROR_GET_SEVERITY(nsresult err) {
|
||||
return uint32_t(err) >> 31;
|
||||
inline bool
|
||||
NS_ERROR_GET_SEVERITY(nsresult aErr)
|
||||
{
|
||||
return uint32_t(aErr) >> 31;
|
||||
}
|
||||
#else
|
||||
#define NS_ERROR_GET_CODE(err) ((err) & 0xffff)
|
||||
|
@ -13,8 +13,9 @@ NS_IMPL_ISUPPORTS(nsErrorService, nsIErrorService)
|
||||
nsresult
|
||||
nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NS_WARN_IF(aOuter))
|
||||
if (NS_WARN_IF(aOuter)) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsRefPtr<nsErrorService> serv = new nsErrorService();
|
||||
return serv->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ NS_IMPL_ISUPPORTS(nsGZFileWriter, nsIGZFileWriter)
|
||||
nsGZFileWriter::nsGZFileWriter()
|
||||
: mInitialized(false)
|
||||
, mFinished(false)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
nsGZFileWriter::~nsGZFileWriter()
|
||||
{
|
||||
@ -34,23 +35,26 @@ NS_IMETHODIMP
|
||||
nsGZFileWriter::Init(nsIFile* aFile)
|
||||
{
|
||||
if (NS_WARN_IF(mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
NS_WARN_IF(mFinished)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get a FILE out of our nsIFile. Convert that into a file descriptor which
|
||||
// gzip can own. Then close our FILE, leaving only gzip's fd open.
|
||||
|
||||
FILE* file;
|
||||
nsresult rv = aFile->OpenANSIFileDesc("wb", &file);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mGZFile = gzdopen(dup(fileno(file)), "wb");
|
||||
fclose(file);
|
||||
|
||||
// gzdopen returns nullptr on error.
|
||||
if (NS_WARN_IF(!mGZFile))
|
||||
if (NS_WARN_IF(!mGZFile)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
@ -61,8 +65,9 @@ NS_IMETHODIMP
|
||||
nsGZFileWriter::Write(const nsACString& aStr)
|
||||
{
|
||||
if (NS_WARN_IF(!mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
NS_WARN_IF(mFinished)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// gzwrite uses a return value of 0 to indicate failure. Otherwise, it
|
||||
// returns the number of uncompressed bytes written. To ensure we can
|
||||
@ -76,8 +81,9 @@ nsGZFileWriter::Write(const nsACString& aStr)
|
||||
// always be either 0 or aStr.Length(), and we shouldn't have to call it
|
||||
// multiple times in order to get it to read the whole buffer.
|
||||
int rv = gzwrite(mGZFile, aStr.BeginReading(), aStr.Length());
|
||||
if (NS_WARN_IF(rv != static_cast<int>(aStr.Length())))
|
||||
if (NS_WARN_IF(rv != static_cast<int>(aStr.Length()))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -86,8 +92,9 @@ NS_IMETHODIMP
|
||||
nsGZFileWriter::Finish()
|
||||
{
|
||||
if (NS_WARN_IF(!mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
NS_WARN_IF(mFinished)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mFinished = true;
|
||||
gzclose(mGZFile);
|
||||
|
@ -33,7 +33,8 @@
|
||||
* and a reference counted memory model (AddRef/Release). This is
|
||||
* modelled after the win32 IUnknown API.
|
||||
*/
|
||||
class NS_NO_VTABLE nsISupports {
|
||||
class NS_NO_VTABLE nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISUPPORTS_IID)
|
||||
|
@ -16,9 +16,9 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
nsInterfaceRequestorAgg(nsIInterfaceRequestor *aFirst,
|
||||
nsIInterfaceRequestor *aSecond,
|
||||
nsIEventTarget *aConsumerTarget = nullptr)
|
||||
nsInterfaceRequestorAgg(nsIInterfaceRequestor* aFirst,
|
||||
nsIInterfaceRequestor* aSecond,
|
||||
nsIEventTarget* aConsumerTarget = nullptr)
|
||||
: mFirst(aFirst)
|
||||
, mSecond(aSecond)
|
||||
, mConsumerTarget(aConsumerTarget)
|
||||
@ -37,13 +37,15 @@ private:
|
||||
NS_IMPL_ISUPPORTS(nsInterfaceRequestorAgg, nsIInterfaceRequestor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInterfaceRequestorAgg::GetInterface(const nsIID &aIID, void **aResult)
|
||||
nsInterfaceRequestorAgg::GetInterface(const nsIID& aIID, void** aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NO_INTERFACE;
|
||||
if (mFirst)
|
||||
if (mFirst) {
|
||||
rv = mFirst->GetInterface(aIID, aResult);
|
||||
if (mSecond && NS_FAILED(rv))
|
||||
}
|
||||
if (mSecond && NS_FAILED(rv)) {
|
||||
rv = mSecond->GetInterface(aIID, aResult);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -62,26 +64,28 @@ nsInterfaceRequestorAgg::~nsInterfaceRequestorAgg()
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor *aFirst,
|
||||
nsIInterfaceRequestor *aSecond,
|
||||
nsIInterfaceRequestor **aResult)
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
|
||||
nsIInterfaceRequestor* aSecond,
|
||||
nsIInterfaceRequestor** aResult)
|
||||
{
|
||||
*aResult = new nsInterfaceRequestorAgg(aFirst, aSecond);
|
||||
if (!*aResult)
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor *aFirst,
|
||||
nsIInterfaceRequestor *aSecond,
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
|
||||
nsIInterfaceRequestor* aSecond,
|
||||
nsIEventTarget* aTarget,
|
||||
nsIInterfaceRequestor **aResult)
|
||||
nsIInterfaceRequestor** aResult)
|
||||
{
|
||||
*aResult = new nsInterfaceRequestorAgg(aFirst, aSecond, aTarget);
|
||||
if (!*aResult)
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -19,18 +19,18 @@ class nsIInterfaceRequestor;
|
||||
* destroyed.
|
||||
*/
|
||||
extern nsresult
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor *aFirst,
|
||||
nsIInterfaceRequestor *aSecond,
|
||||
nsIInterfaceRequestor **aResult);
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
|
||||
nsIInterfaceRequestor* aSecond,
|
||||
nsIInterfaceRequestor** aResult);
|
||||
|
||||
/**
|
||||
* Like the previous method, but aFirst and aSecond will be released on the
|
||||
* provided target thread.
|
||||
*/
|
||||
extern nsresult
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor *aFirst,
|
||||
nsIInterfaceRequestor *aSecond,
|
||||
nsIEventTarget *aTarget,
|
||||
nsIInterfaceRequestor **aResult);
|
||||
NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor* aFirst,
|
||||
nsIInterfaceRequestor* aSecond,
|
||||
nsIEventTarget* aTarget,
|
||||
nsIInterfaceRequestor** aResult);
|
||||
|
||||
#endif // !defined( nsInterfaceRequestorAgg_h__ )
|
||||
|
@ -10,14 +10,15 @@
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMacUtilsImpl, nsIMacUtils)
|
||||
|
||||
nsresult nsMacUtilsImpl::GetArchString(nsAString& archString)
|
||||
nsresult
|
||||
nsMacUtilsImpl::GetArchString(nsAString& aArchString)
|
||||
{
|
||||
if (!mBinaryArchs.IsEmpty()) {
|
||||
archString.Assign(mBinaryArchs);
|
||||
aArchString.Assign(mBinaryArchs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
archString.Truncate();
|
||||
aArchString.Truncate();
|
||||
|
||||
bool foundPPC = false,
|
||||
foundX86 = false,
|
||||
@ -44,14 +45,15 @@ nsresult nsMacUtilsImpl::GetArchString(nsAString& archString)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (archInt == kCFBundleExecutableArchitecturePPC)
|
||||
if (archInt == kCFBundleExecutableArchitecturePPC) {
|
||||
foundPPC = true;
|
||||
else if (archInt == kCFBundleExecutableArchitectureI386)
|
||||
} else if (archInt == kCFBundleExecutableArchitectureI386) {
|
||||
foundX86 = true;
|
||||
else if (archInt == kCFBundleExecutableArchitecturePPC64)
|
||||
} else if (archInt == kCFBundleExecutableArchitecturePPC64) {
|
||||
foundPPC64 = true;
|
||||
else if (archInt == kCFBundleExecutableArchitectureX86_64)
|
||||
} else if (archInt == kCFBundleExecutableArchitectureX86_64) {
|
||||
foundX86_64 = true;
|
||||
}
|
||||
}
|
||||
|
||||
::CFRelease(archList);
|
||||
@ -83,21 +85,24 @@ nsresult nsMacUtilsImpl::GetArchString(nsAString& archString)
|
||||
mBinaryArchs.Append(NS_LITERAL_STRING("x86_64"));
|
||||
}
|
||||
|
||||
archString.Assign(mBinaryArchs);
|
||||
aArchString.Assign(mBinaryArchs);
|
||||
|
||||
return (archString.IsEmpty() ? NS_ERROR_FAILURE : NS_OK);
|
||||
return (aArchString.IsEmpty() ? NS_ERROR_FAILURE : NS_OK);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMacUtilsImpl::GetIsUniversalBinary(bool *aIsUniversalBinary)
|
||||
NS_IMETHODIMP
|
||||
nsMacUtilsImpl::GetIsUniversalBinary(bool* aIsUniversalBinary)
|
||||
{
|
||||
if (NS_WARN_IF(!aIsUniversalBinary))
|
||||
if (NS_WARN_IF(!aIsUniversalBinary)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
*aIsUniversalBinary = false;
|
||||
|
||||
nsAutoString archString;
|
||||
nsresult rv = GetArchString(archString);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// The delimiter char in the arch string is '-', so if that character
|
||||
// is in the string we know we have multiple architectures.
|
||||
@ -106,14 +111,16 @@ NS_IMETHODIMP nsMacUtilsImpl::GetIsUniversalBinary(bool *aIsUniversalBinary)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMacUtilsImpl::GetArchitecturesInBinary(nsAString& archString)
|
||||
NS_IMETHODIMP
|
||||
nsMacUtilsImpl::GetArchitecturesInBinary(nsAString& aArchString)
|
||||
{
|
||||
return GetArchString(archString);
|
||||
return GetArchString(aArchString);
|
||||
}
|
||||
|
||||
/* readonly attribute boolean isTranslated; */
|
||||
// True when running under binary translation (Rosetta).
|
||||
NS_IMETHODIMP nsMacUtilsImpl::GetIsTranslated(bool *aIsTranslated)
|
||||
NS_IMETHODIMP
|
||||
nsMacUtilsImpl::GetIsTranslated(bool* aIsTranslated)
|
||||
{
|
||||
#ifdef __ppc__
|
||||
static bool sInitialized = false;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
@ -16,12 +16,16 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMACUTILS
|
||||
|
||||
nsMacUtilsImpl() {}
|
||||
nsMacUtilsImpl()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
~nsMacUtilsImpl() {}
|
||||
~nsMacUtilsImpl()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult GetArchString(nsAString& archString);
|
||||
nsresult GetArchString(nsAString& aArchString);
|
||||
|
||||
// A string containing a "-" delimited list of architectures
|
||||
// in our binary.
|
||||
|
@ -29,21 +29,21 @@ static nsMemoryImpl sGlobalMemory;
|
||||
NS_IMPL_QUERY_INTERFACE(nsMemoryImpl, nsIMemory)
|
||||
|
||||
NS_IMETHODIMP_(void*)
|
||||
nsMemoryImpl::Alloc(size_t size)
|
||||
nsMemoryImpl::Alloc(size_t aSize)
|
||||
{
|
||||
return NS_Alloc(size);
|
||||
return NS_Alloc(aSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void*)
|
||||
nsMemoryImpl::Realloc(void* ptr, size_t size)
|
||||
nsMemoryImpl::Realloc(void* aPtr, size_t aSize)
|
||||
{
|
||||
return NS_Realloc(ptr, size);
|
||||
return NS_Realloc(aPtr, aSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
nsMemoryImpl::Free(void* ptr)
|
||||
nsMemoryImpl::Free(void* aPtr)
|
||||
{
|
||||
NS_Free(ptr);
|
||||
NS_Free(aPtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -53,21 +53,21 @@ nsMemoryImpl::HeapMinimize(bool aImmediate)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryImpl::IsLowMemory(bool *result)
|
||||
nsMemoryImpl::IsLowMemory(bool* aResult)
|
||||
{
|
||||
NS_ERROR("IsLowMemory is deprecated. See bug 592308.");
|
||||
*result = false;
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryImpl::IsLowMemoryPlatform(bool *result)
|
||||
nsMemoryImpl::IsLowMemoryPlatform(bool* aResult)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
static int sLowMemory = -1; // initialize to unknown, lazily evaluate to 0 or 1
|
||||
if (sLowMemory == -1) {
|
||||
sLowMemory = 0; // assume "not low memory" in case file operations fail
|
||||
*result = false;
|
||||
*aResult = false;
|
||||
|
||||
// check if MemTotal from /proc/meminfo is less than LOW_MEMORY_THRESHOLD_KB
|
||||
FILE* fd = fopen("/proc/meminfo", "r");
|
||||
@ -84,18 +84,19 @@ nsMemoryImpl::IsLowMemoryPlatform(bool *result)
|
||||
}
|
||||
sLowMemory = (mem < LOW_MEMORY_THRESHOLD_KB) ? 1 : 0;
|
||||
}
|
||||
*result = (sLowMemory == 1);
|
||||
*aResult = (sLowMemory == 1);
|
||||
#else
|
||||
*result = false;
|
||||
*aResult = false;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*static*/ nsresult
|
||||
nsMemoryImpl::Create(nsISupports* outer, const nsIID& aIID, void **aResult)
|
||||
nsMemoryImpl::Create(nsISupports* aOuter, const nsIID& aIID, void** aResult)
|
||||
{
|
||||
if (NS_WARN_IF(outer))
|
||||
if (NS_WARN_IF(aOuter)) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
return sGlobalMemory.QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
@ -115,8 +116,9 @@ nsMemoryImpl::FlushMemory(const char16_t* aReason, bool aImmediate)
|
||||
}
|
||||
|
||||
bool lastVal = sIsFlushing.exchange(true);
|
||||
if (lastVal)
|
||||
if (lastVal) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRIntervalTime now = PR_IntervalNow();
|
||||
|
||||
@ -124,8 +126,7 @@ nsMemoryImpl::FlushMemory(const char16_t* aReason, bool aImmediate)
|
||||
// UI thread an run 'em asynchronously.
|
||||
if (aImmediate) {
|
||||
rv = RunFlushers(aReason);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Don't broadcast more than once every 1000ms to avoid being noisy
|
||||
if (PR_IntervalToMicroseconds(now - sLastFlushTime) > 1000) {
|
||||
sFlushEvent.mReason = aReason;
|
||||
@ -151,17 +152,17 @@ nsMemoryImpl::RunFlushers(const char16_t* aReason)
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
os->EnumerateObservers("memory-pressure", getter_AddRefs(e));
|
||||
|
||||
if ( e ) {
|
||||
if (e) {
|
||||
nsCOMPtr<nsIObserver> observer;
|
||||
bool loop = true;
|
||||
|
||||
while (NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop)
|
||||
{
|
||||
while (NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop) {
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
e->GetNext(getter_AddRefs(supports));
|
||||
|
||||
if (!supports)
|
||||
if (!supports) {
|
||||
continue;
|
||||
}
|
||||
|
||||
observer = do_QueryInterface(supports);
|
||||
observer->Observe(observer, "memory-pressure", aReason);
|
||||
@ -174,8 +175,16 @@ nsMemoryImpl::RunFlushers(const char16_t* aReason)
|
||||
}
|
||||
|
||||
// XXX need NS_IMPL_STATIC_ADDREF/RELEASE
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) nsMemoryImpl::FlushEvent::AddRef() { return 2; }
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) nsMemoryImpl::FlushEvent::Release() { return 1; }
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsMemoryImpl::FlushEvent::AddRef()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
nsMemoryImpl::FlushEvent::Release()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
NS_IMPL_QUERY_INTERFACE(nsMemoryImpl::FlushEvent, nsIRunnable)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -195,25 +204,25 @@ nsMemoryImpl::FlushEvent
|
||||
nsMemoryImpl::sFlushEvent;
|
||||
|
||||
XPCOM_API(void*)
|
||||
NS_Alloc(size_t size)
|
||||
NS_Alloc(size_t aSize)
|
||||
{
|
||||
return moz_xmalloc(size);
|
||||
return moz_xmalloc(aSize);
|
||||
}
|
||||
|
||||
XPCOM_API(void*)
|
||||
NS_Realloc(void* ptr, size_t size)
|
||||
NS_Realloc(void* aPtr, size_t aSize)
|
||||
{
|
||||
return moz_xrealloc(ptr, size);
|
||||
return moz_xrealloc(aPtr, aSize);
|
||||
}
|
||||
|
||||
XPCOM_API(void)
|
||||
NS_Free(void* ptr)
|
||||
NS_Free(void* aPtr)
|
||||
{
|
||||
moz_free(ptr);
|
||||
moz_free(aPtr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_GetMemoryManager(nsIMemory* *result)
|
||||
NS_GetMemoryManager(nsIMemory** aResult)
|
||||
{
|
||||
return sGlobalMemory.QueryInterface(NS_GET_IID(nsIMemory), (void**) result);
|
||||
return sGlobalMemory.QueryInterface(NS_GET_IID(nsIMemory), (void**)aResult);
|
||||
}
|
||||
|
@ -21,19 +21,26 @@ class nsMemoryImpl : public nsIMemory
|
||||
public:
|
||||
// We don't use the generic macros because we are a special static object
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) { return 1; }
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release(void) { return 1; }
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_DECL_NSIMEMORY
|
||||
|
||||
static nsresult Create(nsISupports* outer,
|
||||
const nsIID& aIID, void **aResult);
|
||||
static nsresult Create(nsISupports* aOuter,
|
||||
const nsIID& aIID, void** aResult);
|
||||
|
||||
NS_HIDDEN_(nsresult) FlushMemory(const char16_t* aReason, bool aImmediate);
|
||||
NS_HIDDEN_(nsresult) RunFlushers(const char16_t* aReason);
|
||||
|
||||
protected:
|
||||
struct FlushEvent : public nsIRunnable {
|
||||
struct FlushEvent : public nsIRunnable
|
||||
{
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIRUNNABLE
|
||||
const char16_t* mReason;
|
||||
|
@ -58,11 +58,13 @@ public:
|
||||
bool aMinimizeMemoryUsage)
|
||||
: mIdentifier(aIdentifier)
|
||||
, mMinimizeMemoryUsage(aMinimizeMemoryUsage)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
||||
nsCOMPtr<nsIMemoryInfoDumper> dumper =
|
||||
do_GetService("@mozilla.org/memory-info-dumper;1");
|
||||
dumper->DumpMemoryInfoToTempDir(mIdentifier, mMinimizeMemoryUsage);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -81,7 +83,8 @@ public:
|
||||
: mIdentifier(aIdentifier)
|
||||
, mDumpAllTraces(aDumpAllTraces)
|
||||
, mDumpChildProcesses(aDumpChildProcesses)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
@ -164,20 +167,22 @@ void doGCCCDump(const uint8_t recvSig)
|
||||
#if defined(MOZ_SUPPORTS_FIFO) // {
|
||||
namespace {
|
||||
|
||||
void doMemoryReport(const nsCString& inputStr)
|
||||
void
|
||||
doMemoryReport(const nsCString& aInputStr)
|
||||
{
|
||||
bool doMMUMemoryReport = inputStr == NS_LITERAL_CSTRING("minimize memory report");
|
||||
LOG("FifoWatcher(command:%s) dispatching memory report runnable.", inputStr.get());
|
||||
bool doMMUMemoryReport = aInputStr == NS_LITERAL_CSTRING("minimize memory report");
|
||||
LOG("FifoWatcher(command:%s) dispatching memory report runnable.", aInputStr.get());
|
||||
nsRefPtr<DumpMemoryInfoToTempDirRunnable> runnable =
|
||||
new DumpMemoryInfoToTempDirRunnable(/* identifier = */ EmptyString(),
|
||||
doMMUMemoryReport);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
void doGCCCDump(const nsCString& inputStr)
|
||||
void
|
||||
doGCCCDump(const nsCString& aInputStr)
|
||||
{
|
||||
bool doAllTracesGCCCDump = inputStr == NS_LITERAL_CSTRING("gc log");
|
||||
LOG("FifoWatcher(command:%s) dispatching GC/CC log runnable.", inputStr.get());
|
||||
bool doAllTracesGCCCDump = aInputStr == NS_LITERAL_CSTRING("gc log");
|
||||
LOG("FifoWatcher(command:%s) dispatching GC/CC log runnable.", aInputStr.get());
|
||||
nsRefPtr<GCAndCCLogDumpRunnable> runnable =
|
||||
new GCAndCCLogDumpRunnable(/* identifier = */ EmptyString(),
|
||||
doAllTracesGCCCDump,
|
||||
@ -185,7 +190,8 @@ void doGCCCDump(const nsCString& inputStr)
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
bool SetupFifo()
|
||||
bool
|
||||
SetupFifo()
|
||||
{
|
||||
static bool fifoCallbacksRegistered = false;
|
||||
|
||||
@ -212,7 +218,8 @@ bool SetupFifo()
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnFifoEnabledChange(const char* /*unused*/, void* /*unused*/)
|
||||
void
|
||||
OnFifoEnabledChange(const char* /*unused*/, void* /*unused*/)
|
||||
{
|
||||
LOG("%s changed", FifoWatcher::kPrefName);
|
||||
if (SetupFifo()) {
|
||||
@ -333,12 +340,13 @@ public:
|
||||
DumpReportCallback(nsGZFileWriter* aWriter)
|
||||
: mIsFirst(true)
|
||||
, mWriter(aWriter)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Callback(const nsACString &aProcess, const nsACString &aPath,
|
||||
NS_IMETHOD Callback(const nsACString& aProcess, const nsACString& aPath,
|
||||
int32_t aKind, int32_t aUnits, int64_t aAmount,
|
||||
const nsACString &aDescription,
|
||||
nsISupports *aData)
|
||||
const nsACString& aDescription,
|
||||
nsISupports* aData)
|
||||
{
|
||||
if (mIsFirst) {
|
||||
DUMP(mWriter, "[");
|
||||
@ -357,7 +365,7 @@ public:
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
// We're the main process.
|
||||
process.AssignLiteral("Main Process");
|
||||
} else if (ContentChild *cc = ContentChild::GetSingleton()) {
|
||||
} else if (ContentChild* cc = ContentChild::GetSingleton()) {
|
||||
// Try to get the process name from ContentChild.
|
||||
cc->GetProcessName(process);
|
||||
}
|
||||
@ -408,8 +416,8 @@ NS_IMPL_ISUPPORTS(DumpReportCallback, nsIHandleReportCallback)
|
||||
} // namespace mozilla
|
||||
|
||||
static void
|
||||
MakeFilename(const char *aPrefix, const nsAString &aIdentifier,
|
||||
const char *aSuffix, nsACString &aResult)
|
||||
MakeFilename(const char* aPrefix, const nsAString& aIdentifier,
|
||||
const char* aSuffix, nsACString& aResult)
|
||||
{
|
||||
aResult = nsPrintfCString("%s-%s-%d.%s",
|
||||
aPrefix,
|
||||
@ -424,15 +432,16 @@ struct DMDWriteState
|
||||
char mBuf[kBufSize];
|
||||
nsRefPtr<nsGZFileWriter> mGZWriter;
|
||||
|
||||
DMDWriteState(nsGZFileWriter *aGZWriter)
|
||||
DMDWriteState(nsGZFileWriter* aGZWriter)
|
||||
: mGZWriter(aGZWriter)
|
||||
{}
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static void
|
||||
DMDWrite(void* aState, const char* aFmt, va_list ap)
|
||||
{
|
||||
DMDWriteState *state = (DMDWriteState*)aState;
|
||||
DMDWriteState* state = (DMDWriteState*)aState;
|
||||
vsnprintf(state->mBuf, state->kBufSize, aFmt, ap);
|
||||
unused << state->mGZWriter->Write(state->mBuf);
|
||||
}
|
||||
@ -452,8 +461,9 @@ DumpHeader(nsIGZFileWriter* aWriter)
|
||||
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
if (NS_WARN_IF(!mgr))
|
||||
if (NS_WARN_IF(!mgr)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
DUMP(aWriter, mgr->GetHasMozMallocUsableSize() ? "true" : "false");
|
||||
DUMP(aWriter, ",\n");
|
||||
@ -475,17 +485,18 @@ class TempDirMemoryFinishCallback MOZ_FINAL : public nsIFinishReportingCallback
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
TempDirMemoryFinishCallback(nsGZFileWriter *aWriter,
|
||||
nsIFile *aTmpFile,
|
||||
const nsCString &aFilename,
|
||||
const nsString &aIdentifier)
|
||||
TempDirMemoryFinishCallback(nsGZFileWriter* aWriter,
|
||||
nsIFile* aTmpFile,
|
||||
const nsCString& aFilename,
|
||||
const nsString& aIdentifier)
|
||||
: mrWriter(aWriter)
|
||||
, mrTmpFile(aTmpFile)
|
||||
, mrFilename(aFilename)
|
||||
, mIdentifier(aIdentifier)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Callback(nsISupports *aData);
|
||||
NS_IMETHOD Callback(nsISupports* aData);
|
||||
|
||||
private:
|
||||
nsRefPtr<nsGZFileWriter> mrWriter;
|
||||
@ -539,18 +550,21 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
||||
mrFilename,
|
||||
getter_AddRefs(mrTmpFile),
|
||||
NS_LITERAL_CSTRING("memory-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||
rv = mrWriter->Init(mrTmpFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Dump the memory reports to the file.
|
||||
rv = DumpHeader(mrWriter);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Process reporters.
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||
@ -567,7 +581,7 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
nsresult
|
||||
nsMemoryInfoDumper::DumpDMD(const nsAString &aIdentifier)
|
||||
nsMemoryInfoDumper::DumpDMD(const nsAString& aIdentifier)
|
||||
{
|
||||
if (!dmd::IsEnabled()) {
|
||||
return NS_OK;
|
||||
@ -589,13 +603,15 @@ nsMemoryInfoDumper::DumpDMD(const nsAString &aIdentifier)
|
||||
rv = nsDumpUtils::OpenTempFile(dmdFilename,
|
||||
getter_AddRefs(dmdFile),
|
||||
NS_LITERAL_CSTRING("memory-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRefPtr<nsGZFileWriter> dmdWriter = new nsGZFileWriter();
|
||||
rv = dmdWriter->Init(dmdFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Dump DMD output to the file.
|
||||
|
||||
@ -610,13 +626,12 @@ nsMemoryInfoDumper::DumpDMD(const nsAString &aIdentifier)
|
||||
#endif // MOZ_DMD
|
||||
|
||||
NS_IMETHODIMP
|
||||
TempDirMemoryFinishCallback::Callback(nsISupports *aData)
|
||||
TempDirMemoryFinishCallback::Callback(nsISupports* aData)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = DumpFooter(mrWriter);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
nsresult rv = DumpFooter(mrWriter);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// The call to Finish() deallocates the memory allocated by mrWriter's first
|
||||
// DUMP() call (within DumpProcessMemoryReportsToGZFileWriter()). Because
|
||||
@ -624,54 +639,62 @@ TempDirMemoryFinishCallback::Callback(nsISupports *aData)
|
||||
// them -- by "heap-allocated" if nothing else -- we want DMD to see it as
|
||||
// well. So we deliberately don't call Finish() until after DMD finishes.
|
||||
rv = mrWriter->Finish();
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Rename the memory reports file, now that we're done writing all the files.
|
||||
// Its final name is "memory-report<-identifier>-<pid>.json.gz".
|
||||
|
||||
nsCOMPtr<nsIFile> mrFinalFile;
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mrFinalFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
rv = mrFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = mrFinalFile->AppendNative(mrFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mrFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString mrActualFinalFilename;
|
||||
rv = mrFinalFile->GetLeafName(mrActualFinalFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mrTmpFile->MoveTo(/* directory */ nullptr, mrActualFinalFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Write a message to the console.
|
||||
|
||||
nsCOMPtr<nsIConsoleService> cs =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsString path;
|
||||
mrTmpFile->GetPath(path);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsString msg = NS_LITERAL_STRING(
|
||||
"nsIMemoryInfoDumper dumped reports to ");
|
||||
nsString msg = NS_LITERAL_STRING("nsIMemoryInfoDumper dumped reports to ");
|
||||
msg.Append(path);
|
||||
return cs->LogStringMessage(msg.get());
|
||||
}
|
||||
@ -687,7 +710,8 @@ public:
|
||||
nsISupports* aFinishDumpingData)
|
||||
: mFinishDumping(aFinishDumping)
|
||||
, mFinishDumpingData(aFinishDumpingData)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Callback(nsISupports* aData)
|
||||
{
|
||||
@ -726,34 +750,40 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
||||
|
||||
nsCOMPtr<nsIFile> mrFile;
|
||||
nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(mrFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mrFile->InitWithPath(aFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool exists;
|
||||
rv = mrFile->Exists(&exists);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
rv = mrFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the memory reports to the file.
|
||||
|
||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||
rv = mrWriter->Init(mrFile);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = DumpHeader(mrWriter);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Process reports and finish up.
|
||||
nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback(mrWriter);
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
static void Initialize();
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
static nsresult DumpDMD(const nsAString &aIdentifier);
|
||||
static nsresult DumpDMD(const nsAString& aIdentifier);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -215,8 +215,9 @@ static nsresult
|
||||
GetKinfoVmentrySelf(int64_t* aPrss, uint64_t* aMaxreg)
|
||||
{
|
||||
int cnt;
|
||||
struct kinfo_vmentry *vmmap, *kve;
|
||||
if ((vmmap = kinfo_getvmmap(getpid(), &cnt)) == nullptr) {
|
||||
struct kinfo_vmentry* vmmap;
|
||||
struct kinfo_vmentry* kve;
|
||||
if (!(vmmap = kinfo_getvmmap(getpid(), &cnt))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (aPrss) {
|
||||
@ -680,7 +681,7 @@ NS_IMPL_ISUPPORTS(PageFaultsHardReporter, nsIMemoryReporter)
|
||||
static int64_t
|
||||
HeapOverheadRatio(jemalloc_stats_t* aStats)
|
||||
{
|
||||
return (int64_t) 10000 *
|
||||
return (int64_t)10000 *
|
||||
(aStats->waste + aStats->bookkeeping + aStats->page_cache) /
|
||||
((double)aStats->allocated);
|
||||
}
|
||||
@ -1042,7 +1043,7 @@ nsMemoryReporterManager::GetReportsExtended(
|
||||
nsresult
|
||||
nsMemoryReporterManager::StartGettingReports()
|
||||
{
|
||||
GetReportsState *s = mGetReportsState;
|
||||
GetReportsState* s = mGetReportsState;
|
||||
|
||||
// Get reports for this process.
|
||||
GetReportsForThisProcessExtended(s->mHandleReport, s->mHandleReportData,
|
||||
@ -1060,7 +1061,7 @@ typedef nsCOMArray<nsIMemoryReporter> MemoryReporterArray;
|
||||
static PLDHashOperator
|
||||
StrongEnumerator(nsRefPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
|
||||
{
|
||||
MemoryReporterArray *allReporters = static_cast<MemoryReporterArray*>(aData);
|
||||
MemoryReporterArray* allReporters = static_cast<MemoryReporterArray*>(aData);
|
||||
allReporters->AppendElement(aElem->GetKey());
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
@ -1068,7 +1069,7 @@ StrongEnumerator(nsRefPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
|
||||
static PLDHashOperator
|
||||
WeakEnumerator(nsPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
|
||||
{
|
||||
MemoryReporterArray *allReporters = static_cast<MemoryReporterArray*>(aData);
|
||||
MemoryReporterArray* allReporters = static_cast<MemoryReporterArray*>(aData);
|
||||
allReporters->AppendElement(aElem->GetKey());
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
@ -1263,8 +1264,7 @@ nsMemoryReporterManager::RegisterReporterHelper(
|
||||
}
|
||||
|
||||
if (mStrongReporters->Contains(aReporter) ||
|
||||
mWeakReporters->Contains(aReporter))
|
||||
{
|
||||
mWeakReporters->Contains(aReporter)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -1402,7 +1402,9 @@ class Int64Wrapper MOZ_FINAL : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
Int64Wrapper() : mValue(0) { }
|
||||
Int64Wrapper() : mValue(0)
|
||||
{
|
||||
}
|
||||
int64_t mValue;
|
||||
};
|
||||
|
||||
@ -1426,8 +1428,7 @@ public:
|
||||
// do that for distinguished amounts.
|
||||
if (aPath.Equals("heap-allocated") ||
|
||||
(aKind == nsIMemoryReporter::KIND_NONHEAP &&
|
||||
PromiseFlatCString(aPath).Find("explicit") == 0))
|
||||
{
|
||||
PromiseFlatCString(aPath).Find("explicit") == 0)) {
|
||||
Int64Wrapper* wrappedInt64 = static_cast<Int64Wrapper*>(aWrappedExplicit);
|
||||
wrappedInt64->mValue += aAmount;
|
||||
}
|
||||
@ -1510,7 +1511,8 @@ nsMemoryReporterManager::GetResidentFast(int64_t* aAmount)
|
||||
}
|
||||
|
||||
/*static*/
|
||||
int64_t nsMemoryReporterManager::ResidentFast()
|
||||
int64_t
|
||||
nsMemoryReporterManager::ResidentFast()
|
||||
{
|
||||
#ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS
|
||||
int64_t amount;
|
||||
@ -1658,7 +1660,8 @@ public:
|
||||
MinimizeMemoryUsageRunnable(nsIRunnable* aCallback)
|
||||
: mCallback(aCallback)
|
||||
, mRemainingIters(sNumIters)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
|
@ -39,8 +39,8 @@ public:
|
||||
return static_cast<nsMemoryReporterManager*>(imgr.get());
|
||||
}
|
||||
|
||||
typedef nsTHashtable<nsRefPtrHashKey<nsIMemoryReporter> > StrongReportersTable;
|
||||
typedef nsTHashtable<nsPtrHashKey<nsIMemoryReporter> > WeakReportersTable;
|
||||
typedef nsTHashtable<nsRefPtrHashKey<nsIMemoryReporter>> StrongReportersTable;
|
||||
typedef nsTHashtable<nsPtrHashKey<nsIMemoryReporter>> WeakReportersTable;
|
||||
|
||||
void IncrementNumChildProcesses();
|
||||
void DecrementNumChildProcesses();
|
||||
@ -117,7 +117,7 @@ public:
|
||||
// more.
|
||||
//
|
||||
void HandleChildReports(
|
||||
const uint32_t& generation,
|
||||
const uint32_t& aGeneration,
|
||||
const InfallibleTArray<mozilla::dom::MemoryReport>& aChildReports);
|
||||
nsresult FinishReporting();
|
||||
|
||||
@ -139,7 +139,10 @@ public:
|
||||
|
||||
mozilla::InfallibleAmountFn mGhostWindows;
|
||||
|
||||
AmountFns() { mozilla::PodZero(this); }
|
||||
AmountFns()
|
||||
{
|
||||
mozilla::PodZero(this);
|
||||
}
|
||||
};
|
||||
AmountFns mAmountFns;
|
||||
|
||||
@ -202,7 +205,7 @@ private:
|
||||
nsISupports* aHandleReportData,
|
||||
nsIFinishReportingCallback* aFinishReporting,
|
||||
nsISupports* aFinishReportingData,
|
||||
const nsAString &aDMDDumpIdent)
|
||||
const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration)
|
||||
, mTimer(aTimer)
|
||||
, mNumChildProcesses(aNumChildProcesses)
|
||||
|
@ -33,7 +33,9 @@ class MessageLoopIdleTask
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(MessageLoopIdleTask)
|
||||
MessageLoopIdleTask(nsIRunnable* aTask, uint32_t aEnsureRunsAfterMS);
|
||||
virtual ~MessageLoopIdleTask() {}
|
||||
virtual ~MessageLoopIdleTask()
|
||||
{
|
||||
}
|
||||
virtual void Run();
|
||||
|
||||
private:
|
||||
@ -88,8 +90,9 @@ nsresult
|
||||
MessageLoopIdleTask::Init(uint32_t aEnsureRunsAfterMS)
|
||||
{
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (NS_WARN_IF(!mTimer))
|
||||
if (NS_WARN_IF(!mTimer)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsRefPtr<MessageLoopTimerCallback> callback =
|
||||
new MessageLoopTimerCallback(this);
|
||||
@ -118,7 +121,8 @@ MessageLoopIdleTask::Run()
|
||||
|
||||
MessageLoopTimerCallback::MessageLoopTimerCallback(MessageLoopIdleTask* aTask)
|
||||
: mTask(aTask->asWeakPtr())
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MessageLoopTimerCallback::Notify(nsITimer* aTimer)
|
||||
@ -155,8 +159,9 @@ nsMessageLoopConstructor(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
if (NS_WARN_IF(aOuter))
|
||||
if (NS_WARN_IF(aOuter)) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsISupports* messageLoop = new nsMessageLoop();
|
||||
return messageLoop->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ class nsMessageLoop : public nsIMessageLoop
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMESSAGELOOP
|
||||
|
||||
virtual ~nsMessageLoop() {}
|
||||
virtual ~nsMessageLoop()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#define NS_MESSAGE_LOOP_CID \
|
||||
@ -22,6 +24,6 @@ class nsMessageLoop : public nsIMessageLoop
|
||||
{0x93, 0x9e, 0x6a, 0x81, 0x9e, 0x6c, 0x24, 0x8f}}
|
||||
|
||||
extern nsresult
|
||||
nsMessageLoopConstructor(nsISupports* outer,
|
||||
nsMessageLoopConstructor(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void* *aInstancePtr);
|
||||
void** aInstancePtr);
|
||||
|
@ -41,7 +41,8 @@
|
||||
// This file can only be included in an Objective-C context.
|
||||
|
||||
__attribute__((unused))
|
||||
static void nsObjCExceptionLog(NSException* aException)
|
||||
static void
|
||||
nsObjCExceptionLog(NSException* aException)
|
||||
{
|
||||
NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]",
|
||||
[aException name], [aException reason]);
|
||||
@ -50,31 +51,34 @@ static void nsObjCExceptionLog(NSException* aException)
|
||||
// Attach exception info to the crash report.
|
||||
nsCOMPtr<nsICrashReporter> crashReporter =
|
||||
do_GetService("@mozilla.org/toolkit/crash-reporter;1");
|
||||
if (crashReporter)
|
||||
if (crashReporter) {
|
||||
crashReporter->AppendObjCExceptionInfoToAppNotes(static_cast<void*>(aException));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@try {
|
||||
// Try to get stack information out of the exception. 10.5 returns the stack
|
||||
// info with the callStackReturnAddresses selector.
|
||||
NSArray *stackTrace = nil;
|
||||
NSArray* stackTrace = nil;
|
||||
if ([aException respondsToSelector:@selector(callStackReturnAddresses)]) {
|
||||
NSArray* addresses = (NSArray*)
|
||||
[aException performSelector:@selector(callStackReturnAddresses)];
|
||||
if ([addresses count])
|
||||
if ([addresses count]) {
|
||||
stackTrace = addresses;
|
||||
}
|
||||
}
|
||||
|
||||
// 10.4 doesn't respond to callStackReturnAddresses so we'll try to pull the
|
||||
// stack info out of the userInfo. It might not be there, sadly :(
|
||||
if (!stackTrace)
|
||||
if (!stackTrace) {
|
||||
stackTrace = [[aException userInfo] objectForKey:NSStackTraceKey];
|
||||
}
|
||||
|
||||
if (stackTrace) {
|
||||
// The command line should look like this:
|
||||
// /usr/bin/atos -p <pid> -printHeader <stack frame addresses>
|
||||
NSMutableArray *args =
|
||||
NSMutableArray* args =
|
||||
[NSMutableArray arrayWithCapacity:[stackTrace count] + 3];
|
||||
|
||||
[args addObject:@"-p"];
|
||||
@ -91,9 +95,9 @@ static void nsObjCExceptionLog(NSException* aException)
|
||||
[args addObject:[NSString stringWithFormat:@"0x%lx", address]];
|
||||
}
|
||||
|
||||
NSPipe *outPipe = [NSPipe pipe];
|
||||
NSPipe* outPipe = [NSPipe pipe];
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
NSTask* task = [[NSTask alloc] init];
|
||||
[task setLaunchPath:@"/usr/bin/atos"];
|
||||
[task setArguments:args];
|
||||
[task setStandardOutput:outPipe];
|
||||
@ -108,20 +112,19 @@ static void nsObjCExceptionLog(NSException* aException)
|
||||
[task waitUntilExit];
|
||||
[task release];
|
||||
|
||||
NSData *outData =
|
||||
NSData* outData =
|
||||
[[outPipe fileHandleForReading] readDataToEndOfFile];
|
||||
NSString *outString =
|
||||
NSString* outString =
|
||||
[[NSString alloc] initWithData:outData encoding:NSUTF8StringEncoding];
|
||||
|
||||
NSLog(@"Stack trace:\n%@", outString);
|
||||
|
||||
[outString release];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
NSLog(@"<No stack information available for Obj-C exception>");
|
||||
}
|
||||
}
|
||||
@catch (NSException *exn) {
|
||||
@catch (NSException* exn) {
|
||||
NSLog(@"Failed to generate stack trace for Obj-C exception [%@: %@]",
|
||||
[exn name], [exn reason]);
|
||||
}
|
||||
@ -129,7 +132,8 @@ static void nsObjCExceptionLog(NSException* aException)
|
||||
}
|
||||
|
||||
__attribute__((unused))
|
||||
static void nsObjCExceptionAbort()
|
||||
static void
|
||||
nsObjCExceptionAbort()
|
||||
{
|
||||
// We need to raise a mach-o signal here, the Mozilla crash reporter on
|
||||
// Mac OS X does not respond to POSIX signals. Raising mach-o signals directly
|
||||
@ -139,9 +143,10 @@ static void nsObjCExceptionAbort()
|
||||
}
|
||||
|
||||
__attribute__((unused))
|
||||
static void nsObjCExceptionLogAbort(NSException *e)
|
||||
static void
|
||||
nsObjCExceptionLogAbort(NSException* aException)
|
||||
{
|
||||
nsObjCExceptionLog(e);
|
||||
nsObjCExceptionLog(aException);
|
||||
nsObjCExceptionAbort();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static void SanitizeEnvironmentVariables()
|
||||
static void
|
||||
SanitizeEnvironmentVariables()
|
||||
{
|
||||
DWORD bufferSize = GetEnvironmentVariableW(L"PATH", nullptr, 0);
|
||||
if (bufferSize) {
|
||||
|
@ -17,7 +17,8 @@ using namespace mozilla;
|
||||
|
||||
// The presence of this address is the stack must stop the stack walk. If
|
||||
// there is no such address, the structure will be {nullptr, true}.
|
||||
struct CriticalAddress {
|
||||
struct CriticalAddress
|
||||
{
|
||||
void* mAddr;
|
||||
bool mInit;
|
||||
};
|
||||
@ -51,24 +52,26 @@ static CriticalAddress gCriticalAddress;
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
typedef void
|
||||
malloc_logger_t(uint32_t type, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
|
||||
uintptr_t result, uint32_t num_hot_frames_to_skip);
|
||||
extern malloc_logger_t *malloc_logger;
|
||||
malloc_logger_t(uint32_t aType,
|
||||
uintptr_t aArg1, uintptr_t aArg2, uintptr_t aArg3,
|
||||
uintptr_t aResult, uint32_t aNumHotFramesToSkip);
|
||||
extern malloc_logger_t* malloc_logger;
|
||||
|
||||
static void
|
||||
stack_callback(void *pc, void *sp, void *closure)
|
||||
stack_callback(void* aPc, void* aSp, void* aClosure)
|
||||
{
|
||||
const char *name = reinterpret_cast<char *>(closure);
|
||||
const char* name = static_cast<char*>(aClosure);
|
||||
Dl_info info;
|
||||
|
||||
// On Leopard dladdr returns the wrong value for "new_sem_from_pool". The
|
||||
// stack shows up as having two pthread_cond_wait$UNIX2003 frames. The
|
||||
// correct one is the first that we find on our way up, so the
|
||||
// following check for gCriticalAddress.mAddr is critical.
|
||||
if (gCriticalAddress.mAddr || dladdr(pc, &info) == 0 ||
|
||||
info.dli_sname == nullptr || strcmp(info.dli_sname, name) != 0)
|
||||
if (gCriticalAddress.mAddr || dladdr(aPc, &info) == 0 ||
|
||||
!info.dli_sname || strcmp(info.dli_sname, name) != 0) {
|
||||
return;
|
||||
gCriticalAddress.mAddr = pc;
|
||||
}
|
||||
gCriticalAddress.mAddr = aPc;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -91,17 +94,19 @@ static bool OnLionOrLater()
|
||||
#endif
|
||||
|
||||
static void
|
||||
my_malloc_logger(uint32_t type, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
|
||||
uintptr_t result, uint32_t num_hot_frames_to_skip)
|
||||
my_malloc_logger(uint32_t aType,
|
||||
uintptr_t aArg1, uintptr_t aArg2, uintptr_t aArg3,
|
||||
uintptr_t aResult, uint32_t aNumHotFramesToSkip)
|
||||
{
|
||||
static bool once = false;
|
||||
if (once)
|
||||
if (once) {
|
||||
return;
|
||||
}
|
||||
once = true;
|
||||
|
||||
// On Leopard dladdr returns the wrong value for "new_sem_from_pool". The
|
||||
// stack shows up as having two pthread_cond_wait$UNIX2003 frames.
|
||||
const char *name = "new_sem_from_pool";
|
||||
const char* name = "new_sem_from_pool";
|
||||
NS_StackWalk(stack_callback, /* skipFrames */ 0, /* maxFrames */ 0,
|
||||
const_cast<char*>(name), 0, nullptr);
|
||||
}
|
||||
@ -116,8 +121,9 @@ my_malloc_logger(uint32_t type, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
|
||||
void
|
||||
StackWalkInitCriticalAddress()
|
||||
{
|
||||
if(gCriticalAddress.mInit)
|
||||
if (gCriticalAddress.mInit) {
|
||||
return;
|
||||
}
|
||||
gCriticalAddress.mInit = true;
|
||||
// We must not do work when 'new_sem_from_pool' calls realloc, since
|
||||
// it holds a non-reentrant spin-lock and we will quickly deadlock.
|
||||
@ -126,18 +132,18 @@ StackWalkInitCriticalAddress()
|
||||
// use dladdr to check the addresses.
|
||||
|
||||
// malloc_logger can be set by external tools like 'Instruments' or 'leaks'
|
||||
malloc_logger_t *old_malloc_logger = malloc_logger;
|
||||
malloc_logger_t* old_malloc_logger = malloc_logger;
|
||||
malloc_logger = my_malloc_logger;
|
||||
|
||||
pthread_cond_t cond;
|
||||
int r = pthread_cond_init(&cond, 0);
|
||||
MOZ_ASSERT(r == 0);
|
||||
pthread_mutex_t mutex;
|
||||
r = pthread_mutex_init(&mutex,0);
|
||||
r = pthread_mutex_init(&mutex, 0);
|
||||
MOZ_ASSERT(r == 0);
|
||||
r = pthread_mutex_lock(&mutex);
|
||||
MOZ_ASSERT(r == 0);
|
||||
struct timespec abstime = {0, 1};
|
||||
struct timespec abstime = { 0, 1 };
|
||||
r = pthread_cond_timedwait_relative_np(&cond, &mutex, &abstime);
|
||||
|
||||
// restore the previous malloc logger
|
||||
@ -156,12 +162,14 @@ StackWalkInitCriticalAddress()
|
||||
MOZ_ASSERT(r == 0);
|
||||
}
|
||||
|
||||
static bool IsCriticalAddress(void* aPC)
|
||||
static bool
|
||||
IsCriticalAddress(void* aPC)
|
||||
{
|
||||
return gCriticalAddress.mAddr == aPC;
|
||||
}
|
||||
#else
|
||||
static bool IsCriticalAddress(void* aPC)
|
||||
static bool
|
||||
IsCriticalAddress(void* aPC)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -208,26 +216,27 @@ bool EnsureSymInitialized();
|
||||
|
||||
bool EnsureWalkThreadReady();
|
||||
|
||||
struct WalkStackData {
|
||||
struct WalkStackData
|
||||
{
|
||||
uint32_t skipFrames;
|
||||
HANDLE thread;
|
||||
bool walkCallingThread;
|
||||
HANDLE process;
|
||||
HANDLE eventStart;
|
||||
HANDLE eventEnd;
|
||||
void **pcs;
|
||||
void** pcs;
|
||||
uint32_t pc_size;
|
||||
uint32_t pc_count;
|
||||
uint32_t pc_max;
|
||||
void **sps;
|
||||
void** sps;
|
||||
uint32_t sp_size;
|
||||
uint32_t sp_count;
|
||||
void *platformData;
|
||||
void* platformData;
|
||||
};
|
||||
|
||||
void PrintError(char *prefix, WalkStackData* data);
|
||||
unsigned int WINAPI WalkStackThread(void* data);
|
||||
void WalkStackMain64(struct WalkStackData* data);
|
||||
void PrintError(char* aPrefix, WalkStackData* aData);
|
||||
unsigned int WINAPI WalkStackThread(void* aData);
|
||||
void WalkStackMain64(struct WalkStackData* aData);
|
||||
|
||||
|
||||
DWORD gStackWalkThread;
|
||||
@ -236,7 +245,8 @@ CRITICAL_SECTION gDbgHelpCS;
|
||||
}
|
||||
|
||||
// Routine to print an error message to standard error.
|
||||
void PrintError(const char *prefix)
|
||||
void
|
||||
PrintError(const char* aPrefix)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD lastErr = GetLastError();
|
||||
@ -250,7 +260,7 @@ void PrintError(const char *prefix)
|
||||
nullptr
|
||||
);
|
||||
fprintf(stderr, "### ERROR: %s: %s",
|
||||
prefix, lpMsgBuf ? lpMsgBuf : "(null)\n");
|
||||
aPrefix, lpMsgBuf ? lpMsgBuf : "(null)\n");
|
||||
fflush(stderr);
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
@ -262,14 +272,15 @@ EnsureWalkThreadReady()
|
||||
static HANDLE stackWalkThread = nullptr;
|
||||
static HANDLE readyEvent = nullptr;
|
||||
|
||||
if (walkThreadReady)
|
||||
if (walkThreadReady) {
|
||||
return walkThreadReady;
|
||||
}
|
||||
|
||||
if (stackWalkThread == nullptr) {
|
||||
if (!stackWalkThread) {
|
||||
readyEvent = ::CreateEvent(nullptr, FALSE /* auto-reset*/,
|
||||
FALSE /* initially non-signaled */,
|
||||
nullptr);
|
||||
if (readyEvent == nullptr) {
|
||||
if (!readyEvent) {
|
||||
PrintError("CreateEvent");
|
||||
return false;
|
||||
}
|
||||
@ -278,7 +289,7 @@ EnsureWalkThreadReady()
|
||||
stackWalkThread = (HANDLE)
|
||||
_beginthreadex(nullptr, 0, WalkStackThread, (void*)readyEvent,
|
||||
0, &threadID);
|
||||
if (stackWalkThread == nullptr) {
|
||||
if (!stackWalkThread) {
|
||||
PrintError("CreateThread");
|
||||
::CloseHandle(readyEvent);
|
||||
readyEvent = nullptr;
|
||||
@ -288,8 +299,8 @@ EnsureWalkThreadReady()
|
||||
::CloseHandle(stackWalkThread);
|
||||
}
|
||||
|
||||
MOZ_ASSERT((stackWalkThread != nullptr && readyEvent != nullptr) ||
|
||||
(stackWalkThread == nullptr && readyEvent == nullptr));
|
||||
MOZ_ASSERT((stackWalkThread && readyEvent) ||
|
||||
(!stackWalkThread && !readyEvent));
|
||||
|
||||
// The thread was created. Try to wait an arbitrary amount of time (1 second
|
||||
// should be enough) for its event loop to start before posting events to it.
|
||||
@ -312,33 +323,33 @@ EnsureWalkThreadReady()
|
||||
}
|
||||
|
||||
void
|
||||
WalkStackMain64(struct WalkStackData* data)
|
||||
WalkStackMain64(struct WalkStackData* aData)
|
||||
{
|
||||
// Get the context information for the thread. That way we will
|
||||
// know where our sp, fp, pc, etc. are and can fill in the
|
||||
// STACKFRAME64 with the initial values.
|
||||
CONTEXT context;
|
||||
HANDLE myProcess = data->process;
|
||||
HANDLE myThread = data->thread;
|
||||
HANDLE myProcess = aData->process;
|
||||
HANDLE myThread = aData->thread;
|
||||
DWORD64 addr;
|
||||
DWORD64 spaddr;
|
||||
STACKFRAME64 frame64;
|
||||
// skip our own stack walking frames
|
||||
int skip = (data->walkCallingThread ? 3 : 0) + data->skipFrames;
|
||||
int skip = (aData->walkCallingThread ? 3 : 0) + aData->skipFrames;
|
||||
BOOL ok;
|
||||
|
||||
// Get a context for the specified thread.
|
||||
if (!data->platformData) {
|
||||
if (!aData->platformData) {
|
||||
memset(&context, 0, sizeof(CONTEXT));
|
||||
context.ContextFlags = CONTEXT_FULL;
|
||||
if (!GetThreadContext(myThread, &context)) {
|
||||
if (data->walkCallingThread) {
|
||||
if (aData->walkCallingThread) {
|
||||
PrintError("GetThreadContext");
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
context = *static_cast<CONTEXT*>(data->platformData);
|
||||
context = *static_cast<CONTEXT*>(aData->platformData);
|
||||
}
|
||||
|
||||
// Setup initial stack frame to walk from
|
||||
@ -395,7 +406,7 @@ WalkStackMain64(struct WalkStackData* data)
|
||||
} else {
|
||||
addr = 0;
|
||||
spaddr = 0;
|
||||
if (data->walkCallingThread) {
|
||||
if (aData->walkCallingThread) {
|
||||
PrintError("WalkStack64");
|
||||
}
|
||||
}
|
||||
@ -408,19 +419,23 @@ WalkStackMain64(struct WalkStackData* data)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (data->pc_count < data->pc_size)
|
||||
data->pcs[data->pc_count] = (void*)addr;
|
||||
++data->pc_count;
|
||||
if (aData->pc_count < aData->pc_size) {
|
||||
aData->pcs[aData->pc_count] = (void*)addr;
|
||||
}
|
||||
++aData->pc_count;
|
||||
|
||||
if (data->sp_count < data->sp_size)
|
||||
data->sps[data->sp_count] = (void*)spaddr;
|
||||
++data->sp_count;
|
||||
if (aData->sp_count < aData->sp_size) {
|
||||
aData->sps[aData->sp_count] = (void*)spaddr;
|
||||
}
|
||||
++aData->sp_count;
|
||||
|
||||
if (data->pc_max != 0 && data->pc_count == data->pc_max)
|
||||
if (aData->pc_max != 0 && aData->pc_count == aData->pc_max) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame64.AddrReturn.Offset == 0)
|
||||
if (frame64.AddrReturn.Offset == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -440,29 +455,30 @@ WalkStackThread(void* aData)
|
||||
HANDLE readyEvent = (HANDLE)aData;
|
||||
::SetEvent(readyEvent);
|
||||
|
||||
while ((msgRet = ::GetMessage(&msg, (HWND)-1, 0, 0)) != 0) {
|
||||
while ((msgRet = ::GetMessage(&msg, (HWND) - 1, 0, 0)) != 0) {
|
||||
if (msgRet == -1) {
|
||||
PrintError("GetMessage");
|
||||
} else {
|
||||
DWORD ret;
|
||||
|
||||
struct WalkStackData *data = (WalkStackData *)msg.lParam;
|
||||
if (!data)
|
||||
struct WalkStackData* data = (WalkStackData*)msg.lParam;
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't suspend the calling thread until it's waiting for
|
||||
// us; otherwise the number of frames on the stack could vary.
|
||||
ret = ::WaitForSingleObject(data->eventStart, INFINITE);
|
||||
if (ret != WAIT_OBJECT_0)
|
||||
if (ret != WAIT_OBJECT_0) {
|
||||
PrintError("WaitForSingleObject");
|
||||
}
|
||||
|
||||
// Suspend the calling thread, dump his stack, and then resume him.
|
||||
// He's currently waiting for us to finish so now should be a good time.
|
||||
ret = ::SuspendThread( data->thread );
|
||||
ret = ::SuspendThread(data->thread);
|
||||
if (ret == -1) {
|
||||
PrintError("ThreadSuspend");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
WalkStackMain64(data);
|
||||
|
||||
ret = ::ResumeThread(data->thread);
|
||||
@ -488,8 +504,8 @@ WalkStackThread(void* aData)
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData)
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData)
|
||||
{
|
||||
StackWalkInitCriticalAddress();
|
||||
static HANDLE myProcess = nullptr;
|
||||
@ -497,13 +513,14 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
DWORD walkerReturn;
|
||||
struct WalkStackData data;
|
||||
|
||||
if (!EnsureWalkThreadReady())
|
||||
if (!EnsureWalkThreadReady()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
HANDLE targetThread = ::GetCurrentThread();
|
||||
data.walkCallingThread = true;
|
||||
if (aThread) {
|
||||
HANDLE threadToWalk = reinterpret_cast<HANDLE> (aThread);
|
||||
HANDLE threadToWalk = reinterpret_cast<HANDLE>(aThread);
|
||||
// walkCallingThread indicates whether we are walking the caller's stack
|
||||
data.walkCallingThread = (threadToWalk == targetThread);
|
||||
targetThread = threadToWalk;
|
||||
@ -540,12 +557,12 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
data.skipFrames = aSkipFrames;
|
||||
data.thread = myThread;
|
||||
data.process = myProcess;
|
||||
void *local_pcs[1024];
|
||||
void* local_pcs[1024];
|
||||
data.pcs = local_pcs;
|
||||
data.pc_count = 0;
|
||||
data.pc_size = ArrayLength(local_pcs);
|
||||
data.pc_max = aMaxFrames;
|
||||
void *local_sps[1024];
|
||||
void* local_sps[1024];
|
||||
data.sps = local_sps;
|
||||
data.sp_count = 0;
|
||||
data.sp_size = ArrayLength(local_sps);
|
||||
@ -557,10 +574,10 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
WalkStackMain64(&data);
|
||||
|
||||
if (data.pc_count > data.pc_size) {
|
||||
data.pcs = (void**) _alloca(data.pc_count * sizeof(void*));
|
||||
data.pcs = (void**)_alloca(data.pc_count * sizeof(void*));
|
||||
data.pc_size = data.pc_count;
|
||||
data.pc_count = 0;
|
||||
data.sps = (void**) _alloca(data.sp_count * sizeof(void*));
|
||||
data.sps = (void**)_alloca(data.sp_count * sizeof(void*));
|
||||
data.sp_size = data.sp_count;
|
||||
data.sp_count = 0;
|
||||
WalkStackMain64(&data);
|
||||
@ -575,20 +592,22 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
|
||||
walkerReturn = ::SignalObjectAndWait(data.eventStart,
|
||||
data.eventEnd, INFINITE, FALSE);
|
||||
if (walkerReturn != WAIT_OBJECT_0 && !shouldBeThreadSafe)
|
||||
if (walkerReturn != WAIT_OBJECT_0 && !shouldBeThreadSafe) {
|
||||
PrintError("SignalObjectAndWait (1)");
|
||||
}
|
||||
if (data.pc_count > data.pc_size) {
|
||||
data.pcs = (void**) _alloca(data.pc_count * sizeof(void*));
|
||||
data.pcs = (void**)_alloca(data.pc_count * sizeof(void*));
|
||||
data.pc_size = data.pc_count;
|
||||
data.pc_count = 0;
|
||||
data.sps = (void**) _alloca(data.sp_count * sizeof(void*));
|
||||
data.sps = (void**)_alloca(data.sp_count * sizeof(void*));
|
||||
data.sp_size = data.sp_count;
|
||||
data.sp_count = 0;
|
||||
::PostThreadMessage(gStackWalkThread, WM_USER, 0, (LPARAM)&data);
|
||||
walkerReturn = ::SignalObjectAndWait(data.eventStart,
|
||||
data.eventEnd, INFINITE, FALSE);
|
||||
if (walkerReturn != WAIT_OBJECT_0 && !shouldBeThreadSafe)
|
||||
if (walkerReturn != WAIT_OBJECT_0 && !shouldBeThreadSafe) {
|
||||
PrintError("SignalObjectAndWait (2)");
|
||||
}
|
||||
}
|
||||
|
||||
::CloseHandle(data.eventStart);
|
||||
@ -597,14 +616,16 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
|
||||
::CloseHandle(myThread);
|
||||
|
||||
for (uint32_t i = 0; i < data.pc_count; ++i)
|
||||
for (uint32_t i = 0; i < data.pc_count; ++i) {
|
||||
(*aCallback)(data.pcs[i], data.sps[i], aClosure);
|
||||
}
|
||||
|
||||
return data.pc_count == 0 ? NS_ERROR_FAILURE : NS_OK;
|
||||
}
|
||||
|
||||
|
||||
static BOOL CALLBACK callbackEspecial64(
|
||||
static BOOL CALLBACK
|
||||
callbackEspecial64(
|
||||
PCSTR aModuleName,
|
||||
DWORD64 aModuleBase,
|
||||
ULONG aModuleSize,
|
||||
@ -630,8 +651,9 @@ static BOOL CALLBACK callbackEspecial64(
|
||||
retval = !!SymLoadModule64(GetCurrentProcess(), nullptr,
|
||||
(PSTR)aModuleName, nullptr,
|
||||
aModuleBase, aModuleSize);
|
||||
if (!retval)
|
||||
if (!retval) {
|
||||
PrintError("SymLoadModule64");
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
@ -662,7 +684,9 @@ static BOOL CALLBACK callbackEspecial64(
|
||||
#define NS_IMAGEHLP_MODULE64_SIZE sizeof(IMAGEHLP_MODULE64)
|
||||
#endif
|
||||
|
||||
BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr, PIMAGEHLP_MODULE64 aModuleInfo, PIMAGEHLP_LINE64 aLineInfo)
|
||||
BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr,
|
||||
PIMAGEHLP_MODULE64 aModuleInfo,
|
||||
PIMAGEHLP_LINE64 aLineInfo)
|
||||
{
|
||||
BOOL retval = FALSE;
|
||||
|
||||
@ -670,7 +694,7 @@ BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr, PIMAGEHLP_MODULE
|
||||
* Init the vars if we have em.
|
||||
*/
|
||||
aModuleInfo->SizeOfStruct = NS_IMAGEHLP_MODULE64_SIZE;
|
||||
if (nullptr != aLineInfo) {
|
||||
if (aLineInfo) {
|
||||
aLineInfo->SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
}
|
||||
|
||||
@ -679,10 +703,7 @@ BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr, PIMAGEHLP_MODULE
|
||||
* It may already be loaded.
|
||||
*/
|
||||
retval = SymGetModuleInfo64(aProcess, aAddr, aModuleInfo);
|
||||
|
||||
if (FALSE == retval) {
|
||||
BOOL enumRes = FALSE;
|
||||
|
||||
if (retval == FALSE) {
|
||||
/*
|
||||
* Not loaded, here's the magic.
|
||||
* Go through all the modules.
|
||||
@ -692,9 +713,11 @@ BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr, PIMAGEHLP_MODULE
|
||||
// PENUMLOADED_MODULES_CALLBACK64 varies over SDK versions (from
|
||||
// non-const to const over time). See bug 391848 and bug
|
||||
// 415426.
|
||||
enumRes = EnumerateLoadedModules64(aProcess, (PENUMLOADED_MODULES_CALLBACK64)callbackEspecial64, (PVOID)&aAddr);
|
||||
if (FALSE != enumRes)
|
||||
{
|
||||
BOOL enumRes = EnumerateLoadedModules64(
|
||||
aProcess,
|
||||
(PENUMLOADED_MODULES_CALLBACK64)callbackEspecial64,
|
||||
(PVOID)&aAddr);
|
||||
if (enumRes != FALSE) {
|
||||
/*
|
||||
* One final go.
|
||||
* If it fails, then well, we have other problems.
|
||||
@ -707,7 +730,7 @@ BOOL SymGetModuleInfoEspecial64(HANDLE aProcess, DWORD64 aAddr, PIMAGEHLP_MODULE
|
||||
* If we got module info, we may attempt line info as well.
|
||||
* We will not report failure if this does not work.
|
||||
*/
|
||||
if (FALSE != retval && nullptr != aLineInfo) {
|
||||
if (retval != FALSE && aLineInfo) {
|
||||
DWORD displacement = 0;
|
||||
BOOL lineRes = FALSE;
|
||||
lineRes = SymGetLineFromAddr64(aProcess, aAddr, &displacement, aLineInfo);
|
||||
@ -726,16 +749,19 @@ EnsureSymInitialized()
|
||||
static bool gInitialized = false;
|
||||
bool retStat;
|
||||
|
||||
if (gInitialized)
|
||||
if (gInitialized) {
|
||||
return gInitialized;
|
||||
}
|
||||
|
||||
if (!EnsureWalkThreadReady())
|
||||
if (!EnsureWalkThreadReady()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
|
||||
retStat = SymInitialize(GetCurrentProcess(), nullptr, TRUE);
|
||||
if (!retStat)
|
||||
if (!retStat) {
|
||||
PrintError("SymInitialize");
|
||||
}
|
||||
|
||||
gInitialized = retStat;
|
||||
/* XXX At some point we need to arrange to call SymCleanup */
|
||||
@ -745,7 +771,7 @@ EnsureSymInitialized()
|
||||
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
NS_DescribeCodeAddress(void* aPC, nsCodeAddressDetails* aDetails)
|
||||
{
|
||||
aDetails->library[0] = '\0';
|
||||
aDetails->loffset = 0;
|
||||
@ -754,8 +780,9 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
aDetails->function[0] = '\0';
|
||||
aDetails->foffset = 0;
|
||||
|
||||
if (!EnsureSymInitialized())
|
||||
if (!EnsureSymInitialized()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
HANDLE myProcess = ::GetCurrentProcess();
|
||||
BOOL ok;
|
||||
@ -777,7 +804,7 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
if (modInfoRes) {
|
||||
PL_strncpyz(aDetails->library, modInfo.ModuleName,
|
||||
sizeof(aDetails->library));
|
||||
aDetails->loffset = (char*) aPC - (char*) modInfo.BaseOfImage;
|
||||
aDetails->loffset = (char*)aPC - (char*)modInfo.BaseOfImage;
|
||||
|
||||
if (lineInfo.FileName) {
|
||||
PL_strncpyz(aDetails->filename, lineInfo.FileName,
|
||||
@ -787,7 +814,7 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
}
|
||||
|
||||
ULONG64 buffer[(sizeof(SYMBOL_INFO) +
|
||||
MAX_SYM_NAME*sizeof(TCHAR) + sizeof(ULONG64) - 1) / sizeof(ULONG64)];
|
||||
MAX_SYM_NAME * sizeof(TCHAR) + sizeof(ULONG64) - 1) / sizeof(ULONG64)];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
pSymbol->MaxNameLen = MAX_SYM_NAME;
|
||||
@ -806,8 +833,8 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
char *aBuffer, uint32_t aBufferSize)
|
||||
NS_FormatCodeAddressDetails(void* aPC, const nsCodeAddressDetails* aDetails,
|
||||
char* aBuffer, uint32_t aBufferSize)
|
||||
{
|
||||
if (aDetails->function[0]) {
|
||||
_snprintf(aBuffer, aBufferSize, "%s+0x%08lX [%s +0x%016lX]",
|
||||
@ -828,8 +855,9 @@ NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
aDetails->filename, aDetails->lineno);
|
||||
} else {
|
||||
aBuffer[len] = '\n';
|
||||
if (++len != aBufferSize)
|
||||
if (++len != aBufferSize) {
|
||||
aBuffer[len] = '\0';
|
||||
}
|
||||
}
|
||||
aBuffer[aBufferSize - 2] = '\n';
|
||||
aBuffer[aBufferSize - 1] = '\0';
|
||||
@ -860,19 +888,18 @@ NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
#include <cxxabi.h>
|
||||
#endif // MOZ_DEMANGLE_SYMBOLS
|
||||
|
||||
void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
void DemangleSymbol(const char* aSymbol,
|
||||
char* aBuffer,
|
||||
int aBufLen)
|
||||
{
|
||||
aBuffer[0] = '\0';
|
||||
|
||||
#if defined(MOZ_DEMANGLE_SYMBOLS)
|
||||
/* See demangle.h in the gcc source for the voodoo */
|
||||
char * demangled = abi::__cxa_demangle(aSymbol,0,0,0);
|
||||
char* demangled = abi::__cxa_demangle(aSymbol, 0, 0, 0);
|
||||
|
||||
if (demangled)
|
||||
{
|
||||
PL_strncpyz(aBuffer,demangled,aBufLen);
|
||||
if (demangled) {
|
||||
PL_strncpyz(aBuffer, demangled, aBufLen);
|
||||
free(demangled);
|
||||
}
|
||||
#endif // MOZ_DEMANGLE_SYMBOLS
|
||||
@ -1003,7 +1030,7 @@ load_address(void * pc, void * arg)
|
||||
static struct bucket *
|
||||
newbucket(void * pc)
|
||||
{
|
||||
struct bucket * ptr = (struct bucket *) malloc(sizeof (*ptr));
|
||||
struct bucket * ptr = (struct bucket *)malloc(sizeof(*ptr));
|
||||
static int index; /* protected by lock in caller */
|
||||
|
||||
ptr->index = index++;
|
||||
@ -1059,8 +1086,8 @@ cs_operate(int (*operate_func)(void *, void *, void *), void * usrarg)
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData)
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData)
|
||||
{
|
||||
MOZ_ASSERT(!aThread);
|
||||
MOZ_ASSERT(!aPlatformData);
|
||||
@ -1068,8 +1095,9 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
|
||||
StackWalkInitCriticalAddress();
|
||||
|
||||
if (!initialized)
|
||||
if (!initialized) {
|
||||
myinit();
|
||||
}
|
||||
|
||||
args.callback = aCallback;
|
||||
args.skipFrames = aSkipFrames; /* XXX Not handled! */
|
||||
@ -1081,7 +1109,7 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
NS_DescribeCodeAddress(void* aPC, nsCodeAddressDetails* aDetails)
|
||||
{
|
||||
aDetails->library[0] = '\0';
|
||||
aDetails->loffset = 0;
|
||||
@ -1104,8 +1132,9 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
#ifdef __GNUC__
|
||||
DemangleSymbol(info.dli_sname, dembuff, sizeof(dembuff));
|
||||
#else
|
||||
if (!demf || demf(info.dli_sname, dembuff, sizeof (dembuff)))
|
||||
if (!demf || demf(info.dli_sname, dembuff, sizeof(dembuff))) {
|
||||
dembuff[0] = 0;
|
||||
}
|
||||
#endif /*__GNUC__*/
|
||||
PL_strncpyz(aDetails->function,
|
||||
(dembuff[0] != '\0') ? dembuff : info.dli_sname,
|
||||
@ -1117,8 +1146,8 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
char *aBuffer, uint32_t aBufferSize)
|
||||
NS_FormatCodeAddressDetails(void* aPC, const nsCodeAddressDetails* aDetails,
|
||||
char* aBuffer, uint32_t aBufferSize)
|
||||
{
|
||||
snprintf(aBuffer, aBufferSize, "%p %s:%s+0x%lx\n",
|
||||
aPC,
|
||||
@ -1137,20 +1166,20 @@ NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
#endif
|
||||
|
||||
#if HAVE___LIBC_STACK_END
|
||||
extern void *__libc_stack_end; // from ld-linux.so
|
||||
extern void* __libc_stack_end; // from ld-linux.so
|
||||
#endif
|
||||
namespace mozilla {
|
||||
nsresult
|
||||
FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, void **bp,
|
||||
void *aStackEnd)
|
||||
uint32_t aMaxFrames, void* aClosure, void** bp,
|
||||
void* aStackEnd)
|
||||
{
|
||||
// Stack walking code courtesy Kipp's "leaky".
|
||||
|
||||
int32_t skip = aSkipFrames;
|
||||
uint32_t numFrames = 0;
|
||||
while (1) {
|
||||
void **next = (void**)*bp;
|
||||
void** next = (void**)*bp;
|
||||
// bp may not be a frame pointer on i386 if code was compiled with
|
||||
// -fomit-frame-pointer, so do some sanity checks.
|
||||
// (bp should be a frame pointer on ppc(64) but checking anyway may help
|
||||
@ -1164,10 +1193,10 @@ FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
}
|
||||
#if (defined(__ppc__) && defined(XP_MACOSX)) || defined(__powerpc64__)
|
||||
// ppc mac or powerpc64 linux
|
||||
void *pc = *(bp+2);
|
||||
void* pc = *(bp + 2);
|
||||
bp += 3;
|
||||
#else // i386 or powerpc32 linux
|
||||
void *pc = *(bp+1);
|
||||
void* pc = *(bp + 1);
|
||||
bp += 2;
|
||||
#endif
|
||||
if (IsCriticalAddress(pc)) {
|
||||
@ -1181,8 +1210,9 @@ FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
// to order elements on the stack.
|
||||
(*aCallback)(pc, bp, aClosure);
|
||||
numFrames++;
|
||||
if (aMaxFrames != 0 && numFrames == aMaxFrames)
|
||||
if (aMaxFrames != 0 && numFrames == aMaxFrames) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
bp = next;
|
||||
}
|
||||
@ -1196,25 +1226,25 @@ FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData)
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData)
|
||||
{
|
||||
MOZ_ASSERT(!aThread);
|
||||
MOZ_ASSERT(!aPlatformData);
|
||||
StackWalkInitCriticalAddress();
|
||||
|
||||
// Get the frame pointer
|
||||
void **bp;
|
||||
void** bp;
|
||||
#if defined(__i386)
|
||||
__asm__( "movl %%ebp, %0" : "=g"(bp));
|
||||
__asm__("movl %%ebp, %0" : "=g"(bp));
|
||||
#else
|
||||
// It would be nice if this worked uniformly, but at least on i386 and
|
||||
// x86_64, it stopped working with gcc 4.1, because it points to the
|
||||
// end of the saved registers instead of the start.
|
||||
bp = (void**) __builtin_frame_address(0);
|
||||
bp = (void**)__builtin_frame_address(0);
|
||||
#endif
|
||||
|
||||
void *stackEnd;
|
||||
void* stackEnd;
|
||||
#if HAVE___LIBC_STACK_END
|
||||
stackEnd = __libc_stack_end;
|
||||
#else
|
||||
@ -1230,20 +1260,21 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
// libgcc_s.so symbols _Unwind_Backtrace@@GCC_3.3 and _Unwind_GetIP@@GCC_3.0
|
||||
#include <unwind.h>
|
||||
|
||||
struct unwind_info {
|
||||
struct unwind_info
|
||||
{
|
||||
NS_WalkStackCallback callback;
|
||||
int skip;
|
||||
int maxFrames;
|
||||
int numFrames;
|
||||
bool isCriticalAbort;
|
||||
void *closure;
|
||||
void* closure;
|
||||
};
|
||||
|
||||
static _Unwind_Reason_Code
|
||||
unwind_callback (struct _Unwind_Context *context, void *closure)
|
||||
unwind_callback(struct _Unwind_Context* context, void* closure)
|
||||
{
|
||||
unwind_info *info = static_cast<unwind_info *>(closure);
|
||||
void *pc = reinterpret_cast<void *>(_Unwind_GetIP(context));
|
||||
unwind_info* info = static_cast<unwind_info*>(closure);
|
||||
void* pc = reinterpret_cast<void*>(_Unwind_GetIP(context));
|
||||
// TODO Use something like '_Unwind_GetGR()' to get the stack pointer.
|
||||
if (IsCriticalAddress(pc)) {
|
||||
printf("Aborting stack trace, PC is critical\n");
|
||||
@ -1266,8 +1297,8 @@ unwind_callback (struct _Unwind_Context *context, void *closure)
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData)
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData)
|
||||
{
|
||||
MOZ_ASSERT(!aThread);
|
||||
MOZ_ASSERT(!aPlatformData);
|
||||
@ -1290,15 +1321,16 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
// - If aMaxFrames != 0, we want to stop early, and the only way to do that
|
||||
// is to make unwind_callback return something other than _URC_NO_REASON,
|
||||
// which causes _Unwind_Backtrace to return a non-success code.
|
||||
if (info.isCriticalAbort)
|
||||
if (info.isCriticalAbort) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return info.numFrames == 0 ? NS_ERROR_FAILURE : NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
NS_DescribeCodeAddress(void* aPC, nsCodeAddressDetails* aDetails)
|
||||
{
|
||||
aDetails->library[0] = '\0';
|
||||
aDetails->loffset = 0;
|
||||
@ -1316,7 +1348,7 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
PL_strncpyz(aDetails->library, info.dli_fname, sizeof(aDetails->library));
|
||||
aDetails->loffset = (char*)aPC - (char*)info.dli_fbase;
|
||||
|
||||
const char * symbol = info.dli_sname;
|
||||
const char* symbol = info.dli_sname;
|
||||
if (!symbol || symbol[0] == '\0') {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1333,8 +1365,8 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
char *aBuffer, uint32_t aBufferSize)
|
||||
NS_FormatCodeAddressDetails(void* aPC, const nsCodeAddressDetails* aDetails,
|
||||
char* aBuffer, uint32_t aBufferSize)
|
||||
{
|
||||
if (!aDetails->library[0]) {
|
||||
snprintf(aBuffer, aBufferSize, "UNKNOWN %p\n", aPC);
|
||||
@ -1356,8 +1388,8 @@ NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData)
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData)
|
||||
{
|
||||
MOZ_ASSERT(!aThread);
|
||||
MOZ_ASSERT(!aPlatformData);
|
||||
@ -1367,14 +1399,14 @@ NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
namespace mozilla {
|
||||
nsresult
|
||||
FramePointerStackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
void *aClosure, void **bp)
|
||||
void* aClosure, void** aBp)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
NS_DescribeCodeAddress(void* aPC, nsCodeAddressDetails* aDetails)
|
||||
{
|
||||
aDetails->library[0] = '\0';
|
||||
aDetails->loffset = 0;
|
||||
@ -1386,8 +1418,8 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails)
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
char *aBuffer, uint32_t aBufferSize)
|
||||
NS_FormatCodeAddressDetails(void* aPC, const nsCodeAddressDetails* aDetails,
|
||||
char* aBuffer, uint32_t aBufferSize)
|
||||
{
|
||||
aBuffer[0] = '\0';
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -22,7 +22,7 @@ extern "C" {
|
||||
// pointing to when the execution returns to executing that at that PC.
|
||||
// If no approximation can be made it will be nullptr.
|
||||
typedef void
|
||||
(* NS_WalkStackCallback)(void *aPC, void *aSP, void *aClosure);
|
||||
(*NS_WalkStackCallback)(void* aPC, void* aSP, void* aClosure);
|
||||
|
||||
/**
|
||||
* Call aCallback for the C/C++ stack frames on the current thread, from
|
||||
@ -62,10 +62,11 @@ typedef void
|
||||
*/
|
||||
XPCOM_API(nsresult)
|
||||
NS_StackWalk(NS_WalkStackCallback aCallback, uint32_t aSkipFrames,
|
||||
uint32_t aMaxFrames, void *aClosure, uintptr_t aThread,
|
||||
void *aPlatformData);
|
||||
uint32_t aMaxFrames, void* aClosure, uintptr_t aThread,
|
||||
void* aPlatformData);
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/*
|
||||
* The name of the shared library or executable containing an
|
||||
* address and the address's offset within that library, or empty
|
||||
@ -96,7 +97,7 @@ typedef struct {
|
||||
* @param aDetails A structure to be filled in with the result.
|
||||
*/
|
||||
XPCOM_API(nsresult)
|
||||
NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails);
|
||||
NS_DescribeCodeAddress(void* aPC, nsCodeAddressDetails* aDetails);
|
||||
|
||||
/**
|
||||
* Format the information about a code address in a format suitable for
|
||||
@ -116,8 +117,8 @@ NS_DescribeCodeAddress(void *aPC, nsCodeAddressDetails *aDetails);
|
||||
* is the terminating null.
|
||||
*/
|
||||
XPCOM_API(nsresult)
|
||||
NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
|
||||
char *aBuffer, uint32_t aBufferSize);
|
||||
NS_FormatCodeAddressDetails(void* aPC, const nsCodeAddressDetails* aDetails,
|
||||
char* aBuffer, uint32_t aBufferSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ class DumpStatusInfoToTempDirRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DumpStatusInfoToTempDirRunnable()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
@ -45,9 +46,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void doStatusReport(const nsCString& inputStr)
|
||||
void
|
||||
doStatusReport(const nsCString& aInputStr)
|
||||
{
|
||||
LOG("FifoWatcher(%s) dispatching status report runnable.", inputStr.get());
|
||||
LOG("FifoWatcher(%s) dispatching status report runnable.", aInputStr.get());
|
||||
nsRefPtr<DumpStatusInfoToTempDirRunnable> runnable =
|
||||
new DumpStatusInfoToTempDirRunnable();
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -59,14 +61,15 @@ void doStatusReport(const nsCString& inputStr)
|
||||
static bool gStatusReportProgress = 0;
|
||||
static int gNumReporters = 0;
|
||||
|
||||
nsresult getStatus(nsACString& desc)
|
||||
nsresult
|
||||
getStatus(nsACString& aDesc)
|
||||
{
|
||||
if(!gStatusReportProgress)
|
||||
desc.AssignLiteral("Init");
|
||||
else {
|
||||
desc.AssignLiteral("Running: There are ");
|
||||
desc.AppendInt(gNumReporters);
|
||||
desc.AppendLiteral(" reporters");
|
||||
if (!gStatusReportProgress) {
|
||||
aDesc.AssignLiteral("Init");
|
||||
} else {
|
||||
aDesc.AssignLiteral("Running: There are ");
|
||||
aDesc.AppendInt(gNumReporters);
|
||||
aDesc.AppendLiteral(" reporters");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -133,7 +136,7 @@ nsStatusReporterManager::Init()
|
||||
#if DO_STATUS_REPORT
|
||||
if (FifoWatcher::MaybeCreate()) {
|
||||
FifoWatcher* fw = FifoWatcher::GetSingleton();
|
||||
fw->RegisterCallback(NS_LITERAL_CSTRING("status report"),doStatusReport);
|
||||
fw->RegisterCallback(NS_LITERAL_CSTRING("status report"), doStatusReport);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -160,14 +163,16 @@ nsStatusReporterManager::DumpReports()
|
||||
filename,
|
||||
getter_AddRefs(tmpFile),
|
||||
NS_LITERAL_CSTRING("status-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFileOutputStream> ostream =
|
||||
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
|
||||
rv = ostream->Init(tmpFile, -1, -1, 0);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
//Write the reports to the file
|
||||
|
||||
@ -184,18 +189,21 @@ nsStatusReporterManager::DumpReports()
|
||||
|
||||
nsCString process;
|
||||
rv = r->GetProcess(process);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCString name;
|
||||
rv = r->GetName(name);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCString description;
|
||||
rv = r->GetDescription(description);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
@ -204,100 +212,113 @@ nsStatusReporterManager::DumpReports()
|
||||
}
|
||||
|
||||
rv = DumpReport(ostream, process, name, description);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
DUMP(ostream, "\n]\n}\n");
|
||||
|
||||
rv = ostream->Close();
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Rename the status reports file
|
||||
nsCOMPtr<nsIFile> srFinalFile;
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(srFinalFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
rv = srFinalFile->AppendNative(NS_LITERAL_CSTRING("status-reports"));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = srFinalFile->AppendNative(filename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = srFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString srActualFinalFilename;
|
||||
rv = srFinalFile->GetLeafName(srActualFinalFilename);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = tmpFile->MoveTo(/* directory */ nullptr, srActualFinalFilename);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStatusReporterManager::EnumerateReporters(nsISimpleEnumerator** result)
|
||||
nsStatusReporterManager::EnumerateReporters(nsISimpleEnumerator** aResult)
|
||||
{
|
||||
return NS_NewArrayEnumerator(result, mReporters);
|
||||
return NS_NewArrayEnumerator(aResult, mReporters);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStatusReporterManager::RegisterReporter(nsIStatusReporter* reporter)
|
||||
nsStatusReporterManager::RegisterReporter(nsIStatusReporter* aReporter)
|
||||
{
|
||||
if (mReporters.IndexOf(reporter) != -1)
|
||||
if (mReporters.IndexOf(aReporter) != -1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mReporters.AppendObject(reporter);
|
||||
mReporters.AppendObject(aReporter);
|
||||
gNumReporters++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStatusReporterManager::UnregisterReporter(nsIStatusReporter* reporter)
|
||||
nsStatusReporterManager::UnregisterReporter(nsIStatusReporter* aReporter)
|
||||
{
|
||||
if (!mReporters.RemoveObject(reporter))
|
||||
if (!mReporters.RemoveObject(aReporter)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
gNumReporters--;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_RegisterStatusReporter (nsIStatusReporter* reporter)
|
||||
NS_RegisterStatusReporter(nsIStatusReporter* aReporter)
|
||||
{
|
||||
nsCOMPtr<nsIStatusReporterManager> mgr =
|
||||
do_GetService("@mozilla.org/status-reporter-manager;1");
|
||||
if (mgr == nullptr)
|
||||
if (!mgr) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return mgr->RegisterReporter(reporter);
|
||||
}
|
||||
return mgr->RegisterReporter(aReporter);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_UnregisterStatusReporter (nsIStatusReporter* reporter)
|
||||
NS_UnregisterStatusReporter(nsIStatusReporter* aReporter)
|
||||
{
|
||||
nsCOMPtr<nsIStatusReporterManager> mgr =
|
||||
do_GetService("@mozilla.org/status-reporter-manager;1");
|
||||
if (mgr == nullptr)
|
||||
if (!mgr) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return mgr->UnregisterReporter(reporter);
|
||||
}
|
||||
return mgr->UnregisterReporter(aReporter);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_DumpStatusReporter ()
|
||||
NS_DumpStatusReporter()
|
||||
{
|
||||
nsCOMPtr<nsIStatusReporterManager> mgr =
|
||||
do_GetService("@mozilla.org/status-reporter-manager;1");
|
||||
if (mgr == nullptr)
|
||||
if (!mgr) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mgr->DumpReports();
|
||||
}
|
||||
|
@ -51,8 +51,9 @@ uint32_t nsSystemInfo::gUserUmask = 0;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
namespace {
|
||||
nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
||||
nsAutoCString& aRevision)
|
||||
nsresult
|
||||
GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
||||
nsAutoCString& aRevision)
|
||||
{
|
||||
aModel.Truncate();
|
||||
aRevision.Truncate();
|
||||
@ -84,8 +85,9 @@ nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
||||
if (!handle.IsValid()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
STORAGE_PROPERTY_QUERY queryParameters = {StorageDeviceProperty,
|
||||
PropertyStandardQuery};
|
||||
STORAGE_PROPERTY_QUERY queryParameters = {
|
||||
StorageDeviceProperty, PropertyStandardQuery
|
||||
};
|
||||
STORAGE_DEVICE_DESCRIPTOR outputHeader = {sizeof(STORAGE_DEVICE_DESCRIPTOR)};
|
||||
DWORD bytesRead = 0;
|
||||
if (!::DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY,
|
||||
@ -137,8 +139,9 @@ nsSystemInfo::~nsSystemInfo()
|
||||
}
|
||||
|
||||
// CPU-specific information.
|
||||
static const struct PropItems {
|
||||
const char *name;
|
||||
static const struct PropItems
|
||||
{
|
||||
const char* name;
|
||||
bool (*propfun)(void);
|
||||
} cpuPropItems[] = {
|
||||
// x86-specific bits.
|
||||
@ -162,9 +165,10 @@ nsSystemInfo::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
static const struct {
|
||||
static const struct
|
||||
{
|
||||
PRSysInfo cmd;
|
||||
const char *name;
|
||||
const char* name;
|
||||
} items[] = {
|
||||
{ PR_SI_SYSNAME, "name" },
|
||||
{ PR_SI_HOSTNAME, "host" },
|
||||
@ -177,10 +181,10 @@ nsSystemInfo::Init()
|
||||
if (PR_GetSystemInfo(items[i].cmd, buf, sizeof(buf)) == PR_SUCCESS) {
|
||||
rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16(items[i].name),
|
||||
nsDependentCString(buf));
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
NS_WARNING("PR_GetSystemInfo failed");
|
||||
}
|
||||
}
|
||||
@ -212,8 +216,9 @@ nsSystemInfo::Init()
|
||||
for (uint32_t i = 0; i < ArrayLength(cpuPropItems); i++) {
|
||||
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16(cpuPropItems[i].name),
|
||||
cpuPropItems[i].propfun());
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -222,8 +227,9 @@ nsSystemInfo::Init()
|
||||
NS_WARN_IF_FALSE(gotWow64Value, "IsWow64Process failed");
|
||||
if (gotWow64Value) {
|
||||
rv = SetPropertyAsBool(NS_LITERAL_STRING("isWow64"), !!isWow64);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
nsAutoCString hddModel, hddRevision;
|
||||
if (NS_SUCCEEDED(GetHDDInfo(NS_APP_USER_PROFILE_50_DIR, hddModel,
|
||||
@ -257,26 +263,38 @@ nsSystemInfo::Init()
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("secondaryLibrary"),
|
||||
nsDependentCString(gtkver));
|
||||
PR_smprintf_free(gtkver);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mozilla::AndroidBridge::Bridge()) {
|
||||
nsAutoString str;
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str))
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
|
||||
"android/os/Build", "MODEL", str)) {
|
||||
SetPropertyAsAString(NS_LITERAL_STRING("device"), str);
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", str))
|
||||
}
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
|
||||
"android/os/Build", "MANUFACTURER", str)) {
|
||||
SetPropertyAsAString(NS_LITERAL_STRING("manufacturer"), str);
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", str))
|
||||
}
|
||||
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField(
|
||||
"android/os/Build$VERSION", "RELEASE", str)) {
|
||||
SetPropertyAsAString(NS_LITERAL_STRING("release_version"), str);
|
||||
}
|
||||
int32_t version;
|
||||
if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &version))
|
||||
if (!mozilla::AndroidBridge::Bridge()->GetStaticIntField(
|
||||
"android/os/Build$VERSION", "SDK_INT", &version)) {
|
||||
version = 0;
|
||||
}
|
||||
android_sdk_version = version;
|
||||
if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
|
||||
if (version >= 8 &&
|
||||
mozilla::AndroidBridge::Bridge()->GetStaticStringField(
|
||||
"android/os/Build", "HARDWARE", str)) {
|
||||
SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str);
|
||||
}
|
||||
bool isTablet = mozilla::widget::android::GeckoAppShell::IsTablet();
|
||||
SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
|
||||
// NSPR "version" is the kernel version. For Android we want the Android version.
|
||||
@ -298,8 +316,9 @@ nsSystemInfo::Init()
|
||||
|
||||
char characteristics[PROP_VALUE_MAX];
|
||||
if (__system_property_get("ro.build.characteristics", characteristics)) {
|
||||
if (!strcmp(characteristics, "tablet"))
|
||||
if (!strcmp(characteristics, "tablet")) {
|
||||
SetPropertyAsBool(NS_LITERAL_STRING("tablet"), true);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString str;
|
||||
@ -325,7 +344,7 @@ nsSystemInfo::Init()
|
||||
}
|
||||
|
||||
void
|
||||
nsSystemInfo::SetInt32Property(const nsAString &aPropertyName,
|
||||
nsSystemInfo::SetInt32Property(const nsAString& aPropertyName,
|
||||
const int32_t aValue)
|
||||
{
|
||||
NS_WARN_IF_FALSE(aValue > 0, "Unable to read system value");
|
||||
@ -339,7 +358,7 @@ nsSystemInfo::SetInt32Property(const nsAString &aPropertyName,
|
||||
}
|
||||
|
||||
void
|
||||
nsSystemInfo::SetUint32Property(const nsAString &aPropertyName,
|
||||
nsSystemInfo::SetUint32Property(const nsAString& aPropertyName,
|
||||
const uint32_t aValue)
|
||||
{
|
||||
// Only one property is currently set via this function.
|
||||
@ -352,7 +371,7 @@ nsSystemInfo::SetUint32Property(const nsAString &aPropertyName,
|
||||
}
|
||||
|
||||
void
|
||||
nsSystemInfo::SetUint64Property(const nsAString &aPropertyName,
|
||||
nsSystemInfo::SetUint64Property(const nsAString& aPropertyName,
|
||||
const uint64_t aValue)
|
||||
{
|
||||
NS_WARN_IF_FALSE(aValue > 0, "Unable to read system value");
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include "nsHashPropertyBag.h"
|
||||
|
||||
class nsSystemInfo : public nsHashPropertyBag {
|
||||
class nsSystemInfo : public nsHashPropertyBag
|
||||
{
|
||||
public:
|
||||
nsSystemInfo();
|
||||
|
||||
@ -20,11 +21,11 @@ public:
|
||||
static uint32_t gUserUmask;
|
||||
|
||||
protected:
|
||||
void SetInt32Property(const nsAString &aPropertyName,
|
||||
void SetInt32Property(const nsAString& aPropertyName,
|
||||
const int32_t aValue);
|
||||
void SetUint32Property(const nsAString &aPropertyName,
|
||||
void SetUint32Property(const nsAString& aPropertyName,
|
||||
const uint32_t aValue);
|
||||
void SetUint64Property(const nsAString &aPropertyName,
|
||||
void SetUint64Property(const nsAString& aPropertyName,
|
||||
const uint64_t aValue);
|
||||
|
||||
private:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,14 +20,12 @@ public:
|
||||
NEW_STATS
|
||||
};
|
||||
|
||||
static nsresult DumpStatistics(StatisticsType type = ALL_STATS,
|
||||
FILE* out = 0);
|
||||
static nsresult DumpStatistics(StatisticsType aType = ALL_STATS,
|
||||
FILE* aOut = 0);
|
||||
|
||||
static void ResetStatistics(void);
|
||||
static void ResetStatistics();
|
||||
|
||||
static void DemangleSymbol(const char * aSymbol,
|
||||
char * aBuffer,
|
||||
int aBufLen);
|
||||
static void DemangleSymbol(const char* aSymbol, char* aBuffer, int aBufLen);
|
||||
|
||||
static void WalkTheStack(FILE* aStream);
|
||||
/**
|
||||
@ -51,8 +49,9 @@ public:
|
||||
// And now for that utility that you've all been asking for...
|
||||
|
||||
extern "C" void
|
||||
NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
|
||||
double *meanResult, double *stdDevResult);
|
||||
NS_MeanAndStdDev(double aNumberOfValues,
|
||||
double aSumOfValues, double aSumOfSquaredValues,
|
||||
double* aMeanResult, double* aStdDevResult);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
|
@ -41,8 +41,8 @@ nsUUIDGenerator::Init()
|
||||
|
||||
size_t bytes = 0;
|
||||
while (bytes < sizeof(seed)) {
|
||||
size_t nbytes = PR_GetRandomNoise(((unsigned char *)&seed)+bytes,
|
||||
sizeof(seed)-bytes);
|
||||
size_t nbytes = PR_GetRandomNoise(((unsigned char*)&seed) + bytes,
|
||||
sizeof(seed) - bytes);
|
||||
if (nbytes == 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -58,14 +58,18 @@ nsUUIDGenerator::Init()
|
||||
|
||||
mRBytes = 4;
|
||||
#ifdef RAND_MAX
|
||||
if ((unsigned long) RAND_MAX < (unsigned long)0xffffffff)
|
||||
if ((unsigned long)RAND_MAX < 0xffffffffUL) {
|
||||
mRBytes = 3;
|
||||
if ((unsigned long) RAND_MAX < (unsigned long)0x00ffffff)
|
||||
}
|
||||
if ((unsigned long)RAND_MAX < 0x00ffffffUL) {
|
||||
mRBytes = 2;
|
||||
if ((unsigned long) RAND_MAX < (unsigned long)0x0000ffff)
|
||||
}
|
||||
if ((unsigned long)RAND_MAX < 0x0000ffffUL) {
|
||||
mRBytes = 1;
|
||||
if ((unsigned long) RAND_MAX < (unsigned long)0x000000ff)
|
||||
}
|
||||
if ((unsigned long)RAND_MAX < 0x000000ffUL) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* non XP_WIN and non XP_MACOSX */
|
||||
@ -74,11 +78,12 @@ nsUUIDGenerator::Init()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUUIDGenerator::GenerateUUID(nsID** ret)
|
||||
nsUUIDGenerator::GenerateUUID(nsID** aRet)
|
||||
{
|
||||
nsID *id = static_cast<nsID*>(NS_Alloc(sizeof(nsID)));
|
||||
if (id == nullptr)
|
||||
nsID* id = static_cast<nsID*>(NS_Alloc(sizeof(nsID)));
|
||||
if (!id) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = GenerateUUIDInPlace(id);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -86,28 +91,30 @@ nsUUIDGenerator::GenerateUUID(nsID** ret)
|
||||
return rv;
|
||||
}
|
||||
|
||||
*ret = id;
|
||||
*aRet = id;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||||
nsUUIDGenerator::GenerateUUIDInPlace(nsID* aId)
|
||||
{
|
||||
// The various code in this method is probably not threadsafe, so lock
|
||||
// across the whole method.
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
HRESULT hr = CoCreateGuid((GUID*)id);
|
||||
if (FAILED(hr))
|
||||
HRESULT hr = CoCreateGuid((GUID*)aId);
|
||||
if (FAILED(hr)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#elif defined(XP_MACOSX)
|
||||
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
|
||||
if (!uuid)
|
||||
if (!uuid) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
|
||||
memcpy(id, &bytes, sizeof(nsID));
|
||||
memcpy(aId, &bytes, sizeof(nsID));
|
||||
|
||||
CFRelease(uuid);
|
||||
#else /* not windows or OS X; generate randomness using random(). */
|
||||
@ -129,27 +136,28 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t *src = (uint8_t*)&rval;
|
||||
uint8_t* src = (uint8_t*)&rval;
|
||||
// We want to grab the mRBytes least significant bytes of rval, since
|
||||
// mRBytes less than sizeof(rval) means the high bytes are 0.
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
src += sizeof(rval) - mRBytes;
|
||||
#endif
|
||||
uint8_t *dst = ((uint8_t*) id) + (sizeof(nsID) - bytesLeft);
|
||||
uint8_t* dst = ((uint8_t*)aId) + (sizeof(nsID) - bytesLeft);
|
||||
size_t toWrite = (bytesLeft < mRBytes ? bytesLeft : mRBytes);
|
||||
for (size_t i = 0; i < toWrite; i++)
|
||||
for (size_t i = 0; i < toWrite; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
bytesLeft -= toWrite;
|
||||
}
|
||||
|
||||
/* Put in the version */
|
||||
id->m2 &= 0x0fff;
|
||||
id->m2 |= 0x4000;
|
||||
aId->m2 &= 0x0fff;
|
||||
aId->m2 |= 0x4000;
|
||||
|
||||
/* Put in the variant */
|
||||
id->m3[0] &= 0x3f;
|
||||
id->m3[0] |= 0x80;
|
||||
aId->m3[0] &= 0x3f;
|
||||
aId->m3[0] |= 0x80;
|
||||
|
||||
#ifndef ANDROID
|
||||
/* Restore the previous RNG state */
|
||||
|
@ -12,7 +12,8 @@
|
||||
|
||||
#include "nsIUUIDGenerator.h"
|
||||
|
||||
class nsUUIDGenerator MOZ_FINAL : public nsIUUIDGenerator {
|
||||
class nsUUIDGenerator MOZ_FINAL : public nsIUUIDGenerator
|
||||
{
|
||||
public:
|
||||
nsUUIDGenerator();
|
||||
|
||||
@ -30,7 +31,7 @@ protected:
|
||||
mozilla::Mutex mLock;
|
||||
#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID)
|
||||
char mState[128];
|
||||
char *mSavedState;
|
||||
char* mSavedState;
|
||||
uint8_t mRBytes;
|
||||
#endif
|
||||
};
|
||||
|
@ -11,11 +11,11 @@
|
||||
NS_IMPL_ISUPPORTS(nsVersionComparatorImpl, nsIVersionComparator)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsVersionComparatorImpl::Compare(const nsACString& A, const nsACString& B,
|
||||
int32_t *aResult)
|
||||
nsVersionComparatorImpl::Compare(const nsACString& aStr1, const nsACString& aStr2,
|
||||
int32_t* aResult)
|
||||
{
|
||||
*aResult = mozilla::CompareVersions(PromiseFlatCString(A).get(),
|
||||
PromiseFlatCString(B).get());
|
||||
*aResult = mozilla::CompareVersions(PromiseFlatCString(aStr1).get(),
|
||||
PromiseFlatCString(aStr2).get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
class AutoCriticalSection
|
||||
{
|
||||
public:
|
||||
AutoCriticalSection(LPCRITICAL_SECTION section)
|
||||
: mSection(section)
|
||||
AutoCriticalSection(LPCRITICAL_SECTION aSection)
|
||||
: mSection(aSection)
|
||||
{
|
||||
::EnterCriticalSection(mSection);
|
||||
}
|
||||
@ -83,7 +83,7 @@ protected:
|
||||
|
||||
bool HaveResource() const
|
||||
{
|
||||
return mRawRef != nullptr && mRawRef != INVALID_HANDLE_VALUE;
|
||||
return mRawRef && mRawRef != INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
public:
|
||||
@ -94,7 +94,7 @@ public:
|
||||
|
||||
static void Release(RawRef aRawRef)
|
||||
{
|
||||
if (aRawRef != nullptr && aRawRef != INVALID_HANDLE_VALUE) {
|
||||
if (aRawRef && aRawRef != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(aRawRef);
|
||||
}
|
||||
}
|
||||
@ -125,8 +125,8 @@ typedef nsAutoRef<SC_HANDLE> nsAutoServiceHandle;
|
||||
typedef nsAutoRef<HANDLE> nsAutoHandle;
|
||||
typedef nsAutoRef<HMODULE> nsModuleHandle;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
bool
|
||||
IsRunningInWindowsMetro()
|
||||
{
|
||||
@ -158,7 +158,7 @@ IsRunningInWindowsMetro()
|
||||
}
|
||||
|
||||
HMODULE
|
||||
LoadLibrarySystem32(LPCWSTR module)
|
||||
LoadLibrarySystem32(LPCWSTR aModule)
|
||||
{
|
||||
WCHAR systemPath[MAX_PATH + 1] = { L'\0' };
|
||||
|
||||
@ -174,8 +174,8 @@ LoadLibrarySystem32(LPCWSTR module)
|
||||
// No need to re-nullptr terminate
|
||||
}
|
||||
|
||||
size_t fileLen = wcslen(module);
|
||||
wcsncpy(systemPath + systemDirLen, module,
|
||||
size_t fileLen = wcslen(aModule);
|
||||
wcsncpy(systemPath + systemDirLen, aModule,
|
||||
MAX_PATH - systemDirLen);
|
||||
if (systemDirLen + fileLen <= MAX_PATH) {
|
||||
systemPath[systemDirLen + fileLen] = L'\0';
|
||||
@ -184,6 +184,7 @@ LoadLibrarySystem32(LPCWSTR module)
|
||||
}
|
||||
return LoadLibraryW(systemPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -306,9 +306,9 @@ typedef MozRefCountType nsrefcnt;
|
||||
* Use these macros to do 64bit safe pointer conversions.
|
||||
*/
|
||||
|
||||
#define NS_PTR_TO_INT32(x) ((int32_t) (intptr_t) (x))
|
||||
#define NS_PTR_TO_UINT32(x) ((uint32_t) (intptr_t) (x))
|
||||
#define NS_INT32_TO_PTR(x) ((void *) (intptr_t) (x))
|
||||
#define NS_PTR_TO_INT32(x) ((int32_t)(intptr_t)(x))
|
||||
#define NS_PTR_TO_UINT32(x) ((uint32_t)(intptr_t)(x))
|
||||
#define NS_INT32_TO_PTR(x) ((void*)(intptr_t)(x))
|
||||
|
||||
/*
|
||||
* Use NS_STRINGIFY to form a string literal from the value of a macro.
|
||||
|
Loading…
x
Reference in New Issue
Block a user