Not part of build.

Add scripts that can report on only files listed in mozilla/embedding/config manifests.
This commit is contained in:
blythe%netscape.com 2002-11-15 22:48:39 +00:00
parent 81edc8021d
commit ab9a9d27a0
3 changed files with 421 additions and 9 deletions

View File

@ -0,0 +1,185 @@
#!/bin/bash
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is basesummary.linx.bash code, released
# Nov 15, 2002.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2002 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Garrett Arch Blythe, 15-November-2002
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the MPL or the GPL.
#
#
# A little help for my friends.
#
if [ "-h" == "$1" ];then
SHOWHELP="1"
fi
if [ "--help" == "$1" ];then
SHOWHELP="1"
fi
if [ "" == "$1" ]; then
SHOWHELP="1"
fi
if [ "" == "$2" ]; then
SHOWHELP="1"
fi
if [ "" == "$3" ]; then
SHOWHELP="1"
fi
#
# Show the help if required.
#
if [ $SHOWHELP ]; then
echo "usage: $0 <save_results> <old_results> <summary>"
echo " <save_results> is a file that will receive the results of this run."
echo " This file can be used in a future run as the old results."
echo " <old_results> is a results file from a previous run."
echo " It is used to diff with current results and come up with a summary"
echo " of changes."
echo " It is OK if the file does not exist, just supply the argument."
echo " <summary> is a file which will contain a human readable report."
echo " This file is most useful by providing more information than the"
echo " normally single digit output of this script."
echo ""
echo "Run this command from the parent directory of the mozilla tree."
echo ""
echo "This command will output two numbers to stdout that will represent"
echo " the total size of all code and data, and a delta from the prior."
echo " the old results."
echo "For much more detail on size drifts refer to the summary report."
exit
fi
#
# Exclude certain path patterns.
# Be sure to modify the grep command below as well.
#
EXCLUDE_PATTERN_01="test"
EXCLUDE_PATTERN_02="tsv"
EXCLUDE_NAMES="-not -name viewer"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name spacetrace"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name xpidl"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name bloadblame"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name leakstats"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name codesighs"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name htmlrobot"
EXCLUDE_NAMES="$EXCLUDE_NAMES -not -name DumpColors"
#
# Stash our arguments away.
#
COPYSORTTSV="$1"
OLDTSVFILE="$2"
SUMMARYFILE="$3"
#
# Create our temporary directory.
#
MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX`
#
# Find all relevant files.
#
ALLFILES="$MYTMPDIR/allfiles.list"
grep -v '[\;\[]' < ./mozilla/embedding/config/basebrowser-unix | grep -v '^$' | sed 's/^/\.\/mozilla\/dist\/bin\//' > $ALLFILES
#
# Produce the cumulative nm output.
# We are very particular on what switches to use.
# nm --format=bsd --size-sort --print-file-name --demangle
#
NMRESULTS="$MYTMPDIR/nm.txt"
xargs -n 1 nm --format=bsd --size-sort --print-file-name --demangle < $ALLFILES > $NMRESULTS 2> /dev/null
#
# Produce the TSV output.
#
RAWTSVFILE="$MYTMPDIR/raw.tsv"
./mozilla/dist/bin/nm2tsv --input $NMRESULTS > $RAWTSVFILE
#
# Sort the TSV output for useful diffing and eyeballing in general.
#
sort -r $RAWTSVFILE > $COPYSORTTSV
#
# If a historical file was specified, diff it with our sorted tsv values.
# Run it through a tool to summaries the diffs to the module
# level report.
#
rm -f $SUMMARYFILE
DIFFFILE="$MYTMPDIR/diff.txt"
if [ -e $OLDTSVFILE ]; then
diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE
./mozilla/dist/bin/maptsvdifftool --input $DIFFFILE >> $SUMMARYFILE
echo "" >> $SUMMARYFILE
echo "" >> $SUMMARYFILE
fi
#
# Generate the module level report from our new data.
#
./mozilla/dist/bin/codesighs --modules --input $COPYSORTTSV >> $SUMMARYFILE
#
# Output our numbers, that will let tinderbox specify everything all
# at once.
# First number is in fact the total size of all code and data in the map
# files parsed.
# Second number, if present, is growth/shrinkage.
#
if [ $TINDERBOX_OUTPUT ]; then
echo -n "__codesize:"
fi
./mozilla/dist/bin/codesighs --totalonly --input $COPYSORTTSV
if [ -e $DIFFFILE ]; then
if [ $TINDERBOX_OUTPUT ]; then
echo -n "__codesizeDiff:"
fi
./mozilla/dist/bin/maptsvdifftool --summary --input $DIFFFILE
fi
#
# Remove our temporary directory.
#
\rm -rf $MYTMPDIR

View File

@ -0,0 +1,161 @@
#!/bin/bash
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is basesummary.win.bash code, released
# Nov 15, 2002.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2002 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Garrett Arch Blythe, 15-November-2002
#
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL. If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the MPL or the GPL.
#
#
# A little help for my friends.
#
if [ "-h" == "$1" ];then
SHOWHELP="1"
fi
if [ "--help" == "$1" ];then
SHOWHELP="1"
fi
if [ "" == "$1" ]; then
SHOWHELP="1"
fi
if [ "" == "$2" ]; then
SHOWHELP="1"
fi
if [ "" == "$3" ]; then
SHOWHELP="1"
fi
#
# Show the help if required.
#
if [ $SHOWHELP ]; then
echo "usage: $0 <save_results> <old_results> <summary>"
echo " <save_results> is a file that will receive the results of this run."
echo " This file can be used in a future run as the old results."
echo " <old_results> is a results file from a previous run."
echo " It is used to diff with current results and come up with a summary"
echo " of changes."
echo " It is OK if the file does not exist, just supply the argument."
echo " <summary> is a file which will contain a human readable report."
echo " This file is most useful by providing more information than the"
echo " normally single digit output of this script."
echo ""
echo "Run this command from the parent directory of the mozilla tree."
echo ""
echo "This command will output two numbers to stdout that will represent"
echo " the total size of all code and data, and a delta from the prior."
echo " the old results."
echo "For much more detail on size drifts refer to the summary report."
exit
fi
#
# Stash our arguments away.
#
COPYSORTTSV="$1"
OLDTSVFILE="$2"
SUMMARYFILE="$3"
#
# Create our temporary directory.
#
MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX`
#
# Find all map files.
#
ALLMAPSFILE="$MYTMPDIR/allmaps.list"
find ./mozilla -type f -name *.map > $ALLMAPSFILE
#
# Figure out which modules in specific we care about.
# The relevant set meaning that the map file name prefix must be found
# in the file mozilla/embedding/config/basebrowser-win.
#
RELEVANTSETFILE="$MYTMPDIR/relevant.set"
grep -v '\;' < ./mozilla/embedding/config/basebrowser-win | sed 's/.*\\//' | grep '\.[eEdD][xXlL][eElL]' | sed 's/\.[eEdD][xXlL][eElL]//' > $RELEVANTSETFILE
RELEVANTARG=`xargs -n 1 echo --match-module < $RELEVANTSETFILE`
#
# Produce the TSV output.
#
RAWTSVFILE="$MYTMPDIR/raw.tsv"
xargs -n 1 ./mozilla/dist/bin/msmap2tsv $RELEVANTARG --input < $ALLMAPSFILE > $RAWTSVFILE
#
# Sort the TSV output for useful diffing and eyeballing in general.
#
sort -r $RAWTSVFILE > $COPYSORTTSV
#
# If a historical file was specified, diff it with our sorted tsv values.
# Run it through a tool to summaries the diffs to the module
# level report.
#
rm -f $SUMMARYFILE
DIFFFILE="$MYTMPDIR/diff.txt"
if [ -e $OLDTSVFILE ]; then
diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE
./mozilla/dist/bin/maptsvdifftool --input $DIFFFILE >> $SUMMARYFILE
echo "" >> $SUMMARYFILE
echo "" >> $SUMMARYFILE
fi
#
# Generate the module level report from our new data.
#
./mozilla/dist/bin/codesighs --modules --input $COPYSORTTSV >> $SUMMARYFILE
#
# Output our numbers, that will let tinderbox specify everything all
# at once.
# First number is in fact the total size of all code and data in the map
# files parsed.
# Second number, if present, is growth/shrinkage.
#
./mozilla/dist/bin/codesighs --totalonly --input $COPYSORTTSV
if [ -e $DIFFFILE ]; then
./mozilla/dist/bin/maptsvdifftool --summary --input $DIFFFILE
fi
#
# Remove our temporary directory.
#
rm -rf $MYTMPDIR

