diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index f93c8eebcae4..ef21b64078e9 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -643,8 +643,7 @@ static uint32_t gGCStackTraceTableWhenSizeExceeds = 4 * 1024; PNT_TIB pTib = reinterpret_cast(NtCurrentTeb()); void* stackEnd = static_cast(pTib->StackBase); - FramePointerStackWalk(StackWalkCallback, /* skipFrames = */ 0, MaxFrames, - &tmp, fp, stackEnd); + FramePointerStackWalk(StackWalkCallback, MaxFrames, &tmp, fp, stackEnd); #elif defined(XP_MACOSX) // This avoids MozStackWalk(), which has become unusably slow on Mac due to // changes in libunwind. @@ -662,8 +661,7 @@ static uint32_t gGCStackTraceTableWhenSizeExceeds = 4 * 1024; asm("ldr %0, [x29]\n\t" : "=r"(fp)); # endif void* stackEnd = pthread_get_stackaddr_np(pthread_self()); - FramePointerStackWalk(StackWalkCallback, /* skipFrames = */ 0, MaxFrames, - &tmp, fp, stackEnd); + FramePointerStackWalk(StackWalkCallback, MaxFrames, &tmp, fp, stackEnd); #else # if defined(XP_WIN) && defined(_M_X64) int skipFrames = 1; diff --git a/memory/replace/phc/PHC.cpp b/memory/replace/phc/PHC.cpp index 7ddeac75b730..2932f3615226 100644 --- a/memory/replace/phc/PHC.cpp +++ b/memory/replace/phc/PHC.cpp @@ -216,8 +216,7 @@ void StackTrace::Fill() { PNT_TIB pTib = reinterpret_cast(NtCurrentTeb()); void* stackEnd = static_cast(pTib->StackBase); - FramePointerStackWalk(StackWalkCallback, /* aSkipFrames = */ 0, kMaxFrames, - this, fp, stackEnd); + FramePointerStackWalk(StackWalkCallback, kMaxFrames, this, fp, stackEnd); #elif defined(XP_MACOSX) // This avoids MozStackWalk(), which has become unusably slow on Mac due to // changes in libunwind. @@ -231,8 +230,7 @@ void StackTrace::Fill() { "movq (%%rbp), %0\n\t" : "=r"(fp)); void* stackEnd = pthread_get_stackaddr_np(pthread_self()); - FramePointerStackWalk(StackWalkCallback, /* skipFrames = */ 0, kMaxFrames, - this, fp, stackEnd); + FramePointerStackWalk(StackWalkCallback, kMaxFrames, this, fp, stackEnd); #else MozStackWalk(StackWalkCallback, /* aSkipFrames = */ 0, kMaxFrames, this); #endif diff --git a/mozglue/baseprofiler/core/platform.cpp b/mozglue/baseprofiler/core/platform.cpp index ea3a74c8cc39..37c4bc422347 100644 --- a/mozglue/baseprofiler/core/platform.cpp +++ b/mozglue/baseprofiler/core/platform.cpp @@ -1427,8 +1427,8 @@ static void DoFramePointerBacktrace(PSLockRef aLock, const void* stackEnd = aRegisteredThread.StackTop(); if (aRegs.mFP >= aRegs.mSP && aRegs.mFP <= stackEnd) { - FramePointerStackWalk(StackWalkCallback, /* skipFrames */ 0, maxFrames, - &aNativeStack, reinterpret_cast(aRegs.mFP), + FramePointerStackWalk(StackWalkCallback, maxFrames, &aNativeStack, + reinterpret_cast(aRegs.mFP), const_cast(stackEnd)); } } @@ -1453,8 +1453,8 @@ static void DoMozStackWalkBacktrace(PSLockRef aLock, HANDLE thread = GetThreadHandle(aRegisteredThread.GetPlatformData()); MOZ_ASSERT(thread); - MozStackWalkThread(StackWalkCallback, /* skipFrames */ 0, maxFrames, - &aNativeStack, thread, /* context */ nullptr); + MozStackWalkThread(StackWalkCallback, maxFrames, &aNativeStack, thread, + /* context */ nullptr); } #endif diff --git a/mozglue/misc/StackWalk.cpp b/mozglue/misc/StackWalk.cpp index 24868ae5de82..0993612642f4 100644 --- a/mozglue/misc/StackWalk.cpp +++ b/mozglue/misc/StackWalk.cpp @@ -376,7 +376,7 @@ static void WalkStackMain64(struct WalkStackData* aData) { * whose in memory address doesn't match its in-file address. */ -MFBT_API void MozStackWalkThread(MozWalkStackCallback aCallback, +static void DoMozStackWalkThread(MozWalkStackCallback aCallback, uint32_t aSkipFrames, uint32_t aMaxFrames, void* aClosure, HANDLE aThread, CONTEXT* aContext) { @@ -425,10 +425,17 @@ MFBT_API void MozStackWalkThread(MozWalkStackCallback aCallback, } } +MFBT_API void MozStackWalkThread(MozWalkStackCallback aCallback, + uint32_t aMaxFrames, void* aClosure, + HANDLE aThread, CONTEXT* aContext) { + DoMozStackWalkThread(aCallback, /* aSkipFrames = */ 0, aMaxFrames, aClosure, + aThread, aContext); +} + MFBT_API void MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, uint32_t aMaxFrames, void* aClosure) { - MozStackWalkThread(aCallback, aSkipFrames, aMaxFrames, aClosure, nullptr, - nullptr); + DoMozStackWalkThread(aCallback, aSkipFrames, aMaxFrames, aClosure, nullptr, + nullptr); } static BOOL CALLBACK callbackEspecial64(PCSTR aModuleName, DWORD64 aModuleBase, @@ -676,6 +683,11 @@ void DemangleSymbol(const char* aSymbol, char* aBuffer, int aBufLen) { # if ((defined(__i386) || defined(PPC) || defined(__ppc__)) && \ (MOZ_STACKWALK_SUPPORTS_MACOSX || MOZ_STACKWALK_SUPPORTS_LINUX)) +static void DoFramePointerStackWalk(MozWalkStackCallback aCallback, + uint32_t aSkipFrames, uint32_t aMaxFrames, + void* aClosure, void** aBp, + void* aStackEnd); + MFBT_API void MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, uint32_t aMaxFrames, void* aClosure) { // Get the frame pointer @@ -714,8 +726,8 @@ MFBT_API void MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, # else # error Unsupported configuration # endif - FramePointerStackWalk(aCallback, aSkipFrames, aMaxFrames, aClosure, bp, - stackEnd); + DoFramePointerStackWalk(aCallback, aSkipFrames, aMaxFrames, aClosure, bp, + stackEnd); } # elif defined(HAVE__UNWIND_BACKTRACE) @@ -838,11 +850,11 @@ MFBT_API bool MozDescribeCodeAddress(void* aPC, #endif #if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_LINUX) -namespace mozilla { MOZ_ASAN_BLACKLIST -void FramePointerStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, - uint32_t aMaxFrames, void* aClosure, void** aBp, - void* aStackEnd) { +static void DoFramePointerStackWalk(MozWalkStackCallback aCallback, + uint32_t aSkipFrames, uint32_t aMaxFrames, + void* aClosure, void** aBp, + void* aStackEnd) { // Stack walking code courtesy Kipp's "leaky". int32_t skip = aSkipFrames; @@ -880,15 +892,23 @@ void FramePointerStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, aBp = next; } } + +namespace mozilla { + +void FramePointerStackWalk(MozWalkStackCallback aCallback, uint32_t aMaxFrames, + void* aClosure, void** aBp, void* aStackEnd) { + DoFramePointerStackWalk(aCallback, /* aSkipFrames = */ 0, aMaxFrames, + aClosure, aBp, aStackEnd); +} + } // namespace mozilla #else namespace mozilla { MFBT_API void FramePointerStackWalk(MozWalkStackCallback aCallback, - uint32_t aSkipFrames, uint32_t aMaxFrames, - void* aClosure, void** aBp, - void* aStackEnd) {} + uint32_t aMaxFrames, void* aClosure, + void** aBp, void* aStackEnd) {} } // namespace mozilla #endif diff --git a/mozglue/misc/StackWalk.h b/mozglue/misc/StackWalk.h index 3ea9de809127..836440c3ceab 100644 --- a/mozglue/misc/StackWalk.h +++ b/mozglue/misc/StackWalk.h @@ -57,7 +57,6 @@ MFBT_API void MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, * the caller of MozStackWalk to main (or above). * * @param aCallback Same as for MozStackWalk(). - * @param aSkipFrames Same as for MozStackWalk(). * @param aMaxFrames Same as for MozStackWalk(). * @param aClosure Same as for MozStackWalk(). * @param aThread The handle of the thread whose stack is to be walked. @@ -67,9 +66,8 @@ MFBT_API void MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, * null, the CONTEXT will be re-obtained. */ MFBT_API void MozStackWalkThread(MozWalkStackCallback aCallback, - uint32_t aSkipFrames, uint32_t aMaxFrames, - void* aClosure, HANDLE aThread, - CONTEXT* aContext); + uint32_t aMaxFrames, void* aClosure, + HANDLE aThread, CONTEXT* aContext); #else @@ -164,9 +162,8 @@ MFBT_API void MozFormatCodeAddressDetails( namespace mozilla { MFBT_API void FramePointerStackWalk(MozWalkStackCallback aCallback, - uint32_t aSkipFrames, uint32_t aMaxFrames, - void* aClosure, void** aBp, - void* aStackEnd); + uint32_t aMaxFrames, void* aClosure, + void** aBp, void* aStackEnd); #if defined(XP_LINUX) || defined(XP_FREEBSD) MFBT_API void DemangleSymbol(const char* aSymbol, char* aBuffer, int aBufLen); diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 864ea828dbcf..31700169ef99 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -1982,8 +1982,8 @@ static void DoFramePointerBacktrace(PSLockRef aLock, const void* stackEnd = aRegisteredThread.StackTop(); if (aRegs.mFP >= aRegs.mSP && aRegs.mFP <= stackEnd) { - FramePointerStackWalk(StackWalkCallback, /* skipFrames */ 0, maxFrames, - &aNativeStack, reinterpret_cast(aRegs.mFP), + FramePointerStackWalk(StackWalkCallback, maxFrames, &aNativeStack, + reinterpret_cast(aRegs.mFP), const_cast(stackEnd)); } } @@ -2008,8 +2008,8 @@ static void DoMozStackWalkBacktrace(PSLockRef aLock, HANDLE thread = GetThreadHandle(aRegisteredThread.GetPlatformData()); MOZ_ASSERT(thread); - MozStackWalkThread(StackWalkCallback, /* skipFrames */ 0, maxFrames, - &aNativeStack, thread, /* context */ nullptr); + MozStackWalkThread(StackWalkCallback, maxFrames, &aNativeStack, thread, + /* context */ nullptr); } #endif