Chromium Code Reviews| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 | 359 |
| 360 return ret | 360 return ret |
| 361 | 361 |
| 362 def Analyze(self): | 362 def Analyze(self): |
| 363 # Glob all the files in the "valgrind.tmp" directory | 363 # Glob all the files in the "valgrind.tmp" directory |
| 364 filenames = glob.glob(self.TMP_DIR + "/memcheck.*") | 364 filenames = glob.glob(self.TMP_DIR + "/memcheck.*") |
| 365 | 365 |
| 366 use_gdb = (sys.platform == 'darwin') | 366 use_gdb = (sys.platform == 'darwin') |
| 367 analyzer = memcheck_analyze.MemcheckAnalyze(self._source_dir, filenames, sel f._options.show_all_leaks, | 367 analyzer = memcheck_analyze.MemcheckAnalyze(self._source_dir, filenames, sel f._options.show_all_leaks, |
| 368 use_gdb=use_gdb) | 368 use_gdb=use_gdb) |
| 369 return analyzer.Report() | 369 ret = analyzer.Report() |
| 370 if ret != 0: | |
| 371 logging.info("Please see http://dev.chromium.org/developers/how-tos/" | |
| 372 "using-valgrind for the info on Memcheck/Valgrind") | |
| 373 return ret | |
|
stuartmorgan
2009/10/27 20:28:27
The return value is non-zero if there are leaks or
| |
| 370 | 374 |
| 371 class ThreadSanitizer(ValgrindTool): | 375 class ThreadSanitizer(ValgrindTool): |
| 372 """ThreadSanitizer""" | 376 """ThreadSanitizer""" |
| 373 | 377 |
| 374 def __init__(self): | 378 def __init__(self): |
| 375 ValgrindTool.__init__(self) | 379 ValgrindTool.__init__(self) |
| 376 | 380 |
| 377 def ToolName(self): | 381 def ToolName(self): |
| 378 return "tsan" | 382 return "tsan" |
| 379 | 383 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 if platform_suffix == 'mac': | 433 if platform_suffix == 'mac': |
| 430 ret += ["--show-pc=yes"] | 434 ret += ["--show-pc=yes"] |
| 431 | 435 |
| 432 return ret | 436 return ret |
| 433 | 437 |
| 434 def Analyze(self): | 438 def Analyze(self): |
| 435 filenames = glob.glob(self.TMP_DIR + "/tsan.*") | 439 filenames = glob.glob(self.TMP_DIR + "/tsan.*") |
| 436 use_gdb = (sys.platform == 'darwin') | 440 use_gdb = (sys.platform == 'darwin') |
| 437 analyzer = tsan_analyze.TsanAnalyze(self._source_dir, filenames, | 441 analyzer = tsan_analyze.TsanAnalyze(self._source_dir, filenames, |
| 438 use_gdb=use_gdb) | 442 use_gdb=use_gdb) |
| 439 return analyzer.Report() | 443 ret = analyzer.Report() |
| 444 if ret != 0: | |
| 445 logging.info("Please see http://dev.chromium.org/developers/how-tos/" | |
| 446 "using-valgrind/threadsanitizer for the info on " | |
| 447 "ThreadSanitizer") | |
| 448 return ret | |
| 440 | 449 |
| 441 | 450 |
| 442 class ToolFactory: | 451 class ToolFactory: |
| 443 def Create(self, tool_name): | 452 def Create(self, tool_name): |
| 444 if tool_name == "memcheck": | 453 if tool_name == "memcheck": |
| 445 return Memcheck() | 454 return Memcheck() |
| 446 if tool_name == "tsan": | 455 if tool_name == "tsan": |
| 447 if sys.platform != 'linux2': | 456 if sys.platform != 'linux2': |
| 448 logging.info("WARNING: ThreadSanitizer is not working yet on Mac") | 457 logging.info("WARNING: ThreadSanitizer may be unstable on Mac.") |
| 458 logging.info("See http://code.google.com/p/data-race-test/wiki/" | |
| 459 "ThreadSanitizerOnMacOsx for the details") | |
| 449 return ThreadSanitizer() | 460 return ThreadSanitizer() |
| 450 raise RuntimeError, "Unknown tool" \ | 461 raise RuntimeError, "Unknown tool" \ |
| 451 "(tool=%s, platform=%s)" % \ | 462 "(tool=%s, platform=%s)" % \ |
| 452 (tool_name, sys.platform) | 463 (tool_name, sys.platform) |
| 453 | 464 |
| 454 def RunTool(argv): | 465 def RunTool(argv): |
| 455 # TODO(timurrrr): customize optparse instead | 466 # TODO(timurrrr): customize optparse instead |
| 456 tool_name = "memcheck" | 467 tool_name = "memcheck" |
| 457 args = argv[1:] | 468 args = argv[1:] |
| 458 for arg in args: | 469 for arg in args: |
| 459 if arg.startswith("--tool="): | 470 if arg.startswith("--tool="): |
| 460 tool_name = arg[7:] | 471 tool_name = arg[7:] |
| 461 args.remove(arg) | 472 args.remove(arg) |
| 462 break | 473 break |
| 463 | 474 |
| 464 tool = ToolFactory().Create(tool_name) | 475 tool = ToolFactory().Create(tool_name) |
| 465 return tool.Main(args) | 476 return tool.Main(args) |
| 466 | 477 |
| 467 if __name__ == "__main__": | 478 if __name__ == "__main__": |
| 468 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: | 479 if sys.argv.count("-v") > 0 or sys.argv.count("--verbose") > 0: |
| 469 google.logging_utils.config_root(logging.DEBUG) | 480 google.logging_utils.config_root(logging.DEBUG) |
| 470 else: | 481 else: |
| 471 google.logging_utils.config_root() | 482 google.logging_utils.config_root() |
| 472 # TODO(timurrrr): valgrind tools may use -v/--verbose as well | 483 # TODO(timurrrr): valgrind tools may use -v/--verbose as well |
| 473 | 484 |
| 474 ret = RunTool(sys.argv) | 485 ret = RunTool(sys.argv) |
| 475 sys.exit(ret) | 486 sys.exit(ret) |
| OLD | NEW |