simpleperf: Prevent protobuf overflow with finer-grained branch counting
Previously, this check was performed at the granularity of a memory
address. All branches for a single address were counted and added as one
atomic unit. This coarse-grained approach could fail when a single
address (common in kernel profiles) had enough associated branches to
exceed the limit on its own.
This patch refines the logic to check the branch count before adding
each individual branch. This provides a much more accurate, fine-grained
check that ensures no single message exceeds the configured limit,
robustly preventing the overflow error.
The unit test has also been updated to verify this behavior by asserting
that the size of any generated message respects the configured limit.
Bug: none
Test: run simpleperf_unit_test
Change-Id: Ib52a156a1bdf01c494eb041d0feb85e184c4079b
3 files changed