mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1598529 - Empty JSON profiles may in fact contain 1 character - r=gregtatum
JSON profiles from the Base Profiler were assumed to be empty if they contained zero characters, but in fact they contain one character (a single newline). Differential Revision: https://phabricator.services.mozilla.com/D54442 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
bb445b4ac3
commit
2dea92aedc
@ -3985,6 +3985,20 @@ static void TriggerPollJSSamplingOnMainThread() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_BASE_PROFILER
|
||||
static bool HasMinimumLength(const char* aString, size_t aMinimumLength) {
|
||||
if (!aString) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < aMinimumLength; ++i) {
|
||||
if (aString[i] == '\0') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // MOZ_BASE_PROFILER
|
||||
|
||||
static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity,
|
||||
double aInterval, uint32_t aFeatures,
|
||||
const char** aFilters, uint32_t aFilterCount,
|
||||
@ -4052,8 +4066,10 @@ static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity,
|
||||
// post-XPCOM shutdown.
|
||||
baseprofiler::profiler_stop();
|
||||
|
||||
if (baseprofile && baseprofile.get()[0] != '\0') {
|
||||
// The BaseProfiler startup profile will be stored as a separate process
|
||||
// An "empty" profile string may in fact contain 1 character (a newline),
|
||||
// so we want at least 2 characters to register a profile.
|
||||
if (HasMinimumLength(baseprofile.get(), 2)) {
|
||||
// The BaseProfiler startup profile will be stored as a separate "process"
|
||||
// in the Gecko Profiler profile, and shown as a new track under the
|
||||
// corresponding Gecko Profiler thread.
|
||||
ActivePS::AddBaseProfileThreads(aLock, std::move(baseprofile));
|
||||
|
Loading…
Reference in New Issue
Block a user