Title: [97562] trunk/Tools
Revision
97562
Author
[email protected]
Date
2011-10-15 12:34:27 -0700 (Sat, 15 Oct 2011)

Log Message

Extract common gdb code into its own function; Remove script gdb-safari
https://bugs.webkit.org/show_bug.cgi?id=68499

Reviewed by David Kilzer.

Almost identical code is used in webkitdirs::{debugMiniBrowser, debugWebKitTestRunner,
runSafari}() and in the script gdb-safari to launch gdb to debug an application.
We should extract the common parts into a function that can be shared by all callers
so as to remove duplicate code.

As a side effect of removing duplicate code we can remove the script gdb-safari since
its code has been incorporated into webkitdirs::debugSafari() which is called by the
script debug-safari.

* Scripts/debug-safari: Modified to call webkitdirs::debugSafari().
* Scripts/gdb-safari: Removed.
* Scripts/webkitdirs.pm:
(execMacWebKitAppForDebugging): Added; Extracted common debugging code from
debugMiniBrowser(), debugWebKitTestRunner(), runSafari() and
script gdb-safari to here.
(debugSafari): Added.
(runSafari): Extracted debugging code to debugSafari() and debugMacWebKitApp();
Also, return the exit status of WebKit launcher (WebKit.exe) on Windows. Currently,
runSafari() always returns 1 on Windows and the script run-safari exits using this
value as its exit status. Hence, the script run-safari always exits with a nonzero
exit status (i.e. abnormal termination) on Windows. Instead, we should return the
exit status of the WebKit launcher application.
(debugMiniBrowser): Modified to call debugMacWebKitApp().
(debugWebKitTestRunner): Ditto.

Modified Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (97561 => 97562)


--- trunk/Tools/ChangeLog	2011-10-15 19:14:37 UTC (rev 97561)
+++ trunk/Tools/ChangeLog	2011-10-15 19:34:27 UTC (rev 97562)
@@ -1,3 +1,35 @@
+2011-10-15  Daniel Bates  <[email protected]>
+
+        Extract common gdb code into its own function; Remove script gdb-safari
+        https://bugs.webkit.org/show_bug.cgi?id=68499
+
+        Reviewed by David Kilzer.
+
+        Almost identical code is used in webkitdirs::{debugMiniBrowser, debugWebKitTestRunner,
+        runSafari}() and in the script gdb-safari to launch gdb to debug an application.
+        We should extract the common parts into a function that can be shared by all callers
+        so as to remove duplicate code.
+
+        As a side effect of removing duplicate code we can remove the script gdb-safari since
+        its code has been incorporated into webkitdirs::debugSafari() which is called by the
+        script debug-safari.
+
+        * Scripts/debug-safari: Modified to call webkitdirs::debugSafari().
+        * Scripts/gdb-safari: Removed.
+        * Scripts/webkitdirs.pm:
+        (execMacWebKitAppForDebugging): Added; Extracted common debugging code from
+        debugMiniBrowser(), debugWebKitTestRunner(), runSafari() and
+        script gdb-safari to here.
+        (debugSafari): Added.
+        (runSafari): Extracted debugging code to debugSafari() and debugMacWebKitApp();
+        Also, return the exit status of WebKit launcher (WebKit.exe) on Windows. Currently,
+        runSafari() always returns 1 on Windows and the script run-safari exits using this
+        value as its exit status. Hence, the script run-safari always exits with a nonzero
+        exit status (i.e. abnormal termination) on Windows. Instead, we should return the
+        exit status of the WebKit launcher application.
+        (debugMiniBrowser): Modified to call debugMacWebKitApp().
+        (debugWebKitTestRunner): Ditto.
+
 2011-10-15  Robert Hogan  <[email protected]>
 
         [webkit-patch] Put Source/Tools changes at the top of patches, LayoutTests at the bottom

Modified: trunk/Tools/Scripts/debug-safari (97561 => 97562)


--- trunk/Tools/Scripts/debug-safari	2011-10-15 19:14:37 UTC (rev 97561)
+++ trunk/Tools/Scripts/debug-safari	2011-10-15 19:34:27 UTC (rev 97562)
@@ -35,4 +35,4 @@
 
 setConfiguration();
 
-exit exitStatus(runSafari(1));
+exit exitStatus(debugSafari());

Deleted: trunk/Tools/Scripts/gdb-safari (97561 => 97562)


--- trunk/Tools/Scripts/gdb-safari	2011-10-15 19:14:37 UTC (rev 97561)
+++ trunk/Tools/Scripts/gdb-safari	2011-10-15 19:34:27 UTC (rev 97562)
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-
-# Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer. 
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution. 
-# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
-#     its contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission. 
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Simplified "run under gdb" script for WebKit Open Source Project.
-
-use strict;
-use File::Temp qw/:mktemp/;
-use FindBin;
-use lib $FindBin::Bin;
-use webkitdirs;
-
-setConfiguration();
-my $productDir = productDir();
-my $safariPath = safariPath();
-
-# Check to see that gdb is in the usual place.
-my $gdbPath = "/usr/bin/gdb";
-die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
-
-# Check to see that all the frameworks are built.
-checkFrameworks();
-
-$ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-$ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = 'YES';
-
-print "Starting Safari under gdb with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n";
-my @architectureFlags = ("-arch", architecture());
-exec $gdbPath, @architectureFlags, "--arg", $safariPath, @ARGV or die;

