Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: tools/binary_size/models.py

Issue 2802293002: //tools/binary_size: Add object file count to Print() (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/testdata/ActualDiff.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 The primary classes are Symbol, and SymbolGroup. 6 The primary classes are Symbol, and SymbolGroup.
7 7
8 Description of common properties: 8 Description of common properties:
9 * address: The start address of the symbol. 9 * address: The start address of the symbol.
10 May be 0 (e.g. for .bss or for SymbolGroups). 10 May be 0 (e.g. for .bss or for SymbolGroups).
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if isinstance(key, slice): 229 if isinstance(key, slice):
230 return self._symbols.__getitem__(key) 230 return self._symbols.__getitem__(key)
231 if isinstance(key, basestring) or key > len(self._symbols): 231 if isinstance(key, basestring) or key > len(self._symbols):
232 found = self.WhereAddressInRange(key) 232 found = self.WhereAddressInRange(key)
233 if len(found) != 1: 233 if len(found) != 1:
234 raise KeyError('%d symbols found at address %s.' % (len(found), key)) 234 raise KeyError('%d symbols found at address %s.' % (len(found), key))
235 return found[0] 235 return found[0]
236 return self._symbols[key] 236 return self._symbols[key]
237 237
238 def __sub__(self, other): 238 def __sub__(self, other):
239 if other.IsGroup(): 239 other_ids = set(id(s) for s in other)
240 other_ids = set(id(s) for s in other)
241 else:
242 other_ids = set((id(other),))
243 new_symbols = [s for s in self if id(s) not in other_ids] 240 new_symbols = [s for s in self if id(s) not in other_ids]
244 return self._CreateTransformed(new_symbols, section_name=self.section_name) 241 return self._CreateTransformed(new_symbols, section_name=self.section_name)
245 242
246 def __add__(self, other): 243 def __add__(self, other):
247 self_ids = set(id(s) for s in self) 244 self_ids = set(id(s) for s in self)
248 new_symbols = self._symbols + [s for s in other if id(s) not in self_ids] 245 new_symbols = self._symbols + [s for s in other if id(s) not in self_ids]
249 return self._CreateTransformed(new_symbols, section_name=self.section_name, 246 return self._CreateTransformed(new_symbols, section_name=self.section_name,
250 is_sorted=False) 247 is_sorted=False)
251 248
252 @property 249 @property
253 def address(self): 250 def address(self):
254 return 0 251 return 0
255 252
256 @property 253 @property
257 def full_name(self): 254 def full_name(self):
258 return None 255 return None
259 256
260 @property 257 @property
261 def is_anonymous(self): 258 def is_anonymous(self):
262 return False 259 return False
263 260
264 @property 261 @property
262 def object_path(self):
263 return None
264
265 @property
265 def source_path(self): 266 def source_path(self):
266 return None 267 return None
267 268
268 @property 269 @property
269 def size(self): 270 def size(self):
270 if self._size is None: 271 if self._size is None:
271 if self.IsBss(): 272 if self.IsBss():
272 self._size = sum(s.size for s in self) 273 self._size = sum(s.size for s in self)
273 self._size = sum(s.size for s in self if not s.IsBss()) 274 self._size = sum(s.size for s in self if not s.IsBss())
274 return self._size 275 return self._size
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 632
632 def _ExtractPrefixBeforeSeparator(string, separator, count=1): 633 def _ExtractPrefixBeforeSeparator(string, separator, count=1):
633 idx = -len(separator) 634 idx = -len(separator)
634 prev_idx = None 635 prev_idx = None
635 for _ in xrange(count): 636 for _ in xrange(count):
636 idx = string.find(separator, idx + len(separator)) 637 idx = string.find(separator, idx + len(separator))
637 if idx < 0: 638 if idx < 0:
638 break 639 break
639 prev_idx = idx 640 prev_idx = idx
640 return string[:prev_idx] 641 return string[:prev_idx]
OLDNEW
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/testdata/ActualDiff.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698