| 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 # memcheck_analyze.py | 6 # memcheck_analyze.py |
| 7 | 7 |
| 8 ''' Given a valgrind XML file, parses errors and uniques them.''' | 8 ''' Given a valgrind XML file, parses errors and uniques them.''' |
| 9 | 9 |
| 10 import gdb_helper | 10 import gdb_helper |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 self._additional.append(description) | 224 self._additional.append(description) |
| 225 description = None | 225 description = None |
| 226 | 226 |
| 227 if node.localName == "suppression": | 227 if node.localName == "suppression": |
| 228 self._suppression = getCDATAOf(node, "rawtext"); | 228 self._suppression = getCDATAOf(node, "rawtext"); |
| 229 | 229 |
| 230 def __str__(self): | 230 def __str__(self): |
| 231 ''' Pretty print the type and backtrace(s) of this specific error, | 231 ''' Pretty print the type and backtrace(s) of this specific error, |
| 232 including suppression (which is just a mangled backtrace).''' | 232 including suppression (which is just a mangled backtrace).''' |
| 233 output = "" | 233 output = "" |
| 234 output += "\n" # Make sure the ### is at the beginning of line. |
| 235 output += "### BEGIN MEMORY TOOL REPORT (error hash=#%016X#)\n" % \ |
| 236 self.ErrorHash() |
| 234 if (self._commandline): | 237 if (self._commandline): |
| 235 output += self._commandline + "\n" | 238 output += self._commandline + "\n" |
| 236 | 239 |
| 237 output += self._kind + "\n" | 240 output += self._kind + "\n" |
| 238 for backtrace in self._backtraces: | 241 for backtrace in self._backtraces: |
| 239 output += backtrace[0] + "\n" | 242 output += backtrace[0] + "\n" |
| 240 filter = subprocess.Popen("c++filt -n", stdin=subprocess.PIPE, | 243 filter = subprocess.Popen("c++filt -n", stdin=subprocess.PIPE, |
| 241 stdout=subprocess.PIPE, | 244 stdout=subprocess.PIPE, |
| 242 stderr=subprocess.STDOUT, | 245 stderr=subprocess.STDOUT, |
| 243 shell=True, | 246 shell=True, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 323 |
| 321 for frame in range(len(supplines)): | 324 for frame in range(len(supplines)): |
| 322 # Replace the always-changing anonymous namespace prefix with "*". | 325 # Replace the always-changing anonymous namespace prefix with "*". |
| 323 m = re.match("( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" + | 326 m = re.match("( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" + |
| 324 "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)", | 327 "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)", |
| 325 supplines[frame]) | 328 supplines[frame]) |
| 326 if m: | 329 if m: |
| 327 supplines[frame] = "*".join(m.groups()) | 330 supplines[frame] = "*".join(m.groups()) |
| 328 | 331 |
| 329 output += "\n".join(supplines) + "\n" | 332 output += "\n".join(supplines) + "\n" |
| 333 output += "### END MEMORY TOOL REPORT (error hash=#%016X#)\n" % \ |
| 334 self.ErrorHash() |
| 330 | 335 |
| 331 return output | 336 return output |
| 332 | 337 |
| 333 def UniqueString(self): | 338 def UniqueString(self): |
| 334 ''' String to use for object identity. Don't print this, use str(obj) | 339 ''' String to use for object identity. Don't print this, use str(obj) |
| 335 instead.''' | 340 instead.''' |
| 336 rep = self._kind + " " | 341 rep = self._kind + " " |
| 337 for backtrace in self._backtraces: | 342 for backtrace in self._backtraces: |
| 338 for frame in backtrace[1]: | 343 for frame in backtrace[1]: |
| 339 rep += frame[FUNCTION_NAME] | 344 rep += frame[FUNCTION_NAME] |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 if len(args) == 0: | 631 if len(args) == 0: |
| 627 parser.error("no filename specified") | 632 parser.error("no filename specified") |
| 628 filenames = args | 633 filenames = args |
| 629 | 634 |
| 630 analyzer = MemcheckAnalyzer(options.source_dir, use_gdb=True) | 635 analyzer = MemcheckAnalyzer(options.source_dir, use_gdb=True) |
| 631 return analyzer.Report(filenames, None) | 636 return analyzer.Report(filenames, None) |
| 632 | 637 |
| 633 | 638 |
| 634 if __name__ == "__main__": | 639 if __name__ == "__main__": |
| 635 sys.exit(_main()) | 640 sys.exit(_main()) |
| OLD | NEW |