From 9e9c81074a2972ac09a7715665f61485bc65bc19 Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Tue, 12 Aug 2014 11:43:27 -0700 Subject: [PATCH] Bug 1049051 - Part 4: Make PrintCycle internal. r=froydnj --HG-- extra : rebase_source : 594237c0e3e738078a9e571d9515c6feb0fd7bed --- xpcom/glue/BlockingResourceBase.cpp | 78 +++++++++++++++++------------ xpcom/glue/BlockingResourceBase.h | 18 ------- 2 files changed, 46 insertions(+), 50 deletions(-) diff --git a/xpcom/glue/BlockingResourceBase.cpp b/xpcom/glue/BlockingResourceBase.cpp index b3005f18bc40..382fb590a117 100644 --- a/xpcom/glue/BlockingResourceBase.cpp +++ b/xpcom/glue/BlockingResourceBase.cpp @@ -37,6 +37,52 @@ PRCallOnceType BlockingResourceBase::sCallOnce; unsigned BlockingResourceBase::sResourceAcqnChainFrontTPI = (unsigned)-1; BlockingResourceBase::DDT* BlockingResourceBase::sDeadlockDetector; + +/** + * PrintCycle + * Append to |aOut| detailed information about the circular + * dependency in |aCycle|. Returns true if it *appears* that this + * cycle may represent an imminent deadlock, but this is merely a + * heuristic; the value returned may be a false positive or false + * negative. + * + * *NOT* thread safe. Calls |Print()|. + * + * FIXME bug 456272 hack alert: because we can't write call + * contexts into strings, all info is written to stderr, but only + * some info is written into |aOut| + */ +bool +PrintCycle(const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle, nsACString& aOut) +{ + NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!"); + + bool maybeImminent = true; + + fputs("=== Cyclical dependency starts at\n", stderr); + aOut += "Cyclical dependency starts at\n"; + + const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type res = aCycle->ElementAt(0); + maybeImminent &= res->Print(aOut); + + BlockingResourceBase::DDT::ResourceAcquisitionArray::index_type i; + BlockingResourceBase::DDT::ResourceAcquisitionArray::size_type len = aCycle->Length(); + const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements(); + for (i = 1; i < len - 1; ++i, ++it) { + fputs("\n--- Next dependency:\n", stderr); + aOut += "\nNext dependency:\n"; + + maybeImminent &= (*it)->Print(aOut); + } + + fputs("\n=== Cycle completed at\n", stderr); + aOut += "Cycle completed at\n"; + (*it)->Print(aOut); + + return maybeImminent; +} + + bool BlockingResourceBase::Print(nsACString& aOut) const { @@ -182,38 +228,6 @@ BlockingResourceBase::Release() } -bool -BlockingResourceBase::PrintCycle(const DDT::ResourceAcquisitionArray* aCycle, - nsACString& aOut) -{ - NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!"); - - bool maybeImminent = true; - - fputs("=== Cyclical dependency starts at\n", stderr); - aOut += "Cyclical dependency starts at\n"; - - const DDT::ResourceAcquisitionArray::elem_type res = aCycle->ElementAt(0); - maybeImminent &= res->Print(aOut); - - DDT::ResourceAcquisitionArray::index_type i; - DDT::ResourceAcquisitionArray::size_type len = aCycle->Length(); - const DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements(); - for (i = 1; i < len - 1; ++i, ++it) { - fputs("\n--- Next dependency:\n", stderr); - aOut += "\nNext dependency:\n"; - - maybeImminent &= (*it)->Print(aOut); - } - - fputs("\n=== Cycle completed at\n", stderr); - aOut += "Cycle completed at\n"; - (*it)->Print(aOut); - - return maybeImminent; -} - - // // Debug implementation of (OffTheBooks)Mutex void diff --git a/xpcom/glue/BlockingResourceBase.h b/xpcom/glue/BlockingResourceBase.h index 1d44fe87a251..41702659b46a 100644 --- a/xpcom/glue/BlockingResourceBase.h +++ b/xpcom/glue/BlockingResourceBase.h @@ -88,7 +88,6 @@ public: return n; } -private: // ``DDT'' = ``Deadlock Detector Type'' typedef DeadlockDetector DDT; @@ -133,23 +132,6 @@ protected: **/ void Release(); //NS_NEEDS_RESOURCE(this) - /** - * PrintCycle - * Append to |aOut| detailed information about the circular - * dependency in |aCycle|. Returns true if it *appears* that this - * cycle may represent an imminent deadlock, but this is merely a - * heuristic; the value returned may be a false positive or false - * negative. - * - * *NOT* thread safe. Calls |Print()|. - * - * FIXME bug 456272 hack alert: because we can't write call - * contexts into strings, all info is written to stderr, but only - * some info is written into |aOut| - */ - static bool PrintCycle(const DDT::ResourceAcquisitionArray* aCycle, - nsACString& aOut); - /** * ResourceChainFront *