1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/trace-malloc/spacetrace.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,694 @@ 1.4 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef spacetrace_h__ 1.11 +#define spacetrace_h__ 1.12 + 1.13 +/* 1.14 +** spacetrace.h 1.15 +** 1.16 +** SpaceTrace is meant to take the output of trace-malloc and present 1.17 +** a picture of allocations over the run of the application. 1.18 +*/ 1.19 + 1.20 +/* 1.21 +** Required includes. 1.22 +*/ 1.23 +#include <stdint.h> 1.24 +#include "nspr.h" 1.25 +#include "prlock.h" 1.26 +#include "prrwlock.h" 1.27 +#include "nsTraceMalloc.h" 1.28 +#include "tmreader.h" 1.29 +#include "formdata.h" 1.30 + 1.31 +/* 1.32 +** Turn on to attempt adding support for graphs on your platform. 1.33 +*/ 1.34 +#if defined(HAVE_BOUTELL_GD) 1.35 +#define ST_WANT_GRAPHS 1 1.36 +#endif /* HAVE_BOUTELL_GD */ 1.37 +#if !defined(ST_WANT_GRAPHS) 1.38 +#define ST_WANT_GRAPHS 0 1.39 +#endif 1.40 + 1.41 +/* 1.42 +** REPORT_ERROR 1.43 +** REPORT_INFO 1.44 +** 1.45 +** Just report errors and stuff in a consistent manner. 1.46 +*/ 1.47 +#define REPORT_ERROR(code, function) \ 1.48 + PR_fprintf(PR_STDERR, "error(%d):\t%s\n", code, #function) 1.49 +#define REPORT_ERROR_MSG(code, msg) \ 1.50 + PR_fprintf(PR_STDERR, "error(%d):\t%s\n", code, msg) 1.51 +#define REPORT_INFO(msg) \ 1.52 + PR_fprintf(PR_STDOUT, "%s: %s\n", globals.mProgramName, (msg)) 1.53 + 1.54 +#if defined(DEBUG_blythe) && 1 1.55 +#define REPORT_blythe(code, msg) \ 1.56 + PR_fprintf(PR_STDOUT, "gab(%d):\t%s\n", code, msg) 1.57 +#else 1.58 +#define REPORT_blythe(code, msg) 1.59 +#endif /* DEBUG_blythe */ 1.60 + 1.61 +/* 1.62 +** CALLSITE_RUN 1.63 +** 1.64 +** How to get a callsite run. 1.65 +** Allows for further indirection if needed later. 1.66 +*/ 1.67 +#define CALLSITE_RUN(callsite) \ 1.68 + ((STRun*)((callsite)->data)) 1.69 + 1.70 +/* 1.71 +** ST_PERMS 1.72 +** ST_FLAGS 1.73 +** 1.74 +** File permissions we desire. 1.75 +** 0644 1.76 +*/ 1.77 +#define ST_PERMS (PR_IRUSR | PR_IWUSR | PR_IRGRP | PR_IROTH) 1.78 +#define ST_FLAGS (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) 1.79 + 1.80 +/* 1.81 +** Sorting order 1.82 +*/ 1.83 +#define ST_WEIGHT 0 /* size * timeval */ 1.84 +#define ST_SIZE 1 1.85 +#define ST_TIMEVAL 2 1.86 +#define ST_COUNT 3 1.87 +#define ST_HEAPCOST 4 1.88 + 1.89 +/* 1.90 +** Callsite loop direction flags. 1.91 +*/ 1.92 +#define ST_FOLLOW_SIBLINGS 0 1.93 +#define ST_FOLLOW_PARENTS 1 1.94 + 1.95 +/* 1.96 +** Graph data. 1.97 +*/ 1.98 +#define STGD_WIDTH 640 1.99 +#define STGD_HEIGHT 480 1.100 +#define STGD_MARGIN 75 1.101 +#define STGD_SPACE_X (STGD_WIDTH - (2 * STGD_MARGIN)) 1.102 +#define STGD_SPACE_Y (STGD_HEIGHT - (2 * STGD_MARGIN)) 1.103 + 1.104 +/* 1.105 +** Minimum lifetime default, in seconds. 1.106 +*/ 1.107 +#define ST_DEFAULT_LIFETIME_MIN 10 1.108 + 1.109 +/* 1.110 +** Allocations fall to this boundry size by default. 1.111 +** Overhead is taken after alignment. 1.112 +** 1.113 +** The msvcrt malloc has an alignment of 16 with an overhead of 8. 1.114 +** The win32 HeapAlloc has an alignment of 8 with an overhead of 8. 1.115 +*/ 1.116 +#define ST_DEFAULT_ALIGNMENT_SIZE 16 1.117 +#define ST_DEFAULT_OVERHEAD_SIZE 8 1.118 + 1.119 +/* 1.120 +** Numer of substring match specifications to allow. 1.121 +*/ 1.122 +#define ST_SUBSTRING_MATCH_MAX 5 1.123 + 1.124 +/* 1.125 +** Max Number of patterns per rule 1.126 +*/ 1.127 +#define ST_MAX_PATTERNS_PER_RULE 16 1.128 + 1.129 +/* 1.130 +** Rule pointers and child pointers are allocated in steps of ST_ALLOC_STEP 1.131 +*/ 1.132 +#define ST_ALLOC_STEP 16 1.133 + 1.134 +/* 1.135 +** Name of the root category. Appears in UI. 1.136 +*/ 1.137 +#define ST_ROOT_CATEGORY_NAME "All" 1.138 + 1.139 +/* 1.140 +** Size of our option string buffers. 1.141 +*/ 1.142 +#define ST_OPTION_STRING_MAX 256 1.143 + 1.144 +/* 1.145 +** Set the desired resolution of the timevals. 1.146 +** The resolution is just mimicking what is recorded in the trace-malloc 1.147 +** output, and that is currently milliseconds. 1.148 +*/ 1.149 +#define ST_TIMEVAL_RESOLUTION 1000 1.150 +#define ST_TIMEVAL_FORMAT "%.3f" 1.151 +#define ST_TIMEVAL_PRINTABLE(timeval) ((double)(timeval) / (double)ST_TIMEVAL_RESOLUTION) 1.152 +#define ST_TIMEVAL_PRINTABLE64(timeval) ((double)((int64_t)(timeval)) / (double)ST_TIMEVAL_RESOLUTION) 1.153 +#define ST_TIMEVAL_MAX ((uint32_t)-1 - ((uint32_t)-1 % ST_TIMEVAL_RESOLUTION)) 1.154 + 1.155 +#define ST_MICROVAL_RESOLUTION 1000000 1.156 +#define ST_MICROVAL_FORMAT "%.6f" 1.157 +#define ST_MICROVAL_PRINTABLE(timeval) ((double)(timeval) / (double)ST_MICROVAL_RESOLUTION) 1.158 +#define ST_MICROVAL_PRINTABLE64(timeval) ((double)((int64_t)(timeval)) / (double)ST_MICROVAL_RESOLUTION) 1.159 +#define ST_MICROVAL_MAX ((uint32_t)-1 - ((uint32_t)-1 % ST_MICROVAL_RESOLUTION)) 1.160 + 1.161 +/* 1.162 +** Forward Declaration 1.163 +*/ 1.164 +typedef struct __struct_STCategoryNode STCategoryNode; 1.165 +typedef struct __struct_STCategoryRule STCategoryRule; 1.166 + 1.167 + 1.168 +/* 1.169 +** STAllocEvent 1.170 +** 1.171 +** An event that happens to an allocation (malloc, free, et. al.) 1.172 +*/ 1.173 +typedef struct __struct_STAllocEvent 1.174 +{ 1.175 + /* 1.176 + ** The type of allocation event. 1.177 + ** This maps directly to the trace malloc events (i.e. TM_EVENT_MALLOC) 1.178 + */ 1.179 + char mEventType; 1.180 + 1.181 + /* 1.182 + ** Each event, foremost, has a chronologically increasing ID in 1.183 + ** relation to other allocation events. This is a time stamp 1.184 + ** of sorts. 1.185 + */ 1.186 + uint32_t mTimeval; 1.187 + 1.188 + /* 1.189 + ** Every event has a heap ID (pointer). 1.190 + ** In the event of a realloc, this is the new heap ID. 1.191 + ** In the event of a free, this is the previous heap ID value. 1.192 + */ 1.193 + uint32_t mHeapID; 1.194 + 1.195 + /* 1.196 + ** Every event, along with the heap ID, tells of the size. 1.197 + ** In the event of a realloc, this is the new size. 1.198 + ** In th event of a free, this is the previous size. 1.199 + */ 1.200 + uint32_t mHeapSize; 1.201 + 1.202 + /* 1.203 + ** Every event has a callsite/stack backtrace. 1.204 + ** In the event of a realloc, this is the new callsite. 1.205 + ** In the event of a free, this is the previous call site. 1.206 + */ 1.207 + tmcallsite* mCallsite; 1.208 +} STAllocEvent; 1.209 + 1.210 +/* 1.211 +** STAllocation 1.212 +** 1.213 +** An allocation is a temporal entity in the heap. 1.214 +** It possibly lives under different heap IDs (pointers) and different 1.215 +** sizes during its given time. 1.216 +** An allocation is defined by the events during its lifetime. 1.217 +** An allocation's lifetime is defined by the range of event IDs it holds. 1.218 +*/ 1.219 +typedef struct __struct_STAllocation 1.220 +{ 1.221 + /* 1.222 + ** The array of events. 1.223 + */ 1.224 + uint32_t mEventCount; 1.225 + STAllocEvent* mEvents; 1.226 + 1.227 + /* 1.228 + ** The lifetime/lifespan of the allocation. 1.229 + */ 1.230 + uint32_t mMinTimeval; 1.231 + uint32_t mMaxTimeval; 1.232 + 1.233 + /* 1.234 + ** Index of this allocation in the global run. 1.235 + */ 1.236 + uint32_t mRunIndex; 1.237 + 1.238 + /* 1.239 + ** The runtime cost of heap events in this allocation. 1.240 + ** The cost is defined as the number of time units recorded as being 1.241 + ** spent in heap code (time of malloc, free, et al.). 1.242 + ** We do not track individual event cost in order to save space. 1.243 + */ 1.244 + uint32_t mHeapRuntimeCost; 1.245 +} STAllocation; 1.246 + 1.247 +/* 1.248 +** STCallsiteStats 1.249 +** 1.250 +** Stats regarding a run, kept mainly for callsite runs. 1.251 +*/ 1.252 +typedef struct __struct_STCallsiteStats 1.253 +{ 1.254 + /* 1.255 + ** Sum timeval of the allocations. 1.256 + ** Callsite runs total all allocations below the callsite. 1.257 + */ 1.258 + uint64_t mTimeval64; 1.259 + 1.260 + /* 1.261 + ** Sum weight of the allocations. 1.262 + ** Callsite runs total all allocations below the callsite. 1.263 + */ 1.264 + uint64_t mWeight64; 1.265 + 1.266 + /* 1.267 + ** Sum size of the allocations. 1.268 + ** Callsite runs total all allocations below the callsite. 1.269 + */ 1.270 + uint32_t mSize; 1.271 + 1.272 + /* 1.273 + ** A stamp, indicated the relevance of the run. 1.274 + ** If the stamp does not match the origin value, the 1.275 + ** data contained here-in is considered invalid. 1.276 + */ 1.277 + uint32_t mStamp; 1.278 + 1.279 + /* 1.280 + ** A sum total of allocations (note, not sizes) below the callsite. 1.281 + ** This is NOT the same as STRun::mAllocationCount which 1.282 + ** tracks the STRun::mAllocations array size. 1.283 + */ 1.284 + uint32_t mCompositeCount; 1.285 + 1.286 + /* 1.287 + ** A sum total runtime cost of heap operations below the calliste. 1.288 + ** The cost is defined as the number of time units recorded as being 1.289 + ** spent in heap code (time of malloc, free, et al.). 1.290 + */ 1.291 + uint32_t mHeapRuntimeCost; 1.292 +} STCallsiteStats; 1.293 + 1.294 +/* 1.295 +** STRun 1.296 +** 1.297 +** A run is a closed set of allocations. 1.298 +** Given a run, we can deduce information about the contained allocations. 1.299 +** We can also determine if an allocation lives beyond a run (leak). 1.300 +** 1.301 +** A run might be used to represent allocations for an entire application. 1.302 +** A run might also be used to represent allocations from a single callstack. 1.303 +*/ 1.304 +typedef struct __struct_STRun 1.305 +{ 1.306 + /* 1.307 + ** The array of allocations. 1.308 + */ 1.309 + uint32_t mAllocationCount; 1.310 + STAllocation** mAllocations; 1.311 + 1.312 + /* 1.313 + ** Callsites like to keep some information. 1.314 + ** As callsites are possibly shared between all contexts, each 1.315 + ** different context needs to keep different stats. 1.316 + */ 1.317 + STCallsiteStats *mStats; 1.318 + 1.319 +} STRun; 1.320 + 1.321 +/* 1.322 +** Categorize allocations 1.323 +** 1.324 +** The objective is to have a tree of categories with each leaf node of the tree 1.325 +** matching a set of callsites that belong to the category. Each category can 1.326 +** signify a functional area like say css and hence the user can browse this 1.327 +** tree looking for how much of each of these are live at an instant. 1.328 +*/ 1.329 + 1.330 +/* 1.331 +** STCategoryNode 1.332 +*/ 1.333 + 1.334 +struct __struct_STCategoryNode 1.335 +{ 1.336 + /* 1.337 + ** Category name 1.338 + */ 1.339 + const char *categoryName; 1.340 + 1.341 + /* 1.342 + ** Pointer to parent node. NULL for Root. 1.343 + */ 1.344 + STCategoryNode *parent; 1.345 + 1.346 + /* 1.347 + ** For non-leaf nodes, an array of children node pointers. 1.348 + ** NULL if leaf node. 1.349 + */ 1.350 + STCategoryNode** children; 1.351 + uint32_t nchildren; 1.352 + 1.353 + /* 1.354 + ** The Run(s). Valid for both leaf and parent nodes. 1.355 + ** One run per --Context to handle multiple data sets. 1.356 + ** The relevant index for the particular request will be 1.357 + ** mIndex stored by the mContext of the request. 1.358 + */ 1.359 + STRun **runs; 1.360 +}; 1.361 + 1.362 + 1.363 +struct __struct_STCategoryRule 1.364 +{ 1.365 + /* 1.366 + ** The pattern for the rule. Patterns are an array of strings. 1.367 + ** A callsite needs to pass substring match for all the strings. 1.368 + */ 1.369 + char* pats[ST_MAX_PATTERNS_PER_RULE]; 1.370 + uint32_t patlen[ST_MAX_PATTERNS_PER_RULE]; 1.371 + uint32_t npats; 1.372 + 1.373 + /* 1.374 + ** Category name that this rule belongs to 1.375 + */ 1.376 + const char* categoryName; 1.377 + 1.378 + /* 1.379 + ** The node this should be categorized into 1.380 + */ 1.381 + STCategoryNode* node; 1.382 +}; 1.383 + 1.384 + 1.385 +/* 1.386 +** CategoryName to Node mapping table 1.387 +*/ 1.388 +typedef struct __struct_STCategoryMapEntry { 1.389 + STCategoryNode* node; 1.390 + const char * categoryName; 1.391 +} STCategoryMapEntry; 1.392 + 1.393 +/* 1.394 +** Option genres. 1.395 +** 1.396 +** This helps to determine what functionality each option effects. 1.397 +** In specific, this will help use determine when and when not to 1.398 +** totally recaclulate the sorted run and categories. 1.399 +** Be very aware that adding things to a particular genre, or adding a genre, 1.400 +** may completely screw up the caching algorithms of SpaceTrace. 1.401 +** See contextLookup() or ask someone that knows if you are in doubt. 1.402 +*/ 1.403 +typedef enum __enum_STOptionGenre 1.404 +{ 1.405 + CategoryGenre = 0, 1.406 + DataSortGenre, 1.407 + DataSetGenre, 1.408 + DataSizeGenre, 1.409 + UIGenre, 1.410 + ServerGenre, 1.411 + BatchModeGenre, 1.412 + 1.413 + /* 1.414 + ** Last one please. 1.415 + */ 1.416 + MaxGenres 1.417 +} 1.418 +STOptionGenre; 1.419 + 1.420 +/* 1.421 +** STOptions 1.422 +** 1.423 +** Structure containing the varios options for the code. 1.424 +** The definition of these options exists in a different file. 1.425 +** We access that definition via macros to inline our structure definition. 1.426 +*/ 1.427 +#define ST_CMD_OPTION_BOOL(option_name, option_genre, option_help) PRBool m##option_name; 1.428 +#define ST_CMD_OPTION_STRING(option_name, option_genre, default_value, option_help) char m##option_name[ST_OPTION_STRING_MAX]; 1.429 +#define ST_CMD_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help) char m##option_name[array_size][ST_OPTION_STRING_MAX]; 1.430 +#define ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help) const char** m##option_name; uint32_t m##option_name##Count; 1.431 +#define ST_CMD_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help) uint32_t m##option_name; 1.432 +#define ST_CMD_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help) uint64_t m##option_name##64; 1.433 + 1.434 +typedef struct __struct_STOptions 1.435 +{ 1.436 +#include "stoptions.h" 1.437 +} 1.438 +STOptions; 1.439 + 1.440 +typedef struct __struct_STContext 1.441 +/* 1.442 +** A per request, thread safe, manner of accessing the contained members. 1.443 +** A reader/writer lock ensures that the data is properly initialized before 1.444 +** readers of the data begin their work. 1.445 +** 1.446 +** mRWLock reader/writer lock. 1.447 +** writer lock is held to ensure initialization, though 1.448 +** others can be attempting to acquire read locks 1.449 +** at that time. 1.450 +** writer lock is also used in destruction to make sure 1.451 +** there are no more readers of data contained herein. 1.452 +** reader lock is to allow multiple clients to read the 1.453 +** data at the same time; implies is they must not 1.454 +** write anything. 1.455 +** mIndex Consider this much like thread private data or thread 1.456 +** local storage in a few places. 1.457 +** The index is specifically reserved for this context's 1.458 +** usage in other data structure array's provided 1.459 +** for the particular thread/client/context. 1.460 +** This should not be modified after initialization. 1.461 +** mSortedRun A pre sorted run taken from the global run, with our 1.462 +** options applied. 1.463 +** mImageLock An overly simplistic locking mechanism to protect the 1.464 +** shared image cache. 1.465 +** The proper implementation would have a reader/writer 1.466 +** lock per cached image data. 1.467 +** However, this will prove to be simpler for the time 1.468 +** being. 1.469 +** mFootprintCached Whether or not YData contains something useful. 1.470 +** mTimevalCached Whether or not YData contains something useful. 1.471 +** mLifespanCached Whether or not YData contains something useful. 1.472 +** mWeightCached Whether or not YData contains something useful. 1.473 +** mFootprintYData Precomputed cached graph data. 1.474 +** mTimevalYData Precomputed cached graph data. 1.475 +** mLifespanYData Precomputed cached graph data. 1.476 +** mWeightYData Precomputed cached graph data. 1.477 +*/ 1.478 +{ 1.479 + PRRWLock* mRWLock; 1.480 + uint32_t mIndex; 1.481 + STRun* mSortedRun; 1.482 +#if ST_WANT_GRAPHS 1.483 + PRLock* mImageLock; 1.484 + PRBool mFootprintCached; 1.485 + PRBool mTimevalCached; 1.486 + PRBool mLifespanCached; 1.487 + PRBool mWeightCached; 1.488 + uint32_t mFootprintYData[STGD_SPACE_X]; 1.489 + uint32_t mTimevalYData[STGD_SPACE_X]; 1.490 + uint32_t mLifespanYData[STGD_SPACE_X]; 1.491 + uint64_t mWeightYData64[STGD_SPACE_X]; 1.492 +#endif 1.493 +} 1.494 +STContext; 1.495 + 1.496 + 1.497 +typedef struct __struct_STContextCacheItem 1.498 +/* 1.499 +** This basically pools the common items that the context cache will 1.500 +** want to track on a per context basis. 1.501 +** 1.502 +** mOptions What options this item represents. 1.503 +** mContext State/data this cache item is wrapping. 1.504 +** mReferenceCount A count of clients currently using this item. 1.505 +** Should this item be 0, then the cache might 1.506 +** decide to evict this context. 1.507 +** Should this item not be 0, once it reaches 1.508 +** zero a condition variable in the context cache 1.509 +** will be signaled to notify the availability. 1.510 +** mLastAccessed A timestamp of when this item was last accessed/released. 1.511 +** Ignore this unless the reference count is 0, 1.512 +** This is used to evict the oldest unused item from 1.513 +** the context cache. 1.514 +** mInUse Mainly PR_FALSE only at the beginning of the process, 1.515 +** but this indicates that the item has not yet been 1.516 +** used at all, and thus shouldn't be evaluated for 1.517 +** a cache hit. 1.518 +*/ 1.519 +{ 1.520 + STOptions mOptions; 1.521 + STContext mContext; 1.522 + int32_t mReferenceCount; 1.523 + PRIntervalTime mLastAccessed; 1.524 + PRBool mInUse; 1.525 +} 1.526 +STContextCacheItem; 1.527 + 1.528 + 1.529 +typedef struct __struct_STContextCache 1.530 +/* 1.531 +** A thread safe, possibly blocking, cache of context items. 1.532 +** 1.533 +** mLock Must hold the lock to read/access/write to this struct, as 1.534 +** well as any items it holds. 1.535 +** mCacheMiss All items are busy and there were no cache matches. 1.536 +** This condition variable is used to wait until an item becomes 1.537 +** "available" to be evicted from the cache. 1.538 +** mItems Array of items. 1.539 +** mItemCount Number of items in array. 1.540 +** This is generally the same as the global option's command line 1.541 +** mContexts.... 1.542 +*/ 1.543 +{ 1.544 + PRLock* mLock; 1.545 + PRCondVar* mCacheMiss; 1.546 + STContextCacheItem* mItems; 1.547 + uint32_t mItemCount; 1.548 +} 1.549 +STContextCache; 1.550 + 1.551 + 1.552 +/* 1.553 +** STRequest 1.554 +** 1.555 +** Things specific to a request. 1.556 +*/ 1.557 +typedef struct __struct_STRequest 1.558 +{ 1.559 + /* 1.560 + ** Sink/where to output. 1.561 + */ 1.562 + PRFileDesc* mFD; 1.563 + 1.564 + /* 1.565 + ** The filename requested. 1.566 + */ 1.567 + const char* mGetFileName; 1.568 + 1.569 + /* 1.570 + ** The GET form data, if any. 1.571 + */ 1.572 + const FormData* mGetData; 1.573 + 1.574 + /* 1.575 + ** Options specific to this request. 1.576 + */ 1.577 + STOptions mOptions; 1.578 + 1.579 + /* 1.580 + ** The context/data/state of the request. 1.581 + */ 1.582 + STContext* mContext; 1.583 +} STRequest; 1.584 + 1.585 + 1.586 +/* 1.587 +** STGlobals 1.588 +** 1.589 +** Various globals we keep around. 1.590 +*/ 1.591 +typedef struct __struct_STGlobals 1.592 +{ 1.593 + /* 1.594 + ** The string which identifies this program. 1.595 + */ 1.596 + const char* mProgramName; 1.597 + 1.598 + /* 1.599 + ** Options derived from the command line. 1.600 + ** These are used as defaults, and should remain static during 1.601 + ** the run of the application. 1.602 + */ 1.603 + STOptions mCommandLineOptions; 1.604 + 1.605 + /* 1.606 + ** Context cache. 1.607 + ** As clients come in, based on their options, a different context 1.608 + ** will be used to service them. 1.609 + */ 1.610 + STContextCache mContextCache; 1.611 + 1.612 + /* 1.613 + ** Various counters for different types of events. 1.614 + */ 1.615 + uint32_t mMallocCount; 1.616 + uint32_t mCallocCount; 1.617 + uint32_t mReallocCount; 1.618 + uint32_t mFreeCount; 1.619 + 1.620 + /* 1.621 + ** Total events, operation counter. 1.622 + */ 1.623 + uint32_t mOperationCount; 1.624 + 1.625 + /* 1.626 + ** The "run" of the input. 1.627 + */ 1.628 + STRun mRun; 1.629 + 1.630 + /* 1.631 + ** Operation minimum/maximum timevals. 1.632 + ** So that we can determine the overall timeval of the run. 1.633 + ** NOTE: These are NOT the options to control the data set. 1.634 + */ 1.635 + uint32_t mMinTimeval; 1.636 + uint32_t mMaxTimeval; 1.637 + 1.638 + /* 1.639 + ** Calculates peak allocation overall for all allocations. 1.640 + */ 1.641 + uint32_t mPeakMemoryUsed; 1.642 + uint32_t mMemoryUsed; 1.643 + 1.644 + /* 1.645 + ** A list of rules for categorization read in from the mCategoryFile 1.646 + */ 1.647 + STCategoryRule** mCategoryRules; 1.648 + uint32_t mNRules; 1.649 + 1.650 + /* 1.651 + ** CategoryName to Node mapping table 1.652 + */ 1.653 + STCategoryMapEntry** mCategoryMap; 1.654 + uint32_t mNCategoryMap; 1.655 + 1.656 + /* 1.657 + ** Categorized allocations. For now we support only one tree. 1.658 + */ 1.659 + STCategoryNode mCategoryRoot; 1.660 + 1.661 + /* 1.662 + ** tmreader hash tables. 1.663 + ** Moved into globals since we need to destroy these only after all 1.664 + ** client threads are finishes (after PR_Cleanup). 1.665 + */ 1.666 + tmreader* mTMR; 1.667 +} STGlobals; 1.668 + 1.669 + 1.670 +/* 1.671 +** Function prototypes 1.672 +*/ 1.673 +extern STRun* createRun(STContext* inContext, uint32_t aStamp); 1.674 +extern void freeRun(STRun* aRun); 1.675 +extern int initCategories(STGlobals* g); 1.676 +extern int categorizeRun(STOptions* inOptions, STContext* inContext, const STRun* aRun, STGlobals* g); 1.677 +extern STCategoryNode* findCategoryNode(const char *catName, STGlobals *g); 1.678 +extern int freeCategories(STGlobals* g); 1.679 +extern int displayCategoryReport(STRequest* inRequest, STCategoryNode *root, int depth); 1.680 + 1.681 +extern int recalculateAllocationCost(STOptions* inOptions, STContext* inContext, STRun* aRun, STAllocation* aAllocation, PRBool updateParent); 1.682 +extern void htmlHeader(STRequest* inRequest, const char* aTitle); 1.683 +extern void htmlFooter(STRequest* inRequest); 1.684 +extern void htmlAnchor(STRequest* inRequest, 1.685 + const char* aHref, 1.686 + const char* aText, 1.687 + const char* aTarget, 1.688 + const char* aClass, 1.689 + STOptions* inOptions); 1.690 +extern char *FormatNumber(int32_t num); 1.691 + 1.692 +/* 1.693 +** shared globals 1.694 +*/ 1.695 +extern STGlobals globals; 1.696 + 1.697 +#endif /* spacetrace_h__ */