Accept non zero-terminated strings in ftrace fields

ReadIntoString() fails if strings are not null terminated.

There are three cases in which ReadIntoString() is called:

1. For fixed fields declared as:

  ```
          field:char newcomm[16]; offset:28;      size:16;        signed:1;
  ```
  the max length of the string is bounded by the fixed size.

2. For variable length fields declared at the end of an event:

  ```
          field:char buf[];       offset:16;      size:0; signed:1;
  ```
  the max length of the buffer is bounded by the event size.

3. For __data_loc fields:

  ```
          field:__data_loc char[] name;   offset:16;      size:4; signed:1;
  ```
  each field has an offset and a size. The max length of the string is
  bounded by the fixed size.

In some rare cases, e.g., if this kernel commit is missing:

`f0a515780393("tracing: Don't make assumptions about length of string on task rename")`

the kernel can output a buffer that's not zero-terminated (e.g. for case
1)

In all cases, the string size is limited explicitly. The code should
still stop copying when it finds the '\0' terminator, but, if it doesn't
find that, it could still copy what's there. There's no risk of going
out of bounds, so this commit stops complaining (and eventually hitting
a PERFETTO_CHECK), if strings are not null terminated.

Bug: 205763418
Change-Id: I2159ecbc4dd42d31f54613efa5e77c9d7eca09fb
3 files changed
tree: ac3ac3e0e62e7df44d232b91a7e95ced2c8248d6
  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.