Bug 1049051 - Part 4: Make PrintCycle internal. r=froydnj

--HG--
extra : rebase_source : 594237c0e3e738078a9e571d9515c6feb0fd7bed
This commit is contained in:
Eric Rahm 2014-08-12 11:43:27 -07:00
Родитель ac663bd332
Коммит 9e9c81074a
2 изменённых файлов: 46 добавлений и 50 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -88,7 +88,6 @@ public:
return n;
}
private:
// ``DDT'' = ``Deadlock Detector Type''
typedef DeadlockDetector<BlockingResourceBase> 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
*