Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: tools/valgrind/asan/asan_symbolize.py

Issue 586533004: Fix path prefix stripping in asan_symbolize.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 from third_party import asan_symbolize 7 from third_party import asan_symbolize
8 8
9 import os 9 import os
10 import re
11 import sys 10 import sys
12 11
13 def fix_filename(file_name):
14 for path_to_cut in sys.argv[1:]:
15 file_name = re.sub(".*" + path_to_cut, "", file_name)
16 file_name = re.sub(".*asan_[a-z_]*.cc:[0-9]*", "_asan_rtl_", file_name)
17 file_name = re.sub(".*crtstuff.c:0", "???:0", file_name)
18 return file_name
19
20 class LineBuffered(object): 12 class LineBuffered(object):
21 """Disable buffering on a file object.""" 13 """Disable buffering on a file object."""
22 def __init__(self, stream): 14 def __init__(self, stream):
23 self.stream = stream 15 self.stream = stream
24 16
25 def write(self, data): 17 def write(self, data):
26 self.stream.write(data) 18 self.stream.write(data)
27 if '\n' in data: 19 if '\n' in data:
28 self.stream.flush() 20 self.stream.flush()
29 21
30 def __getattr__(self, attr): 22 def __getattr__(self, attr):
31 return getattr(self.stream, attr) 23 return getattr(self.stream, attr)
32 24
33 25
34 def disable_buffering(): 26 def disable_buffering():
35 """Makes this process and child processes stdout unbuffered.""" 27 """Makes this process and child processes stdout unbuffered."""
36 if not os.environ.get('PYTHONUNBUFFERED'): 28 if not os.environ.get('PYTHONUNBUFFERED'):
37 # Since sys.stdout is a C++ object, it's impossible to do 29 # Since sys.stdout is a C++ object, it's impossible to do
38 # sys.stdout.write = lambda... 30 # sys.stdout.write = lambda...
39 sys.stdout = LineBuffered(sys.stdout) 31 sys.stdout = LineBuffered(sys.stdout)
40 os.environ['PYTHONUNBUFFERED'] = 'x' 32 os.environ['PYTHONUNBUFFERED'] = 'x'
41 33
42 34
43 def main(): 35 def main():
44 disable_buffering() 36 disable_buffering()
45 asan_symbolize.demangle = True 37 asan_symbolize.demangle = True
46 loop = asan_symbolize.SymbolizationLoop(binary_name_filter=fix_filename) 38 asan_symbolize.fix_filename_patterns = sys.argv[1:]
39 asan_symbolize.logfile = sys.stdin
40 loop = asan_symbolize.SymbolizationLoop()
47 loop.process_logfile() 41 loop.process_logfile()
48 42
49 if __name__ == '__main__': 43 if __name__ == '__main__':
50 main() 44 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698