ftrace: fix seq-clear flags when symbolizing kernel addresses

The logic that emits SEQ_INCREMENTAL_STATE_CLEARED had a
logical bug. That logic used to look at (max_index_at_start == 0)
to determine if we need to reset the interning state by emitting
a SEQ_INCREMENTAL_STATE_CLEARED flag.
This is the bug:
- We are at the start of a new batch and we are processing events
  for CPU0. Before this call, the ftrace controller did a
  FtraceMetadata::Clear(), so last_kernel_addr_index_written = 0
  and the interning map is cleared.
- There are N events with addresses (e.g. workqueue events) in
  the CPU0 buffer. We try to symbolize them and all of them fail
  the Lookup(). This event (the sym failure) is not too unlikely.
  Many ftrace events contain (useless) pointers to data structures.
- At the end of the loop, we set last_kernel_addr_index_written = N.
  However we have not written any symbol, so we never even started
  the set_interned_data() section.
- On the next round (e.g. on CPU1) we find some other symbol which
  passes the lookup. We create the interned_data section but we
  do NOT set SEQ_INCREMENTAL_STATE_CLEARED because at this point
  max_index_at_start = N, not 0.
- By doing so we fail to signal the restart of the intern numbering
  to trace processor, even though we actuall restart it (by virtue
  of having called FtraceMetadata::Clear() before CPU0.

Bug: 190075739
(cherry picked from commit c1ba22d9d500a3456c1f25854275fb378fc129d7)
Change-Id: Ic467018c6752c492a48065839f17b589c83f7d53
Merged-In: Ic467018c6752c492a48065839f17b589c83f7d53
1 file changed
tree: 1f095d717a89c3a19d7c7a9779fe3b9742e85fd2
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. src/
  13. test/
  14. tools/
  15. ui/
  16. .clang-format
  17. .clang-tidy
  18. .gitattributes
  19. .gitignore
  20. .gn
  21. .style.yapf
  22. Android.bp
  23. Android.bp.extras
  24. BUILD
  25. BUILD.extras
  26. BUILD.gn
  27. CHANGELOG
  28. codereview.settings
  29. DIR_METADATA
  30. heapprofd.rc
  31. LICENSE
  32. meson.build
  33. METADATA
  34. MODULE_LICENSE_APACHE2
  35. OWNERS
  36. perfetto.rc
  37. PerfettoIntegrationTests.xml
  38. PRESUBMIT.py
  39. README.chromium
  40. README.md
  41. TEST_MAPPING
  42. traced_perf.rc
  43. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.