!11 hwasan_symbolize should run in python2 and python3, and python3 is default now

From: @si-gui
Reviewed-by: @haijianzhang
Signed-off-by: @haijianzhang
This commit is contained in:
openeuler-ci-bot 2020-09-25 17:37:38 +08:00 committed by Gitee
commit aa472a629b
2 changed files with 132 additions and 1 deletions

View File

@ -0,0 +1,127 @@
From 9cfd1d498364487b7d1ba990188bffbd9a73d942 Mon Sep 17 00:00:00 2001
From: si-gui <245140120@qq.com>
Date: Fri, 25 Sep 2020 17:06:30 +0800
Subject: [PATCH] hwasan_symbolize should run in python2 and python3, and
python3 is default now
Signed-off-by: si-gui <245140120@qq.com>
---
lib/hwasan/scripts/hwasan_symbolize | 45 +++++++++++++++--------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/lib/hwasan/scripts/hwasan_symbolize b/lib/hwasan/scripts/hwasan_symbolize
index f77e36f..a488110 100755
--- a/lib/hwasan/scripts/hwasan_symbolize
+++ b/lib/hwasan/scripts/hwasan_symbolize
@@ -10,6 +10,7 @@
# HWAddressSanitizer offline symbolization script.
#
#===------------------------------------------------------------------------===#
+from __future__ import print_function
import glob
import os
import re
@@ -41,14 +42,14 @@ class Symbolizer:
pass
def __write(self, s):
- print >>self.__pipe.stdin, s
+ print(s,file=self.__pipe.stdin)
if self.__log:
- print >>sys.stderr, ("#>> |%s|" % (s,))
+ print(("#>> |%s|" % (s,)),file=sys.stderr)
def __read(self):
s = self.__pipe.stdout.readline().rstrip()
if self.__log:
- print >>sys.stderr, ("# << |%s|" % (s,))
+ print(("# << |%s|" % (s,)),file=sys.stderr)
if s == '':
raise Symbolizer.__EOF
return s
@@ -73,7 +74,7 @@ class Symbolizer:
full_path = os.path.join(p, os.path.basename(name))
if os.path.exists(full_path):
return full_path
- print >>sys.stderr, "Could not find symbols for", name
+ print("Could not find symbols for",name,file=sys.stderr)
return None
def iter_locals(self, binary, addr):
@@ -125,16 +126,16 @@ def symbolize_line(line, symbolizer_path):
frames = list(symbolizer.iter_call_stack(binary, addr))
if len(frames) > 0:
- print "%s#%s%s%s in %s" % (match.group(1).encode('utf-8'), match.group(2).encode('utf-8'),
- match.group(3).encode('utf-8'), frames[0][0], frames[0][1])
+ print("%s#%s%s%s in %s" % (match.group(1).encode('utf-8'), match.group(2).encode('utf-8'),
+ match.group(3).encode('utf-8'), frames[0][0], frames[0][1]))
for i in range(1, len(frames)):
space1 = ' ' * match.end(1)
space2 = ' ' * (match.start(4) - match.end(1) - 2)
- print "%s->%s%s in %s" % (space1, space2, frames[i][0], frames[i][1])
+ print("%s->%s%s in %s" % (space1, space2, frames[i][0], frames[i][1]))
else:
- print line.rstrip().encode('utf-8')
+ print(line.rstrip().encode('utf-8'))
else:
- print line.rstrip().encode('utf-8')
+ print(line.rstrip().encode('utf-8'))
def save_access_address(line):
global last_access_address, last_access_tag
@@ -174,10 +175,10 @@ def process_stack_history(line, symbolizer, ignore_tags=False):
tag_offset = local[5]
if not ignore_tags and (tag_offset is None or base_tag ^ tag_offset != last_access_tag):
continue
- print ''
- print 'Potentially referenced stack object:'
- print ' %d bytes inside variable "%s" in stack frame of function "%s"' % (obj_offset, local[2], local[0])
- print ' at %s' % (local[1],)
+ print('')
+ print('Potentially referenced stack object:')
+ print(' %d bytes inside variable "%s" in stack frame of function "%s"' % (obj_offset, local[2], local[0]))
+ print(' at %s' % (local[1],))
return True
return False
@@ -200,7 +201,7 @@ if not binary_prefixes:
for p in binary_prefixes:
if not os.path.isdir(p):
- print >>sys.stderr, "Symbols path does not exist or is not a directory:", p
+ print("Symbols path does not exist or is not a directory:",p,file=sys.stderr)
sys.exit(1)
# Source location.
@@ -257,19 +258,19 @@ if not symbolizer_path:
symbolizer_path = candidates[0]
break
-if not os.path.exists(symbolizer_path):
- print >>sys.stderr, "Symbolizer path does not exist:", symbolizer_path
+if not os.path.exists(str(symbolizer_path)):
+ print("Symbolizer path does not exist:",symbolizer_path,file=sys.stderr)
sys.exit(1)
if args.v:
- print "Looking for symbols in:"
+ print("Looking for symbols in:")
for s in binary_prefixes:
- print " %s" % (s,)
- print "Stripping source path prefixes:"
+ print(" %s" % (s,))
+ print("Stripping source path prefixes:")
for s in paths_to_cut:
- print " %s" % (s,)
- print "Using llvm-symbolizer binary in:\n %s" % (symbolizer_path,)
- print
+ print(" %s" % (s,))
+ print("Using llvm-symbolizer binary in:\n %s" % (symbolizer_path,))
+ print()
symbolizer = Symbolizer(symbolizer_path, binary_prefixes, paths_to_cut)
symbolizer.enable_logging(args.d)
--
2.23.0

View File

@ -4,12 +4,13 @@
Name: compiler-rt Name: compiler-rt
Version: 10.0.1 Version: 10.0.1
Release: 2 Release: 3
Summary: LLVM "compiler-rt" runtime libraries Summary: LLVM "compiler-rt" runtime libraries
License: NCSA or MIT License: NCSA or MIT
URL: http://llvm.org URL: http://llvm.org
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{crt_srcdir}.tar.xz Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{crt_srcdir}.tar.xz
Patch0000: 0001-PATCH-std-thread-copy.patch Patch0000: 0001-PATCH-std-thread-copy.patch
Patch0001: 0002-hwasan_symbolize-should-run-in-python2-and-python3.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++
@ -102,6 +103,9 @@ fi
%endif %endif
%changelog %changelog
* Fri Sep 25 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 10.0.1-3
- hwasan_symbolize should run in python2 and python3, and python3 is default now
* Sat Sep 19 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 10.0.1-2 * Sat Sep 19 2020 Guoshuai Sun <sunguoshuai@huawei.com> - 10.0.1-2
- Keep "/usr/bin/env python" instead of /usr/bin/python3 in hwasan_symbolize - Keep "/usr/bin/env python" instead of /usr/bin/python3 in hwasan_symbolize