Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 import logging | 10 import logging |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 files: A list of filenames. | 35 files: A list of filenames. |
| 36 ''' | 36 ''' |
| 37 | 37 |
| 38 self.reports = [] | 38 self.reports = [] |
| 39 self.used_suppressions = [] | 39 self.used_suppressions = [] |
| 40 for file in files: | 40 for file in files: |
| 41 self.ParseReportFile(file) | 41 self.ParseReportFile(file) |
| 42 | 42 |
| 43 def ReadLine(self): | 43 def ReadLine(self): |
| 44 self.line_ = self.cur_fd_.readline() | 44 self.line_ = self.cur_fd_.readline() |
| 45 self.stack_trace_line_ = None | |
|
Timur Iskhodzhanov
2011/11/22 13:08:28
not needed, too much copy-paste from the TSan/Mac
| |
| 46 | 45 |
| 47 def ReadSection(self): | 46 def ReadSection(self): |
| 48 result = [self.line_] | 47 result = [self.line_] |
| 49 self.ReadLine() | 48 self.ReadLine() |
| 50 while len(self.line_.strip()) > 0: | 49 while len(self.line_.strip()) > 0: |
| 51 result.append(self.line_) | 50 result.append(self.line_) |
| 52 self.ReadLine() | 51 self.ReadLine() |
| 53 return result | 52 return result |
| 54 | 53 |
| 55 def ParseReportFile(self, filename): | 54 def ParseReportFile(self, filename): |
| 56 self.cur_fd_ = open(filename, 'r') | 55 self.cur_fd_ = open(filename, 'r') |
| 57 | 56 |
| 58 while True: | 57 while True: |
| 59 self.ReadLine() | 58 self.ReadLine() |
| 60 if (self.line_ == ''): break | 59 if (self.line_ == ''): break |
| 61 if re.search("FINAL SUMMARY:", self.line_): | 60 |
| 62 # No more reports since this point. | |
| 63 break | |
| 64 tmp = [] | |
| 65 match = re.search("^Error #[0-9]+: (.*)", self.line_) | 61 match = re.search("^Error #[0-9]+: (.*)", self.line_) |
| 66 if match: | 62 if match: |
| 67 self.line_ = match.groups()[0].strip() + "\n" | 63 self.line_ = match.groups()[0].strip() + "\n" |
| 68 tmp.extend(self.ReadSection()) | 64 tmp = self.ReadSection() |
| 69 self.reports.append(tmp) | 65 self.reports.append(tmp) |
| 70 elif self.line_.startswith("ASSERT FAILURE"): | |
| 71 self.reports.append(self.line_.strip()) | |
| 72 | |
| 73 while True: | |
| 74 self.ReadLine(); | |
| 75 if (self.line_ == ''): break | |
| 76 | 66 |
| 77 if re.search("SUPPRESSIONS USED:", self.line_): | 67 if re.search("SUPPRESSIONS USED:", self.line_): |
| 78 self.ReadLine() | 68 self.ReadLine() |
| 79 while self.line_.strip() != "": | 69 while self.line_.strip() != "": |
| 80 line = self.line_.strip() | 70 line = self.line_.strip() |
| 81 (count, name) = re.match(" *([0-9]+)x(?: \(leaked .*\))?: (.*)", | 71 (count, name) = re.match(" *([0-9]+)x(?: \(leaked .*\))?: (.*)", |
| 82 line).groups() | 72 line).groups() |
| 83 self.used_suppressions.append("%7s %s" % (count, name)) | 73 self.used_suppressions.append("%7s %s" % (count, name)) |
| 84 self.ReadLine() | 74 self.ReadLine() |
| 85 break | |
| 86 | |
| 87 while True: | |
| 88 self.ReadLine(); | |
| 89 if (self.line_ == ''): break | |
| 90 | 75 |
| 91 if self.line_.startswith("ASSERT FAILURE"): | 76 if self.line_.startswith("ASSERT FAILURE"): |
| 92 self.reports.append(self.line_.strip()) | 77 self.reports.append(self.line_.strip()) |
| 93 | 78 |
| 94 self.cur_fd_.close() | 79 self.cur_fd_.close() |
| 95 | 80 |
| 96 def Report(self, check_sanity): | 81 def Report(self, check_sanity): |
| 97 sys.stdout.flush() | 82 sys.stdout.flush() |
| 98 #TODO(timurrrr): support positive tests / check_sanity==True | 83 #TODO(timurrrr): support positive tests / check_sanity==True |
| 99 | 84 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 128 | 113 |
| 129 (options, args) = parser.parse_args() | 114 (options, args) = parser.parse_args() |
| 130 if len(args) == 0: | 115 if len(args) == 0: |
| 131 parser.error("no filename specified") | 116 parser.error("no filename specified") |
| 132 filenames = args | 117 filenames = args |
| 133 | 118 |
| 134 analyzer = DrMemoryAnalyze(options.source_dir, filenames) | 119 analyzer = DrMemoryAnalyze(options.source_dir, filenames) |
| 135 retcode = analyzer.Report(False) | 120 retcode = analyzer.Report(False) |
| 136 | 121 |
| 137 sys.exit(retcode) | 122 sys.exit(retcode) |
| OLD | NEW |