Title: [116859] trunk/Tools
Revision
116859
Author
[email protected]
Date
2012-05-12 11:08:59 -0700 (Sat, 12 May 2012)

Log Message

run-safari and co. should support --guard-malloc command line argument
https://bugs.webkit.org/show_bug.cgi?id=86287

Reviewed by Dan Bernstein.

Add setUpGuardMallocIfNeeded(), which consults the argument --guard-malloc on OS X,
setting DYLD_INSERT_LIBRARIES="/usr/lib/libgmalloc.dylib" if it's enabled.

Use setUpGuardMallocIfNeeded() before running a WebKit app (whether standalone or
in the debugger). This will cause gmalloc to be loaded for gdb as well, but this
tends to be harmless.

Change "malloc guard" to the more common "Guard Malloc" in run-webkit-tests.

* Scripts/old-run-webkit-tests:
* Scripts/webkitdirs.pm:
(appendToEnvironmentVariableList):
(setUpGuardMallocIfNeeded):
(printHelpAndExitForRunAndDebugWebKitAppIfNeeded):
(runMacWebKitApp):
(execMacWebKitAppForDebugging):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(parse_args):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (116858 => 116859)


--- trunk/Tools/ChangeLog	2012-05-12 17:09:59 UTC (rev 116858)
+++ trunk/Tools/ChangeLog	2012-05-12 18:08:59 UTC (rev 116859)
@@ -1,3 +1,29 @@
+2012-05-12  Tim Horton  <[email protected]>
+
+        run-safari and co. should support --guard-malloc command line argument
+        https://bugs.webkit.org/show_bug.cgi?id=86287
+
+        Reviewed by Dan Bernstein.
+
+        Add setUpGuardMallocIfNeeded(), which consults the argument --guard-malloc on OS X,
+        setting DYLD_INSERT_LIBRARIES="/usr/lib/libgmalloc.dylib" if it's enabled.
+
+        Use setUpGuardMallocIfNeeded() before running a WebKit app (whether standalone or
+        in the debugger). This will cause gmalloc to be loaded for gdb as well, but this
+        tends to be harmless.
+
+        Change "malloc guard" to the more common "Guard Malloc" in run-webkit-tests.
+
+        * Scripts/old-run-webkit-tests:
+        * Scripts/webkitdirs.pm:
+        (appendToEnvironmentVariableList):
+        (setUpGuardMallocIfNeeded):
+        (printHelpAndExitForRunAndDebugWebKitAppIfNeeded):
+        (runMacWebKitApp):
+        (execMacWebKitAppForDebugging):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
+        (parse_args):
+
 2012-05-11  Ojan Vafai  <[email protected]>
 
         Add previous/next buttons the garden-o-matics perf panel

Modified: trunk/Tools/Scripts/old-run-webkit-tests (116858 => 116859)


--- trunk/Tools/Scripts/old-run-webkit-tests	2012-05-12 17:09:59 UTC (rev 116858)
+++ trunk/Tools/Scripts/old-run-webkit-tests	2012-05-12 18:08:59 UTC (rev 116859)
@@ -281,7 +281,7 @@
   --complex-text                  Use the complex text code path for all text (Mac OS X and Windows only)
   -c|--configuration config       Set DumpRenderTree build configuration
   --gc-between-tests              Force garbage collection between each test
-  -g|--guard-malloc               Enable malloc guard
+  -g|--guard-malloc               Enable Guard Malloc
   --exit-after-n-failures N       Exit after the first N failures (includes crashes) instead of running all tests
   --exit-after-n-crashes-or-timeouts N
                                   Exit after the first N crashes instead of running all tests

Modified: trunk/Tools/Scripts/webkitdirs.pm (116858 => 116859)


--- trunk/Tools/Scripts/webkitdirs.pm	2012-05-12 17:09:59 UTC (rev 116858)
+++ trunk/Tools/Scripts/webkitdirs.pm	2012-05-12 18:08:59 UTC (rev 116859)
@@ -103,6 +103,7 @@
 my $isInspectorFrontend;
 my $isWK2;
 my $shouldTargetWebProcess;
