| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2010 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 ThreadSanitizer output file, parses errors and uniques them.''' | 8 ''' Given a ThreadSanitizer output file, parses errors and uniques them.''' |
| 9 | 9 |
| 10 import logging | 10 import logging |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 45 self.stack_trace_line_ = None |
| 46 | 46 |
| 47 def ReadSection(self): | 47 def ReadSection(self): |
| 48 FILE_PREFIXES_TO_CUT = [ | 48 FILE_PREFIXES_TO_CUT = [ |
| 49 "build\\src\\", | 49 "build\\src\\", |
| 50 "chromium\\src\\", | 50 "chromium\\src\\", |
| 51 "crt_bld\\self_x86\\", | 51 "crt_bld\\self_x86\\", |
| 52 ] | 52 ] |
| 53 CUT_STACK_BELOW = ".*testing.*Test.*Run.*" | 53 CUT_STACK_BELOW = ".*testing.*Test.*Run.*|testing::internal.*" |
| 54 | 54 |
| 55 result = [self.line_] | 55 result = [self.line_] |
| 56 self.ReadLine() | 56 self.ReadLine() |
| 57 cnt = 1 | 57 cnt = 1 |
| 58 while len(self.line_.strip()) > 0: | 58 while len(self.line_.strip()) > 0: |
| 59 tmp_line = self.line_ | 59 tmp_line = self.line_ |
| 60 match_syscall = re.search("system call (.*)\n", tmp_line) | 60 match_syscall = re.search("system call (.*)\n", tmp_line) |
| 61 if match_syscall: | 61 if match_syscall: |
| 62 syscall_name = match_syscall.groups()[0] | 62 syscall_name = match_syscall.groups()[0] |
| 63 result.append(" #%2i <sys.call> %s\n" % (cnt, syscall_name)) | 63 result.append(" #%2i <sys.call> %s\n" % (cnt, syscall_name)) |
| 64 cnt = cnt + 1 | 64 cnt = cnt + 1 |
| 65 self.ReadLine() # skip "<system call> line | 65 self.ReadLine() # skip "<system call> line |
| 66 self.ReadLine() | 66 self.ReadLine() |
| 67 continue | 67 continue |
| 68 | 68 |
| 69 # Dr. Memory sometimes prints adjacent malloc'ed regions next to the | 69 # Dr. Memory sometimes prints adjacent malloc'ed regions next to the |
| 70 # access address in the UNADDRESSABLE ACCESS reports like this: | 70 # access address in the UNADDRESSABLE ACCESS reports like this: |
| 71 # Note: next higher malloc: <address range> | 71 # Note: next higher malloc: <address range> |
| 72 # Note: prev lower malloc: <address range> | 72 # Note: prev lower malloc: <address range> |
| 73 match_malloc_info = re.search("Note: .* malloc: +0x.*", tmp_line) | 73 # Note: 0x1234-0x5678 overlaps freed memory 0x1000-0x6000 |
| 74 if match_malloc_info: | 74 if tmp_line.startswith("Note: "): |
| 75 result.append(tmp_line) | 75 result.append(tmp_line) |
| 76 self.ReadLine() | 76 self.ReadLine() |
| 77 continue | 77 continue |
| 78 | 78 |
| 79 match_binary_fname = re.search("0x[0-9a-fA-F]+ <(.*)> .*!([^+]*)" | 79 match_binary_fname = re.search("0x[0-9a-fA-F]+ <(.*)> .*!([^+]*)" |
| 80 "(?:\+0x[0-9a-fA-F]+)?\n", tmp_line) | 80 "(?:\+0x[0-9a-fA-F]+)?\n", tmp_line) |
| 81 if match_binary_fname: | 81 if match_binary_fname: |
| 82 self.ReadLine() | 82 self.ReadLine() |
| 83 match_src_line = re.search("\s*(.*):([0-9]+)(?:\+0x[0-9a-fA-F]+)?", | 83 match_src_line = re.search("\s*(.*):([0-9]+)(?:\+0x[0-9a-fA-F]+)?", |
| 84 self.line_) | 84 self.line_) |
| 85 if match_src_line: | 85 if match_src_line: |
| 86 binary, fname = match_binary_fname.groups() | 86 binary, fname = match_binary_fname.groups() |
| 87 if re.search(CUT_STACK_BELOW, fname): | 87 if re.search(CUT_STACK_BELOW, fname): |
| 88 break | 88 break |
| 89 report_line = (" #%2i %-50s" % (cnt, fname)) | 89 report_line = (" #%2i %-50s" % (cnt, fname)) |
| 90 if not re.search("\.exe\+0x", binary): | 90 if (not re.search("\.exe\+0x", binary) and |
| 91 not re.search("chrome\.dll", binary)): |
| 91 # Print the DLL name | 92 # Print the DLL name |
| 92 report_line += " " + binary | 93 report_line += " " + binary |
| 93 src, lineno = match_src_line.groups() | 94 src, lineno = match_src_line.groups() |
| 94 if src != "??": | 95 if src != "??": |
| 95 for pat in FILE_PREFIXES_TO_CUT: | 96 for pat in FILE_PREFIXES_TO_CUT: |
| 96 idx = src.rfind(pat) | 97 idx = src.rfind(pat) |
| 97 if idx != -1: | 98 if idx != -1: |
| 98 src = src[idx+len(pat):] | 99 src = src[idx+len(pat):] |
| 99 report_line += " " + src | 100 report_line += " " + src |
| 100 if int(lineno) != 0: | 101 if int(lineno) != 0: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 158 |
| 158 (options, args) = parser.parse_args() | 159 (options, args) = parser.parse_args() |
| 159 if len(args) == 0: | 160 if len(args) == 0: |
| 160 parser.error("no filename specified") | 161 parser.error("no filename specified") |
| 161 filenames = args | 162 filenames = args |
| 162 | 163 |
| 163 analyzer = DrMemoryAnalyze(options.source_dir, filenames) | 164 analyzer = DrMemoryAnalyze(options.source_dir, filenames) |
| 164 retcode = analyzer.Report(False) | 165 retcode = analyzer.Report(False) |
| 165 | 166 |
| 166 sys.exit(retcode) | 167 sys.exit(retcode) |
| OLD | NEW |