Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from __future__ import print_function | |
| 6 | |
| 5 import collections | 7 import collections |
| 6 import datetime | 8 import datetime |
| 7 import logging | 9 import logging |
| 8 import multiprocessing | 10 import multiprocessing |
| 9 import os | 11 import os |
| 10 import posixpath | 12 import posixpath |
| 11 import Queue | 13 import Queue |
| 12 import re | 14 import re |
| 13 import subprocess | 15 import subprocess |
| 14 import sys | 16 import sys |
| 15 import threading | 17 import threading |
| 16 | 18 import time |
| 17 | 19 |
| 18 # addr2line builds a possibly infinite memory cache that can exhaust | 20 # addr2line builds a possibly infinite memory cache that can exhaust |
| 19 # the computer's memory if allowed to grow for too long. This constant | 21 # the computer's memory if allowed to grow for too long. This constant |
| 20 # controls how many lookups we do before restarting the process. 4000 | 22 # controls how many lookups we do before restarting the process. 4000 |
| 21 # gives near peak performance without extreme memory usage. | 23 # gives near peak performance without extreme memory usage. |
| 22 ADDR2LINE_RECYCLE_LIMIT = 4000 | 24 ADDR2LINE_RECYCLE_LIMIT = 4000 |
| 23 | 25 |
| 24 | 26 |
| 25 class ELFSymbolizer(object): | 27 class ELFSymbolizer(object): |
| 26 """An uber-fast (multiprocessing, pipelined and asynchronous) ELF symbolizer. | 28 """An uber-fast (multiprocessing, pipelined and asynchronous) ELF symbolizer. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 a2l.Terminate() | 179 a2l.Terminate() |
| 178 | 180 |
| 179 def _CreateNewA2LInstance(self): | 181 def _CreateNewA2LInstance(self): |
| 180 assert(len(self._a2l_instances) < self.max_concurrent_jobs) | 182 assert(len(self._a2l_instances) < self.max_concurrent_jobs) |
| 181 a2l = ELFSymbolizer.Addr2Line(self) | 183 a2l = ELFSymbolizer.Addr2Line(self) |
| 182 self._a2l_instances.append(a2l) | 184 self._a2l_instances.append(a2l) |
| 183 return a2l | 185 return a2l |
| 184 | 186 |
| 185 def _CreateDisambiguationTable(self): | 187 def _CreateDisambiguationTable(self): |
| 186 """ Non-unique file names will result in None entries""" | 188 """ Non-unique file names will result in None entries""" |
| 189 start_time = time.time() | |
| 190 print('Collecting information about available source files...', | |
|
Primiano Tucci (use gerrit)
2014/07/21 16:18:09
Please use logging.info / debug. We typically use
| |
| 191 file=sys.stderr) | |
| 187 self.disambiguation_table = {} | 192 self.disambiguation_table = {} |
| 188 | 193 |
| 189 for root, _, filenames in os.walk(self.source_root_path): | 194 for root, _, filenames in os.walk(self.source_root_path): |
| 190 for f in filenames: | 195 for f in filenames: |
| 191 self.disambiguation_table[f] = os.path.join(root, f) if (f not in | 196 self.disambiguation_table[f] = os.path.join(root, f) if (f not in |
| 192 self.disambiguation_table) else None | 197 self.disambiguation_table) else None |
| 198 print('Finished collecting information about ' | |
| 199 'possible files (took %.1f s).' % | |
| 200 (time.time() - start_time), file=sys.stderr) | |
| 193 | 201 |
| 194 | 202 |
| 195 class Addr2Line(object): | 203 class Addr2Line(object): |
| 196 """A python wrapper around an addr2line instance. | 204 """A python wrapper around an addr2line instance. |
| 197 | 205 |
| 198 The communication with the addr2line process looks as follows: | 206 The communication with the addr2line process looks as follows: |
| 199 [STDIN] [STDOUT] (from addr2line's viewpoint) | 207 [STDIN] [STDOUT] (from addr2line's viewpoint) |
| 200 > f001111 | 208 > f001111 |
| 201 > f002222 | 209 > f002222 |
| 202 < Symbol::Name(foo, bar) for f001111 | 210 < Symbol::Name(foo, bar) for f001111 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 self.source_line = source_line | 460 self.source_line = source_line |
| 453 # In the case of |inlines|=True, the |inlined_by| points to the outer | 461 # In the case of |inlines|=True, the |inlined_by| points to the outer |
| 454 # function inlining the current one (and so on, to form a chain). | 462 # function inlining the current one (and so on, to form a chain). |
| 455 self.inlined_by = None | 463 self.inlined_by = None |
| 456 self.disambiguated = disambiguated | 464 self.disambiguated = disambiguated |
| 457 self.was_ambiguous = was_ambiguous | 465 self.was_ambiguous = was_ambiguous |
| 458 | 466 |
| 459 def __str__(self): | 467 def __str__(self): |
| 460 return '%s [%s:%d]' % ( | 468 return '%s [%s:%d]' % ( |
| 461 self.name or '??', self.source_path or '??', self.source_line or 0) | 469 self.name or '??', self.source_path or '??', self.source_line or 0) |
| OLD | NEW |