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() | |
237 if (self._commandline): | 234 if (self._commandline): |
238 output += self._commandline + "\n" | 235 output += self._commandline + "\n" |
239 | 236 |
240 output += self._kind + "\n" | 237 output += self._kind + "\n" |
241 for backtrace in self._backtraces: | 238 for backtrace in self._backtraces: |
242 output += backtrace[0] + "\n" | 239 output += backtrace[0] + "\n" |
243 filter = subprocess.Popen("c++filt -n", stdin=subprocess.PIPE, | 240 filter = subprocess.Popen("c++filt -n", stdin=subprocess.PIPE, |
244 stdout=subprocess.PIPE, | 241 stdout=subprocess.PIPE, |
245 stderr=subprocess.STDOUT, | 242 stderr=subprocess.STDOUT, |
246 shell=True, | 243 shell=True, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 320 |
324 for frame in range(len(supplines)): | 321 for frame in range(len(supplines)): |
325 # Replace the always-changing anonymous namespace prefix with "*". | 322 # Replace the always-changing anonymous namespace prefix with "*". |
326 m = re.match("( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" + | 323 m = re.match("( +fun:)_ZN.*_GLOBAL__N_.*\.cc_" + |
327 "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)", | 324 "[0-9a-fA-F]{8}_[0-9a-fA-F]{8}(.*)", |
328 supplines[frame]) | 325 supplines[frame]) |
329 if m: | 326 if m: |
330 supplines[frame] = "*".join(m.groups()) | 327 supplines[frame] = "*".join(m.groups()) |
331 | 328 |
332 output += "\n".join(supplines) + "\n" | 329 output += "\n".join(supplines) + "\n" |
333 output += "### END MEMORY TOOL REPORT (error hash=#%016X#)\n" % | |
334 self.ErrorHash() | |
335 | 330 |
336 return output | 331 return output |
337 | 332 |
338 def UniqueString(self): | 333 def UniqueString(self): |
339 ''' String to use for object identity. Don't print this, use str(obj) | 334 ''' String to use for object identity. Don't print this, use str(obj) |
340 instead.''' | 335 instead.''' |
341 rep = self._kind + " " | 336 rep = self._kind + " " |
342 for backtrace in self._backtraces: | 337 for backtrace in self._backtraces: |
343 for frame in backtrace[1]: | 338 for frame in backtrace[1]: |
344 rep += frame[FUNCTION_NAME] | 339 rep += frame[FUNCTION_NAME] |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 if len(args) == 0: | 626 if len(args) == 0: |
632 parser.error("no filename specified") | 627 parser.error("no filename specified") |
633 filenames = args | 628 filenames = args |
634 | 629 |
635 analyzer = MemcheckAnalyzer(options.source_dir, use_gdb=True) | 630 analyzer = MemcheckAnalyzer(options.source_dir, use_gdb=True) |
636 return analyzer.Report(filenames, None) | 631 return analyzer.Report(filenames, None) |
637 | 632 |
638 | 633 |
639 if __name__ == "__main__": | 634 if __name__ == "__main__": |
640 sys.exit(_main()) | 635 sys.exit(_main()) |
OLD | NEW |