GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — async-profiler/src/arguments.h at jonoffcpu-dev · jonoffcpu/async-profiler Expand file tree/ Copy patharguments.hMore file actions 343 lines (298 loc) · 9 KB / Copy patharguments.hFile metadata and controls343 lines (298 loc) · 9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 /* * Copyright The async-profiler authors * SPDX-License-Identifier: Apache-2.0 */ #ifndef _ARGUMENTS_H #define _ARGUMENTS_H #include <stddef.h> #include <string.h> #include <vector> const long DEFAULT_INTERVAL = 10000000; // 10 ms const long DEFAULT_ALLOC_INTERVAL = 524287; // 512 KiB const long DEFAULT_LOCK_INTERVAL = 10000; // 10 us const long DEFAULT_PROC_INTERVAL = 30; // 30 seconds const int DEFAULT_JSTACKDEPTH = 2048; const char* const EVENT_CPU = "cpu"; const char* const EVENT_ALLOC = "alloc"; const char* const EVENT_NATIVEMEM = "nativemem"; const char* const EVENT_LOCK = "lock"; const char* const EVENT_NATIVELOCK = "nativelock"; const char* const EVENT_WALL = "wall"; const char* const EVENT_CTIMER = "ctimer"; const char* const EVENT_ITIMER = "itimer"; const char* const EVENT_SIGNAL = "signal"; #define SHORT_ENUM __attribute__((__packed__)) enum SHORT_ENUM Action { ACTION_NONE, ACTION_START, ACTION_RESUME, ACTION_STOP, ACTION_DUMP, ACTION_STATUS, ACTION_METRICS, ACTION_LIST, ACTION_VERSION }; enum SHORT_ENUM Counter { COUNTER_SAMPLES, COUNTER_TOTAL }; enum SHORT_ENUM SignalCookieDelivery { SIGNAL_COOKIE_QUEUED, SIGNAL_COOKIE_COALESCING }; enum Style { STYLE_SIMPLE = 0x1, STYLE_DOTTED = 0x2, STYLE_NORMALIZE = 0x4, STYLE_SIGNATURES = 0x8, STYLE_ANNOTATE = 0x10, STYLE_LIB_NAMES = 0x20, STYLE_NO_SEMICOLON = 0x40 }; // Whenever enum changes, update SETTING_CSTACK in FlightRecorder enum SHORT_ENUM CStack { CSTACK_DEFAULT, // use perf_event_open stack if available or Frame Pointer links otherwise CSTACK_NO, // do not collect native frames CSTACK_FP, // walk stack using Frame Pointer links CSTACK_DWARF, // use DWARF unwinding info from .eh_frame section CSTACK_VM // unwind using HotSpot VMStructs }; enum SHORT_ENUM Clock { CLK_DEFAULT, CLK_TSC, CLK_MONOTONIC }; enum SHORT_ENUM Output { OUTPUT_NONE, OUTPUT_TEXT, OUTPUT_COLLAPSED, OUTPUT_FLAMEGRAPH, OUTPUT_TREE, OUTPUT_JFR, OUTPUT_OTLP }; enum JfrOption { NO_SYSTEM_INFO = 0x1, NO_SYSTEM_PROPS = 0x2, NO_NATIVE_LIBS = 0x4, NO_CPU_LOAD = 0x8, NO_HEAP_SUMMARY = 0x10, IN_MEMORY = 0x100, JFR_SYNC_OPTS = NO_SYSTEM_INFO | NO_SYSTEM_PROPS | NO_NATIVE_LIBS | NO_CPU_LOAD | NO_HEAP_SUMMARY }; // Keep this in sync with JfrSync.java enum EventCategory { EC_CPU, // jdk.ExecutionSample EC_ALLOC, // jdk.ObjectAllocationInNewTLAB, jdk.ObjectAllocationOutsideTLAB EC_LOCK, // jdk.JavaMonitorEnter, jdk.ThreadPark EC_WALL, // profiler.WallClockSample EC_NATIVEMEM, // profiler.Malloc, profiler.Free EC_NATIVELOCK, // profiler.NativeLock EC_TRACE, // jdk.MethodTrace EC_SPAN, // profiler.Span EC_CATEGORIES }; struct StackWalkFeatures { unsigned short stats : 1; // collect stack walking duration statistics unsigned short jnienv : 1; // verify JNIEnv* obtained using VMStructs unsigned short agct : 1; // force usage of AsyncGetCallTrace instead of VMStructs unsigned short mixed : 1; // mixed stack traces with Java and native frames interleaved unsigned short vtable_target : 1; // show receiver classes of vtable/itable stubs unsigned short comp_task : 1; // display current compilation task for JIT threads unsigned short pc_addr : 1; // record exact PC address for each sample unsigned short _padding : 9; // pad structure to 16 bits }; struct Multiplier { char symbol; long multiplier; }; constexpr Multiplier NANOS[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {0, 0}}; constexpr Multiplier BYTES[] = {{'b', 1}, {'k', 1024}, {'m', 1048576}, {'g', 1073741824}, {0, 0}}; constexpr Multiplier SECONDS[] = {{'s', 1}, {'m', 60}, {'h', 3600}, {'d', 86400}, {0, 0}}; constexpr Multiplier UNIVERSAL[] = {{'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {'b', 1}, {'k', 1024}, {'g', 1073741824}, {0, 0}}; class Error { private: const char* _message; public: static const Error OK; explicit Error(const char* message) : _message(message) { } const char* message() { return _message; } operator bool() { return _message != NULL; } }; class Arguments { private: char* _buf; bool _shared; const char* expandFilePattern(const char* pattern); bool parseRateLimit(char* str); static long long hash(const char* arg); static Output detectOutputFormat(const char* file); static int parseTimeout(const char* str); public: Action _action; Counter _counter; const char* _event; std::vector<const char*> _trace; int _timeout; int _loop; size_t _mem_limit; long _interval; long _alloc; long _nativemem; long _lock; long _nativelock; long _wall; long _proc; bool _all; int _jstackdepth; int _truncated_stack_depth; int _signal; bool _signal_cookie; SignalCookieDelivery _signal_cookie_delivery; int _cookie_signal; const char* _signal_id; unsigned long long _signal_epoch; const char* _file; const char* _log; const char* _loglevel; const char* _unknown_arg; const char* _filter; std::vector<const char*> _include; std::vector<const char*> _exclude; unsigned char _mcache; bool _preloaded; bool _quiet; bool _threads; bool _sched; bool _record_cpu; bool _tlab; bool _live; bool _nofree; bool _nobatch; bool _nostop; bool _alluser; bool _fdtransfer; const char* _fdtransfer_path; int _target_cpu; int _style; StackWalkFeatures _features; CStack _cstack; Clock _clock; Output _output; int _rate_limit[EC_CATEGORIES]; long _chunk_size; long _chunk_time; const char* _jfr_sync; int _jfr_options; int _dump_traces; int _dump_flat; unsigned int _file_num; const char* _begin; const char* _end; // FlameGraph parameters const char* _title; double _minwidth; bool _reverse; bool _inverted; Arguments() : _buf(NULL), _shared(false), _action(ACTION_NONE), _counter(COUNTER_SAMPLES), _event(NULL), _trace(), _timeout(0), _loop(0), _mem_limit(0), _interval(0), _alloc(-1), _nativemem(-1), _lock(-1), _nativelock(-1), _wall(-1), _proc(-1), _all(false), _jstackdepth(DEFAULT_JSTACKDEPTH), _truncated_stack_depth(DEFAULT_JSTACKDEPTH), _signal(0), _signal_cookie(false), _signal_cookie_delivery(SIGNAL_COOKIE_QUEUED), _cookie_signal(0), _signal_id(NULL), _signal_epoch(0), _file(NULL), _log(NULL), _loglevel(NULL), _unknown_arg(NULL), _filter(NULL), _include(), _exclude(), _mcache(0), _preloaded(false), _quiet(false), _threads(false), _sched(false), _record_cpu(false), _tlab(false), _live(false), _nofree(false), _nobatch(false), _nostop(false), _alluser(false), _fdtransfer(false), _fdtransfer_path(NULL), _target_cpu(-1), _style(0), _features{}, _cstack(CSTACK_DEFAULT), _clock(CLK_DEFAULT), _output(OUTPUT_NONE), _chunk_size(100 * 1024 * 1024), _chunk_time(3600), _jfr_sync(NULL), _jfr_options(0), _dump_traces(0), _dump_flat(0), _file_num(0), _begin(NULL), _end(NULL), _title(NULL), _minwidth(0), _reverse(false), _inverted(false) { for (int i = 0; i < EC_CATEGORIES; i++) _rate_limit[i] = -1; } ~Arguments(); void save(); Error parse(const char* args); const char* file(); bool hasTemporaryLog() const; bool hasOutputFile() const { return _file != NULL && (_action == ACTION_STOP || _action == ACTION_DUMP ? _output != OUTPUT_JFR : _action >= ACTION_STATUS); } bool hasOption(JfrOption option) const { return (_jfr_options & option) != 0; } int eventMask() const { bool cookie_only = _signal_cookie && _event != NULL && strcmp(_event, EVENT_SIGNAL) == 0; return (_event != NULL && !cookie_only ? 1 << EC_CPU : 0) | (_alloc >= 0 ? 1 << EC_ALLOC : 0) | (_lock >= 0 ? 1 << EC_LOCK : 0) | (_wall >= 0 ? 1 << EC_WALL : 0) | (_nativemem >= 0 ? 1 << EC_NATIVEMEM : 0) | (_nativelock >= 0 ? 1 << EC_NATIVELOCK : 0) | (!_trace.empty() ? 1 << EC_TRACE : 0); } static bool isUrl(const char* file); static long parseUnits(const char* str, const Multiplier* multipliers); }; extern Arguments _global_args; #endif // _ARGUMENTS_H |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |