Changeset 38100 in webkit


Ignore:
Timestamp:
Nov 4, 2008 10:56:28 AM (15 years ago)
Author:
Darin Adler
Message:

2008-11-03 Darin Adler <Darin Adler>

Reviewed by Tim Hatcher.

  • Scripts/check-for-exit-time-destructors: Added. Started as a copy of check-for-global-initializers.
  • Scripts/check-for-global-initializers: Added code to make this script rerun any time it's modified, and also to properly run again after the first time it reports an error.
Location:
trunk/WebKitTools
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r38082 r38100  
     12008-11-03  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Tim Hatcher.
     4
     5        - https://bugs.webkit.org/show_bug.cgi?id=22061
     6          create script to check for exit-time destructors
     7
     8        * Scripts/check-for-exit-time-destructors: Added.
     9        Started as a copy of check-for-global-initializers.
     10
     11        * Scripts/check-for-global-initializers: Added code to make
     12        this script rerun any time it's modified, and also to properly
     13        run again after the first time it reports an error.
     14
    1152008-11-03  Pierre-Olivier Latour  <pol@apple.com>
    216
  • trunk/WebKitTools/Scripts/check-for-exit-time-destructors

    r38045 r38100  
    2727# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 # "check-for-global-initializers" script for WebKit Open Source Project
     29# "check-for-exit-time-destructors" script for WebKit Open Source Project
    3030
    3131# Intended to be invoked from an Xcode build step to check if there are
    32 # any global initializers in a target.
     32# any exit-time destructors in a target.
    3333
    3434use warnings;
     
    3838
    3939sub touch($);
     40sub printFunctions($$);
    4041
    4142my $arch = $ENV{'CURRENT_ARCH'};
     
    5354my $buildTimestampPath = $ENV{'TARGET_TEMP_DIR'} . "/" . basename($0) . ".timestamp";
    5455my $buildTimestampAge = -M $buildTimestampPath;
    55 
    56 touch($buildTimestampPath);
     56my $scriptAge = -M $0;
    5757
    5858my $list = $ENV{"LINK_FILE_LIST_${variant}_${arch}"};
     
    7070
    7171for my $file (sort @files) {
    72     if (defined $buildTimestampAge) {
     72    if (defined $buildTimestampAge && $buildTimestampAge < $scriptAge) {
    7373        my $fileAge = -M $file;
    7474        next if defined $fileAge && $fileAge > $buildTimestampAge;
     
    7979        next;
    8080    }
    81     my $sawGlobal = 0;
     81    my $sawAtExit = 0;
    8282    while (<NM>) {
    8383        if (/^STDOUT:/) {
    84             $sawGlobal = 1 if /__GLOBAL__I/;
     84            $sawAtExit = 1 if /___cxa_atexit/;
    8585        } else {
    8686            print STDERR if $_ ne "nm: no name list\n";
     
    8888    }
    8989    close NM;
    90     if ($sawGlobal) {
    91         my $shortName = $file;
    92         $shortName =~ s/.*\///;
    93 
    94         # Special cases for files that have initializers in debug builds.
    95         if ($configuration eq "Debug" or $variant eq "debug" or $debugRoot) {
    96             if ($target eq "JavaScriptCore") {
    97                 next if $shortName eq "AllInOneFile.o";
    98                 next if $shortName eq "Opcode.o";
    99                 next if $shortName eq "StructureID.o";
    100                 next if $shortName eq "nodes.o";
    101             }
    102             if ($target eq "WebCore") {
    103                 next if $shortName eq "CachedPage.o";
    104                 next if $shortName eq "CachedResource.o";
    105                 next if $shortName eq "Frame.o";
    106                 next if $shortName eq "JSCustomSQLTransactionCallback.o";
    107                 next if $shortName eq "JSEventListener.o";
    108                 next if $shortName eq "Node.o";
    109                 next if $shortName eq "Page.o";
    110                 next if $shortName eq "Range.o";
    111                 next if $shortName eq "RenderObject.o";
    112                 next if $shortName eq "SubresourceLoader.o";
    113                 next if $shortName eq "SVGElementInstance.o";
    114                 next if $shortName eq "bidi.o";
    115             }
    116         }
    117 
    118         print "$shortName has a global initializer in it! ($file)\n";
    119         $sawError = 1;
    120     }
     90    next unless $sawAtExit;
     91
     92    my $shortName = $file;
     93    $shortName =~ s/.*\///;
     94
     95    if ($target eq "WebCore") {
     96        next if $shortName eq "AccessibilityObject.o";
     97        next if $shortName eq "AccessibilityRenderObject.o";
     98        next if $shortName eq "ApplicationCacheStorage.o";
     99        next if $shortName eq "ApplyStyleCommand.o";
     100        next if $shortName eq "ArchiveFactory.o";
     101        next if $shortName eq "CSSMutableStyleDeclaration.o";
     102        next if $shortName eq "CSSPrimitiveValue.o";
     103        next if $shortName eq "CSSSelector.o";
     104        next if $shortName eq "CSSStyleSelector.o";
     105        next if $shortName eq "CachedImage.o";
     106        next if $shortName eq "ColorMac.o";
     107        next if $shortName eq "DOMImplementation.o";
     108        next if $shortName eq "Document.o";
     109        next if $shortName eq "EventHandler.o";
     110        next if $shortName eq "EventHandlerMac.o";
     111        next if $shortName eq "FTPDirectoryDocument.o";
     112        next if $shortName eq "FontCache.o";
     113        next if $shortName eq "FontCacheMac.o";
     114        next if $shortName eq "FormDataStreamMac.o";
     115        next if $shortName eq "Frame.o";
     116        next if $shortName eq "FrameLoader.o";
     117        next if $shortName eq "FrameMac.o";
     118        next if $shortName eq "GCController.o";
     119        next if $shortName eq "GraphicsContextMac.o";
     120        next if $shortName eq "HTMLButtonElement.o";
     121        next if $shortName eq "HTMLElement.o";
     122        next if $shortName eq "HTMLFieldSetElement.o";
     123        next if $shortName eq "HTMLInputElement.o";
     124        next if $shortName eq "HTMLInterchange.o";
     125        next if $shortName eq "HTMLKeygenElement.o";
     126        next if $shortName eq "HTMLLegendElement.o";
     127        next if $shortName eq "HTMLOptGroupElement.o";
     128        next if $shortName eq "HTMLOptionElement.o";
     129        next if $shortName eq "HTMLParser.o";
     130        next if $shortName eq "HTMLSelectElement.o";
     131        next if $shortName eq "HTMLTableElement.o";
     132        next if $shortName eq "HTMLTextAreaElement.o";
     133        next if $shortName eq "IconDatabase.o";
     134        next if $shortName eq "Image.o";
     135        next if $shortName eq "IndentOutdentCommand.o";
     136        next if $shortName eq "InspectorController.o";
     137        next if $shortName eq "JSDOMBinding.o";
     138        next if $shortName eq "JSHTMLElementWrapperFactory.o";
     139        next if $shortName eq "JSInspectedObjectWrapper.o";
     140        next if $shortName eq "JSInspectorCallbackWrapper.o";
     141        next if $shortName eq "JSSVGElementWrapperFactory.o";
     142        next if $shortName eq "JavaScriptDebugServer.o";
     143        next if $shortName eq "JavaScriptProfile.o";
     144        next if $shortName eq "JavaScriptProfileNode.o";
     145        next if $shortName eq "KURL.o";
     146        next if $shortName eq "LocalStorage.o";
     147        next if $shortName eq "NetworkStateNotifier.o";
     148        next if $shortName eq "Page.o";
     149        next if $shortName eq "PasteboardMac.o";
     150        next if $shortName eq "RenderBlock.o";
     151        next if $shortName eq "RenderCounter.o";
     152        next if $shortName eq "RenderFlexibleBox.o";
     153        next if $shortName eq "RenderLayer.o";
     154        next if $shortName eq "RenderListItem.o";
     155        next if $shortName eq "RenderScrollbarTheme.o";
     156        next if $shortName eq "RenderStyle.o";
     157        next if $shortName eq "RenderThemeMac.o";
     158        next if $shortName eq "ReplaceSelectionCommand.o";
     159        next if $shortName eq "ResourceResponseMac.o";
     160        next if $shortName eq "SVGAnimateMotionElement.o";
     161        next if $shortName eq "SVGAnimationElement.o";
     162        next if $shortName eq "SVGLangSpace.o";
     163        next if $shortName eq "SVGResource.o";
     164        next if $shortName eq "SVGResourceMarker.o";
     165        next if $shortName eq "SVGSMILElement.o";
     166        next if $shortName eq "SVGSVGElement.o";
     167        next if $shortName eq "SVGStyleElement.o";
     168        next if $shortName eq "SVGTextContentElement.o";
     169        next if $shortName eq "ScriptElement.o";
     170        next if $shortName eq "ScrollView.o";
     171        next if $shortName eq "ScrollbarThemeMac.o";
     172        next if $shortName eq "SecurityOrigin.o";
     173        next if $shortName eq "SimpleFontDataMac.o";
     174        next if $shortName eq "TextEncoding.o";
     175        next if $shortName eq "ThemeMac.o";
     176        next if $shortName eq "ThreadCheck.o";
     177        next if $shortName eq "XMLHttpRequest.o";
     178        next if $shortName eq "XPathExpressionNode.o";
     179        next if $shortName eq "XPathParser.o";
     180        next if $shortName eq "XPathValue.o";
     181        next if $shortName eq "bidi.o";
     182        next if $shortName eq "htmlediting.o";
     183        next if $shortName eq "markup.o";
     184        next if $shortName eq "runtime_root.o";
     185    }
     186
     187    if ($target eq "WebKit") {
     188        next if $shortName eq "AccessibilityObject.o";
     189        next if $shortName eq "WebBackForwardList.o";
     190        next if $shortName eq "WebBaseNetscapePluginStream.o";
     191        next if $shortName eq "WebHTMLRepresentation.o";
     192        next if $shortName eq "WebHistoryItem.o";
     193        next if $shortName eq "WebNSPasteboardExtras.o";
     194        next if $shortName eq "WebPasteboardHelper.o";
     195        next if $shortName eq "WebStringTruncator.o";
     196        next if $shortName eq "WebView.o";
     197    }
     198
     199    $sawError = 1 if printFunctions($shortName, $file);
    121200}
    122201
     
    126205}
    127206
     207touch($buildTimestampPath);
    128208exit 0;
    129209
     
    134214    close(TOUCH);
    135215}
     216
     217sub demangle($)
     218{
     219    my ($symbol) = @_;
     220    if (!open FILT, "c++filt $symbol |") {
     221        print "Could not open c++filt\n";
     222        return;
     223    }
     224    my $result = <FILT>;
     225    close FILT;
     226    chomp $result;
     227    return $result;
     228}
     229
     230sub printFunctions($$)
     231{
     232    my ($shortName, $path) = @_;
     233    if (!open OTOOL, "otool -tV '$path' |") {
     234        print "Could not open $path\n";
     235        return 0;
     236    }
     237    my %functions;
     238    my $currentSymbol = "";
     239    while (<OTOOL>) {
     240        $currentSymbol = $1 if /^(\w+):$/;
     241        $functions{demangle($currentSymbol)} = 1 if /___cxa_atexit/;
     242    }
     243    close OTOOL;
     244    my $result = 0;
     245    for my $function (sort keys %functions) {
     246        if (!$result) {
     247            print "$shortName has exit time destructors in it! ($path)\n";
     248            $result = 1;
     249        }
     250        print "    $function\n";
     251    }
     252    return $result;
     253}
  • trunk/WebKitTools/Scripts/check-for-global-initializers

    r38045 r38100  
    5353my $buildTimestampPath = $ENV{'TARGET_TEMP_DIR'} . "/" . basename($0) . ".timestamp";
    5454my $buildTimestampAge = -M $buildTimestampPath;
    55 
    56 touch($buildTimestampPath);
     55my $scriptAge = -M $0;
    5756
    5857my $list = $ENV{"LINK_FILE_LIST_${variant}_${arch}"};
     
    7069
    7170for my $file (sort @files) {
    72     if (defined $buildTimestampAge) {
     71    if (defined $buildTimestampAge && $buildTimestampAge < $scriptAge) {
    7372        my $fileAge = -M $file;
    7473        next if defined $fileAge && $fileAge > $buildTimestampAge;
     
    126125}
    127126
     127touch($buildTimestampPath);
    128128exit 0;
    129129
Note: See TracChangeset for help on using the changeset viewer.