OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 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 # valgrind_test.py | 6 # valgrind_test.py |
7 | 7 |
8 """Runs an exe through Valgrind and puts the intermediate files in a | 8 """Runs an exe through Valgrind and puts the intermediate files in a |
9 directory. | 9 directory. |
10 """ | 10 """ |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 def GetAnalyzeResults(self, check_sanity=False): | 430 def GetAnalyzeResults(self, check_sanity=False): |
431 # Glob all the files in the "testing.tmp" directory | 431 # Glob all the files in the "testing.tmp" directory |
432 filenames = glob.glob(self.TMP_DIR + "/" + self.ToolName() + ".*") | 432 filenames = glob.glob(self.TMP_DIR + "/" + self.ToolName() + ".*") |
433 | 433 |
434 # If we have browser wrapper, the logfiles are named as | 434 # If we have browser wrapper, the logfiles are named as |
435 # "toolname.wrapper_PID.valgrind_PID". | 435 # "toolname.wrapper_PID.valgrind_PID". |
436 # Let's extract the list of wrapper_PIDs and name it ppids | 436 # Let's extract the list of wrapper_PIDs and name it ppids |
437 ppids = set([int(f.split(".")[-2]) \ | 437 ppids = set([int(f.split(".")[-2]) \ |
438 for f in filenames if re.search("\.[0-9]+\.[0-9]+$", f)]) | 438 for f in filenames if re.search("\.[0-9]+\.[0-9]+$", f)]) |
439 | 439 |
| 440 analyzer = self.CreateAnalyzer() |
440 if len(ppids) == 0: | 441 if len(ppids) == 0: |
441 # Fast path - no browser wrapper was set. | 442 # Fast path - no browser wrapper was set. |
442 return self.CreateAnalyzer(filenames).Report(check_sanity) | 443 return analyzer.Report(filenames, check_sanity) |
443 | 444 |
444 ret = 0 | 445 ret = 0 |
445 for ppid in ppids: | 446 for ppid in ppids: |
446 print "=====================================================" | 447 print "=====================================================" |
447 print " Below is the report for valgrind wrapper PID=%d." % ppid | 448 print " Below is the report for valgrind wrapper PID=%d." % ppid |
448 print " You can find the corresponding test " | 449 print " You can find the corresponding test " |
449 print " by searching the above log for 'PID=%d'" % ppid | 450 print " by searching the above log for 'PID=%d'" % ppid |
450 sys.stdout.flush() | 451 sys.stdout.flush() |
451 | 452 |
452 ppid_filenames = [f for f in filenames \ | 453 ppid_filenames = [f for f in filenames \ |
453 if re.search("\.%d\.[0-9]+$" % ppid, f)] | 454 if re.search("\.%d\.[0-9]+$" % ppid, f)] |
454 # check_sanity won't work with browser wrappers | 455 # check_sanity won't work with browser wrappers |
455 assert check_sanity == False | 456 assert check_sanity == False |
456 ret |= self.CreateAnalyzer(ppid_filenames).Report() | 457 ret |= analyzer.Report(ppid_filenames) |
457 print "=====================================================" | 458 print "=====================================================" |
458 sys.stdout.flush() | 459 sys.stdout.flush() |
459 | 460 |
460 if ret != 0: | 461 if ret != 0: |
461 print "" | 462 print "" |
462 print "The Valgrind reports are grouped by test names." | 463 print "The Valgrind reports are grouped by test names." |
463 print "Each test has its PID printed in the log when the test was run" | 464 print "Each test has its PID printed in the log when the test was run" |
464 print "and at the beginning of its Valgrind report." | 465 print "and at the beginning of its Valgrind report." |
465 sys.stdout.flush() | 466 sys.stdout.flush() |
466 | 467 |
(...skipping 28 matching lines...) Expand all Loading... |
495 if self._options.show_all_leaks: | 496 if self._options.show_all_leaks: |
496 ret += ["--show-reachable=yes"] | 497 ret += ["--show-reachable=yes"] |
497 else: | 498 else: |
498 ret += ["--show-possible=no"] | 499 ret += ["--show-possible=no"] |
499 | 500 |
500 if self._options.track_origins: | 501 if self._options.track_origins: |
501 ret += ["--track-origins=yes"] | 502 ret += ["--track-origins=yes"] |
502 | 503 |
503 return ret | 504 return ret |
504 | 505 |
505 def CreateAnalyzer(self, filenames): | 506 def CreateAnalyzer(self): |
506 use_gdb = common.IsMac() | 507 use_gdb = common.IsMac() |
507 return memcheck_analyze.MemcheckAnalyze(self._source_dir, filenames, | 508 return memcheck_analyze.MemcheckAnalyzer(self._source_dir, |
508 self._options.show_all_leaks, | 509 self._options.show_all_leaks, |
509 use_gdb=use_gdb) | 510 use_gdb=use_gdb) |
510 | 511 |
511 def Analyze(self, check_sanity=False): | 512 def Analyze(self, check_sanity=False): |
512 ret = self.GetAnalyzeResults(check_sanity) | 513 ret = self.GetAnalyzeResults(check_sanity) |
513 | 514 |
514 if ret != 0: | 515 if ret != 0: |
515 logging.info("Please see http://dev.chromium.org/developers/how-tos/" | 516 logging.info("Please see http://dev.chromium.org/developers/how-tos/" |
516 "using-valgrind for the info on Memcheck/Valgrind") | 517 "using-valgrind for the info on Memcheck/Valgrind") |
517 return ret | 518 return ret |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 ValgrindTool.__init__(self) | 650 ValgrindTool.__init__(self) |
650 ThreadSanitizerBase.__init__(self) | 651 ThreadSanitizerBase.__init__(self) |
651 | 652 |
652 def ToolSpecificFlags(self): | 653 def ToolSpecificFlags(self): |
653 proc = ThreadSanitizerBase.ToolSpecificFlags(self) | 654 proc = ThreadSanitizerBase.ToolSpecificFlags(self) |
654 # The -v flag is needed for printing the list of used suppressions and | 655 # The -v flag is needed for printing the list of used suppressions and |
655 # obtaining addresses for loaded shared libraries on Mac. | 656 # obtaining addresses for loaded shared libraries on Mac. |
656 proc += ["-v"] | 657 proc += ["-v"] |
657 return proc | 658 return proc |
658 | 659 |
659 def CreateAnalyzer(self, filenames): | 660 def CreateAnalyzer(self): |
660 use_gdb = common.IsMac() | 661 use_gdb = common.IsMac() |
661 return tsan_analyze.TsanAnalyze(self._source_dir, filenames) | 662 return tsan_analyze.TsanAnalyzer(self._source_dir) |
662 | 663 |
663 def Analyze(self, check_sanity=False): | 664 def Analyze(self, check_sanity=False): |
664 ret = self.GetAnalyzeResults(check_sanity) | 665 ret = self.GetAnalyzeResults(check_sanity) |
665 | 666 |
666 if ret != 0: | 667 if ret != 0: |
667 logging.info(self.INFO_MESSAGE) | 668 logging.info(self.INFO_MESSAGE) |
668 return ret | 669 return ret |
669 | 670 |
670 class ThreadSanitizerWindows(ThreadSanitizerBase, PinTool): | 671 class ThreadSanitizerWindows(ThreadSanitizerBase, PinTool): |
671 def __init__(self): | 672 def __init__(self): |
(...skipping 23 matching lines...) Expand all Loading... |
695 logfilename = self.TMP_DIR + "/tsan.%p" | 696 logfilename = self.TMP_DIR + "/tsan.%p" |
696 proc += ["--log-file=" + logfilename] | 697 proc += ["--log-file=" + logfilename] |
697 | 698 |
698 # TODO(timurrrr): Add flags for Valgrind trace children analog when we | 699 # TODO(timurrrr): Add flags for Valgrind trace children analog when we |
699 # start running complex tests (e.g. UI) under TSan/Win. | 700 # start running complex tests (e.g. UI) under TSan/Win. |
700 | 701 |
701 return proc | 702 return proc |
702 | 703 |
703 def Analyze(self, check_sanity=False): | 704 def Analyze(self, check_sanity=False): |
704 filenames = glob.glob(self.TMP_DIR + "/tsan.*") | 705 filenames = glob.glob(self.TMP_DIR + "/tsan.*") |
705 analyzer = tsan_analyze.TsanAnalyze(self._source_dir, filenames) | 706 analyzer = tsan_analyze.TsanAnalyzer(self._source_dir) |
706 ret = analyzer.Report(check_sanity) | 707 ret = analyzer.Report(filenames, check_sanity) |
707 if ret != 0: | 708 if ret != 0: |
708 logging.info(self.INFO_MESSAGE) | 709 logging.info(self.INFO_MESSAGE) |
709 return ret | 710 return ret |
710 | 711 |
711 | 712 |
712 class DrMemory(BaseTool): | 713 class DrMemory(BaseTool): |
713 """Dr.Memory | 714 """Dr.Memory |
714 Dynamic memory error detector for Windows. | 715 Dynamic memory error detector for Windows. |
715 | 716 |
716 http://dynamorio.org/drmemory.html | 717 http://dynamorio.org/drmemory.html |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 817 |
817 if __name__ == "__main__": | 818 if __name__ == "__main__": |
818 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: | 819 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: |
819 logging_utils.config_root(logging.DEBUG) | 820 logging_utils.config_root(logging.DEBUG) |
820 else: | 821 else: |
821 logging_utils.config_root() | 822 logging_utils.config_root() |
822 # TODO(timurrrr): valgrind tools may use -v/--verbose as well | 823 # TODO(timurrrr): valgrind tools may use -v/--verbose as well |
823 | 824 |
824 ret = RunTool(sys.argv) | 825 ret = RunTool(sys.argv) |
825 sys.exit(ret) | 826 sys.exit(ret) |
OLD | NEW |