| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 anonymous_syms = attributed_syms.Inverted() | 186 anonymous_syms = attributed_syms.Inverted() |
| 187 if star_syms or anonymous_syms: | 187 if star_syms or anonymous_syms: |
| 188 missing_size = star_syms.size + anonymous_syms.size | 188 missing_size = star_syms.size + anonymous_syms.size |
| 189 yield ('+ Without %d merge sections and %d anonymous entries (' | 189 yield ('+ Without %d merge sections and %d anonymous entries (' |
| 190 'accounting for %d bytes):') % ( | 190 'accounting for %d bytes):') % ( |
| 191 len(star_syms), len(anonymous_syms), missing_size) | 191 len(star_syms), len(anonymous_syms), missing_size) |
| 192 yield '+ ' + one_stat(attributed_syms) | 192 yield '+ ' + one_stat(attributed_syms) |
| 193 | 193 |
| 194 | 194 |
| 195 def _UtcToLocal(utc): | 195 def _UtcToLocal(utc): |
| 196 epoch = time.mktime(utc.timetuple()) | 196 epoch = time.mktime(utc.timetuple()) |
| 197 offset = (datetime.datetime.fromtimestamp(epoch) - | 197 offset = (datetime.datetime.fromtimestamp(epoch) - |
| 198 datetime.datetime.utcfromtimestamp(epoch)) | 198 datetime.datetime.utcfromtimestamp(epoch)) |
| 199 return utc + offset | 199 return utc + offset |
| 200 | 200 |
| 201 | 201 |
| 202 def DescribeSizeInfoMetadata(size_info): | 202 def DescribeSizeInfoMetadata(size_info): |
| 203 time_str = 'Unknown' | 203 display_dict = size_info.metadata.copy() |
| 204 if size_info.timestamp: | 204 timestamp = display_dict.get(models.METADATA_ELF_MTIME) |
| 205 time_str = _UtcToLocal(size_info.timestamp).strftime('%Y-%m-%d %H:%M:%S') | 205 if timestamp: |
| 206 return 'mapfile mtime=%s \ttag=%s' % (time_str, size_info.tag) | 206 timestamp_obj = datetime.datetime.utcfromtimestamp(timestamp) |
| 207 display_dict[models.METADATA_ELF_MTIME] = ( |
| 208 _UtcToLocal(timestamp_obj).strftime('%Y-%m-%d %H:%M:%S')) |
| 209 return ' '.join(sorted('%s=%s' % t for t in display_dict.iteritems())) |
| 207 | 210 |
| 208 | 211 |
| 209 def GenerateLines(obj, verbose=False): | 212 def GenerateLines(obj, verbose=False): |
| 210 return Describer(verbose).GenerateLines(obj) | 213 return Describer(verbose).GenerateLines(obj) |
| 211 | 214 |
| 212 | 215 |
| 213 def WriteLines(lines, func): | 216 def WriteLines(lines, func): |
| 214 for l in lines: | 217 for l in lines: |
| 215 func(l) | 218 func(l) |
| 216 func('\n') | 219 func('\n') |
| OLD | NEW |