summaryrefslogtreecommitdiff
path: root/xpcom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-10-29 11:02:27 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-02 14:39:54 +0200
commitee86d3eb9c468edbb81550d27114ed66b3d71ee5 (patch)
treea00ffa052ffb8d072203938f595548dcd3b2e0ed /xpcom
parentd0acadd727468ccaa4e3cbe3673e29890c2551ca (diff)
downloaduxp-ee86d3eb9c468edbb81550d27114ed66b3d71ee5.tar.gz
Issue #21 - Remove Telemetry plumbing and fix build.
Note this won't give working applications. Requires FE changes and additional js module changes (next part).
Diffstat (limited to 'xpcom')
-rw-r--r--xpcom/base/CycleCollectedJSContext.cpp1
-rw-r--r--xpcom/base/nsMemoryReporterManager.cpp1
-rw-r--r--xpcom/build/LateWriteChecks.cpp101
-rw-r--r--xpcom/build/XPCOMInit.cpp4
-rw-r--r--xpcom/threads/BackgroundHangMonitor.cpp124
-rw-r--r--xpcom/threads/HangMonitor.cpp2
-rw-r--r--xpcom/threads/ThreadStackHelper.cpp225
-rw-r--r--xpcom/threads/ThreadStackHelper.h100
-rw-r--r--xpcom/threads/moz.build1
9 files changed, 9 insertions, 550 deletions
diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp
index 0a4c2da4fa..17a989c833 100644
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -60,7 +60,6 @@
#include "mozilla/Move.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Sprintf.h"
-#include "mozilla/Telemetry.h"
#include "mozilla/TimelineConsumers.h"
#include "mozilla/TimelineMarker.h"
#include "mozilla/Unused.h"
diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp
index 810254bcc6..4397f470e8 100644
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -23,7 +23,6 @@
#include "mozilla/PodOperations.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
-#include "mozilla/Telemetry.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/dom/PMemoryReportRequestParent.h" // for dom::MemoryReport
#include "mozilla/dom/ContentParent.h"
diff --git a/xpcom/build/LateWriteChecks.cpp b/xpcom/build/LateWriteChecks.cpp
index daa18c0d5e..7ace9a0fbd 100644
--- a/xpcom/build/LateWriteChecks.cpp
+++ b/xpcom/build/LateWriteChecks.cpp
@@ -7,11 +7,9 @@
#include "mozilla/IOInterposer.h"
#include "mozilla/PoisonIOInterposer.h"
-#include "mozilla/ProcessedStack.h"
#include "mozilla/SHA1.h"
#include "mozilla/Scoped.h"
#include "mozilla/StaticPtr.h"
-#include "mozilla/Telemetry.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryServiceUtils.h"
#include "nsPrintfCString.h"
@@ -34,8 +32,6 @@
#include "LateWriteChecks.h"
-#define OBSERVE_LATE_WRITES
-
using namespace mozilla;
/*************************** Auxiliary Declarations ***************************/
@@ -111,102 +107,7 @@ private:
void
LateWriteObserver::Observe(IOInterposeObserver::Observation& aOb)
{
-#ifdef OBSERVE_LATE_WRITES
- // Crash if that is the shutdown check mode
- if (gShutdownChecks == SCM_CRASH) {
- MOZ_CRASH();
- }
-
- // If we have shutdown mode SCM_NOTHING or we can't record then abort
- if (gShutdownChecks == SCM_NOTHING || !Telemetry::CanRecordExtended()) {
- return;
- }
-
- // Write the stack and loaded libraries to a file. We can get here
- // concurrently from many writes, so we use multiple temporary files.
- std::vector<uintptr_t> rawStack;
-
- MozStackWalk(RecordStackWalker, /* skipFrames */ 0, /* maxFrames */ 0,
- reinterpret_cast<void*>(&rawStack), 0, nullptr);
- Telemetry::ProcessedStack stack = Telemetry::GetStackAndModules(rawStack);
-
- nsPrintfCString nameAux("%s%s%s", mProfileDirectory,
- NS_SLASH, "Telemetry.LateWriteTmpXXXXXX");
- char* name;
- nameAux.GetMutableData(&name);
-
- // We want the sha1 of the entire file, so please don't write to fd
- // directly; use sha1Stream.
- FILE* stream;
-#ifdef XP_WIN
- HANDLE hFile;
- do {
- // mkstemp isn't supported so keep trying until we get a file
- int result = _mktemp_s(name, strlen(name) + 1);
- hFile = CreateFileA(name, GENERIC_WRITE, 0, nullptr, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, nullptr);
- } while (GetLastError() == ERROR_FILE_EXISTS);
-
- if (hFile == INVALID_HANDLE_VALUE) {
- NS_RUNTIMEABORT("Um, how did we get here?");
- }
-
- // http://support.microsoft.com/kb/139640
- int fd = _open_osfhandle((intptr_t)hFile, _O_APPEND);
- if (fd == -1) {
- NS_RUNTIMEABORT("Um, how did we get here?");
- }
-
- stream = _fdopen(fd, "w");
-#else
- int fd = mkstemp(name);
- stream = fdopen(fd, "w");
-#endif
-
- SHA1Stream sha1Stream(stream);
-
- size_t numModules = stack.GetNumModules();
- sha1Stream.Printf("%u\n", (unsigned)numModules);
- for (size_t i = 0; i < numModules; ++i) {
- Telemetry::ProcessedStack::Module module = stack.GetModule(i);
- sha1Stream.Printf("%s %s\n", module.mBreakpadId.c_str(),
- module.mName.c_str());
- }
-
- size_t numFrames = stack.GetStackSize();
- sha1Stream.Printf("%u\n", (unsigned)numFrames);
- for (size_t i = 0; i < numFrames; ++i) {
- const Telemetry::ProcessedStack::Frame& frame = stack.GetFrame(i);
- // NOTE: We write the offsets, while the atos tool expects a value with
- // the virtual address added. For example, running otool -l on the the firefox
- // binary shows
- // cmd LC_SEGMENT_64
- // cmdsize 632
- // segname __TEXT
- // vmaddr 0x0000000100000000
- // so to print the line matching the offset 123 one has to run
- // atos -o firefox 0x100000123.
- sha1Stream.Printf("%d %x\n", frame.mModIndex, (unsigned)frame.mOffset);
- }
-
- SHA1Sum::Hash sha1;
- sha1Stream.Finish(sha1);
-
- // Note: These files should be deleted by telemetry once it reads them. If
- // there were no telemetry runs by the time we shut down, we just add files
- // to the existing ones instead of replacing them. Given that each of these
- // files is a bug to be fixed, that is probably the right thing to do.
-
- // We append the sha1 of the contents to the file name. This provides a simple
- // client side deduplication.
- nsPrintfCString finalName("%s%s", mProfileDirectory,
- "/Telemetry.LateWriteFinal-");
- for (int i = 0; i < 20; ++i) {
- finalName.AppendPrintf("%02x", sha1[i]);
- }
- PR_Delete(finalName.get());
- PR_Rename(name, finalName.get());
-#endif
+/* *** STUB *** */
}
/******************************* Setup/Teardown *******************************/
diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp
index e96314a1c5..3291c06c07 100644
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -131,7 +131,6 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
#include "mozilla/Services.h"
#include "mozilla/Omnijar.h"
#include "mozilla/HangMonitor.h"
-#include "mozilla/Telemetry.h"
#include "mozilla/BackgroundHangMonitor.h"
#include "nsChromeRegistry.h"
@@ -757,8 +756,6 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
RegisterStrongMemoryReporter(new VPXReporter());
#endif
- mozilla::Telemetry::Init();
-
mozilla::HangMonitor::Startup();
mozilla::BackgroundHangMonitor::Startup();
@@ -812,7 +809,6 @@ NS_InitMinimalXPCOM()
AbstractThread::InitStatics();
SharedThreadPool::InitStatics();
- mozilla::Telemetry::Init();
mozilla::HangMonitor::Startup();
mozilla::BackgroundHangMonitor::Startup();
diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp
index 7af342c8c9..b0b41e291e 100644
--- a/xpcom/threads/BackgroundHangMonitor.cpp
+++ b/xpcom/threads/BackgroundHangMonitor.cpp
@@ -10,13 +10,10 @@
#include "mozilla/Move.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPtr.h"
-#include "mozilla/Telemetry.h"
-#include "mozilla/ThreadHangStats.h"
#include "mozilla/ThreadLocal.h"
#include "prinrval.h"
#include "prthread.h"
-#include "ThreadStackHelper.h"
#include "nsIObserverService.h"
#include "nsIObserver.h"
#include "mozilla/Services.h"
@@ -30,7 +27,7 @@
#define BHR_BETA_MOD 1;
// Maximum depth of the call stack in the reported thread hangs. This value represents
-// the 99.9th percentile of the thread hangs stack depths reported by Telemetry.
+// the 99.9th percentile of the thread hangs stack depths reported.
static const size_t kMaxThreadHangStackDepth = 30;
// An utility comparator function used by std::unique to collapse "(* script)" entries in
@@ -174,12 +171,6 @@ public:
bool mWaiting;
// Is the thread dedicated to a single BackgroundHangMonitor
BackgroundHangMonitor::ThreadType mThreadType;
- // Platform-specific helper to get hang stacks
- ThreadStackHelper mStackHelper;
- // Stack of current hang
- Telemetry::HangStack mHangStack;
- // Statistics for telemetry
- Telemetry::ThreadHangStats mStats;
// Annotations for the current hang
UniquePtr<HangMonitor::HangAnnotations> mAnnotations;
// Annotators registered for this thread
@@ -190,10 +181,6 @@ public:
uint32_t aMaxTimeoutMs,
BackgroundHangMonitor::ThreadType aThreadType = BackgroundHangMonitor::THREAD_SHARED);
- // Report a hang; aManager->mLock IS locked
- Telemetry::HangHistogram& ReportHang(PRIntervalTime aHangTime);
- // Report a permanent hang; aManager->mLock IS locked
- void ReportPermaHang();
// Called by BackgroundHangMonitor::NotifyActivity
void NotifyActivity()
{
@@ -325,14 +312,12 @@ BackgroundHangManager::RunMonitorThread()
// Skip subsequent iterations and tolerate a race on mWaiting here
currentThread->mWaiting = true;
currentThread->mHanging = false;
- currentThread->ReportPermaHang();
continue;
}
if (MOZ_LIKELY(!currentThread->mHanging)) {
if (MOZ_UNLIKELY(hangTime >= currentThread->mTimeout)) {
// A hang started
- currentThread->mStackHelper.GetStack(currentThread->mHangStack);
currentThread->mHangStart = interval;
currentThread->mHanging = true;
currentThread->mAnnotations =
@@ -341,7 +326,6 @@ BackgroundHangManager::RunMonitorThread()
} else {
if (MOZ_LIKELY(interval != currentThread->mHangStart)) {
// A hang ended
- currentThread->ReportHang(intervalNow - currentThread->mHangStart);
currentThread->mHanging = false;
}
}
@@ -390,7 +374,6 @@ BackgroundHangThread::BackgroundHangThread(const char* aName,
, mHanging(false)
, mWaiting(true)
, mThreadType(aThreadType)
- , mStats(aName)
{
if (sTlsKeyInitialized && IsShared()) {
sTlsKey.set(this);
@@ -416,69 +399,6 @@ BackgroundHangThread::~BackgroundHangThread()
if (sTlsKeyInitialized && IsShared()) {
sTlsKey.set(nullptr);
}
-
- // Move our copy of ThreadHangStats to Telemetry storage
- Telemetry::RecordThreadHangStats(mStats);
-}
-
-Telemetry::HangHistogram&
-BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
-{
- // Recovered from a hang; called on the monitor thread
- // mManager->mLock IS locked
-
- // Remove unwanted "js::RunScript" frame from the stack
- for (size_t i = 0; i < mHangStack.length(); ) {
- const char** f = mHangStack.begin() + i;
- if (!mHangStack.IsInBuffer(*f) && !strcmp(*f, "js::RunScript")) {
- mHangStack.erase(f);
- } else {
- i++;
- }
- }
-
- // Collapse duplicated "(chrome script)" and "(content script)" entries in the stack.
- auto it = std::unique(mHangStack.begin(), mHangStack.end(), StackScriptEntriesCollapser);
- mHangStack.erase(it, mHangStack.end());
-
- // Limit the depth of the reported stack if greater than our limit. Only keep its
- // last entries, since the most recent frames are at the end of the vector.
- if (mHangStack.length() > kMaxThreadHangStackDepth) {
- const int elementsToRemove = mHangStack.length() - kMaxThreadHangStackDepth;
- // Replace the oldest frame with a known label so that we can tell this stack
- // was limited.
- mHangStack[0] = "(reduced stack)";
- mHangStack.erase(mHangStack.begin() + 1, mHangStack.begin() + elementsToRemove);
- }
-
- Telemetry::HangHistogram newHistogram(Move(mHangStack));
- for (Telemetry::HangHistogram* oldHistogram = mStats.mHangs.begin();
- oldHistogram != mStats.mHangs.end(); oldHistogram++) {
- if (newHistogram == *oldHistogram) {
- // New histogram matches old one
- oldHistogram->Add(aHangTime, Move(mAnnotations));
- return *oldHistogram;
- }
- }
- // Add new histogram
- newHistogram.Add(aHangTime, Move(mAnnotations));
- if (!mStats.mHangs.append(Move(newHistogram))) {
- MOZ_CRASH();
- }
- return mStats.mHangs.back();
-}
-
-void
-BackgroundHangThread::ReportPermaHang()
-{
- // Permanently hanged; called on the monitor thread
- // mManager->mLock IS locked
-
- Telemetry::HangHistogram& hang = ReportHang(mMaxTimeout);
- Telemetry::HangStack& stack = hang.GetNativeStack();
- if (stack.empty()) {
- mStackHelper.GetNativeStack(stack);
- }
}
MOZ_ALWAYS_INLINE void
@@ -493,7 +413,6 @@ BackgroundHangThread::Update()
mManager->Wakeup();
} else {
PRIntervalTime duration = intervalNow - mInterval;
- mStats.mActivity.Add(duration);
if (MOZ_UNLIKELY(duration >= mTimeout)) {
/* Wake up the manager thread to tell it that a hang ended */
mManager->Wakeup();
@@ -552,19 +471,12 @@ BackgroundHangMonitor::IsDisabled() {
bool
BackgroundHangMonitor::DisableOnBeta() {
- nsAdoptingCString clientID = Preferences::GetCString("toolkit.telemetry.cachedClientID");
- bool telemetryEnabled = Preferences::GetBool("toolkit.telemetry.enabled");
-
- if (!telemetryEnabled || !clientID || BackgroundHangMonitor::ShouldDisableOnBeta(clientID)) {
- if (XRE_IsParentProcess()) {
- BackgroundHangMonitor::Shutdown();
- } else {
- BackgroundHangManager::sDisabled = true;
- }
- return true;
+ if (XRE_IsParentProcess()) {
+ BackgroundHangMonitor::Shutdown();
+ } else {
+ BackgroundHangManager::sDisabled = true;
}
-
- return false;
+ return true;
}
void
@@ -575,7 +487,6 @@ BackgroundHangMonitor::Startup()
if (!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "beta")) {
if (XRE_IsParentProcess()) { // cached ClientID hasn't been read yet
- ThreadStackHelper::Startup();
BackgroundHangThread::Startup();
BackgroundHangManager::sInstance = new BackgroundHangManager();
@@ -589,7 +500,6 @@ BackgroundHangMonitor::Startup()
}
}
- ThreadStackHelper::Startup();
BackgroundHangThread::Startup();
BackgroundHangManager::sInstance = new BackgroundHangManager();
#endif
@@ -610,7 +520,6 @@ BackgroundHangMonitor::Shutdown()
we don't want to hold the lock when it's being destroyed. */
BackgroundHangManager::sInstance->Shutdown();
BackgroundHangManager::sInstance = nullptr;
- ThreadStackHelper::Shutdown();
BackgroundHangManager::sDisabled = true;
#endif
}
@@ -652,11 +561,8 @@ BackgroundHangMonitor::NotifyActivity()
"This thread is not initialized for hang monitoring");
return;
}
-
- if (Telemetry::CanRecordExtended()) {
- mThread->NotifyActivity();
- }
#endif
+// STUB
}
void
@@ -668,11 +574,8 @@ BackgroundHangMonitor::NotifyWait()
"This thread is not initialized for hang monitoring");
return;
}
-
- if (Telemetry::CanRecordExtended()) {
- mThread->NotifyWait();
- }
#endif
+// STUB
}
bool
@@ -719,15 +622,4 @@ BackgroundHangMonitor::ThreadHangStatsIterator::ThreadHangStatsIterator()
#endif
}
-Telemetry::ThreadHangStats*
-BackgroundHangMonitor::ThreadHangStatsIterator::GetNext()
-{
- if (!mThread) {
- return nullptr;
- }
- Telemetry::ThreadHangStats* stats = &mThread->mStats;
- mThread = mThread->getNext();
- return stats;
-}
-
} // namespace mozilla
diff --git a/xpcom/threads/HangMonitor.cpp b/xpcom/threads/HangMonitor.cpp
index 1f512a28c0..1fd74066a0 100644
--- a/xpcom/threads/HangMonitor.cpp
+++ b/xpcom/threads/HangMonitor.cpp
@@ -9,8 +9,6 @@
#include "mozilla/BackgroundHangMonitor.h"
#include "mozilla/Monitor.h"
#include "mozilla/Preferences.h"
-#include "mozilla/ProcessedStack.h"
-#include "mozilla/Telemetry.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/UniquePtr.h"
#include "nsReadableUtils.h"
diff --git a/xpcom/threads/ThreadStackHelper.cpp b/xpcom/threads/ThreadStackHelper.cpp
deleted file mode 100644
index 72d82e4daa..0000000000
--- a/xpcom/threads/ThreadStackHelper.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; 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/. */
-
-#include "ThreadStackHelper.h"
-#include "MainThreadUtils.h"
-#include "nsJSPrincipals.h"
-#include "nsScriptSecurityManager.h"
-#include "jsfriendapi.h"
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/IntegerPrintfMacros.h"
-#include "mozilla/Move.h"
-#include "mozilla/Scoped.h"
-#include "mozilla/UniquePtr.h"
-#include "mozilla/MemoryChecking.h"
-#include "mozilla/Sprintf.h"
-
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wshadow"
-#endif
-
-#if defined(MOZ_VALGRIND)
-# include <valgrind/valgrind.h>
-#endif
-
-#include <string.h>
-#include <vector>
-#include <cstdlib>
-
-#ifdef XP_LINUX
-#include <ucontext.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#endif
-
-#ifdef __GNUC__
-# pragma GCC diagnostic pop // -Wshadow
-#endif
-
-#if defined(XP_LINUX)
-#include <pthread.h>
-#endif
-
-namespace mozilla {
-
-void
-ThreadStackHelper::Startup()
-{
-#if defined(XP_LINUX)
- MOZ_ASSERT(NS_IsMainThread());
- if (!sInitialized) {
- // TODO: centralize signal number allocation
- sFillStackSignum = SIGRTMIN + 4;
- if (sFillStackSignum > SIGRTMAX) {
- // Leave uninitialized
- MOZ_ASSERT(false);
- return;
- }
- struct sigaction sigact = {};
- sigact.sa_sigaction = FillStackHandler;
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = SA_SIGINFO | SA_RESTART;
- MOZ_ALWAYS_TRUE(!::sigaction(sFillStackSignum, &sigact, nullptr));
- }
- sInitialized++;
-#endif
-}
-
-void
-ThreadStackHelper::Shutdown()
-{
-#if defined(XP_LINUX)
- MOZ_ASSERT(NS_IsMainThread());
- if (sInitialized == 1) {
- struct sigaction sigact = {};
- sigact.sa_handler = SIG_DFL;
- MOZ_ALWAYS_TRUE(!::sigaction(sFillStackSignum, &sigact, nullptr));
- }
- sInitialized--;
-#endif
-}
-
-ThreadStackHelper::ThreadStackHelper()
- : mStackToFill(nullptr)
-{
-#if defined(XP_LINUX)
- MOZ_ALWAYS_TRUE(!::sem_init(&mSem, 0, 0));
- mThreadID = ::syscall(SYS_gettid);
-#elif defined(XP_WIN)
- mInitialized = !!::DuplicateHandle(
- ::GetCurrentProcess(), ::GetCurrentThread(),
- ::GetCurrentProcess(), &mThreadID,
- THREAD_SUSPEND_RESUME
- , FALSE, 0);
- MOZ_ASSERT(mInitialized);
-#endif
-}
-
-ThreadStackHelper::~ThreadStackHelper()
-{
-#if defined(XP_LINUX)
- MOZ_ALWAYS_TRUE(!::sem_destroy(&mSem));
-#elif defined(XP_WIN)
- if (mInitialized) {
- MOZ_ALWAYS_TRUE(!!::CloseHandle(mThreadID));
- }
-#endif
-}
-
-namespace {
-template<typename T>
-class ScopedSetPtr
-{
-private:
- T*& mPtr;
-public:
- ScopedSetPtr(T*& p, T* val) : mPtr(p) { mPtr = val; }
- ~ScopedSetPtr() { mPtr = nullptr; }
-};
-} // namespace
-
-void
-ThreadStackHelper::GetStack(Stack& aStack)
-{
- // Always run PrepareStackBuffer first to clear aStack
- if (!PrepareStackBuffer(aStack)) {
- // Skip and return empty aStack
- return;
- }
-
- ScopedSetPtr<Stack> stackPtr(mStackToFill, &aStack);
-
-#if defined(XP_LINUX)
- if (!sInitialized) {
- MOZ_ASSERT(false);
- return;
- }
- siginfo_t uinfo = {};
- uinfo.si_signo = sFillStackSignum;
- uinfo.si_code = SI_QUEUE;
- uinfo.si_pid = getpid();
- uinfo.si_uid = getuid();
- uinfo.si_value.sival_ptr = this;
- if (::syscall(SYS_rt_tgsigqueueinfo, uinfo.si_pid,
- mThreadID, sFillStackSignum, &uinfo)) {
- // rt_tgsigqueueinfo was added in Linux 2.6.31.
- // Could have failed because the syscall did not exist.
- return;
- }
- MOZ_ALWAYS_TRUE(!::sem_wait(&mSem));
-
-#elif defined(XP_WIN)
- if (!mInitialized) {
- MOZ_ASSERT(false);
- return;
- }
- if (::SuspendThread(mThreadID) == DWORD(-1)) {
- MOZ_ASSERT(false);
- return;
- }
-
- // SuspendThread is asynchronous, so the thread may still be running. Use
- // GetThreadContext to ensure it's really suspended.
- // See https://blogs.msdn.microsoft.com/oldnewthing/20150205-00/?p=44743.
- CONTEXT context;
- context.ContextFlags = CONTEXT_CONTROL;
- if (::GetThreadContext(mThreadID, &context)) {
- FillStackBuffer();
- FillThreadContext();
- }
-
- MOZ_ALWAYS_TRUE(::ResumeThread(mThreadID) != DWORD(-1));
-#endif
-}
-
-void
-ThreadStackHelper::GetNativeStack(Stack& aStack)
-{
- /*** STUB ***/
-}
-
-#ifdef XP_LINUX
-
-int ThreadStackHelper::sInitialized;
-int ThreadStackHelper::sFillStackSignum;
-
-void
-ThreadStackHelper::FillStackHandler(int aSignal, siginfo_t* aInfo,
- void* aContext)
-{
- ThreadStackHelper* const helper =
- reinterpret_cast<ThreadStackHelper*>(aInfo->si_value.sival_ptr);
- helper->FillStackBuffer();
- helper->FillThreadContext(aContext);
- ::sem_post(&helper->mSem);
-}
-
-#endif // XP_LINUX
-
-bool
-ThreadStackHelper::PrepareStackBuffer(Stack& aStack)
-{
- // Return false to skip getting the stack and return an empty stack
- aStack.clear();
- return false;
-}
-
-void
-ThreadStackHelper::FillStackBuffer()
-{
- MOZ_ASSERT(mStackToFill->empty());
- /*** STUB ***/
-}
-
-MOZ_ASAN_BLACKLIST void
-ThreadStackHelper::FillThreadContext(void* aContext)
-{
- /*** STUB ***/
-}
-
-} // namespace mozilla
diff --git a/xpcom/threads/ThreadStackHelper.h b/xpcom/threads/ThreadStackHelper.h
deleted file mode 100644
index 04bcb7b0ab..0000000000
--- a/xpcom/threads/ThreadStackHelper.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; 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/. */
-
-#ifndef mozilla_ThreadStackHelper_h
-#define mozilla_ThreadStackHelper_h
-
-#include "mozilla/ThreadHangStats.h"
-
-#include "GeckoProfiler.h"
-
-#include <stddef.h>
-
-#if defined(XP_LINUX)
-#include <signal.h>
-#include <semaphore.h>
-#include <sys/types.h>
-#elif defined(XP_WIN)
-#include <windows.h>
-#endif
-
-namespace mozilla {
-
-/**
- * ThreadStackHelper is used to retrieve the profiler pseudo-stack of a
- * thread, as an alternative of using the profiler to take a profile.
- * The target thread first declares an ThreadStackHelper instance;
- * then another thread can call ThreadStackHelper::GetStack to retrieve
- * the pseudo-stack of the target thread at that instant.
- *
- * Only non-copying labels are included in the stack, which means labels
- * with custom text and markers are not included.
- */
-class ThreadStackHelper
-{
-public:
- typedef Telemetry::HangStack Stack;
-
-private:
- Stack* mStackToFill;
-
- bool PrepareStackBuffer(Stack& aStack);
- void FillStackBuffer();
- void FillThreadContext(void* aContext = nullptr);
-
-public:
- /**
- * Initialize ThreadStackHelper. Must be called from main thread.
- */
- static void Startup();
- /**
- * Uninitialize ThreadStackHelper. Must be called from main thread.
- */
- static void Shutdown();
-
- /**
- * Create a ThreadStackHelper instance targeting the current thread.
- */
- ThreadStackHelper();
-
- ~ThreadStackHelper();
-
- /**
- * Retrieve the current pseudostack of the thread associated
- * with this ThreadStackHelper.
- *
- * @param aStack Stack instance to be filled.
- */
- void GetStack(Stack& aStack);
-
- /**
- * Retrieve the current native stack of the thread associated
- * with this ThreadStackHelper.
- *
- * @param aNativeStack Stack instance to be filled.
- */
- void GetNativeStack(Stack& aStack);
-
-#if defined(XP_LINUX)
-private:
- static int sInitialized;
- static int sFillStackSignum;
-
- static void FillStackHandler(int aSignal, siginfo_t* aInfo, void* aContext);
-
- sem_t mSem;
- pid_t mThreadID;
-
-#elif defined(XP_WIN)
-private:
- bool mInitialized;
- HANDLE mThreadID;
-
-#endif
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ThreadStackHelper_h
diff --git a/xpcom/threads/moz.build b/xpcom/threads/moz.build
index 9383400cb6..b09608eba6 100644
--- a/xpcom/threads/moz.build
+++ b/xpcom/threads/moz.build
@@ -62,7 +62,6 @@ UNIFIED_SOURCES += [
'nsTimerImpl.cpp',
'SharedThreadPool.cpp',
'TaskQueue.cpp',
- 'ThreadStackHelper.cpp',
'ThrottledEventQueue.cpp',
'TimerThread.cpp',
]