From cb1d58302ded7e047bd0d00464338ef164910efd Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 7 Jan 2013 20:04:23 -0800 Subject: [PATCH] Bug 827691 - Treat [stack:nnnn] entries in /proc/self/maps as anonymous memory. r=jlebar. --HG-- extra : rebase_source : bfe5db77f0a4329a6cafeecfdb9b9de605f53bc5 --- xpcom/base/MapsMemoryReporter.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/xpcom/base/MapsMemoryReporter.cpp b/xpcom/base/MapsMemoryReporter.cpp index 2ef4c2667f10..692484bc9e95 100644 --- a/xpcom/base/MapsMemoryReporter.cpp +++ b/xpcom/base/MapsMemoryReporter.cpp @@ -335,6 +335,19 @@ MapsReporter::ParseMapping( return NS_OK; } +static bool +IsAnonymous(const nsACString &aName) +{ + // Recent kernels (e.g. 3.5) have multiple [stack:nnnn] entries, where |nnnn| + // is a thread ID. However, [stack:nnnn] entries count both stack memory + // *and* anonymous memory because the kernel only knows about the start of + // each thread stack, not its end. So we treat such entries as anonymous + // memory instead of stack. This is consistent with older kernels that don't + // even show [stack:nnnn] entries. + return aName.IsEmpty() || + StringBeginsWith(aName, NS_LITERAL_CSTRING("[stack:")); +} + void MapsReporter::GetReporterNameAndDescription( const char *aPath, @@ -376,7 +389,7 @@ MapsReporter::GetReporterNameAndDescription( "perform some privileged actions without the overhead of a " "syscall."); } - else if (!basename.IsEmpty()) { + else if (!IsAnonymous(basename)) { nsAutoCString dirname; GetDirname(absPath, dirname);