+my $shouldUseGuardMalloc;
 my $xcodeVersion;
 
 # Variables for Win32 support
@@ -1383,6 +1384,32 @@
     $shouldTargetWebProcess = checkForArgumentAndRemoveFromARGV("--target-web-process");
 }
 
+sub appendToEnvironmentVariableList
+{
+    my ($environmentVariableName, $value) = @_;
+
+    if (defined($ENV{$environmentVariableName})) {
+        $ENV{$environmentVariableName} .= ":" . $value;
+    } else {
+        $ENV{$environmentVariableName} = $value;
+    }
+}
+
+sub setUpGuardMallocIfNeeded
+{
+    if (!isDarwin()) {
+        return;
+    }
+
+    if (!defined($shouldUseGuardMalloc)) {
+        $shouldUseGuardMalloc = checkForArgumentAndRemoveFromARGV("--guard-malloc");
+    }
+
+    if ($shouldUseGuardMalloc) {
+        appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", "/usr/lib/libgmalloc.dylib");
+    }
+}
+
 sub relativeScriptsDir()
 {
     my $scriptDir = File::Spec->catpath("", File::Spec->abs2rel($FindBin::Bin, getcwd()), "");
@@ -2484,6 +2511,7 @@
 Usage: @{[basename($0)]} [options] [args ...]
   --help                Show this help message
   --no-saved-state      Disable application resume for the session on Mac OS 10.7
+  --guard-malloc        Enable Guard Malloc (Mac OS X only)
 EOF
     exit(1);
 }
@@ -2502,6 +2530,9 @@
     print "Starting @{[basename($appPath)]} with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+
+    setUpGuardMallocIfNeeded();
+
     if (defined($useOpenCommand) && $useOpenCommand == USE_OPEN_COMMAND) {
         return system("open", "-W", "-a", $appPath, "--args", argumentsForRunAndDebugMacWebKitApp());
     }
@@ -2521,6 +2552,9 @@
     my $productDir = productDir();
     $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
     $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES";
+
+    setUpGuardMallocIfNeeded();
+
     my @architectureFlags = ("-arch", architecture());
     if (!shouldTargetWebProcess()) {
         print "Starting @{[basename($appPath)]} under gdb with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
@@ -2529,8 +2563,9 @@
         my $webProcessShimPath = File::Spec->catfile($productDir, "WebProcessShim.dylib");
         my $webProcessPath = File::Spec->catdir($productDir, "WebProcess.app");
         my $webKit2ExecutablePath = File::Spec->catfile($productDir, "WebKit2.framework", "WebKit2");
-        $ENV{DYLD_INSERT_LIBRARIES} = $webProcessShimPath;
 
+        appendToEnvironmentVariableList("DYLD_INSERT_LIBRARIES", $webProcessShimPath);
+
         print "Starting WebProcess under gdb with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
         exec { $gdbPath } $gdbPath, @architectureFlags, "--args", $webProcessPath, $webKit2ExecutablePath, "-type", "webprocess", "-client-executable", $appPath or die;
     }

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py (116858 => 116859)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-05-12 17:09:59 UTC (rev 116858)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py	2012-05-12 18:08:59 UTC (rev 116859)
@@ -252,7 +252,7 @@
         optparse.make_option("-l", "--leaks", action="" default=False,
             help="Enable leaks checking (Mac OS X only)"),
         optparse.make_option("-g", "--guard-malloc", action="" default=False,
-            help="Enable malloc guard (Mac OS X only)"),
+            help="Enable Guard Malloc (Mac OS X only)"),
         optparse.make_option("--threaded", action="" default=False,
             help="Run a concurrent _javascript_ thread with each test"),
         optparse.make_option("--webkit-test-runner", "-2", action=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to