View File

@ -50,15 +50,17 @@ typedef struct __struct_Options
/*
** Options to control how we perform.
**
** mProgramName Used in help text.
** mInput File to read for input.
** Default is stdin.
** mInputName Name of the file.
** mOutput Output file, append.
** Default is stdout.
** mOutputName Name of the file.
** mHelp Wether or not help should be shown.
** mAddress Wether or not to output addresses.
** mProgramName Used in help text.
** mInput File to read for input.
** Default is stdin.
** mInputName Name of the file.
** mOutput Output file, append.
** Default is stdout.
** mOutputName Name of the file.
** mHelp Wether or not help should be shown.
** mAddress Wether or not to output addresses.
** mMatchModules Array of strings which the module name should match.
** mMatchModuleCount Number of items in array.
*/
{
const char* mProgramName;
@ -68,6 +70,8 @@ typedef struct __struct_Options
char* mOutputName;
int mHelp;
int mAddresses;
char** mMatchModules;
unsigned mMatchModuleCount;
}
Options;
@ -91,11 +95,13 @@ static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DE
static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."};
static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."};
static Switch gAddressesSwitch = {"--addresses", "-a", 0, NULL, "Output segment addresses." DESC_NEWLINE "Helps reveal symbol ordering." DESC_NEWLINE "Lack of simplifies size diffing."};
static Switch gMatchModuleSwitch = {"--match-module", "-mm", 1, NULL, "Specify a valid module name." DESC_NEWLINE "Multiple specifications allowed." DESC_NEWLINE "If a module name does not match one of the names specified then no output will occur."};
static Switch* gSwitches[] = {
&gInputSwitch,
&gOutputSwitch,
&gAddressesSwitch,
&gMatchModuleSwitch,
&gHelpSwitch
};
@ -584,6 +590,32 @@ int readmap(Options* inOptions, MSMap_Module* inModule)
{
fsm.mHasModule = __LINE__;
forceContinue = 1;
if(0 != inOptions->mMatchModuleCount)
{
unsigned matchLoop = 0;
/*
** If this module name doesn't match, then bail.
** Compare in a case sensitive manner, exact match only.
*/
for(matchLoop = 0; matchLoop < inOptions->mMatchModuleCount; matchLoop++)
{
if(0 == strcmp(inModule->mModule, inOptions->mMatchModules[matchLoop]))
{
break;
}
}
if(matchLoop == inOptions->mMatchModuleCount)
{
/*
** A match did not occur, bail out of read loop.
** No error, however.
*/
break;
}
}
}
else
{
@ -1058,6 +1090,34 @@ int initOptions(Options* outOptions, int inArgc, char** inArgv)
{
outOptions->mHelp = __LINE__;
}
else if(current == &gMatchModuleSwitch)
{
void* moved = NULL;
/*
** Add the value to the list of allowed module names.
*/
moved = realloc(outOptions->mMatchModules, sizeof(char*) * (outOptions->mMatchModuleCount + 1));
if(NULL != moved)
{
outOptions->mMatchModules = (char**)moved;
outOptions->mMatchModules[outOptions->mMatchModuleCount] = strdup(current->mValue);
if(NULL != outOptions->mMatchModules[outOptions->mMatchModuleCount])
{
outOptions->mMatchModuleCount++;
}
else
{
retval = __LINE__;
ERROR_REPORT(retval, current->mValue, "Unable to duplicate string.");
}
}
else
{
retval = __LINE__;
ERROR_REPORT(retval, current->mValue, "Unable to allocate space for string.");
}
}
else
{
retval = __LINE__;
@ -1085,6 +1145,12 @@ void cleanOptions(Options* inOptions)
{
fclose(inOptions->mOutput);
}
while(0 != inOptions->mMatchModuleCount)
{
inOptions->mMatchModuleCount--;
CLEANUP(inOptions->mMatchModules[inOptions->mMatchModuleCount]);
}
CLEANUP(inOptions->mMatchModules);
memset(inOptions, 0, sizeof(Options));
}