| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 """Classes that comprise the data model for binary size analysis.""" | 4 """Classes that comprise the data model for binary size analysis.""" |
| 5 | 5 |
| 6 import collections | 6 import collections |
| 7 import copy | 7 import copy |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 self.full_name = full_name or '' | 106 self.full_name = full_name or '' |
| 107 self.source_path = source_path or '' | 107 self.source_path = source_path or '' |
| 108 self.object_path = object_path or '' | 108 self.object_path = object_path or '' |
| 109 self.size = size_without_padding | 109 self.size = size_without_padding |
| 110 # Change this to be a bitfield of flags if ever there is a need to add | 110 # Change this to be a bitfield of flags if ever there is a need to add |
| 111 # another similar thing. | 111 # another similar thing. |
| 112 self.is_anonymous = is_anonymous | 112 self.is_anonymous = is_anonymous |
| 113 self.padding = 0 | 113 self.padding = 0 |
| 114 | 114 |
| 115 def __repr__(self): | 115 def __repr__(self): |
| 116 return '%s@%x(size=%d,padding=%d,name=%s,path=%s,anon=%d)' % ( | 116 return ('%s@%x(size_without_padding=%d,padding=%d,name=%s,path=%s,anon=%d)' |
| 117 self.section_name, self.address, self.size_without_padding, | 117 % (self.section_name, self.address, self.size_without_padding, |
| 118 self.padding, self.name, self.source_path or self.object_path, | 118 self.padding, self.name, self.source_path or self.object_path, |
| 119 int(self.is_anonymous)) | 119 int(self.is_anonymous))) |
| 120 | 120 |
| 121 | 121 |
| 122 class SymbolGroup(BaseSymbol): | 122 class SymbolGroup(BaseSymbol): |
| 123 """Represents a group of symbols using the same interface as Symbol. | 123 """Represents a group of symbols using the same interface as Symbol. |
| 124 | 124 |
| 125 SymbolGroups are immutable. All filtering / sorting will return new | 125 SymbolGroups are immutable. All filtering / sorting will return new |
| 126 SymbolGroups objects. | 126 SymbolGroups objects. |
| 127 | 127 |
| 128 Overrides many __functions__. E.g. the following are all valid: | 128 Overrides many __functions__. E.g. the following are all valid: |
| 129 * len(group) | 129 * len(group) |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 566 |
| 567 for remaining_syms in symbols_by_key.itervalues(): | 567 for remaining_syms in symbols_by_key.itervalues(): |
| 568 for old_sym in remaining_syms: | 568 for old_sym in remaining_syms: |
| 569 duped = copy.copy(old_sym) | 569 duped = copy.copy(old_sym) |
| 570 duped.size = -duped.size | 570 duped.size = -duped.size |
| 571 duped.padding = -duped.padding | 571 duped.padding = -duped.padding |
| 572 removed.append(duped) | 572 removed.append(duped) |
| 573 | 573 |
| 574 for section_name, padding in padding_by_section_name.iteritems(): | 574 for section_name, padding in padding_by_section_name.iteritems(): |
| 575 similar.append(Symbol(section_name, padding, | 575 similar.append(Symbol(section_name, padding, |
| 576 name='** aggregate padding of delta symbols')) | 576 name="** aggregate padding of diff'ed symbols")) |
| 577 return SymbolDiff(added, removed, similar) | 577 return SymbolDiff(added, removed, similar) |
| 578 | 578 |
| 579 | 579 |
| 580 def _ExtractPrefixBeforeSeparator(string, separator, count=1): | 580 def _ExtractPrefixBeforeSeparator(string, separator, count=1): |
| 581 idx = -len(separator) | 581 idx = -len(separator) |
| 582 prev_idx = None | 582 prev_idx = None |
| 583 for _ in xrange(count): | 583 for _ in xrange(count): |
| 584 idx = string.find(separator, idx + len(separator)) | 584 idx = string.find(separator, idx + len(separator)) |
| 585 if idx < 0: | 585 if idx < 0: |
| 586 break | 586 break |
| 587 prev_idx = idx | 587 prev_idx = idx |
| 588 return string[:prev_idx] | 588 return string[:prev_idx] |
| OLD | NEW |