Bug 1737376 - StreamMarkersToJSON should accept all markers if aThreadId is unspecified - r=julienw

Before bug 1577658, StreamMarkersToJSON directly called DeserializeAfterKindAndStream [1], which accepted an unspecified ProfilerThreadId [2], in which case it would output any marker [3].
This is used in particular when streaming markers from the Java thread, which is done with fake thread information including an unspecified thread id [4].

Bug 1577658 modified StreamMarkersToJSON to use an updated DeserializeAfterKindAndStream, and didn't account for unspecified thread ids.
This patch adds the missing check, so that all markers found in the given buffer will be output.

[1] https://searchfox.org/mozilla-central/rev/8dc9602bebd48a94a12aaeb18a65a02d9aed4de3/tools/profiler/core/ProfileBufferEntry.cpp#1286-1287
[2] https://searchfox.org/mozilla-central/rev/8dc9602bebd48a94a12aaeb18a65a02d9aed4de3/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h#302
[3] https://searchfox.org/mozilla-central/rev/8dc9602bebd48a94a12aaeb18a65a02d9aed4de3/mozglue/baseprofiler/public/BaseProfilerMarkersDetail.h#313-317
[4] https://searchfox.org/mozilla-central/rev/8dc9602bebd48a94a12aaeb18a65a02d9aed4de3/tools/profiler/core/platform.cpp#2997,3006

Differential Revision: https://phabricator.services.mozilla.com/D129450
This commit is contained in:
Gerald Squelart 2021-10-26 21:00:50 +00:00
Родитель 9c95211ab1
Коммит 0ff5eeaa62
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -1445,7 +1445,9 @@ void ProfileBuffer::StreamMarkersToJSON(SpliceableJSONWriter& aWriter,
mozilla::base_profiler_markers_detail::DeserializeAfterKindAndStream(
aER,
[&](const ProfilerThreadId& aMarkerThreadId) {
return (aMarkerThreadId == aThreadId) ? &aWriter : nullptr;
return (!aThreadId.IsSpecified() || aMarkerThreadId == aThreadId)
? &aWriter
: nullptr;
},
[&](ProfileChunkedBuffer& aChunkedBuffer) {
ProfilerBacktrace backtrace("", &aChunkedBuffer);