Bug 1470268 - Add allocation filter to dmd.py. r=njn

This adds an '--allocation-filter' param that can be used to limit output to
only allocations that include the filter in their stack. For example:
  dmd.py --allocation-filter fontconfig dmd.json.gz
limits its output to just allocations that have an instance of 'fontconfig' in
in one of their stack frames.

--HG--
extra : rebase_source : 9ed34d5c7a6a2b76e96455e66b2e8196686ade16
This commit is contained in:
Eric Rahm 2018-06-20 13:11:50 -07:00
parent 3af306752a
commit ca834a09a7

View File

@ -195,6 +195,9 @@ variable is used to find breakpad symbols for stack fixing.
p.add_argument('--filter-stacks-for-testing', action='store_true',
help='filter stack traces; only useful for testing purposes')
p.add_argument('--allocation-filter',
help='Only print entries that have a stack that matches the filter')
p.add_argument('input_file',
help='a file produced by DMD')
@ -550,6 +553,11 @@ def printDigest(args, digest):
kindUsableSize = 0
maxRecord = 1000
if args.allocation_filter:
sortedRecords = list(filter(
lambda x: any(map(lambda y: args.allocation_filter in y, x.allocatedAtDesc)),
sortedRecords))
# First iteration: get totals, etc.
for record in sortedRecords:
kindBlocks += record.numBlocks