OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import sys | 6 import sys |
7 | 7 |
8 from lib.policy import PolicySet | 8 from lib.policy import PolicySet |
9 from lib.subcommand import SubCommand | 9 from lib.subcommand import SubCommand |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 0 : min(len(bucket.symbolized_stackfunction), 1 + depth)], | 80 0 : min(len(bucket.symbolized_stackfunction), 1 + depth)], |
81 bucket.symbolized_stacksourcefile[ | 81 bucket.symbolized_stacksourcefile[ |
82 0 : min(len(bucket.symbolized_stacksourcefile), 1 + depth)]): | 82 0 : min(len(bucket.symbolized_stacksourcefile), 1 + depth)]): |
83 stacktrace_sequence += '%s(@%s) ' % (function, sourcefile) | 83 stacktrace_sequence += '%s(@%s) ' % (function, sourcefile) |
84 if not stacktrace_sequence in sizes: | 84 if not stacktrace_sequence in sizes: |
85 sizes[stacktrace_sequence] = 0 | 85 sizes[stacktrace_sequence] = 0 |
86 sizes[stacktrace_sequence] += committed | 86 sizes[stacktrace_sequence] += committed |
87 | 87 |
88 @staticmethod | 88 @staticmethod |
89 def _accumulate(dump, policy, bucket_set, component_name, depth, sizes): | 89 def _accumulate(dump, policy, bucket_set, component_name, depth, sizes): |
90 rule = policy.find_rule(component_name) | 90 allocator_type = [] |
91 if not rule: | 91 rule = None |
92 pass | 92 while True: |
93 elif rule.allocator_type == 'malloc': | 93 rule = policy.find_rule(component_name, rule) |
94 for bucket_id, _, committed, allocs, frees in dump.iter_stacktrace: | 94 if not rule: |
95 bucket = bucket_set.get(bucket_id) | 95 break |
96 if not bucket or bucket.allocator_type == 'malloc': | 96 if rule.allocator_type not in allocator_type: |
97 component_match = policy.find_malloc(bucket) | 97 allocator_type.append(rule.allocator_type) |
98 elif bucket.allocator_type == 'mmap': | 98 else: |
99 continue | 99 continue |
100 else: | 100 |
101 assert False | 101 if rule.allocator_type == 'malloc': |
102 if component_match == component_name: | 102 for bucket_id, _, committed, allocs, frees in dump.iter_stacktrace: |
103 precedence = '' | 103 bucket = bucket_set.get(bucket_id) |
104 precedence += '(alloc=%d) ' % allocs | 104 if not bucket or bucket.allocator_type == 'malloc': |
105 precedence += '(free=%d) ' % frees | 105 component_match = policy.find_malloc(bucket) |
106 if bucket.typeinfo: | 106 elif bucket.allocator_type == 'mmap': |
107 precedence += '(type=%s) ' % bucket.symbolized_typeinfo | 107 continue |
108 precedence += '(type.name=%s) ' % bucket.typeinfo_name | 108 else: |
109 ExpandCommand._add_size(precedence, bucket, depth, committed, sizes) | 109 assert False |
110 elif rule.allocator_type == 'mmap': | 110 if component_match == component_name: |
111 for _, region in dump.iter_map: | 111 precedence = '' |
112 if region[0] != 'hooked': | 112 precedence += '(alloc=%d) ' % allocs |
113 continue | 113 precedence += '(free=%d) ' % frees |
114 component_match, bucket = policy.find_mmap(region, bucket_set) | 114 if bucket.typeinfo: |
115 if component_match == component_name: | 115 precedence += '(type=%s) ' % bucket.symbolized_typeinfo |
116 ExpandCommand._add_size('', bucket, depth, | 116 precedence += '(type.name=%s) ' % bucket.typeinfo_name |
117 region[1]['committed'], sizes) | 117 ExpandCommand._add_size(precedence, bucket, depth, committed, sizes) |
| 118 elif rule.allocator_type == 'mmap': |
| 119 for _, region in dump.iter_map: |
| 120 if region[0] != 'hooked': |
| 121 continue |
| 122 component_match, bucket = policy.find_mmap(region, bucket_set) |
| 123 if component_match == component_name: |
| 124 ExpandCommand._add_size('', bucket, depth, |
| 125 region[1]['committed'], sizes) |
OLD | NEW |