pw_trace_tokenized: Fix incorrect timestamp

Issue reproduce:
1. start tracing
2. stop tracing
3. fetch trace data
4. start tracing again
5. stop tracing
6. fetch trace data
7. timestamp for trace entry is not correct

Root cause:
In current design, timestamp of the first trace event represents
real time, timestamps of subsequent trace events represent time
difference between current trace event and the previous trace event.
The issue in existing code is that real time is only used for the first
trace event of the first round of tracing. Subsequent rounds of tracing
doesn't use real time for the first trace event.

Bug: 433273214
Change-Id: I7c48422db4d3562bc8815311b66ea7e53508053e
Signed-off-by: Chris Guo <chrisguo@google.com>
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/306952
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Dave Roth <davidroth@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Docs-Not-Needed: Dave Roth <davidroth@google.com>
Commit-Queue: Dave Roth <davidroth@google.com>
5 files changed
tree: 2ba01c00c4578bd89d5a77664c08f0cd81a5c3e0
  1. .allstar/
  2. .gemini/
  3. .github/
  4. .vscode/
  5. build_overrides/
  6. docker/
  7. docs/
  8. kudzu/
  9. pw_alignment/
  10. pw_allocator/
  11. pw_analog/
  12. pw_android_toolchain/
  13. pw_arduino_build/
  14. pw_assert/
  15. pw_assert_basic/
  16. pw_assert_fuchsia/
  17. pw_assert_log/
  18. pw_assert_tokenized/
  19. pw_assert_trap/
  20. pw_assert_zephyr/
  21. pw_async/
  22. pw_async2/
  23. pw_async2_basic/
  24. pw_async2_epoll/
  25. pw_async_basic/
  26. pw_async_fuchsia/
  27. pw_atomic/
  28. pw_base64/
  29. pw_bloat/
  30. pw_blob_store/
  31. pw_bluetooth/
  32. pw_bluetooth_hci/
  33. pw_bluetooth_profiles/
  34. pw_bluetooth_proxy/
  35. pw_bluetooth_sapphire/
  36. pw_boot/
  37. pw_boot_cortex_m/
  38. pw_build/
  39. pw_build_android/
  40. pw_build_info/
  41. pw_build_mcuxpresso/
  42. pw_bytes/
  43. pw_channel/
  44. pw_checksum/
  45. pw_chre/
  46. pw_chrono/
  47. pw_chrono_embos/
  48. pw_chrono_freertos/
  49. pw_chrono_rp2040/
  50. pw_chrono_stl/
  51. pw_chrono_threadx/
  52. pw_chrono_zephyr/
  53. pw_cli/
  54. pw_cli_analytics/
  55. pw_clock_tree/
  56. pw_clock_tree_mcuxpresso/
  57. pw_compilation_testing/
  58. pw_config_loader/
  59. pw_console/
  60. pw_containers/
  61. pw_cpu_exception/
  62. pw_cpu_exception_cortex_m/
  63. pw_cpu_exception_risc_v/
  64. pw_crypto/
  65. pw_digital_io/
  66. pw_digital_io_linux/
  67. pw_digital_io_mcuxpresso/
  68. pw_digital_io_rp2040/
  69. pw_digital_io_zephyr/
  70. pw_display/
  71. pw_dma_mcuxpresso/
  72. pw_docgen/
  73. pw_doctor/
  74. pw_elf/
  75. pw_emu/
  76. pw_env_setup/
  77. pw_env_setup_zephyr/
  78. pw_file/
  79. pw_flatbuffers/
  80. pw_format/
  81. pw_function/
  82. pw_fuzzer/
  83. pw_grpc/
  84. pw_hdlc/
  85. pw_hex_dump/
  86. pw_i2c/
  87. pw_i2c_linux/
  88. pw_i2c_mcuxpresso/
  89. pw_i2c_rp2040/
  90. pw_i2c_zephyr/
  91. pw_ide/
  92. pw_interrupt/
  93. pw_interrupt_cortex_m/
  94. pw_interrupt_freertos/
  95. pw_interrupt_zephyr/
  96. pw_intrusive_ptr/
  97. pw_json/
  98. pw_kernel/
  99. pw_kvs/
  100. pw_libc/
  101. pw_libcxx/
  102. pw_log/
  103. pw_log_android/
  104. pw_log_basic/
  105. pw_log_fuchsia/
  106. pw_log_null/
  107. pw_log_rpc/
  108. pw_log_string/
  109. pw_log_tokenized/
  110. pw_log_zephyr/
  111. pw_malloc/
  112. pw_malloc_freelist/
  113. pw_malloc_freertos/
  114. pw_metric/
  115. pw_minimal_cpp_stdlib/
  116. pw_module/
  117. pw_multibuf/
  118. pw_multisink/
  119. pw_numeric/
  120. pw_package/
  121. pw_perf_test/
  122. pw_persistent_ram/
  123. pw_polyfill/
  124. pw_preprocessor/
  125. pw_presubmit/
  126. pw_protobuf/
  127. pw_protobuf_compiler/
  128. pw_random/
  129. pw_random_fuchsia/
  130. pw_result/
  131. pw_ring_buffer/
  132. pw_router/
  133. pw_rpc/
  134. pw_rpc_transport/
  135. pw_rust/
  136. pw_sensor/
  137. pw_snapshot/
  138. pw_software_update/
  139. pw_span/
  140. pw_spi/
  141. pw_spi_linux/
  142. pw_spi_mcuxpresso/
  143. pw_spi_rp2040/
  144. pw_status/
  145. pw_stm32cube_build/
  146. pw_stream/
  147. pw_stream_shmem_mcuxpresso/
  148. pw_stream_uart_linux/
  149. pw_stream_uart_mcuxpresso/
  150. pw_string/
  151. pw_symbolizer/
  152. pw_sync/
  153. pw_sync_baremetal/
  154. pw_sync_embos/
  155. pw_sync_freertos/
  156. pw_sync_stl/
  157. pw_sync_threadx/
  158. pw_sync_zephyr/
  159. pw_sys_io/
  160. pw_sys_io_ambiq_sdk/
  161. pw_sys_io_arduino/
  162. pw_sys_io_baremetal_lm3s6965evb/
  163. pw_sys_io_baremetal_stm32f429/
  164. pw_sys_io_emcraft_sf2/
  165. pw_sys_io_mcuxpresso/
  166. pw_sys_io_rp2040/
  167. pw_sys_io_stdio/
  168. pw_sys_io_stm32cube/
  169. pw_sys_io_zephyr/
  170. pw_system/
  171. pw_target_runner/
  172. pw_thread/
  173. pw_thread_embos/
  174. pw_thread_freertos/
  175. pw_thread_stl/
  176. pw_thread_threadx/
  177. pw_thread_zephyr/
  178. pw_tls_client/
  179. pw_tls_client_boringssl/
  180. pw_tls_client_mbedtls/
  181. pw_tokenizer/
  182. pw_toolchain/
  183. pw_trace/
  184. pw_trace_tokenized/
  185. pw_transfer/
  186. pw_uart/
  187. pw_uart_mcuxpresso/
  188. pw_unit_test/
  189. pw_uuid/
  190. pw_varint/
  191. pw_watch/
  192. pw_web/
  193. pw_work_queue/
  194. seed/
  195. targets/
  196. third_party/
  197. ts/
  198. zephyr/
  199. .bazelignore
  200. .bazelrc
  201. .bazelversion
  202. .black.toml
  203. .clang-format
  204. .clang-tidy
  205. .eslintrc.cjs
  206. .git-blame-ignore-revs
  207. .gitattributes
  208. .gitignore
  209. .gn
  210. .mypy.ini
  211. .prettierignore
  212. .prettierrc.cjs
  213. .pw_ide.yaml
  214. .pylintrc
  215. .ruff.toml
  216. activate.bat
  217. Android.bp
  218. AUTHORS
  219. bootstrap.bat
  220. bootstrap.fish
  221. bootstrap.sh
  222. BUILD.bazel
  223. BUILD.gn
  224. BUILDCONFIG.gn
  225. CMakeLists.txt
  226. GEMINI.md
  227. go.mod
  228. go.sum
  229. jest.config.ts
  230. Kconfig.zephyr
  231. LICENSE
  232. MODULE.bazel
  233. MODULE.bazel.lock
  234. modules.gni
  235. OWNERS
  236. package-lock.json
  237. package.json
  238. pigweed.json
  239. PIGWEED_MODULES
  240. pnpm-lock.yaml
  241. pw
  242. README.md
  243. REPO.bazel
  244. rollup-protos.config.js
  245. rollup.config.js
  246. tsconfig.json
  247. workflows.json
  248. WORKSPACE
  249. WORKSPACE_OWNERS
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links