[PATCH] D27404: Make asan_symbolize.py py3-compatible

NAKAMURA Takumi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 06:19:10 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294450: asan_symbolize.py: [Py3] Get rid of "print" statement. Use print() or write()… (authored by chapuni).

Changed prior to commit:
  https://reviews.llvm.org/D27404?vs=80241&id=87645#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27404

Files:
  compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py


Index: compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
===================================================================
--- compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
+++ compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py
@@ -89,7 +89,7 @@
       for hint in self.dsym_hints:
         cmd.append('--dsym-hint=%s' % hint)
     if DEBUG:
-      print ' '.join(cmd)
+      print(' '.join(cmd))
     try:
       result = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                                 stdout=subprocess.PIPE,
@@ -107,8 +107,8 @@
     try:
       symbolizer_input = '"%s" %s' % (binary, offset)
       if DEBUG:
-        print symbolizer_input
-      print >> self.pipe.stdin, symbolizer_input
+        print(symbolizer_input)
+      self.pipe.stdin.write("%s\n" % symbolizer_input)
       while True:
         function_name = self.pipe.stdout.readline().rstrip()
         if not function_name:
@@ -153,7 +153,7 @@
       cmd += ['--demangle']
     cmd += ['-e', self.binary]
     if DEBUG:
-      print ' '.join(cmd)
+      print(' '.join(cmd))
     return subprocess.Popen(cmd,
                             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                             bufsize=0,
@@ -165,8 +165,8 @@
       return None
     lines = []
     try:
-      print >> self.pipe.stdin, offset
-      print >> self.pipe.stdin, self.output_terminator
+      self.pipe.stdin.write("%s\n" % offset)
+      self.pipe.stdin.write("%s\n" % self.output_terminator)
       is_first_frame = True
       while True:
         function_name = self.pipe.stdout.readline().rstrip()
@@ -223,7 +223,7 @@
 
   def open_atos(self):
     if DEBUG:
-      print 'atos -o %s -arch %s' % (self.binary, self.arch)
+      print('atos -o %s -arch %s' % (self.binary, self.arch))
     cmdline = ['atos', '-o', self.binary, '-arch', self.arch]
     self.atos = UnbufferedLineConverter(cmdline, close_stderr=True)
 
@@ -238,7 +238,7 @@
     #   foo(type1, type2) (in object.name) (filename.cc:80)
     match = re.match('^(.*) \(in (.*)\) \((.*:\d*)\)$', atos_line)
     if DEBUG:
-      print 'atos_line: ', atos_line
+      print('atos_line: ', atos_line)
     if match:
       function_name = match.group(1)
       function_name = re.sub('\(.*?\)', '', function_name)
@@ -352,7 +352,7 @@
       function_name, file_name, line_no = res
       result = ['%s in %s %s:%d' % (
           addr, function_name, file_name, line_no)]
-      print result
+      print(result)
       return result
     else:
       return None
@@ -438,7 +438,7 @@
     self.frame_no = 0
     for line in logfile:
       processed = self.process_line(line)
-      print '\n'.join(processed)
+      print('\n'.join(processed))
 
   def process_line_echo(self, line):
     return [line.rstrip()]
@@ -452,7 +452,7 @@
     if not match:
       return [self.current_line]
     if DEBUG:
-      print line
+      print(line)
     _, frameno_str, addr, binary, offset = match.groups()
     arch = ""
     # Arch can be embedded in the filename, e.g.: "libabc.dylib:x86_64h"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27404.87645.patch
Type: text/x-patch
Size: 3050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170208/73a1fd60/attachment.bin>


More information about the llvm-commits mailing list