void profiler_usage() { LOG( "SPS: "); LOG( "SPS: Environment variable usage:"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_MODE=native for native unwind only"); LOG( "SPS: MOZ_PROFILER_MODE=pseudo for pseudo unwind only"); LOG( "SPS: MOZ_PROFILER_MODE=combined for combined native & pseudo unwind"); LOG( "SPS: If unset, default is 'combined' on native-capable"); LOG( "SPS: platforms, 'pseudo' on others."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_INTERVAL=<number> (milliseconds, 1 to 1000)"); LOG( "SPS: If unset, platform default is used."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_ENTRIES=<number> (count, minimum of 1)"); LOG( "SPS: If unset, platform default is used."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_VERBOSE"); LOG( "SPS: If set to any value, increases verbosity (recommended)."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_STACK_SCAN=<number> (default is zero)"); LOG( "SPS: The number of dubious (stack-scanned) frames allowed"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_NEW"); LOG( "SPS: Needs to be set to use Breakpad-based unwinding."); LOG( "SPS: "); LOGF("SPS: This platform %s native unwinding.", is_native_unwinding_avail() ? "supports" : "does not support"); LOG( "SPS: "); /* Re-set defaults */ sUnwindMode = is_native_unwinding_avail() ? UnwCOMBINED : UnwPSEUDO; sUnwindInterval = 0; /* We'll have to look elsewhere */ sProfileEntries = 0; sUnwindStackScan = 0; LOG( "SPS:"); LOGF("SPS: Unwind mode = %s", name_UnwMode(sUnwindMode)); LOGF("SPS: Sampling interval = %d ms (zero means \"platform default\")", (int)sUnwindInterval); LOGF("SPS: Entry store size = %d (zero means \"platform default\")", (int)sProfileEntries); LOGF("SPS: UnwindStackScan = %d (max dubious frames per unwind).", (int)sUnwindStackScan); LOG( "SPS: Use env var MOZ_PROFILER_MODE=help for further information."); LOG( "SPS:"); return; }
// Read env vars at startup, so as to set sUnwindMode and sInterval. void read_profiler_env_vars() { bool nativeAvail = is_native_unwinding_avail(); /* Set defaults */ sUnwindMode = nativeAvail ? UnwCOMBINED : UnwPSEUDO; sUnwindInterval = 0; /* We'll have to look elsewhere */ sProfileEntries = 0; const char* stackMode = PR_GetEnv(PROFILER_MODE); const char* interval = PR_GetEnv(PROFILER_INTERVAL); const char* entries = PR_GetEnv(PROFILER_ENTRIES); const char* scanCount = PR_GetEnv(PROFILER_STACK); if (!set_profiler_mode(stackMode) || !set_profiler_interval(interval) || !set_profiler_entries(entries) || !set_profiler_scan(scanCount)) { profiler_usage(); } else { LOG( "SPS:"); LOGF("SPS: Unwind mode = %s", name_UnwMode(sUnwindMode)); LOGF("SPS: Sampling interval = %d ms (zero means \"platform default\")", (int)sUnwindInterval); LOGF("SPS: Entry store size = %d (zero means \"platform default\")", (int)sProfileEntries); LOGF("SPS: UnwindStackScan = %d (max dubious frames per unwind).", (int)sUnwindStackScan); LOG( "SPS: Use env var MOZ_PROFILER_MODE=help for further information."); LOG( "SPS:"); } }
bool set_profiler_mode(const char* mode) { if (mode) { if (0 == strcmp(mode, "pseudo")) { sUnwindMode = UnwPSEUDO; return true; } else if (0 == strcmp(mode, "native") && is_native_unwinding_avail()) { sUnwindMode = UnwNATIVE; return true; } else if (0 == strcmp(mode, "combined") && is_native_unwinding_avail()) { sUnwindMode = UnwCOMBINED; return true; } else { return false; } } return true; }
void profiler_usage() { LOG( "SPS: "); LOG( "SPS: Environment variable usage:"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_HELP"); LOG( "SPS: If set to any value, prints this message."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_INTERVAL=<number> (milliseconds, 1 to 1000)"); LOG( "SPS: If unset, platform default is used."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_ENTRIES=<number> (count, minimum of 1)"); LOG( "SPS: If unset, platform default is used."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_VERBOSE"); LOG( "SPS: If set to any value, increases verbosity (recommended)."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_STACK_SCAN=<number> (default is zero)"); LOG( "SPS: The number of dubious (stack-scanned) frames allowed"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_LUL_TEST"); LOG( "SPS: If set to any value, runs LUL unit tests at startup of"); LOG( "SPS: the unwinder thread, and prints a short summary of results."); LOG( "SPS: "); LOGF("SPS: This platform %s native unwinding.", is_native_unwinding_avail() ? "supports" : "does not support"); LOG( "SPS: "); /* Re-set defaults */ sUnwindInterval = 0; /* We'll have to look elsewhere */ sProfileEntries = 0; sUnwindStackScan = 0; LOG( "SPS:"); LOGF("SPS: Sampling interval = %d ms (zero means \"platform default\")", (int)sUnwindInterval); LOGF("SPS: Entry store size = %d (zero means \"platform default\")", (int)sProfileEntries); LOGF("SPS: UnwindStackScan = %d (max dubious frames per unwind).", (int)sUnwindStackScan); LOG( "SPS:"); return; }