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