| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # suppressions.py | 6 # suppressions.py |
| 7 | 7 |
| 8 """Post-process Valgrind suppression matcher. | 8 """Post-process Valgrind suppression matcher. |
| 9 | 9 |
| 10 Suppressions are defined as follows: | 10 Suppressions are defined as follows: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 If ran from the command line, suppressions.py does a self-test | 24 If ran from the command line, suppressions.py does a self-test |
| 25 of the Suppression class. | 25 of the Suppression class. |
| 26 """ | 26 """ |
| 27 | 27 |
| 28 import os | 28 import os |
| 29 import re | 29 import re |
| 30 import sys | 30 import sys |
| 31 | 31 |
| 32 import path_utils | |
| 33 | |
| 34 | |
| 35 ELLIPSIS = '...' | 32 ELLIPSIS = '...' |
| 36 | 33 |
| 37 | 34 |
| 38 def GetSuppressions(): | |
| 39 suppressions_root = path_utils.ScriptDir() | |
| 40 JOIN = os.path.join | |
| 41 | |
| 42 result = {} | |
| 43 | |
| 44 supp_filename = JOIN(suppressions_root, "memcheck", "suppressions.txt") | |
| 45 vg_common = ReadSuppressionsFromFile(supp_filename) | |
| 46 supp_filename = JOIN(suppressions_root, "tsan", "suppressions.txt") | |
| 47 tsan_common = ReadSuppressionsFromFile(supp_filename) | |
| 48 result['common_suppressions'] = vg_common + tsan_common | |
| 49 | |
| 50 supp_filename = JOIN(suppressions_root, "memcheck", "suppressions_mac.txt") | |
| 51 vg_mac = ReadSuppressionsFromFile(supp_filename) | |
| 52 supp_filename = JOIN(suppressions_root, "tsan", "suppressions_mac.txt") | |
| 53 tsan_mac = ReadSuppressionsFromFile(supp_filename) | |
| 54 result['mac_suppressions'] = vg_mac + tsan_mac | |
| 55 | |
| 56 supp_filename = JOIN(suppressions_root, "tsan", "suppressions_win32.txt") | |
| 57 tsan_win = ReadSuppressionsFromFile(supp_filename) | |
| 58 result['win_suppressions'] = tsan_win | |
| 59 | |
| 60 supp_filename = JOIN(suppressions_root, "..", "heapcheck", "suppressions.txt") | |
| 61 result['heapcheck_suppressions'] = ReadSuppressionsFromFile(supp_filename) | |
| 62 | |
| 63 supp_filename = JOIN(suppressions_root, "drmemory", "suppressions.txt") | |
| 64 result['drmem_suppressions'] = ReadSuppressionsFromFile(supp_filename) | |
| 65 supp_filename = JOIN(suppressions_root, "drmemory", "suppressions_full.txt") | |
| 66 result['drmem_full_suppressions'] = ReadSuppressionsFromFile(supp_filename) | |
| 67 | |
| 68 return result | |
| 69 | |
| 70 | |
| 71 def GlobToRegex(glob_pattern, ignore_case=False): | 35 def GlobToRegex(glob_pattern, ignore_case=False): |
| 72 """Translate glob wildcards (*?) into regex syntax. Escape the rest.""" | 36 """Translate glob wildcards (*?) into regex syntax. Escape the rest.""" |
| 73 regex = '' | 37 regex = '' |
| 74 for char in glob_pattern: | 38 for char in glob_pattern: |
| 75 if char == '*': | 39 if char == '*': |
| 76 regex += '.*' | 40 regex += '.*' |
| 77 elif char == '?': | 41 elif char == '?': |
| 78 regex += '.' | 42 regex += '.' |
| 79 elif ignore_case and char.isalpha(): | 43 elif ignore_case and char.isalpha(): |
| 80 regex += '[%s%s]' % (char.lower(), char.upper()) | 44 regex += '[%s%s]' % (char.lower(), char.upper()) |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 "instruction=test 0x08(%eax) $0x01\n" | 961 "instruction=test 0x08(%eax) $0x01\n" |
| 998 "ntdll.dll!*\n" | 962 "ntdll.dll!*\n" |
| 999 "*!foo\n") | 963 "*!foo\n") |
| 1000 assert str(supp) == supp_str, ( | 964 assert str(supp) == supp_str, ( |
| 1001 "str(supp) != supp_str:\nleft: %s\nright: %s" % (str(supp), supp_str)) | 965 "str(supp) != supp_str:\nleft: %s\nright: %s" % (str(supp), supp_str)) |
| 1002 | 966 |
| 1003 | 967 |
| 1004 if __name__ == '__main__': | 968 if __name__ == '__main__': |
| 1005 SelfTest() | 969 SelfTest() |
| 1006 print 'PASS' | 970 print 'PASS' |
| OLD | NEW |