OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 # drmemory_analyze.py | 6 # drmemory_analyze.py |
7 | 7 |
8 ''' Given a Dr. Memory output file, parses errors and uniques them.''' | 8 ''' Given a Dr. Memory output file, parses errors and uniques them.''' |
9 | 9 |
10 from collections import defaultdict | 10 from collections import defaultdict |
(...skipping 22 matching lines...) Expand all Loading... |
33 supp_lines[l] = "name=<insert_a_suppression_name_here>" | 33 supp_lines[l] = "name=<insert_a_suppression_name_here>" |
34 if supp_lines[l].startswith("chrome.dll!"): | 34 if supp_lines[l].startswith("chrome.dll!"): |
35 supp_lines[l] = supp_lines[l].replace("chrome.dll!", "*!") | 35 supp_lines[l] = supp_lines[l].replace("chrome.dll!", "*!") |
36 bang_index = supp_lines[l].find("!") | 36 bang_index = supp_lines[l].find("!") |
37 d_exe_index = supp_lines[l].find(".exe!") | 37 d_exe_index = supp_lines[l].find(".exe!") |
38 if bang_index >= 4 and d_exe_index + 4 == bang_index: | 38 if bang_index >= 4 and d_exe_index + 4 == bang_index: |
39 supp_lines[l] = "*" + supp_lines[l][bang_index:] | 39 supp_lines[l] = "*" + supp_lines[l][bang_index:] |
40 self._suppression = "\n".join(supp_lines) | 40 self._suppression = "\n".join(supp_lines) |
41 | 41 |
42 def __str__(self): | 42 def __str__(self): |
43 output = "" | 43 output = self._report + "\n" |
44 output += "### BEGIN MEMORY TOOL REPORT (error hash=#%016X#)\n" % | |
45 self.ErrorHash() | |
46 output += self._report + "\n" | |
47 if self._testcase: | 44 if self._testcase: |
48 output += "The report came from the `%s` test.\n" % self._testcase | 45 output += "The report came from the `%s` test.\n" % self._testcase |
49 output += "Suppression (error hash=#%016X#):\n" % self.ErrorHash() | 46 output += "Suppression (error hash=#%016X#):\n" % self.ErrorHash() |
50 output += (" For more info on using suppressions see " | 47 output += (" For more info on using suppressions see " |
51 "http://dev.chromium.org/developers/how-tos/using-drmemory#TOC-Suppressi
ng-error-reports-from-the-\n") | 48 "http://dev.chromium.org/developers/how-tos/using-drmemory#TOC-Suppressi
ng-error-reports-from-the-\n") |
52 output += "{\n%s\n}\n" % self._suppression | 49 output += "{\n%s\n}\n" % self._suppression |
53 output += "### END MEMORY TOOL REPORT (error hash=#%016X#)\n" % | |
54 self.ErrorHash() | |
55 return output | 50 return output |
56 | 51 |
57 # This is a device-independent hash identifying the suppression. | 52 # This is a device-independent hash identifying the suppression. |
58 # By printing out this hash we can find duplicate reports between tests and | 53 # By printing out this hash we can find duplicate reports between tests and |
59 # different shards running on multiple buildbots | 54 # different shards running on multiple buildbots |
60 def ErrorHash(self): | 55 def ErrorHash(self): |
61 return int(hashlib.md5(self._suppression).hexdigest()[:16], 16) | 56 return int(hashlib.md5(self._suppression).hexdigest()[:16], 16) |
62 | 57 |
63 def __hash__(self): | 58 def __hash__(self): |
64 return hash(self._suppression) | 59 return hash(self._suppression) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if len(args) == 0: | 188 if len(args) == 0: |
194 parser.error("no filename specified") | 189 parser.error("no filename specified") |
195 filenames = args | 190 filenames = args |
196 | 191 |
197 logging.getLogger().setLevel(logging.INFO) | 192 logging.getLogger().setLevel(logging.INFO) |
198 return DrMemoryAnalyzer().Report(filenames, None, False) | 193 return DrMemoryAnalyzer().Report(filenames, None, False) |
199 | 194 |
200 | 195 |
201 if __name__ == '__main__': | 196 if __name__ == '__main__': |
202 sys.exit(main()) | 197 sys.exit(main()) |
OLD | NEW |