tools/trace-malloc/stoptions.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /*
michael@0 8 ** stoptions.h
michael@0 9 **
michael@0 10 ** Abstract the spacetrace options into a reusable format, such that
michael@0 11 ** many different pieces of the code can utilize the common list.
michael@0 12 */
michael@0 13
michael@0 14 /*
michael@0 15 ** There are three types of options.
michael@0 16 ** The destinction is quite important.
michael@0 17 **
michael@0 18 ** CMD options are accessible from only the comamnd line.
michael@0 19 ** Such options should be considered global/static for the entire
michael@0 20 ** run of the application.
michael@0 21 ** Once set, no one can change these options during the run.
michael@0 22 **
michael@0 23 ** WEB options are accessible from the web server options page.
michael@0 24 ** Such options can and will be changed on a per user basis during
michael@0 25 ** the run of the application.
michael@0 26 ** You should NEVER make an option a WEB only option, as this will
michael@0 27 ** break batch mode processing, and will likely not correctly
michael@0 28 ** define the options structure itself.
michael@0 29 ** These options will control the data caching used in the application
michael@0 30 ** to match a client to a cache of data.
michael@0 31 **
michael@0 32 ** ALL options are both CMD and WEB options, with the properties of WEB
michael@0 33 ** options (the user will change these on a per client basis).
michael@0 34 ** Most likely this is the type of option you will desire to create.
michael@0 35 */
michael@0 36
michael@0 37 /*
michael@0 38 ** All types of options have some combination of the following elements:
michael@0 39 **
michael@0 40 ** option_name The name of the option.
michael@0 41 ** option_genre Area the option effects; STOptionGenre.
michael@0 42 ** default_value The default value for the option.
michael@0 43 ** array_size Used to size a string array.
michael@0 44 ** multiplier Some numbers prefer conversion.
michael@0 45 ** option_help Help text to explain the option.
michael@0 46 **
michael@0 47 ** NOTE! that the multiplier should be applied to the default value if you
michael@0 48 ** are going to assign the default_value into anything.
michael@0 49 **
michael@0 50 ** Be very aware that adding things to a particular genre, or adding a genre,
michael@0 51 ** may completely screw up the caching algorithms of SpaceTrace.
michael@0 52 ** See contextLookup() or ask someone that knows if you are in doubt.
michael@0 53 **
michael@0 54 ** The actual definition of the WEB and CMD macros however is left to the
michael@0 55 ** end user.
michael@0 56 ** We cover those that you do not define herein.
michael@0 57 */
michael@0 58 #if !defined(ST_CMD_OPTION_BOOL)
michael@0 59 #define ST_CMD_OPTION_BOOL(option_name, option_genre, option_help)
michael@0 60 #endif
michael@0 61 #if !defined(ST_WEB_OPTION_BOOL)
michael@0 62 #define ST_WEB_OPTION_BOOL(option_name, option_genre, option_help)
michael@0 63 #endif
michael@0 64 #if !defined(ST_CMD_OPTION_STRING)
michael@0 65 #define ST_CMD_OPTION_STRING(option_name, option_genre, default_value, option_help)
michael@0 66 #endif
michael@0 67 #if !defined(ST_WEB_OPTION_STRING)
michael@0 68 #define ST_WEB_OPTION_STRING(option_name, option_genre, default_value, option_help)
michael@0 69 #endif
michael@0 70 #if !defined(ST_CMD_OPTION_STRING_ARRAY)
michael@0 71 #define ST_CMD_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help)
michael@0 72 #endif
michael@0 73 #if !defined(ST_WEB_OPTION_STRING_ARRAY)
michael@0 74 #define ST_WEB_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help)
michael@0 75 #endif
michael@0 76 #if !defined(ST_CMD_OPTION_STRING_PTR_ARRAY)
michael@0 77 #define ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help)
michael@0 78 #endif
michael@0 79 #if !defined(ST_WEB_OPTION_STRING_PTR_ARRAY)
michael@0 80 #define ST_WEB_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help)
michael@0 81 #endif
michael@0 82 #if !defined(ST_CMD_OPTION_UINT32)
michael@0 83 #define ST_CMD_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help)
michael@0 84 #endif
michael@0 85 #if !defined(ST_WEB_OPTION_UINT32)
michael@0 86 #define ST_WEB_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help)
michael@0 87 #endif
michael@0 88 #if !defined(ST_CMD_OPTION_UINT64)
michael@0 89 #define ST_CMD_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help)
michael@0 90 #endif
michael@0 91 #if !defined(ST_WEB_OPTION_UINT64)
michael@0 92 #define ST_WEB_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help)
michael@0 93 #endif
michael@0 94
michael@0 95 /*
michael@0 96 ** ALL macros expand to both CMD and WEB macros.
michael@0 97 ** This basically means such options are accessible from both the command
michael@0 98 ** line and from the web options.
michael@0 99 */
michael@0 100 #define ST_ALL_OPTION_BOOL(option_name, option_genre, option_help) \
michael@0 101 ST_CMD_OPTION_BOOL(option_name, option_genre, option_help) \
michael@0 102 ST_WEB_OPTION_BOOL(option_name, option_genre, option_help)
michael@0 103 #define ST_ALL_OPTION_STRING(option_name, option_genre, default_value, option_help) \
michael@0 104 ST_CMD_OPTION_STRING(option_name, option_genre, default_value, option_help) \
michael@0 105 ST_WEB_OPTION_STRING(option_name, option_genre, default_value, option_help)
michael@0 106 #define ST_ALL_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help) \
michael@0 107 ST_CMD_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help) \
michael@0 108 ST_WEB_OPTION_STRING_ARRAY(option_name, option_genre, array_size, option_help)
michael@0 109 #define ST_ALL_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help) \
michael@0 110 ST_CMD_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help) \
michael@0 111 ST_WEB_OPTION_STRING_PTR_ARRAY(option_name, option_genre, option_help)
michael@0 112 #define ST_ALL_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help) \
michael@0 113 ST_CMD_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help) \
michael@0 114 ST_WEB_OPTION_UINT32(option_name, option_genre, default_value, multiplier, option_help)
michael@0 115 #define ST_ALL_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help) \
michael@0 116 ST_CMD_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help) \
michael@0 117 ST_WEB_OPTION_UINT64(option_name, option_genre, default_value, multiplier, option_help)
michael@0 118
michael@0 119
michael@0 120
michael@0 121 /****************************************************************************
michael@0 122 ** BEGIN, THE OPTIONS
michael@0 123 **
michael@0 124 ** Order is somewhat relevant in that it will control 3 different things:
michael@0 125 ** 1) The order the members will be in the options structure.
michael@0 126 ** 2) The order the options are presented on the command line.
michael@0 127 ** 3) The order the options are presented on the web options page.
michael@0 128 */
michael@0 129
michael@0 130 ST_ALL_OPTION_STRING(CategoryName,
michael@0 131 CategoryGenre,
michael@0 132 ST_ROOT_CATEGORY_NAME,
michael@0 133 "Specify a category for reports to focus upon.\n"
michael@0 134 "See http://lxr.mozilla.org/mozilla/source/tools/trace-malloc/rules.txt\n")
michael@0 135
michael@0 136 ST_ALL_OPTION_UINT32(OrderBy,
michael@0 137 DataSortGenre,
michael@0 138 ST_SIZE, /* for dp :-D */
michael@0 139 1,
michael@0 140 "Determine the sort order.\n"
michael@0 141 "0 by weight (size * lifespan).\n"
michael@0 142 "1 by size.\n"
michael@0 143 "2 by lifespan.\n"
michael@0 144 "3 by allocation count.\n"
michael@0 145 "4 by performance cost.\n")
michael@0 146
michael@0 147 ST_ALL_OPTION_STRING_ARRAY(RestrictText,
michael@0 148 DataSetGenre,
michael@0 149 ST_SUBSTRING_MATCH_MAX,
michael@0 150 "Exclude allocations which do not have this text in their backtrace.\n"
michael@0 151 "Multiple restrictions are treated as a logical AND operation.\n")
michael@0 152
michael@0 153 ST_ALL_OPTION_UINT32(SizeMin,
michael@0 154 DataSetGenre,
michael@0 155 0,
michael@0 156 1,
michael@0 157 "Exclude allocations that are below this byte size.\n")
michael@0 158
michael@0 159 ST_ALL_OPTION_UINT32(SizeMax,
michael@0 160 DataSetGenre,
michael@0 161 0xFFFFFFFF,
michael@0 162 1,
michael@0 163 "Exclude allocations that are above this byte size.\n")
michael@0 164
michael@0 165 ST_ALL_OPTION_UINT32(LifetimeMin,
michael@0 166 DataSetGenre,
michael@0 167 ST_DEFAULT_LIFETIME_MIN,
michael@0 168 ST_TIMEVAL_RESOLUTION,
michael@0 169 "Allocations must live this number of seconds or be ignored.\n")
michael@0 170
michael@0 171 ST_ALL_OPTION_UINT32(LifetimeMax,
michael@0 172 DataSetGenre,
michael@0 173 ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
michael@0 174 ST_TIMEVAL_RESOLUTION,
michael@0 175 "Allocations living longer than this number of seconds will be ignored.\n")
michael@0 176
michael@0 177 ST_ALL_OPTION_UINT32(TimevalMin,
michael@0 178 DataSetGenre,
michael@0 179 0,
michael@0 180 ST_TIMEVAL_RESOLUTION,
michael@0 181 "Allocations existing solely before this second will be ignored.\n"
michael@0 182 "Live allocations at this second and after can be considered.\n")
michael@0 183
michael@0 184 ST_ALL_OPTION_UINT32(TimevalMax,
michael@0 185 DataSetGenre,
michael@0 186 ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
michael@0 187 ST_TIMEVAL_RESOLUTION,
michael@0 188 "Allocations existing solely after this second will be ignored.\n"
michael@0 189 "Live allocations at this second and before can be considered.\n")
michael@0 190
michael@0 191 ST_ALL_OPTION_UINT32(AllocationTimevalMin,
michael@0 192 DataSetGenre,
michael@0 193 0,
michael@0 194 ST_TIMEVAL_RESOLUTION,
michael@0 195 "Live and dead allocations created before this second will be ignored.\n")
michael@0 196
michael@0 197 ST_ALL_OPTION_UINT32(AllocationTimevalMax,
michael@0 198 DataSetGenre,
michael@0 199 ST_TIMEVAL_MAX / ST_TIMEVAL_RESOLUTION,
michael@0 200 ST_TIMEVAL_RESOLUTION,
michael@0 201 "Live and dead allocations created after this second will be ignored.\n")
michael@0 202
michael@0 203 ST_ALL_OPTION_UINT32(AlignBy,
michael@0 204 DataSizeGenre,
michael@0 205 ST_DEFAULT_ALIGNMENT_SIZE,
michael@0 206 1,
michael@0 207 "All allocation sizes are made to be a multiple of this number.\n"
michael@0 208 "Closer to actual heap conditions; set to 1 for true sizes.\n")
michael@0 209
michael@0 210 ST_ALL_OPTION_UINT32(Overhead,
michael@0 211 DataSizeGenre,
michael@0 212 ST_DEFAULT_OVERHEAD_SIZE,
michael@0 213 1,
michael@0 214 "After alignment, all allocations are made to increase by this number.\n"
michael@0 215 "Closer to actual heap conditions; set to 0 for true sizes.\n")
michael@0 216
michael@0 217 ST_ALL_OPTION_UINT32(ListItemMax,
michael@0 218 UIGenre,
michael@0 219 500,
michael@0 220 1,
michael@0 221 "Specifies the maximum number of list items to present in each list.\n")
michael@0 222
michael@0 223 ST_ALL_OPTION_UINT64(WeightMin,
michael@0 224 DataSetGenre,
michael@0 225 0,
michael@0 226 1,
michael@0 227 "Exclude allocations that are below this weight (lifespan * size).\n")
michael@0 228
michael@0 229 ST_ALL_OPTION_UINT64(WeightMax,
michael@0 230 DataSetGenre,
michael@0 231 (0xFFFFFFFFLL << 32) + 0xFFFFFFFFLL,
michael@0 232 1,
michael@0 233 "Exclude allocations that are above this weight (lifespan * size).\n")
michael@0 234
michael@0 235 ST_CMD_OPTION_STRING(FileName,
michael@0 236 DataSetGenre,
michael@0 237 "-",
michael@0 238 "Specifies trace-malloc input file.\n"
michael@0 239 "\"-\" indicates stdin will be used as input.\n")
michael@0 240
michael@0 241 ST_CMD_OPTION_STRING(CategoryFile,
michael@0 242 CategoryGenre,
michael@0 243 "rules.txt",
michael@0 244 "Specifies the category rules file.\n"
michael@0 245 "This file contains rules about how to categorize allocations.\n")
michael@0 246
michael@0 247
michael@0 248 ST_CMD_OPTION_UINT32(HttpdPort,
michael@0 249 ServerGenre,
michael@0 250 1969,
michael@0 251 1,
michael@0 252 "Specifies the default port the web server will listen on.\n")
michael@0 253
michael@0 254 ST_CMD_OPTION_STRING(OutputDir,
michael@0 255 BatchModeGenre,
michael@0 256 ".",
michael@0 257 "Specifies a directory to output batch mode requests.\n"
michael@0 258 "The directory must exist and must not use a trailing slash.\n")
michael@0 259
michael@0 260 ST_CMD_OPTION_STRING_PTR_ARRAY(BatchRequest,
michael@0 261 BatchModeGenre,
michael@0 262 "This implicitly turns on batch mode.\n"
michael@0 263 "Save each requested file into the output dir, then exit.\n")
michael@0 264
michael@0 265 ST_CMD_OPTION_UINT32(Contexts,
michael@0 266 ServerGenre,
michael@0 267 1,
michael@0 268 1,
michael@0 269 "How many configurations to cache at the cost of a lot of memory.\n"
michael@0 270 "Dedicated servers can cache more client configurations for performance.\n")
michael@0 271
michael@0 272 ST_CMD_OPTION_BOOL(Help,
michael@0 273 UIGenre,
michael@0 274 "Show command line help.\n"
michael@0 275 "See http://www.mozilla.org/projects/footprint/spaceTrace.html\n")
michael@0 276
michael@0 277 /*
michael@0 278 ** END, THE OPTIONS
michael@0 279 ****************************************************************************/
michael@0 280
michael@0 281 /*
michael@0 282 ** Everything is undefined after the header is included.
michael@0 283 ** This sets it up for multiple inclusion if so desired.
michael@0 284 */
michael@0 285 #undef ST_ALL_OPTION_BOOL
michael@0 286 #undef ST_CMD_OPTION_BOOL
michael@0 287 #undef ST_WEB_OPTION_BOOL
michael@0 288 #undef ST_ALL_OPTION_STRING
michael@0 289 #undef ST_CMD_OPTION_STRING
michael@0 290 #undef ST_WEB_OPTION_STRING
michael@0 291 #undef ST_ALL_OPTION_STRING_ARRAY
michael@0 292 #undef ST_CMD_OPTION_STRING_ARRAY
michael@0 293 #undef ST_WEB_OPTION_STRING_ARRAY
michael@0 294 #undef ST_ALL_OPTION_STRING_PTR_ARRAY
michael@0 295 #undef ST_CMD_OPTION_STRING_PTR_ARRAY
michael@0 296 #undef ST_WEB_OPTION_STRING_PTR_ARRAY
michael@0 297 #undef ST_ALL_OPTION_UINT32
michael@0 298 #undef ST_CMD_OPTION_UINT32
michael@0 299 #undef ST_WEB_OPTION_UINT32
michael@0 300 #undef ST_ALL_OPTION_UINT64
michael@0 301 #undef ST_CMD_OPTION_UINT64
michael@0 302 #undef ST_WEB_OPTION_UINT64

mercurial