#!/usr/bin/env python

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from third_party import asan_symbolize

import re
import sys

def fix_filename(file_name):
  for path_to_cut in sys.argv[1:]:
    file_name = re.sub(".*" + path_to_cut, "", file_name)
  file_name = re.sub(".*asan_[a-z_]*.cc:[0-9]*", "_asan_rtl_", file_name)
  file_name = re.sub(".*crtstuff.c:0", "???:0", file_name)
  return file_name

def main():
  loop = asan_symbolize.SymbolizationLoop(binary_name_filter=fix_filename)
  loop.process_stdin()

if __name__ == '__main__':
  main()

@@ -223,16 +223,26 @@
 bolize%0A%0A
+import os%0A
 import r
@@ -243,16 +243,16 @@
 port re%0A
-
 import s
@@ -534,19 +534,655 @@
 me%0A%0A
-def main():
+class Unbuffered(object):%0A  %22%22%22Disable buffering on a file object.%22%22%22%0A  def __init__(self, stream):%0A    self.stream = stream%0A%0A  def write(self, data):%0A    self.stream.write(data)%0A    if '%5Cn' in data:%0A      self.stream.flush()%0A%0A  def __getattr__(self, attr):%0A    return getattr(self.stream, attr)%0A%0A%0Adef disable_buffering():%0A  %22%22%22Makes this process and child processes stdout unbuffered.%22%22%22%0A  if not os.environ.get('PYTHONUNBUFFERED'):%0A    # Since sys.stdout is a C++ object, it's impossible to do%0A    # sys.stdout.write = lambda...%0A    sys.stdout = Unbuffered(sys.stdout)%0A    os.environ%5B'PYTHONUNBUFFERED'%5D = 'x'%0A%0A%0Adef main():%0A  disable_buffering()
 %0A  l

Disable buffering in asan_symbolize.py This should help some buildbots that are timing out otherwise.