Commit 72477d86 authored by timurrrr@chromium.org's avatar timurrrr@chromium.org

Avoid duplicate error reports / suppressions when UI test reports are analyzed separately

Review URL: http://codereview.chromium.org/3056025

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54118 0039d316-1c4b-4281-b951-d872f2087c98
parent b0db42f4
This diff is collapsed.
...@@ -33,7 +33,7 @@ class _StackTraceLine(object): ...@@ -33,7 +33,7 @@ class _StackTraceLine(object):
else: else:
return self.raw_line_.replace(self.binary, '%s:%s' % (file, line)) return self.raw_line_.replace(self.binary, '%s:%s' % (file, line))
class TsanAnalyze: class TsanAnalyzer:
''' Given a set of ThreadSanitizer output files, parse all the errors out of ''' Given a set of ThreadSanitizer output files, parse all the errors out of
them, unique them and output the results.''' them, unique them and output the results.'''
...@@ -48,37 +48,27 @@ class TsanAnalyze: ...@@ -48,37 +48,27 @@ class TsanAnalyze:
"(has been created by T.* at this point|is program's main thread)") "(has been created by T.* at this point|is program's main thread)")
SANITY_TEST_SUPPRESSION = "ThreadSanitizer sanity test" SANITY_TEST_SUPPRESSION = "ThreadSanitizer sanity test"
def __init__(self, source_dir, files, use_gdb=False): def __init__(self, source_dir, use_gdb=False):
'''Reads in a set of files. '''Reads in a set of files.
Args: Args:
source_dir: Path to top of source tree for this build source_dir: Path to top of source tree for this build
files: A list of filenames.
''' '''
self.use_gdb = use_gdb self._use_gdb = use_gdb
if use_gdb:
global TheAddressTable
TheAddressTable = gdb_helper.AddressTable()
self.races = []
self.used_suppressions = {}
for file in files:
self.ParseReportFile(file)
if self.use_gdb:
TheAddressTable.ResolveAll()
def ReadLine(self): def ReadLine(self):
self.line_ = self.cur_fd_.readline() self.line_ = self.cur_fd_.readline()
self.stack_trace_line_ = None self.stack_trace_line_ = None
if not self.use_gdb: if not self._use_gdb:
return return
global TheAddressTable global TheAddressTable
match = TsanAnalyze.LOAD_LIB_RE.match(self.line_) match = TsanAnalyzer.LOAD_LIB_RE.match(self.line_)
if match: if match:
binary, ip = match.groups() binary, ip = match.groups()
TheAddressTable.AddBinaryAt(binary, ip) TheAddressTable.AddBinaryAt(binary, ip)
return return
match = TsanAnalyze.TSAN_LINE_RE.match(self.line_) match = TsanAnalyzer.TSAN_LINE_RE.match(self.line_)
if match: if match:
address, binary_name = match.groups() address, binary_name = match.groups()
stack_trace_line = _StackTraceLine(self.line_, address, binary_name) stack_trace_line = _StackTraceLine(self.line_, address, binary_name)
...@@ -106,7 +96,7 @@ class TsanAnalyze: ...@@ -106,7 +96,7 @@ class TsanAnalyze:
break break
tmp = [] tmp = []
while re.search(TsanAnalyze.THREAD_CREATION_STR, self.line_): while re.search(TsanAnalyzer.THREAD_CREATION_STR, self.line_):
tmp.extend(self.ReadSection()) tmp.extend(self.ReadSection())
self.ReadLine() self.ReadLine()
if re.search("Possible data race", self.line_): if re.search("Possible data race", self.line_):
...@@ -123,14 +113,29 @@ class TsanAnalyze: ...@@ -123,14 +113,29 @@ class TsanAnalyze:
self.used_suppressions[supp_name] = count self.used_suppressions[supp_name] = count
self.cur_fd_.close() self.cur_fd_.close()
def Report(self, check_sanity=False): def Report(self, files, check_sanity=False):
'''TODO!!!
files: A list of filenames.
'''
global TheAddressTable
if self._use_gdb:
TheAddressTable = gdb_helper.AddressTable()
else:
TheAddressTable = None
self.races = []
self.used_suppressions = {}
for file in files:
self.ParseReportFile(file)
if self._use_gdb:
TheAddressTable.ResolveAll()
is_sane = False is_sane = False
print "-----------------------------------------------------" print "-----------------------------------------------------"
print "Suppressions used:" print "Suppressions used:"
print " count name" print " count name"
for item in sorted(self.used_suppressions.items(), key=lambda (k,v): (v,k)): for item in sorted(self.used_suppressions.items(), key=lambda (k,v): (v,k)):
print "%7s %s" % (item[1], item[0]) print "%7s %s" % (item[1], item[0])
if item[0].startswith(TsanAnalyze.SANITY_TEST_SUPPRESSION): if item[0].startswith(TsanAnalyzer.SANITY_TEST_SUPPRESSION):
is_sane = True is_sane = True
print "-----------------------------------------------------" print "-----------------------------------------------------"
sys.stdout.flush() sys.stdout.flush()
...@@ -156,7 +161,7 @@ class TsanAnalyze: ...@@ -156,7 +161,7 @@ class TsanAnalyze:
return 0 return 0
if __name__ == '__main__': if __name__ == '__main__':
'''For testing only. The TsanAnalyze class should be imported instead.''' '''For testing only. The TsanAnalyzer class should be imported instead.'''
retcode = 0 retcode = 0
parser = optparse.OptionParser("usage: %prog [options] <files to analyze>") parser = optparse.OptionParser("usage: %prog [options] <files to analyze>")
parser.add_option("", "--source_dir", parser.add_option("", "--source_dir",
...@@ -168,7 +173,7 @@ if __name__ == '__main__': ...@@ -168,7 +173,7 @@ if __name__ == '__main__':
parser.error("no filename specified") parser.error("no filename specified")
filenames = args filenames = args
analyzer = TsanAnalyze(options.source_dir, filenames, use_gdb=True) analyzer = TsanAnalyzer(options.source_dir, use_gdb=True)
retcode = analyzer.Report() retcode = analyzer.Report(filenames)
sys.exit(retcode) sys.exit(retcode)
...@@ -437,9 +437,10 @@ class ValgrindTool(BaseTool): ...@@ -437,9 +437,10 @@ class ValgrindTool(BaseTool):
ppids = set([int(f.split(".")[-2]) \ ppids = set([int(f.split(".")[-2]) \
for f in filenames if re.search("\.[0-9]+\.[0-9]+$", f)]) for f in filenames if re.search("\.[0-9]+\.[0-9]+$", f)])
analyzer = self.CreateAnalyzer()
if len(ppids) == 0: if len(ppids) == 0:
# Fast path - no browser wrapper was set. # Fast path - no browser wrapper was set.
return self.CreateAnalyzer(filenames).Report(check_sanity) return analyzer.Report(filenames, check_sanity)
ret = 0 ret = 0
for ppid in ppids: for ppid in ppids:
...@@ -453,7 +454,7 @@ class ValgrindTool(BaseTool): ...@@ -453,7 +454,7 @@ class ValgrindTool(BaseTool):
if re.search("\.%d\.[0-9]+$" % ppid, f)] if re.search("\.%d\.[0-9]+$" % ppid, f)]
# check_sanity won't work with browser wrappers # check_sanity won't work with browser wrappers
assert check_sanity == False assert check_sanity == False
ret |= self.CreateAnalyzer(ppid_filenames).Report() ret |= analyzer.Report(ppid_filenames)
print "=====================================================" print "====================================================="
sys.stdout.flush() sys.stdout.flush()
...@@ -502,9 +503,9 @@ class Memcheck(ValgrindTool): ...@@ -502,9 +503,9 @@ class Memcheck(ValgrindTool):
return ret return ret
def CreateAnalyzer(self, filenames): def CreateAnalyzer(self):
use_gdb = common.IsMac() use_gdb = common.IsMac()
return memcheck_analyze.MemcheckAnalyze(self._source_dir, filenames, return memcheck_analyze.MemcheckAnalyzer(self._source_dir,
self._options.show_all_leaks, self._options.show_all_leaks,
use_gdb=use_gdb) use_gdb=use_gdb)
...@@ -656,9 +657,9 @@ class ThreadSanitizerPosix(ThreadSanitizerBase, ValgrindTool): ...@@ -656,9 +657,9 @@ class ThreadSanitizerPosix(ThreadSanitizerBase, ValgrindTool):
proc += ["-v"] proc += ["-v"]
return proc return proc
def CreateAnalyzer(self, filenames): def CreateAnalyzer(self):
use_gdb = common.IsMac() use_gdb = common.IsMac()
return tsan_analyze.TsanAnalyze(self._source_dir, filenames) return tsan_analyze.TsanAnalyzer(self._source_dir)
def Analyze(self, check_sanity=False): def Analyze(self, check_sanity=False):
ret = self.GetAnalyzeResults(check_sanity) ret = self.GetAnalyzeResults(check_sanity)
...@@ -702,8 +703,8 @@ class ThreadSanitizerWindows(ThreadSanitizerBase, PinTool): ...@@ -702,8 +703,8 @@ class ThreadSanitizerWindows(ThreadSanitizerBase, PinTool):
def Analyze(self, check_sanity=False): def Analyze(self, check_sanity=False):
filenames = glob.glob(self.TMP_DIR + "/tsan.*") filenames = glob.glob(self.TMP_DIR + "/tsan.*")
analyzer = tsan_analyze.TsanAnalyze(self._source_dir, filenames) analyzer = tsan_analyze.TsanAnalyzer(self._source_dir)
ret = analyzer.Report(check_sanity) ret = analyzer.Report(filenames, check_sanity)
if ret != 0: if ret != 0:
logging.info(self.INFO_MESSAGE) logging.info(self.INFO_MESSAGE)
return ret return ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment