initial retooling of common prefs for multi user access.
more in this area to come.
This commit is contained in:
blythe%netscape.com 2002-05-07 23:39:34 +00:00
Родитель 8ff49240a7
Коммит 7057da38c6
3 изменённых файлов: 430 добавлений и 204 удалений

Просмотреть файл

@ -70,16 +70,6 @@
*/
#include "nsQuickSort.h"
/*
** Turn on to attempt adding support for graphs on your platform.
*/
#if defined(HAVE_BOUTELL_GD)
#define WANT_GRAPHS 1
#endif /* HAVE_BOUTELL_GD */
#if !defined(WANT_GRAPHS)
#define WANT_GRAPHS 0
#endif
/*
** the globals variables. happy joy.
*/
@ -105,11 +95,11 @@ int showHelp(void)
{
int retval = 0;
if(0 != globals.mOptions.mShowHelp)
if(0 != globals.mOptions.mHelp)
{
PR_fprintf(PR_STDOUT,
"Usage:\t%s [OPTION]... [-|filename]\n\n",
globals.mOptions.mProgramName);
globals.mProgramName);
PR_fprintf(PR_STDOUT, "%s",
"OPTIONS:\n"
@ -210,7 +200,7 @@ int showHelp(void)
" By default, there is no maximum.\n"
"\n");
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
PR_fprintf(PR_STDOUT, "%s",
" -gmin<num> Set the graph minimum in seconds.\n"
" Excludes representing graph intervals before said second.\n"
@ -222,7 +212,7 @@ int showHelp(void)
" Excludes representing graph intervals after said second.\n"
" By default, there is no maximum.\n"
"\n");
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
PR_fprintf(PR_STDOUT,
" -a<num> Set an allocation alignment boundry.\n"
@ -309,11 +299,6 @@ int initOptions(int aArgCount, char** aArgArray)
const PRUint32 listItemMax = 500;
PRStatus prStatus = PR_SUCCESS;
/*
** Set the program name.
*/
PR_snprintf(globals.mOptions.mProgramName, sizeof(globals.mOptions.mProgramName), "%s", aArgArray[0]);
/*
** As a default, stdin is the input.
*/
@ -364,10 +349,12 @@ int initOptions(int aArgCount, char** aArgArray)
*/
globals.mOptions.mAllocationTimevalMax = ST_TIMEVAL_MAX;
#if ST_WANT_GRAPHS
/*
** As a default, there is no maximum graph timeval.
*/
globals.mOptions.mGraphTimevalMax = ST_TIMEVAL_MAX;
#endif
/*
** As a default, we align byte sizes to a particular size.
@ -426,7 +413,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
else
@ -434,7 +421,7 @@ int initOptions(int aArgCount, char** aArgArray)
/*
** Help.
*/
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -450,7 +437,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -466,7 +453,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -483,7 +470,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -500,18 +487,18 @@ int initOptions(int aArgCount, char** aArgArray)
/*
** Increase size of batch buffer.
*/
expand = (const char**)realloc((void*)globals.mOptions.mBatchRequests, sizeof(const char*) * (globals.mOptions.mBatchRequestCount + 1));
expand = (const char**)realloc((void*)globals.mOptions.mBatchRequest, sizeof(const char*) * (globals.mOptions.mBatchRequestCount + 1));
if(NULL != expand)
{
/*
** Reassign in case of pointer move.
*/
globals.mOptions.mBatchRequests = expand;
globals.mOptions.mBatchRequest = expand;
/*
** Add new entry, increase the count.
*/
globals.mOptions.mBatchRequests[globals.mOptions.mBatchRequestCount] = &aArgArray[traverse][2];
globals.mOptions.mBatchRequest[globals.mOptions.mBatchRequestCount] = &aArgArray[traverse][2];
globals.mOptions.mBatchRequestCount++;
}
else
@ -523,7 +510,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -539,7 +526,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -557,7 +544,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -575,7 +562,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -585,7 +572,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -603,7 +590,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -621,7 +608,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -639,13 +626,13 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
}
break;
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
case 'g':
{
if(0 == strncmp(&aArgArray[traverse][2], "min", 3))
@ -659,7 +646,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -677,7 +664,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -687,11 +674,11 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
case 's':
{
@ -706,7 +693,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
else if(0 == strncmp(&aArgArray[traverse][2], "max", 3))
@ -720,13 +707,13 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -744,7 +731,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -762,7 +749,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
else
{
@ -772,7 +759,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -790,7 +777,7 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
else if(0 == strncmp(&aArgArray[traverse][2], "max", 3))
@ -804,13 +791,13 @@ int initOptions(int aArgCount, char** aArgArray)
if(1 != scanRes)
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -850,7 +837,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -867,7 +854,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -884,7 +871,7 @@ int initOptions(int aArgCount, char** aArgArray)
else
{
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
}
break;
@ -896,7 +883,7 @@ int initOptions(int aArgCount, char** aArgArray)
** Error and show help.
*/
retval = __LINE__;
globals.mOptions.mShowHelp = __LINE__;
globals.mOptions.mHelp = __LINE__;
}
break;
}
@ -927,7 +914,7 @@ int initOptions(int aArgCount, char** aArgArray)
return retval;
}
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** createGraph
**
@ -985,9 +972,9 @@ gdImagePtr createGraph(int* aTransparencyColor)
return retval;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** drawGraph
**
@ -1152,7 +1139,7 @@ void drawGraph(gdImagePtr aImage, int aColor, const char* aGraphTitle, const cha
}
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
#if defined(HAVE_BOUTELL_GD)
/*
@ -2682,7 +2669,7 @@ void htmlAnchor(STRequest* inRequest, const char* aHref, const char* aText, cons
for(loop = 0; loop < globals.mOptions.mBatchRequestCount; loop++)
{
comparison = strcmp(aHref, globals.mOptions.mBatchRequests[loop]);
comparison = strcmp(aHref, globals.mOptions.mBatchRequest[loop]);
if(0 == comparison)
{
break;
@ -4246,7 +4233,7 @@ int displayCallsiteDetails(STRequest* inRequest, tmcallsite* aCallsite)
return retval;
}
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** graphFootprint
**
@ -4438,9 +4425,9 @@ int graphFootprint(STRequest* inRequest, STRun* aRun)
return retval;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** graphTimeval
**
@ -4636,9 +4623,9 @@ int graphTimeval(STRequest* inRequest, STRun* aRun)
return retval;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** graphLifespan
**
@ -4837,9 +4824,9 @@ int graphLifespan(STRequest* inRequest, STRun* aRun)
return retval;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** graphWeight
**
@ -5051,7 +5038,7 @@ int graphWeight(STRequest* inRequest, STRun* aRun)
return retval;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
/*
** fillOptions
@ -5086,10 +5073,10 @@ void fillOptions(STOptions* outOptions, STOptionChange* outWhatChanged, const ch
getDataPRUint32(inFormData, "mAllocationTimevalMin", &outOptions->mAllocationTimevalMin, &outWhatChanged->mSet, ST_TIMEVAL_RESOLUTION);
getDataPRUint32(inFormData, "mAllocationTimevalMax", &outOptions->mAllocationTimevalMax, &outWhatChanged->mSet, ST_TIMEVAL_RESOLUTION);
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
getDataPRUint32(inFormData, "mGraphTimevalMin", &outOptions->mGraphTimevalMin, &outWhatChanged->mGraph, ST_TIMEVAL_RESOLUTION);
getDataPRUint32(inFormData, "mGraphTimevalMax", &outOptions->mGraphTimevalMax, &outWhatChanged->mGraph, ST_TIMEVAL_RESOLUTION);
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
getDataPRUint32(inFormData, "mSizeMin", &outOptions->mSizeMin, &outWhatChanged->mSet, 1);
getDataPRUint32(inFormData, "mSizeMax", &outOptions->mSizeMax, &outWhatChanged->mSet, 1);
@ -5170,7 +5157,7 @@ int applySettings(STRequest* inRequest)
}
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** If any of the set was changed, we need to throw away all our
** cached graphs.
@ -5190,7 +5177,7 @@ int applySettings(STRequest* inRequest)
globals.mCache.mLifespanCached = 0;
globals.mCache.mWeightCached = 0;
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
return retval;
}
@ -5261,7 +5248,7 @@ int displaySettings(STRequest* inRequest)
PR_fprintf(inRequest->mFD, "<input type=text name=\"mOrderBy\" value=\"%u\"><br>\n", globals.mOptions.mOrderBy);
PR_fprintf(inRequest->mFD, "<hr>\n");
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
PR_fprintf(inRequest->mFD, "Modify the seconds for which the graphs cover;<br>\n");
PR_fprintf(inRequest->mFD, "meaning that a narrower range will produce a more detailed graph for that timespan.<p>\n");
PR_fprintf(inRequest->mFD, "Minimum graph second?<br>\n");
@ -5269,7 +5256,7 @@ int displaySettings(STRequest* inRequest)
PR_fprintf(inRequest->mFD, "Maximum graph second?<br>\n");
PR_fprintf(inRequest->mFD, "<input type=text name=\"mGraphTimevalMax\" value=\"%u\"><br>\n", globals.mOptions.mGraphTimevalMax / ST_TIMEVAL_RESOLUTION);
PR_fprintf(inRequest->mFD, "<hr>\n");
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
PR_fprintf(inRequest->mFD, "Modify the secondss to target allocations created during a particular timespan;<br>\n");
PR_fprintf(inRequest->mFD, "meaning that the allocations created only within the timespan are of interest.<p>\n");
@ -5376,7 +5363,7 @@ int displayIndex(STRequest* inRequest)
PR_fprintf(inRequest->mFD, "\n<li>");
htmlAnchor(inRequest, "memory_leaks.html", "Memory Leak Report", NULL);
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
PR_fprintf(inRequest->mFD, "\n<li>Graphs");
PR_fprintf(inRequest->mFD, "<ul>");
@ -5394,7 +5381,7 @@ int displayIndex(STRequest* inRequest)
htmlAnchor(inRequest, "weight_graph.html", "Allocation Weights", NULL);
PR_fprintf(inRequest->mFD, "\n</ul>\n");
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
PR_fprintf(inRequest->mFD, "\n</ul>\n");
@ -5679,7 +5666,7 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
htmlFooter(&request);
}
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
else if(0 == strcmp("footprint_graph.html", aFileName))
{
int displayRes = 0;
@ -5692,8 +5679,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
htmlFooter(&request);
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("times_graph.html", aFileName))
{
int displayRes = 0;
@ -5706,8 +5693,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
htmlFooter(&request);
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("lifespan_graph.html", aFileName))
{
int displayRes = 0;
@ -5720,8 +5707,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
htmlFooter(&request);
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("weight_graph.html", aFileName))
{
int displayRes = 0;
@ -5734,8 +5721,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
htmlFooter(&request);
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("footprint.png", aFileName))
{
int graphRes = 0;
@ -5747,8 +5734,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
REPORT_ERROR(__LINE__, graphFootprint);
}
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("times.png", aFileName))
{
int graphRes = 0;
@ -5760,8 +5747,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
REPORT_ERROR(__LINE__, graphTimeval);
}
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("lifespan.png", aFileName))
{
int graphRes = 0;
@ -5773,8 +5760,8 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
REPORT_ERROR(__LINE__, graphLifespan);
}
}
#endif /* WANT_GRAPHS */
#if WANT_GRAPHS
#endif /* ST_WANT_GRAPHS */
#if ST_WANT_GRAPHS
else if(0 == strcmp("weight.png", aFileName))
{
int graphRes = 0;
@ -5786,7 +5773,7 @@ int handleRequest(tmreader* aTMR, PRFileDesc* aFD, const char* aFileName, const
REPORT_ERROR(__LINE__, graphWeight);
}
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
else if(0 == strcmp("categories_summary.html", aFileName))
{
int displayRes = 0;
@ -5930,7 +5917,7 @@ void handleClient(void* inArg)
** mime type, otherwise, say it is text/html.
*/
PR_fprintf(aFD, "HTTP/1.1 200 OK%s", crlf);
PR_fprintf(aFD, "Server: %s%s", "$Id: spacetrace.c,v 1.27 2002-05-04 02:06:52 blythe%netscape.com Exp $", crlf);
PR_fprintf(aFD, "Server: %s%s", "$Id: spacetrace.c,v 1.28 2002-05-07 23:39:33 blythe%netscape.com Exp $", crlf);
if(NULL != getData)
{
if(NULL == cookieData || (NULL != cookieData && 0 != strcmp(getData, cookieData)))
@ -6184,7 +6171,7 @@ int batchMode(void)
*/
for(loop = 0; loop < globals.mOptions.mBatchRequestCount; loop++)
{
sprintfRes = PR_snprintf(aFileName, sizeof(aFileName), "%s%c%s", globals.mOptions.mOutputDir, PR_GetDirectorySeparator(), globals.mOptions.mBatchRequests[loop]);
sprintfRes = PR_snprintf(aFileName, sizeof(aFileName), "%s%c%s", globals.mOptions.mOutputDir, PR_GetDirectorySeparator(), globals.mOptions.mBatchRequest[loop]);
if((PRUint32)-1 != sprintfRes)
{
PRFileDesc* outFile = NULL;
@ -6194,7 +6181,7 @@ int batchMode(void)
{
PRStatus closeRes = PR_SUCCESS;
handleRes = handleRequest(globals.mTMR, outFile, globals.mOptions.mBatchRequests[loop], NULL, NULL);
handleRes = handleRequest(globals.mTMR, outFile, globals.mOptions.mBatchRequest[loop], NULL, NULL);
if(0 != handleRes)
{
failureSum += __LINE__;
@ -6248,7 +6235,7 @@ int doRun(void)
/*
** Create the new trace-malloc reader.
*/
globals.mTMR = tmreader_new(globals.mOptions.mProgramName, NULL);
globals.mTMR = tmreader_new(globals.mProgramName, NULL);
if(NULL != globals.mTMR)
{
int tmResult = 0;
@ -6271,7 +6258,7 @@ int doRun(void)
if(0 == retval)
{
#if WANT_GRAPHS
#if ST_WANT_GRAPHS
/*
** May want to set the max graph timeval, now that we have it.
*/
@ -6279,7 +6266,7 @@ int doRun(void)
{
globals.mOptions.mGraphTimevalMax = (globals.mMaxTimeval - globals.mMinTimeval);
}
#endif /* WANT_GRAPHS */
#endif /* ST_WANT_GRAPHS */
/*
** Create the default sorted run.
@ -6369,6 +6356,11 @@ int main(int aArgCount, char** aArgArray)
*/
memset(&globals, 0, sizeof(globals));
/*
** Set the program name.
*/
globals.mProgramName = aArgArray[0];
/*
** Set the minimum timeval really high so other code
** that checks the timeval will get it right.

Просмотреть файл

@ -51,6 +51,16 @@
#include "nsTraceMalloc.h"
#include "tmreader.h"
/*
** Turn on to attempt adding support for graphs on your platform.
*/
#if defined(HAVE_BOUTELL_GD)
#define ST_WANT_GRAPHS 1
#endif /* HAVE_BOUTELL_GD */
#if !defined(ST_WANT_GRAPHS)
#define ST_WANT_GRAPHS 0
#endif
/*
** REPORT_ERROR
** REPORT_INFO
@ -60,7 +70,7 @@
#define REPORT_ERROR(code, function) \
PR_fprintf(PR_STDERR, "error(%d):\t%s\n", code, #function)
#define REPORT_INFO(msg) \
PR_fprintf(PR_STDOUT, "%s: %s\n", globals.mOptions.mProgramName, (msg))
PR_fprintf(PR_STDOUT, "%s: %s\n", globals.mProgramName, (msg))
/*
** CALLSITE_RUN
@ -111,7 +121,11 @@
#define ST_DEFAULT_LIFETIME_MIN 10
/*
** Allocations fall to this boundry size by default.
** Allocations fall to this boundry size by default.
** Overhead is taken after alignment.
**
** The msvcrt malloc has an alignment of 16 with an overhead of 8.
** The win32 HeapAlloc has an alignment of 8 with an overhead of 8.
*/
#define ST_DEFAULT_ALIGNMENT_SIZE 16
#define ST_DEFAULT_OVERHEAD_SIZE 8
@ -388,116 +402,24 @@ typedef struct __struct_STCategoryMapEntry {
/*
** STOptions
** STOptions
**
** Structure containing the various options for this code.
** Structure containing the varios options for the code.
** The definition of these options exists in a different file.
** We access that definition via macros to inline our structure definition.
*/
#define ST_CMD_OPTION_BOOL(option_name, option_help) PRBool m##option_name;
#define ST_CMD_OPTION_STRING(option_name, default_value, option_help) char m##option_name[ST_OPTION_STRING_MAX];
#define ST_CMD_OPTION_STRING_ARRAY(option_name, array_size, option_help) char m##option_name[array_size][ST_OPTION_STRING_MAX];
#define ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_help) const char** m##option_name; PRUint32 m##option_name##Count;
#define ST_CMD_OPTION_UINT32(option_name, default_value, multiplier, option_help) PRUint32 m##option_name;
#define ST_CMD_OPTION_UINT64(option_name, default_value, multiplier, option_help) PRUint64 m##option_name##64;
typedef struct __struct_STOptions
{
/*
** The string which identifies this program.
*/
char mProgramName[ST_OPTION_STRING_MAX];
/*
** File from which we retrieve the input.
** The input should have been generated from a trace malloc run.
*/
char mFileName[ST_OPTION_STRING_MAX];
/*
** Which directory we will take over and write our output.
*/
char mOutputDir[ST_OPTION_STRING_MAX];
/*
** The various batch mode requests we've received.
*/
const char** mBatchRequests;
PRUint32 mBatchRequestCount;
/*
** Httpd port, where we accept queries.
*/
PRUint32 mHttpdPort;
/*
** Wether or not we should show help.
*/
int mShowHelp;
/*
** Maximum number of items to put in a list.
*/
PRUint32 mListItemMax;
/*
** Sort order control.
*/
PRUint32 mOrderBy;
/*
** Memory alignment size.
** Overhead, taken after alignment.
**
** The msvcrt malloc has an alignment of 16 with an overhead of 8.
** The win32 HeapAlloc has an alignment of 8 with an overhead of 8.
*/
PRUint32 mAlignBy;
PRUint32 mOverhead;
/*
** Timeval control.
*/
PRUint32 mTimevalMin;
PRUint32 mTimevalMax;
/*
** Allocation timeval control.
*/
PRUint32 mAllocationTimevalMin;
PRUint32 mAllocationTimevalMax;
/*
** Size control.
*/
PRUint32 mSizeMin;
PRUint32 mSizeMax;
/*
** Lifetime timeval control.
*/
PRUint32 mLifetimeMin;
PRUint32 mLifetimeMax;
/*
** Weight control.
*/
PRUint64 mWeightMin64;
PRUint64 mWeightMax64;
/*
** Graph timeval control.
*/
PRUint32 mGraphTimevalMin;
PRUint32 mGraphTimevalMax;
/*
** Restrict callsite backtraces to those containing text.
*/
char mRestrictText[ST_SUBSTRING_MATCH_MAX][ST_OPTION_STRING_MAX];
/*
** File containing rules to categorize allocations
*/
char mCategoryFile[ST_OPTION_STRING_MAX];
/*
** Category to focus report on. '\0' if not focussing on a category.
*/
char mCategoryName[ST_OPTION_STRING_MAX];
} STOptions;
#include "stoptions.h"
}
STOptions;
/*
** STOptionChange
@ -593,6 +515,11 @@ typedef struct __struct_STCache
*/
typedef struct __struct_STGlobals
{
/*
** The string which identifies this program.
*/
const char* mProgramName;
/*
** Options derived from the command line.
*/

Просмотреть файл

@ -0,0 +1,307 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 stoptions.h code, released
* May 7, 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, 07-May-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.
*/
/*
** stoptions.h
**
** Abstract the spacetrace options into a reusable format, such that
** many different pieces of the code can utilize the common list.
*/
/*
** There are three types of options.
** The destinction is quite important.
**
** CMD options are accessible from only the comamnd line.
** Such options should be considered global/static for the entire
** run of the application.
** Once set, no one can change these options during the run.
**
** WEB options are accessible from the web server options page.
** Such options can and will be changed on a per user basis during
** the run of the application.
** You should NEVER make an option a WEB only option, as this will
** break batch mode processing, and will likely not correctly
** define the options structure itself.
** These options will control the data caching used in the application
** to match a client to a cache of data.
**
** ALL options are both CMD and WEB options, with the properties of WEB
** options (the user will change these on a per client basis).
** Most likely this is the type of option you will desire to create.
*/
/*
** All types of options have some combination of the following elements:
**
** option_name The name of the option.
** default_value The default value for the option.
** array_size Used to size a string array.
** multiplier Some numbers prefer conversion.
** option_help Help text to explain the option.
**
** The actual definition of the WEB and CMD macros however is left to the
** end user.
** We cover those that you do not define herein.
*/
#if !defined(ST_CMD_OPTION_BOOL)
#define ST_CMD_OPTION_BOOL(option_name, option_help)
#endif
#if !defined(ST_WEB_OPTION_BOOL)
#define ST_WEB_OPTION_BOOL(option_name, option_help)
#endif
#if !defined(ST_CMD_OPTION_STRING)
#define ST_CMD_OPTION_STRING(option_name, default_value, option_help)
#endif
#if !defined(ST_WEB_OPTION_STRING)
#define ST_WEB_OPTION_STRING(option_name, default_value, option_help)
#endif
#if !defined(ST_CMD_OPTION_STRING_ARRAY)
#define ST_CMD_OPTION_STRING_ARRAY(option_name, array_size, option_help)
#endif
#if !defined(ST_WEB_OPTION_STRING_ARRAY)
#define ST_WEB_OPTION_STRING_ARRAY(option_name, array_size, option_help)
#endif
#if !defined(ST_CMD_OPTION_STRING_PTR_ARRAY)
#define ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_help)
#endif
#if !defined(ST_WEB_OPTION_STRING_PTR_ARRAY)
#define ST_WEB_OPTION_STRING_PTR_ARRAY(option_name, option_help)
#endif
#if !defined(ST_CMD_OPTION_UINT32)
#define ST_CMD_OPTION_UINT32(option_name, default_value, multiplier, option_help)
#endif
#if !defined(ST_WEB_OPTION_UINT32)
#define ST_WEB_OPTION_UINT32(option_name, default_value, multiplier, option_help)
#endif
#if !defined(ST_CMD_OPTION_UINT64)
#define ST_CMD_OPTION_UINT64(option_name, default_value, multiplier, option_help)
#endif
#if !defined(ST_WEB_OPTION_UINT64)
#define ST_WEB_OPTION_UINT64(option_name, default_value, multiplier, option_help)
#endif
/*
** ALL macros expand to both CMD and WEB macros.
** This basically means such options are accessible from both the command
** line and from the web options.
*/
#define ST_ALL_OPTION_BOOL(option_name, option_help) \
ST_CMD_OPTION_BOOL(option_name, option_help) \
ST_WEB_OPTION_BOOL(option_name, option_help)
#define ST_ALL_OPTION_STRING(option_name, default_value, option_help) \
ST_CMD_OPTION_STRING(option_name, default_value, option_help) \
ST_WEB_OPTION_STRING(option_name, default_value, option_help)
#define ST_ALL_OPTION_STRING_ARRAY(option_name, array_size, option_help) \
ST_CMD_OPTION_STRING_ARRAY(option_name, array_size, option_help) \
ST_WEB_OPTION_STRING_ARRAY(option_name, array_size, option_help)
#define ST_ALL_OPTION_STRING_PTR_ARRAY(option_name, option_help) \
ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_help) \
ST_WEB_OPTION_STRING_PTR_ARRAY(option_name, option_help)
#define ST_ALL_OPTION_UINT32(option_name, default_value, multiplier, option_help) \
ST_CMD_OPTION_UINT32(option_name, default_value, multiplier, option_help) \
ST_WEB_OPTION_UINT32(option_name, default_value, multiplier, option_help)
#define ST_ALL_OPTION_UINT64(option_name, default_value, multiplier, option_help) \
ST_CMD_OPTION_UINT64(option_name, default_value, multiplier, option_help) \
ST_WEB_OPTION_UINT64(option_name, default_value, multiplier, option_help)
/****************************************************************************
** BEGIN, THE OPTIONS
**
** Order is somewhat relevant in that it will control 3 different things:
** 1) The order the members will be in the options structure.
** 2) The order the options are presented on the command line.
** 3) The order teh options are presented on the web options page.
*/
ST_ALL_OPTION_STRING(CategoryName,
ST_ROOT_CATEGORY_NAME,
"Specify a category to focus upon.\n"
"Generated reports will focus on allocations in this category.\n")
ST_ALL_OPTION_UINT32(OrderBy,
ST_SIZE, /* for dp :-D */
1,
"Determine the sort order.\n"
"0 by weight (size * lifespan).\n"
"1 by size.\n"
"2 by lifespan.\n"
"3 by allocation count.\n"
"4 by performance cost.\n")
ST_ALL_OPTION_STRING_ARRAY(RestrictText,
ST_SUBSTRING_MATCH_MAX,
"Exclude allocations which do not have this text in their backtrace.\n"
"Multiple restrictions are allowed as a logical AND operation.\n")
ST_ALL_OPTION_UINT32(SizeMin,
0,
1,
"Exclude allocations that are below this byte size.\n")
ST_ALL_OPTION_UINT32(SizeMax,
0xFFFFFFFF,
1,
"Exclude allocations that are above this byte size.\n")
ST_ALL_OPTION_UINT32(LifetimeMin,
ST_DEFAULT_LIFETIME_MIN,
ST_TIMEVAL_RESOLUTION,
"Allocations must live this number of seconds or be ignored.\n")
ST_ALL_OPTION_UINT32(LifetimeMax,
ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
ST_TIMEVAL_RESOLUTION,
"Allocations living longer than this number of seconds will be ignored.\n")
ST_ALL_OPTION_UINT32(TimevalMin,
0,
ST_TIMEVAL_RESOLUTION,
"Allocations existing solely before this second will be ignored.\n"
"Live allocations at this second and after can be considered.\n")
ST_ALL_OPTION_UINT32(TimevalMax,
ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
ST_TIMEVAL_RESOLUTION,
"Allocations existing solely after this second will be ignored.\n"
"Live allocations at this second and before can be considered.\n")
ST_ALL_OPTION_UINT32(AllocationTimevalMin,
0,
ST_TIMEVAL_RESOLUTION,
"Live and dead allocations created before this second will be ignored.\n")
ST_ALL_OPTION_UINT32(AllocationTimevalMax,
ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
ST_TIMEVAL_RESOLUTION,
"Live and dead allocations created after this second will be ignored.\n")
ST_ALL_OPTION_UINT32(AlignBy,
ST_DEFAULT_ALIGNMENT_SIZE,
1,
"All allocation sizes are made to be a multiple of this number.\n"
"Closer to actual heap conditions; set to 1 for true sizes.\n")
ST_ALL_OPTION_UINT32(Overhead,
ST_DEFAULT_OVERHEAD_SIZE,
1,
"After alignment, all allocations are made to increase by this number.\n"
"Closer to actual heap conditions; set to 0 for true sizes.\n")
ST_ALL_OPTION_UINT32(ListItemMax,
500,
1,
"Specifies the maximum number of list items to present in each list.\n")
ST_ALL_OPTION_UINT64(WeightMin,
LL_INIT(0, 0),
LL_INIT(0, 1),
"Exclude allocations that are below this weight (lifespan * size).\n")
ST_ALL_OPTION_UINT64(WeightMax,
LL_INIT(0xFFFFFFFF, 0xFFFFFFFF),
LL_INIT(0, 1),
"Exclude allocations that are above this weight (lifespan * size).\n")
#if ST_WANT_GRAPHS
ST_ALL_OPTION_UINT32(GraphTimevalMin,
0,
ST_TIMEVAL_RESOLUTION,
"Have all graphs exclude data prior to this second.\n")
ST_ALL_OPTION_UINT32(GraphTimevalMax,
ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
ST_TIMEVAL_RESOLUTION,
"Have all graphs exclude data beyond this second.\n")
#endif /* ST_WANT_GRAPHS */
ST_CMD_OPTION_STRING(FileName,
"-",
"Specifies trace-malloc input file.\n"
"\"-\" indicates stdin will be used as input.\n")
ST_CMD_OPTION_STRING(CategoryFile,
"rules.txt",
"Specifies the category rules file.\n"
"This file contains rules about how to categorize allocations.\n")
ST_CMD_OPTION_UINT32(HttpdPort,
1969,
1,
"Specifies the default port the web server will listen on.\n")
ST_CMD_OPTION_STRING(OutputDir,
".",
"Specifies a directory to output batch mode requests.\n"
"The directory must exist and must not use a trailing slash.\n")
ST_CMD_OPTION_STRING_PTR_ARRAY(BatchRequest,
"Execute in batch mode, multiple requests allowed.\n"
"Save each requested file into the output dir, then exit.\n")
ST_CMD_OPTION_BOOL(Help,
"Show command line help.\n")
/*
** END, THE OPTIONS
****************************************************************************/
/*
** Everything is undefined after the header is included.
** This sets it up for multiple inclusion if so desired.
*/
#undef ST_ALL_OPTION_BOOL
#undef ST_CMD_OPTION_BOOL
#undef ST_WEB_OPTION_BOOL
#undef ST_ALL_OPTION_STRING
#undef ST_CMD_OPTION_STRING
#undef ST_WEB_OPTION_STRING
#undef ST_ALL_OPTION_STRING_ARRAY
#undef ST_CMD_OPTION_STRING_ARRAY
#undef ST_WEB_OPTION_STRING_ARRAY
#undef ST_ALL_OPTION_STRING_PTR_ARRAY
#undef ST_CMD_OPTION_STRING_PTR_ARRAY
#undef ST_WEB_OPTION_STRING_PTR_ARRAY
#undef ST_ALL_OPTION_UINT32
#undef ST_CMD_OPTION_UINT32
#undef ST_WEB_OPTION_UINT32
#undef ST_ALL_OPTION_UINT64
#undef ST_CMD_OPTION_UINT64
#undef ST_WEB_OPTION_UINT64