[PATCH] New options for asan-symbolizer script: set cross-compile prefix, set path to sysroot, print help message
Maria Guseva
m.guseva at samsung.com
Tue Jul 29 04:16:22 PDT 2014
Hi glider, samsonov, kcc,
The patch adds new features in asan-symbolizer script which are helpful for using ASan on embedded systems:
# add cross-compile prefix for binutils
# define path to sysroot with sanitized binaries
Features are enabled by command line options.
The patch also extends command line interface with help option.
http://reviews.llvm.org/D4703
Files:
lib/asan/scripts/asan_symbolize.py
Index: lib/asan/scripts/asan_symbolize.py
===================================================================
--- lib/asan/scripts/asan_symbolize.py
+++ lib/asan/scripts/asan_symbolize.py
@@ -18,8 +18,10 @@
symbolizers = {}
DEBUG = False
-demangle = False;
-
+demangle = False
+cc_prefix = None
+sysroot_path = None
+binary_name_filter=None
# FIXME: merge the code that calls fix_filename().
def fix_filename(file_name):
@@ -29,6 +31,9 @@
file_name = re.sub('.*crtstuff.c:0', '???:0', file_name)
return file_name
+def Sysroot_path_filter(binary_name):
+ return sysroot_path + binary_name
+
def GuessArch(addr):
# Guess which arch we're running. 10 = len('0x') + 8 hex digits.
if len(addr) > 10:
@@ -124,7 +129,10 @@
self.pipe = self.open_addr2line()
def open_addr2line(self):
- cmd = ['addr2line', '-f']
+ addr2line_tool = 'addr2line'
+ if cc_prefix:
+ addr2line_tool = cc_prefix + addr2line_tool
+ cmd = [addr2line_tool, '-f']
if demangle:
cmd += ['--demangle']
cmd += ['-e', self.binary]
@@ -395,11 +403,38 @@
symbolized_line = self.symbolize_address(addr, binary, offset)
return self.get_symbolized_lines(symbolized_line)
+def usage():
+ print """
+ASan symbolization script
+Usage: asan_symbolize.py [options] < asan.log
+Options:
+ -c cross_compile_prefix Cross-compile prefix for binutils
+ -s path_to_sysroot Path to sysroot for sanitized binaries
+ -d, --demangle Demangle function names
+Example:
+ asan_symbolize.py -c "$HOME/opt/cross/bin/arm-linux-gnueabi-" -s "$HOME/SymbolFiles" < asan.log
+"""
if __name__ == '__main__':
- opts, args = getopt.getopt(sys.argv[1:], "d", ["demangle"])
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "hds:c:", ["demangle", "help"])
+ except getopt.GetoptError as err:
+ print str(err)
+ usage()
+ sys.exit(2)
for o, a in opts:
if o in ("-d", "--demangle"):
demangle = True;
- loop = SymbolizationLoop()
+ elif o == "-s":
+ binary_name_filter = Sysroot_path_filter
+ sysroot_path = a
+ elif o == "-c":
+ cc_prefix = a
+ elif o in ("-h", "--help"):
+ usage()
+ sys.exit()
+ else:
+ assert False, "unhandled option"
+
+ loop = SymbolizationLoop(binary_name_filter)
loop.process_stdin()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4703.11972.patch
Type: text/x-patch
Size: 2333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140729/b9891283/attachment.bin>
More information about the llvm-commits
mailing list