OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Runs an exe through Valgrind and puts the intermediate files in a | 5 """Runs an exe through Valgrind and puts the intermediate files in a |
6 directory. | 6 directory. |
7 """ | 7 """ |
8 | 8 |
9 import datetime | 9 import datetime |
10 import glob | 10 import glob |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 parser.add_option("", "--use_debug", action="store_true", | 826 parser.add_option("", "--use_debug", action="store_true", |
827 default=False, dest="use_debug", | 827 default=False, dest="use_debug", |
828 help="Run Dr. Memory debug build") | 828 help="Run Dr. Memory debug build") |
829 parser.add_option("", "--trace_children", action="store_true", | 829 parser.add_option("", "--trace_children", action="store_true", |
830 default=True, | 830 default=True, |
831 help="TODO: default value differs from Valgrind") | 831 help="TODO: default value differs from Valgrind") |
832 | 832 |
833 def ToolCommand(self): | 833 def ToolCommand(self): |
834 """Get the tool command to run.""" | 834 """Get the tool command to run.""" |
835 # WINHEAP is what Dr. Memory supports as there are issues w/ both | 835 # WINHEAP is what Dr. Memory supports as there are issues w/ both |
836 # jemalloc (http://code.google.com/p/drmemory/issues/detail?id=320) and | 836 # jemalloc (https://github.com/DynamoRIO/drmemory/issues/320) and |
837 # tcmalloc (http://code.google.com/p/drmemory/issues/detail?id=314) | 837 # tcmalloc (https://github.com/DynamoRIO/drmemory/issues/314) |
838 add_env = { | 838 add_env = { |
839 "CHROME_ALLOCATOR" : "WINHEAP", | 839 "CHROME_ALLOCATOR" : "WINHEAP", |
840 "JSIMD_FORCEMMX" : "1", # http://code.google.com/p/drmemory/issues/deta
il?id=540 | 840 "JSIMD_FORCEMMX" : "1", # https://github.com/DynamoRIO/drmemory/issues/
540 |
841 } | 841 } |
842 for k,v in add_env.iteritems(): | 842 for k,v in add_env.iteritems(): |
843 logging.info("export %s=%s", k, v) | 843 logging.info("export %s=%s", k, v) |
844 os.putenv(k, v) | 844 os.putenv(k, v) |
845 | 845 |
846 drmem_cmd = os.getenv("DRMEMORY_COMMAND") | 846 drmem_cmd = os.getenv("DRMEMORY_COMMAND") |
847 if not drmem_cmd: | 847 if not drmem_cmd: |
848 raise RuntimeError, "Please set DRMEMORY_COMMAND environment variable " \ | 848 raise RuntimeError, "Please set DRMEMORY_COMMAND environment variable " \ |
849 "with the path to drmemory.exe" | 849 "with the path to drmemory.exe" |
850 proc = drmem_cmd.split(" ") | 850 proc = drmem_cmd.split(" ") |
851 | 851 |
852 # By default, don't run python (this will exclude python's children as well) | 852 # By default, don't run python (this will exclude python's children as well) |
853 # to reduce runtime. We're not really interested in spending time finding | 853 # to reduce runtime. We're not really interested in spending time finding |
854 # bugs in the python implementation. | 854 # bugs in the python implementation. |
855 # With file-based config we must update the file every time, and | 855 # With file-based config we must update the file every time, and |
856 # it will affect simultaneous drmem uses by this user. While file-based | 856 # it will affect simultaneous drmem uses by this user. While file-based |
857 # config has many advantages, here we may want this-instance-only | 857 # config has many advantages, here we may want this-instance-only |
858 # (http://code.google.com/p/drmemory/issues/detail?id=334). | 858 # (https://github.com/DynamoRIO/drmemory/issues/334). |
859 drconfig_cmd = [ proc[0].replace("drmemory.exe", "drconfig.exe") ] | 859 drconfig_cmd = [ proc[0].replace("drmemory.exe", "drconfig.exe") ] |
860 drconfig_cmd += ["-quiet"] # suppress errors about no 64-bit libs | 860 drconfig_cmd += ["-quiet"] # suppress errors about no 64-bit libs |
861 run_drconfig = True | 861 run_drconfig = True |
862 if self._options.follow_python: | 862 if self._options.follow_python: |
863 logging.info("Following python children") | 863 logging.info("Following python children") |
864 # -unreg fails if not already registered so query for that first | 864 # -unreg fails if not already registered so query for that first |
865 query_cmd = drconfig_cmd + ["-isreg", "python.exe"] | 865 query_cmd = drconfig_cmd + ["-isreg", "python.exe"] |
866 query_proc = subprocess.Popen(query_cmd, stdout=subprocess.PIPE, | 866 query_proc = subprocess.Popen(query_cmd, stdout=subprocess.PIPE, |
867 shell=True) | 867 shell=True) |
868 (query_out, query_err) = query_proc.communicate() | 868 (query_out, query_err) = query_proc.communicate() |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 proc += self._args | 983 proc += self._args |
984 return proc | 984 return proc |
985 | 985 |
986 def CreateBrowserWrapper(self, command): | 986 def CreateBrowserWrapper(self, command): |
987 os.putenv("BROWSER_WRAPPER", command) | 987 os.putenv("BROWSER_WRAPPER", command) |
988 | 988 |
989 def Analyze(self, check_sanity=False): | 989 def Analyze(self, check_sanity=False): |
990 # Use one analyzer for all the log files to avoid printing duplicate reports | 990 # Use one analyzer for all the log files to avoid printing duplicate reports |
991 # | 991 # |
992 # TODO(timurrrr): unify this with Valgrind and other tools when we have | 992 # TODO(timurrrr): unify this with Valgrind and other tools when we have |
993 # http://code.google.com/p/drmemory/issues/detail?id=684 | 993 # https://github.com/DynamoRIO/drmemory/issues/684 |
994 analyzer = drmemory_analyze.DrMemoryAnalyzer() | 994 analyzer = drmemory_analyze.DrMemoryAnalyzer() |
995 | 995 |
996 ret = 0 | 996 ret = 0 |
997 if not self._options.indirect and not self._options.indirect_webkit_layout: | 997 if not self._options.indirect and not self._options.indirect_webkit_layout: |
998 filenames = glob.glob(self.log_dir + "/*/results.txt") | 998 filenames = glob.glob(self.log_dir + "/*/results.txt") |
999 | 999 |
1000 ret = analyzer.Report(filenames, None, check_sanity) | 1000 ret = analyzer.Report(filenames, None, check_sanity) |
1001 else: | 1001 else: |
1002 testcases = glob.glob(self.log_dir + "/testcase.*.logs") | 1002 testcases = glob.glob(self.log_dir + "/testcase.*.logs") |
1003 # If we have browser wrapper, the per-test logdirs are named as | 1003 # If we have browser wrapper, the per-test logdirs are named as |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 return RaceVerifier() | 1187 return RaceVerifier() |
1188 try: | 1188 try: |
1189 platform_name = common.PlatformNames()[0] | 1189 platform_name = common.PlatformNames()[0] |
1190 except common.NotImplementedError: | 1190 except common.NotImplementedError: |
1191 platform_name = sys.platform + "(Unknown)" | 1191 platform_name = sys.platform + "(Unknown)" |
1192 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, | 1192 raise RuntimeError, "Unknown tool (tool=%s, platform=%s)" % (tool_name, |
1193 platform_name) | 1193 platform_name) |
1194 | 1194 |
1195 def CreateTool(tool): | 1195 def CreateTool(tool): |
1196 return ToolFactory().Create(tool) | 1196 return ToolFactory().Create(tool) |
OLD | NEW |