From 8aac33760c1ea49406656c926838b52301cb81c1 Mon Sep 17 00:00:00 2001 From: "aroben@apple.com" Date: Sat, 17 Nov 2007 20:49:33 +0000 Subject: [PATCH] Make it easy to run Safari in the debugger on Windows WebKitSite: Update Windows debugging instructions Reviewed by Mark Rowe. * building/debug.html: WebKitTools: Make it easy to run Safari in the debugger on Windows I've added a new script, debug-safari, which launches Safari in the debugger. On OS X it just calls gdb-safari. Reviewed by Mark Rowe. * FindSafari/FindSafari.cpp: (_tmain): Added a /debugger flag, which in combination with /printSafariLauncher will print a script that launches Safari in the debugger. * Scripts/debug-safari: Added. * Scripts/run-safari: Changed to call runSafari(). * Scripts/run-webkit-nightly.cmd: Prepends the launcher script with vsvars32.bat, which will let us find VS/VC++ Express, and passes the first argument along to FindSafari. * Scripts/webkitdirs.pm: (sub runSafari): Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27878 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKitSite/ChangeLog | 8 +++++ WebKitSite/building/debug.html | 9 ++--- WebKitTools/ChangeLog | 21 +++++++++++ WebKitTools/FindSafari/FindSafari.cpp | 41 +++++++++++++++++++--- WebKitTools/Scripts/debug-safari | 38 ++++++++++++++++++++ WebKitTools/Scripts/run-safari | 26 ++------------ WebKitTools/Scripts/run-webkit-nightly.cmd | 8 ++++- WebKitTools/Scripts/webkitdirs.pm | 31 ++++++++++++++++ 8 files changed, 146 insertions(+), 36 deletions(-) create mode 100755 WebKitTools/Scripts/debug-safari diff --git a/WebKitSite/ChangeLog b/WebKitSite/ChangeLog index 2902a6fc5b36..69812167188b 100644 --- a/WebKitSite/ChangeLog +++ b/WebKitSite/ChangeLog @@ -1,3 +1,11 @@ +2007-11-17 Adam Roben + + Update Windows debugging instructions + + Reviewed by Mark Rowe. + + * building/debug.html: + 2007-11-14 Brady Eidson For future use diff --git a/WebKitSite/building/debug.html b/WebKitSite/building/debug.html index ebc639d0500e..3ddf9fe21f50 100644 --- a/WebKitSite/building/debug.html +++ b/WebKitSite/building/debug.html @@ -35,13 +35,8 @@

Debugging on Windows

-

-You can launch the Visual Studio development environment with the following -command:

-

devenv /debugexe Safari.exe [args to safari]

-

The arguments to Safari should be the same ones that run-safari uses, -namely the /frameworkPath switch (to point to the path at which the updated -WebKit can be found) and debug if the WebKit you built is a debug version.

+

To launch Safari in the Visual Studio or Visual C++ Express debugger, simply run:

+

debug-safari

