OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # |
| 3 # Copyright 2016 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 |
| 9 """Utils for running under *SAN""" |
| 10 |
| 11 |
| 12 import default_flavor |
| 13 import os |
| 14 |
| 15 |
| 16 class XSanFlavorUtils(default_flavor.DefaultFlavorUtils): |
| 17 def __init__(self, *args, **kwargs): |
| 18 super(XSanFlavorUtils, self).__init__(*args, **kwargs) |
| 19 self._sanitizer = { |
| 20 # We'd love to just pass 'address,undefined' and get all the checks, but |
| 21 # we're not anywhere close to being able to do that. Instead we start |
| 22 # with a set of checks that we know pass or nearly pass. See here for |
| 23 # more information: |
| 24 # http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation |
| 25 'ASAN': ('address,bool,function,integer-divide-by-zero,nonnull-attribute,' |
| 26 'null,object-size,return,returns-nonnull-attribute,shift,' |
| 27 'signed-integer-overflow,unreachable,vla-bound,vptr'), |
| 28 # MSAN and TSAN can't run together with ASAN, so they're their own bots. |
| 29 'MSAN': 'memory', |
| 30 'TSAN': 'thread', |
| 31 }[self._bot_info.bot_cfg['extra_config']] |
| 32 |
| 33 def compile(self, target): |
| 34 cmd = [os.path.join(self._bot_info.skia_dir, 'tools', 'xsan_build'), |
| 35 self._sanitizer, target] |
| 36 self._bot_info.run(cmd) |
| 37 |
| 38 def step(self, cmd, env=None, **kwargs): |
| 39 """Wrapper for the Step API; runs a step as appropriate for this flavor.""" |
| 40 lsan_suppressions = self._bot_info.skia_dir.join('tools', 'lsan.supp') |
| 41 tsan_suppressions = self._bot_info.skia_dir.join('tools', 'tsan.supp') |
| 42 ubsan_suppressions = self._bot_info.skia_dir.join('tools', 'ubsan.supp') |
| 43 env = dict(env or {}) |
| 44 env['ASAN_OPTIONS'] = 'symbolize=1 detect_leaks=1' |
| 45 env['LSAN_OPTIONS'] = ('symbolize=1 print_suppressions=1 suppressions=%s' % |
| 46 lsan_suppressions) |
| 47 env['TSAN_OPTIONS'] = 'suppressions=%s' % tsan_suppressions |
| 48 env['UBSAN_OPTIONS'] = 'suppressions=%s' % ubsan_suppressions |
| 49 |
| 50 path_to_app = os.path.join(self._bot_info.out_dir, |
| 51 self._bot_info.configuration, cmd[0]) |
| 52 new_cmd = [path_to_app] |
| 53 new_cmd.extend(cmd[1:]) |
| 54 return self._bot_info.run(new_cmd, env=env, **kwargs) |
OLD | NEW |