Bug 698928 - Use debug.assertion if about:memory hits a problem. r=nnethercote.

--HG--
extra : rebase_source : 539d8ac810cf155dea4dd9d8fe258605da75649a
This commit is contained in:
Jesse Ruderman 2012-02-20 18:17:30 -08:00
Родитель 76fd40b789
Коммит 94eff07c4c
1 изменённых файлов: 17 добавлений и 5 удалений

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

@ -80,7 +80,16 @@ function flipBackslashes(aUnsafeStr)
function assert(aCond, aMsg) function assert(aCond, aMsg)
{ {
if (!aCond) { if (!aCond) {
throw("assertion failed: " + aMsg); reportAssertionFailure(aMsg)
throw("aboutMemory.js assertion failed: " + aMsg);
}
}
function reportAssertionFailure(aMsg)
{
var debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
if (debug.isDebugBuild) {
debug.assertion(aMsg, "false", "aboutMemory.js", 0);
} }
} }
@ -576,7 +585,7 @@ function buildTree(aReports, aTreeName)
} }
} }
if (!foundReport) { if (!foundReport) {
assert(aTreeName !== 'explicit'); assert(aTreeName !== 'explicit', "aTreeName !== 'explicit'");
return null; return null;
} }
@ -1254,10 +1263,11 @@ function appendTreeElements(aPOuter, aT, aProcess)
if (aT._amount === treeBytes) { if (aT._amount === treeBytes) {
percText = "100.0"; percText = "100.0";
} else { } else {
let perc = (100 * aT._amount / treeBytes); if (!(0 <= aT._amount && aT._amount <= treeBytes)) {
if (!(0 <= perc && perc <= 100)) {
tIsInvalid = true; tIsInvalid = true;
gUnsafePathsWithInvalidValuesForThisProcess.push(unsafePath); gUnsafePathsWithInvalidValuesForThisProcess.push(unsafePath);
reportAssertionFailure("Invalid value for " +
flipBackslashes(unsafePath));
} }
percText = (100 * aT._amount / treeBytes).toFixed(2); percText = (100 * aT._amount / treeBytes).toFixed(2);
percText = pad(percText, 5, '0'); percText = pad(percText, 5, '0');
@ -1416,7 +1426,7 @@ function appendOtherElements(aP, aReportsByProcess)
if (!r._done) { if (!r._done) {
assert(r._kind === KIND_OTHER, assert(r._kind === KIND_OTHER,
"_kind !== KIND_OTHER for " + flipBackslashes(r._unsafePath)); "_kind !== KIND_OTHER for " + flipBackslashes(r._unsafePath));
assert(r._nMerged === undefined); // we don't allow dup'd OTHER Reports assert(r._nMerged === undefined, "dup'd OTHER report");
let o = new OtherReport(r._unsafePath, r._units, r._amount, let o = new OtherReport(r._unsafePath, r._units, r._amount,
r._description); r._description);
otherReports.push(o); otherReports.push(o);
@ -1434,6 +1444,8 @@ function appendOtherElements(aP, aReportsByProcess)
let oIsInvalid = o.isInvalid(); let oIsInvalid = o.isInvalid();
if (oIsInvalid) { if (oIsInvalid) {
gUnsafePathsWithInvalidValuesForThisProcess.push(o._unsafePath); gUnsafePathsWithInvalidValuesForThisProcess.push(o._unsafePath);
reportAssertionFailure("Invalid value for " +
flipBackslashes(o._unsafePath));
} }
appendMrValueSpan(pre, pad(o._asString, maxStringLength, ' '), oIsInvalid); appendMrValueSpan(pre, pad(o._asString, maxStringLength, ' '), oIsInvalid);
appendMrNameSpan(pre, KIND_OTHER, kNoKids, o._description, o._unsafePath, appendMrNameSpan(pre, KIND_OTHER, kNoKids, o._description, o._unsafePath,