зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531966 - Dump out the contents of leaked nsStringBuffers when logging them. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D22037 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5baf191ea3
Коммит
49edb9400b
|
@ -348,8 +348,8 @@ static BloatEntry* GetBloatEntry(const char* aTypeName,
|
|||
return entry;
|
||||
}
|
||||
|
||||
static void DumpSerialNumbers(const SerialHash::Iterator& aHashEntry,
|
||||
FILE* aFd) {
|
||||
static void DumpSerialNumbers(const SerialHash::Iterator& aHashEntry, FILE* aFd,
|
||||
bool aDumpAsStringBuffer) {
|
||||
SerialNumberRecord* record = aHashEntry.Data();
|
||||
auto* outputFile = aFd;
|
||||
#ifdef HAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR
|
||||
|
@ -360,6 +360,19 @@ static void DumpSerialNumbers(const SerialHash::Iterator& aHashEntry,
|
|||
fprintf(outputFile, "%" PRIdPTR " @%p (%d references)\n",
|
||||
record->serialNumber, aHashEntry.Key(), record->refCount);
|
||||
#endif
|
||||
|
||||
if (aDumpAsStringBuffer) {
|
||||
// This output will be wrong if the nsStringBuffer was used to
|
||||
// store a char16_t string.
|
||||
auto* buffer = static_cast<const nsStringBuffer*>(aHashEntry.Key());
|
||||
nsDependentCString bufferString(static_cast<char*>(buffer->Data()),
|
||||
buffer->StorageSize() - 1);
|
||||
fprintf(outputFile,
|
||||
"Contents of leaked nsStringBuffer with storage size %d as a "
|
||||
"char*: %s\n",
|
||||
buffer->StorageSize(), bufferString.get());
|
||||
}
|
||||
|
||||
if (!record->allocationStack.empty()) {
|
||||
static const size_t bufLen = 1024;
|
||||
char buf[bufLen];
|
||||
|
@ -446,9 +459,12 @@ nsresult nsTraceRefcnt::DumpStatistics() {
|
|||
fprintf(gBloatLog, "nsTraceRefcnt::DumpStatistics: %d entries\n", count);
|
||||
|
||||
if (gSerialNumbers) {
|
||||
bool onlyLoggingStringBuffers = gTypesToLog && gTypesToLog->Count() == 1 &&
|
||||
gTypesToLog->Contains("nsStringBuffer");
|
||||
|
||||
fprintf(gBloatLog, "\nSerial Numbers of Leaked Objects:\n");
|
||||
for (auto iter = gSerialNumbers->Iter(); !iter.Done(); iter.Next()) {
|
||||
DumpSerialNumbers(iter, gBloatLog);
|
||||
DumpSerialNumbers(iter, gBloatLog, onlyLoggingStringBuffers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче