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