| 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 """Methods for converting model objects to human-readable formats.""" | 4 """Methods for converting model objects to human-readable formats.""" |
| 5 | 5 |
| 6 import datetime | 6 import datetime |
| 7 import itertools | 7 import itertools |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 import models | 10 import models |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if k in section_names and k != '.bss') | 41 if k in section_names and k != '.bss') |
| 42 yield 'Section Sizes (Total={:,} bytes):'.format(total_bytes) | 42 yield 'Section Sizes (Total={:,} bytes):'.format(total_bytes) |
| 43 for name in section_names: | 43 for name in section_names: |
| 44 size = section_sizes[name] | 44 size = section_sizes[name] |
| 45 if name == '.bss': | 45 if name == '.bss': |
| 46 yield '{}: {:,} bytes (not included in totals)'.format(name, size) | 46 yield '{}: {:,} bytes (not included in totals)'.format(name, size) |
| 47 else: | 47 else: |
| 48 percent = float(size) / total_bytes if total_bytes else 0 | 48 percent = float(size) / total_bytes if total_bytes else 0 |
| 49 yield '{}: {:,} bytes ({:.1%})'.format(name, size, percent) | 49 yield '{}: {:,} bytes ({:.1%})'.format(name, size, percent) |
| 50 | 50 |
| 51 if self.verbose: |
| 52 yield '' |
| 53 yield 'Other section sizes:' |
| 54 section_names = sorted(k for k in section_sizes.iterkeys() |
| 55 if k not in section_names) |
| 56 for name in section_names: |
| 57 yield '{}: {:,} bytes'.format(name, section_sizes[name]) |
| 58 |
| 51 def _DescribeSymbol(self, sym): | 59 def _DescribeSymbol(self, sym): |
| 52 # SymbolGroups are passed here when we don't want to expand them. | 60 # SymbolGroups are passed here when we don't want to expand them. |
| 53 if sym.IsGroup(): | 61 if sym.IsGroup(): |
| 54 if self.verbose: | 62 if self.verbose: |
| 55 yield ('{} {:<8} {} (count={}) padding={} ' | 63 yield ('{} {:<8} {} (count={}) padding={} ' |
| 56 'size_without_padding={}').format( | 64 'size_without_padding={}').format( |
| 57 sym.section, sym.size, sym.name, len(sym), sym.padding, | 65 sym.section, sym.size, sym.name, len(sym), sym.padding, |
| 58 sym.size_without_padding) | 66 sym.size_without_padding) |
| 59 else: | 67 else: |
| 60 yield '{} {:<8} {} (count={})'.format(sym.section, sym.size, sym.name, | 68 yield '{} {:<8} {} (count={})'.format(sym.section, sym.size, sym.name, |
| 61 len(sym)) | 69 len(sym)) |
| 62 return | 70 return |
| 63 | 71 |
| 64 if self.verbose: | 72 if self.verbose: |
| 65 yield '{}@0x{:<8x} size={} padding={} size_without_padding={}'.format( | 73 yield '{}@0x{:<8x} size={} padding={} size_without_padding={}'.format( |
| 66 sym.section, sym.address, sym.size, sym.padding, | 74 sym.section, sym.address, sym.size, sym.padding, |
| 67 sym.size_without_padding) | 75 sym.size_without_padding) |
| 68 yield ' source_path={} \tobject_path={}'.format( | 76 yield ' source_path={} \tobject_path={}'.format( |
| 69 sym.source_path, sym.object_path) | 77 sym.source_path, sym.object_path) |
| 70 if sym.full_name: | 78 if sym.full_name: |
| 71 yield ' full_name={} \tis_anonymous={}'.format( | 79 yield ' is_anonymous={} full_name={}'.format( |
| 72 sym.full_name, sym.is_anonymous) | 80 int(sym.is_anonymous), sym.full_name) |
| 73 if sym.name: | 81 if sym.name: |
| 74 yield ' name={} \tis_anonymous={}'.format( | 82 yield ' is_anonymous={} name={}'.format( |
| 75 sym.name, sym.is_anonymous) | 83 int(sym.is_anonymous), sym.name) |
| 76 else: | 84 else: |
| 77 yield '{}@0x{:<8x} {:<7} {}'.format( | 85 yield '{}@0x{:<8x} {:<7} {}'.format( |
| 78 sym.section, sym.address, sym.size, | 86 sym.section, sym.address, sym.size, |
| 79 sym.source_path or sym.object_path or '{no path}') | 87 sym.source_path or sym.object_path or '{no path}') |
| 80 if sym.name: | 88 if sym.name: |
| 81 yield ' {}'.format(sym.name) | 89 yield ' {}'.format(sym.name) |
| 82 | 90 |
| 83 def _DescribeSymbolGroup(self, group, prefix_func=None): | 91 def _DescribeSymbolGroup(self, group, prefix_func=None): |
| 84 total_size = group.size | 92 total_size = group.size |
| 85 yield 'Showing {:,} symbols with total size: {} bytes'.format( | 93 yield 'Showing {:,} symbols with total size: {} bytes'.format( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 207 |
| 200 | 208 |
| 201 def GenerateLines(obj, verbose=False): | 209 def GenerateLines(obj, verbose=False): |
| 202 return Describer(verbose).GenerateLines(obj) | 210 return Describer(verbose).GenerateLines(obj) |
| 203 | 211 |
| 204 | 212 |
| 205 def WriteLines(lines, func): | 213 def WriteLines(lines, func): |
| 206 for l in lines: | 214 for l in lines: |
| 207 func(l) | 215 func(l) |
| 208 func('\n') | 216 func('\n') |
| OLD | NEW |