Modified: trunk/Tools/Scripts/webkitdirs.pm (97561 => 97562)


--- trunk/Tools/Scripts/webkitdirs.pm	2011-10-15 19:14:37 UTC (rev 97561)
+++ trunk/Tools/Scripts/webkitdirs.pm	2011-10-15 19:34:27 UTC (rev 97562)
@@ -51,6 +51,7 @@
        &chdirWebKit
        &checkFrameworks
        &currentSVNRevision
+       &debugSafari
        &passedConfiguration
        &productDir
        &runMacWebKitApp
@@ -2032,34 +2033,55 @@
     return system { $appPath } $appPath, @ARGV;
 }
 
+sub execMacWebKitAppForDebugging($)
+{
+    my ($appPath) = @_;
+
+    my $gdbPath = "/usr/bin/gdb";
+    die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
+
+    my $productDir = productDir();
+    print "Starting @{[basename($appPath)]} under gdb 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";
+    my @architectureFlags = ("-arch", architecture());
+    exec { $gdbPath } $gdbPath, @architectureFlags, $appPath or die;
+}
+
+sub debugSafari
+{
+    if (isAppleMacWebKit()) {
+        checkFrameworks();
+        execMacWebKitAppForDebugging(safariPath());
+    }
+
+    if (isAppleWinWebKit()) {
+        setupCygwinEnv();
+        my $productDir = productDir();
+        chomp($ENV{WEBKITNIGHTLY} = `cygpath -wa "$productDir"`);
+        my $safariPath = safariPath();
+        chomp($safariPath = `cygpath -wa "$safariPath"`);
+        return system { $vcBuildPath } $vcBuildPath, "/debugexe", "\"$safariPath\"", @ARGV;
+    }
+
+    return 1; # Unsupported platform; can't debug Safari on this platform.
+}
+
 sub runSafari
 {
-    my ($debugger) = @_;
 
     if (isAppleMacWebKit()) {
-        if ($debugger) {
-            return system "$FindBin::Bin/gdb-safari", argumentsForConfiguration();
-        }
         return runMacWebKitApp(safariPath());
     }
 
     if (isAppleWinWebKit()) {
         my $result;
         my $productDir = productDir();
-        if ($debugger) {
-            setupCygwinEnv();
-            chomp($ENV{WEBKITNIGHTLY} = `cygpath -wa "$productDir"`);
-            my $safariPath = safariPath();
-            chomp($safariPath = `cygpath -wa "$safariPath"`);
-            $result = system $vcBuildPath, "/debugexe", "\"$safariPath\"", @ARGV;
-        } else {
-            my $webKitLauncherPath = File::Spec->catfile(productDir(), "WebKit.exe");
-            $result = system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
-        }
-        return $result if $result;
+        my $webKitLauncherPath = File::Spec->catfile(productDir(), "WebKit.exe");
+        return system { $webKitLauncherPath } $webKitLauncherPath, @ARGV;
     }
 
-    return 1;
+    return 1; # Unsupported platform; can't run Safari on this platform.
 }
 
 sub runMiniBrowser
@@ -2074,20 +2096,7 @@
 sub debugMiniBrowser
 {
     if (isAppleMacWebKit()) {
-        my $gdbPath = "/usr/bin/gdb";
-        die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
-
-        my $productDir = productDir();
-
-        $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-        $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = 'YES';
-
-        my $miniBrowserPath = "$productDir/MiniBrowser.app/Contents/MacOS/MiniBrowser";
-
-        print "Starting MiniBrowser under gdb with DYLD_FRAMEWORK_PATH set to point to built WebKit2 in $productDir.\n";
-        my @architectureFlags = ("-arch", architecture());
-        exec $gdbPath, @architectureFlags, $miniBrowserPath or die;
-        return;
+        execMacWebKitAppForDebugging(File::Spec->catfile(productDir(), "MiniBrowser.app", "Contents", "MacOS", "MiniBrowser"));
     }
     
     return 1;
@@ -2112,19 +2121,7 @@
 sub debugWebKitTestRunner
 {
     if (isAppleMacWebKit()) {
-        my $gdbPath = "/usr/bin/gdb";
-        die "Can't find gdb executable. Is gdb installed?\n" unless -x $gdbPath;
-
-        my $productDir = productDir();
-        $ENV{DYLD_FRAMEWORK_PATH} = $productDir;
-        $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = 'YES';
-
-        my $webKitTestRunnerPath = "$productDir/WebKitTestRunner";
-
-        print "Starting WebKitTestRunner under gdb with DYLD_FRAMEWORK_PATH set to point to $productDir.\n";
-        my @architectureFlags = ("-arch", architecture());
-        exec $gdbPath, @architectureFlags, $webKitTestRunnerPath or die;
-        return;
+        execMacWebKitAppForDebugging(File::Spec->catfile(productDir(), "WebKitTestRunner"));
     }
 
     return 1;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to