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