+ + Make it easy to run Safari in the debugger on Windows + + I've added a new script, debug-safari, which launches Safari in the + debugger. On OS X it just calls gdb-safari. + + Reviewed by Mark Rowe. + + * FindSafari/FindSafari.cpp: + (_tmain): Added a /debugger flag, which in combination with + /printSafariLauncher will print a script that launches Safari in the + debugger. + * Scripts/debug-safari: Added. + * Scripts/run-safari: Changed to call runSafari(). + * Scripts/run-webkit-nightly.cmd: Prepends the launcher script with + vsvars32.bat, which will let us find VS/VC++ Express, and passes the + first argument along to FindSafari. + * Scripts/webkitdirs.pm: + (sub runSafari): Added. + 2007-11-16 Alexey Proskuryakov Reviewed by Adam Roben. diff --git a/WebKitTools/FindSafari/FindSafari.cpp b/WebKitTools/FindSafari/FindSafari.cpp index f2ec2a8d8a8a..46e10a9fd841 100644 --- a/WebKitTools/FindSafari/FindSafari.cpp +++ b/WebKitTools/FindSafari/FindSafari.cpp @@ -128,19 +128,46 @@ int _tmain(int argc, TCHAR* argv[]) return 1; } - if (argc < 2 || _tcscmp(argv[1], TEXT("/printSafariLauncher"))) { - _tprintf(TEXT("%s"), path); + bool printLauncher = false; + bool debugger = false; + + for (int i = 1; i < argc; ++i) { + if (!_tcscmp(argv[i], TEXT("/printSafariLauncher"))) { + printLauncher = true; + continue; + } + if (!_tcscmp(argv[i], TEXT("/debugger"))) { + debugger = true; + continue; + } + } + + if (!printLauncher) { + _tprintf(TEXT("%s\n"), path); free(path); return 0; } - TCHAR* lines[] = { + LPCTSTR lines[] = { TEXT("@echo off"), TEXT("mkdir 2>NUL \"%%TMP%%\\WebKitNightly\\Safari.resources\""), TEXT("xcopy /y /i /d \"%sSafari.exe\" \"%%TMP%%\\WebKitNightly\""), TEXT("xcopy /y /i /d /e \"%sSafari.resources\" \"%%TMP%%\\WebKitNightly\\Safari.resources\""), TEXT("set PATH=\"%%CD%%;%s;%%PATH%%\""), - TEXT("\"%%TMP%%\\WebKitNightly\\Safari.exe\" /customWebKit"), + }; + + LPCTSTR command = TEXT("\"%TMP%\\WebKitNightly\\Safari.exe\" /customWebKit"); + + LPCTSTR launchLines[] = { + TEXT("%s"), + }; + + LPCTSTR debuggerLines[] = { + TEXT("if exist \"%%DevEnvDir%%\\VCExpress.exe\" ("), + TEXT("\"%%DevEnvDir%%\\VCExpress.exe\" /debugExe %s"), + TEXT(") else ("), + TEXT("\"%%DevEnvDir%%\\devenv.exe\" /debugExe %s"), + TEXT(")"), }; for (int i = 0; i < ARRAYSIZE(lines); ++i) { @@ -148,6 +175,12 @@ int _tmain(int argc, TCHAR* argv[]) _tprintf(TEXT("\n")); } + LPCTSTR* endLines = debugger ? debuggerLines : launchLines; + for (unsigned i = 0; i < (debugger ? ARRAYSIZE(debuggerLines) : ARRAYSIZE(launchLines)); ++i) { + _tprintf(endLines[i], command); + _tprintf(TEXT("\n")); + } + free(path); return 0; } diff --git a/WebKitTools/Scripts/debug-safari b/WebKitTools/Scripts/debug-safari new file mode 100755 index 000000000000..52e97fe9caf5 --- /dev/null +++ b/WebKitTools/Scripts/debug-safari @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2007 Apple 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. + +# Script to run Safari in the platform's debugger for the WebKit Open Source Project. + +use strict; +use FindBin; +use lib $FindBin::Bin; +use webkitdirs; + +setConfiguration(); + +exit exitStatus(runSafari(1)); diff --git a/WebKitTools/Scripts/run-safari b/WebKitTools/Scripts/run-safari index b044ddfe6843..4474b6927310 100755 --- a/WebKitTools/Scripts/run-safari +++ b/WebKitTools/Scripts/run-safari @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2005 Apple Computer, Inc. All rights reserved. +# Copyright (C) 2005, 2007 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -29,35 +29,13 @@ # Simplified "run" script for Web Kit Open Source Project. use strict; -use File::Temp qw/tempfile/; use FindBin; use lib $FindBin::Bin; use webkitdirs; setConfiguration(); -my $productDir = productDir(); -my $safariPath = safariPath(); # Check to see that all the frameworks are built. checkFrameworks(); -# Set up DYLD_FRAMEWORK_PATH to point to the product directory. -print "Starting Safari with DYLD_FRAMEWORK_PATH set to point to built WebKit in $productDir.\n"; - -my @args; -if (isOSX()) { - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; - @args = @ARGV; -} elsif (isCygwin()) { - my $script = "run-webkit-nightly.cmd"; - my $result = system "cp", "$FindBin::Bin/$script", $productDir; - die if $result; - - chdir $productDir; - - $safariPath = "cmd"; - @args = ("/c", "call $script"); -} -exec $safariPath, @args or die; - +exit exitStatus(runSafari()); diff --git a/WebKitTools/Scripts/run-webkit-nightly.cmd b/WebKitTools/Scripts/run-webkit-nightly.cmd index 865c966ad0c4..93037aba0ee3 100755 --- a/WebKitTools/Scripts/run-webkit-nightly.cmd +++ b/WebKitTools/Scripts/run-webkit-nightly.cmd @@ -1,4 +1,10 @@ @echo off set script="%TMP%\run-webkit-nightly2.cmd" -FindSafari.exe /printSafariLauncher > %script% +set vsvars="%VS80COMNTOOLS%\vsvars32.bat" +if exist %vsvars% ( + copy %vsvars% "%script%" +) else ( + del "%script%" +) +FindSafari.exe %1 /printSafariLauncher >> "%script%" call %script% diff --git a/WebKitTools/Scripts/webkitdirs.pm b/WebKitTools/Scripts/webkitdirs.pm index a2b1e32e4774..cd35373af083 100644 --- a/WebKitTools/Scripts/webkitdirs.pm +++ b/WebKitTools/Scripts/webkitdirs.pm @@ -766,4 +766,35 @@ sub exitStatus($) return WEXITSTATUS($returnvalue); } +sub runSafari +{ + my ($debugger) = @_; + + if (isOSX()) { + return system "$FindBin::Bin/gdb-safari", @ARGV if $debugger; + + my $productDir = productDir(); + print "Starting Safari 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"; + return system safariPath(), @ARGV; + } + + if (isCygwin()) { + my $script = "run-webkit-nightly.cmd"; + my $result = system "cp", "$FindBin::Bin/$script", productDir(); + return $result if $result; + + my $cwd = getcwd(); + chdir productDir(); + + my $debuggerFlag = $debugger ? "/debugger" : ""; + $result = system "cmd", "/c", "call $script $debuggerFlag"; + chdir $cwd; + return $result; + } + + return 1; +} + 1; -- 2.36.0