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
5 # found in the LICENSE file.
7 from third_party
import asan_symbolize
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
)
20 class LineBuffered(object):
21 """Disable buffering on a file object."""
22 def __init__(self
, stream
):
25 def write(self
, data
):
26 self
.stream
.write(data
)
30 def __getattr__(self
, attr
):
31 return getattr(self
.stream
, attr
)
34 def disable_buffering():
35 """Makes this process and child processes stdout unbuffered."""
36 if not os
.environ
.get('PYTHONUNBUFFERED'):
37 # Since sys.stdout is a C++ object, it's impossible to do
38 # sys.stdout.write = lambda...
39 sys
.stdout
= LineBuffered(sys
.stdout
)
40 os
.environ
['PYTHONUNBUFFERED'] = 'x'
45 asan_symbolize
.demangle
= True
46 loop
= asan_symbolize
.SymbolizationLoop(binary_name_filter
=fix_filename
)
49 if __name__
== '__main__':