@encharm/cws 4.5.3 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CLAUDE.md +83 -0
  3. package/README.md +20 -4
  4. package/binding.gyp +8 -2
  5. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  7. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  8. package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
  9. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  10. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  11. package/dist/bindings/cws_linux_arm64_node137.node +0 -0
  12. package/dist/bindings/cws_linux_arm64_node147.node +0 -0
  13. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  14. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  15. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  16. package/dist/bindings/cws_linux_x64_node147.node +0 -0
  17. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  18. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  19. package/dist/bindings/cws_win32_x64_node137.node +0 -0
  20. package/dist/bindings/cws_win32_x64_node147.node +0 -0
  21. package/dist/client.d.ts +1 -0
  22. package/dist/client.js +15 -1
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +2 -0
  25. package/dist/server.d.ts +1 -0
  26. package/dist/server.js +16 -2
  27. package/dist/shared.d.ts +1 -0
  28. package/dist/shared.js +3 -2
  29. package/package.json +1 -1
  30. package/src/Addon.cpp +4 -1
  31. package/src/Addon.h +80 -15
  32. package/src/Extensions.cpp +7 -1
  33. package/src/Extensions.h +2 -1
  34. package/src/Group.cpp +1 -1
  35. package/src/Group.h +4 -1
  36. package/src/HTTPSocket.cpp +1 -1
  37. package/src/Hub.cpp +11 -76
  38. package/src/Hub.h +12 -10
  39. package/src/Networking.h +11 -0
  40. package/src/Socket.h +201 -6
  41. package/src/WebSocket.cpp +8 -5
  42. package/src/Zlib.cpp +138 -0
  43. package/src/Zlib.h +38 -0
  44. package/src/cSNode.cpp +2 -0
  45. package/src/cSNode.h +4 -0
  46. package/src/headers/26/acorn_version.h +6 -0
  47. package/src/headers/26/aliased_buffer-inl.h +264 -0
  48. package/src/headers/26/aliased_buffer.h +205 -0
  49. package/src/headers/26/aliased_struct-inl.h +143 -0
  50. package/src/headers/26/aliased_struct.h +248 -0
  51. package/src/headers/26/amaro_version.h +6 -0
  52. package/src/headers/26/async_context_frame.h +33 -0
  53. package/src/headers/26/async_wrap-inl.h +123 -0
  54. package/src/headers/26/async_wrap.h +254 -0
  55. package/src/headers/26/base_object-inl.h +333 -0
  56. package/src/headers/26/base_object.h +339 -0
  57. package/src/headers/26/base_object_types.h +76 -0
  58. package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
  59. package/src/headers/26/blob_serializer_deserializer.h +142 -0
  60. package/src/headers/26/builtin_info.h +57 -0
  61. package/src/headers/26/callback_queue-inl.h +97 -0
  62. package/src/headers/26/callback_queue.h +79 -0
  63. package/src/headers/26/cares_wrap.h +475 -0
  64. package/src/headers/26/cleanup_queue-inl.h +36 -0
  65. package/src/headers/26/cleanup_queue.h +79 -0
  66. package/src/headers/26/compile_cache.h +134 -0
  67. package/src/headers/26/connect_wrap.h +26 -0
  68. package/src/headers/26/connection_wrap.h +30 -0
  69. package/src/headers/26/cppgc_helpers-inl.h +69 -0
  70. package/src/headers/26/cppgc_helpers.h +162 -0
  71. package/src/headers/26/crypto/crypto_aes.h +107 -0
  72. package/src/headers/26/crypto/crypto_argon2.h +88 -0
  73. package/src/headers/26/crypto/crypto_bio.h +193 -0
  74. package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
  75. package/src/headers/26/crypto/crypto_cipher.h +291 -0
  76. package/src/headers/26/crypto/crypto_common.h +48 -0
  77. package/src/headers/26/crypto/crypto_context.h +219 -0
  78. package/src/headers/26/crypto/crypto_dh.h +104 -0
  79. package/src/headers/26/crypto/crypto_dsa.h +50 -0
  80. package/src/headers/26/crypto/crypto_ec.h +102 -0
  81. package/src/headers/26/crypto/crypto_hash.h +157 -0
  82. package/src/headers/26/crypto/crypto_hkdf.h +62 -0
  83. package/src/headers/26/crypto/crypto_hmac.h +92 -0
  84. package/src/headers/26/crypto/crypto_kem.h +131 -0
  85. package/src/headers/26/crypto/crypto_keygen.h +382 -0
  86. package/src/headers/26/crypto/crypto_keys.h +366 -0
  87. package/src/headers/26/crypto/crypto_kmac.h +79 -0
  88. package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
  89. package/src/headers/26/crypto/crypto_pqc.h +39 -0
  90. package/src/headers/26/crypto/crypto_random.h +127 -0
  91. package/src/headers/26/crypto/crypto_rsa.h +108 -0
  92. package/src/headers/26/crypto/crypto_scrypt.h +85 -0
  93. package/src/headers/26/crypto/crypto_sig.h +159 -0
  94. package/src/headers/26/crypto/crypto_spkac.h +21 -0
  95. package/src/headers/26/crypto/crypto_timing.h +20 -0
  96. package/src/headers/26/crypto/crypto_tls.h +342 -0
  97. package/src/headers/26/crypto/crypto_turboshake.h +105 -0
  98. package/src/headers/26/crypto/crypto_util.h +775 -0
  99. package/src/headers/26/crypto/crypto_x509.h +140 -0
  100. package/src/headers/26/dataqueue/queue.h +311 -0
  101. package/src/headers/26/debug_utils-inl.h +291 -0
  102. package/src/headers/26/debug_utils.h +200 -0
  103. package/src/headers/26/diagnosticfilename-inl.h +33 -0
  104. package/src/headers/26/embedded_data.h +17 -0
  105. package/src/headers/26/encoding_binding.h +59 -0
  106. package/src/headers/26/env-inl.h +956 -0
  107. package/src/headers/26/env.h +1294 -0
  108. package/src/headers/26/env_properties.h +562 -0
  109. package/src/headers/26/ffi/data.h +30 -0
  110. package/src/headers/26/ffi/fast.h +96 -0
  111. package/src/headers/26/ffi/jit_memory.h +26 -0
  112. package/src/headers/26/ffi/types.h +99 -0
  113. package/src/headers/26/handle_wrap.h +123 -0
  114. package/src/headers/26/histogram-inl.h +211 -0
  115. package/src/headers/26/histogram.h +474 -0
  116. package/src/headers/26/inspector/dom_storage_agent.h +68 -0
  117. package/src/headers/26/inspector/inspector_object_utils.h +38 -0
  118. package/src/headers/26/inspector/io_agent.h +30 -0
  119. package/src/headers/26/inspector/main_thread_interface.h +116 -0
  120. package/src/headers/26/inspector/network_agent.h +110 -0
  121. package/src/headers/26/inspector/network_inspector.h +45 -0
  122. package/src/headers/26/inspector/network_requests_buffer.h +195 -0
  123. package/src/headers/26/inspector/network_resource_manager.h +29 -0
  124. package/src/headers/26/inspector/node_json.h +24 -0
  125. package/src/headers/26/inspector/node_string.h +101 -0
  126. package/src/headers/26/inspector/notification_emitter.h +38 -0
  127. package/src/headers/26/inspector/protocol_helper.h +27 -0
  128. package/src/headers/26/inspector/runtime_agent.h +41 -0
  129. package/src/headers/26/inspector/storage_agent.h +33 -0
  130. package/src/headers/26/inspector/target_agent.h +59 -0
  131. package/src/headers/26/inspector/target_manager.h +70 -0
  132. package/src/headers/26/inspector/tracing_agent.h +43 -0
  133. package/src/headers/26/inspector/worker_agent.h +40 -0
  134. package/src/headers/26/inspector/worker_inspector.h +124 -0
  135. package/src/headers/26/inspector_agent.h +168 -0
  136. package/src/headers/26/inspector_io.h +78 -0
  137. package/src/headers/26/inspector_profiler.h +149 -0
  138. package/src/headers/26/inspector_socket.h +60 -0
  139. package/src/headers/26/inspector_socket_server.h +110 -0
  140. package/src/headers/26/js_native_api.h +634 -0
  141. package/src/headers/26/js_native_api_types.h +244 -0
  142. package/src/headers/26/js_native_api_v8.h +485 -0
  143. package/src/headers/26/js_native_api_v8_internals.h +45 -0
  144. package/src/headers/26/js_stream.h +57 -0
  145. package/src/headers/26/json_utils.h +172 -0
  146. package/src/headers/26/large_pages/node_large_page.h +34 -0
  147. package/src/headers/26/lru_cache-inl.h +69 -0
  148. package/src/headers/26/memory_tracker-inl.h +461 -0
  149. package/src/headers/26/memory_tracker.h +341 -0
  150. package/src/headers/26/module_wrap.h +231 -0
  151. package/src/headers/26/ncrypto.h +2008 -0
  152. package/src/headers/26/node.h +1693 -0
  153. package/src/headers/26/node_api.h +265 -0
  154. package/src/headers/26/node_api_internals.h +48 -0
  155. package/src/headers/26/node_api_types.h +58 -0
  156. package/src/headers/26/node_binding.h +170 -0
  157. package/src/headers/26/node_blob.h +160 -0
  158. package/src/headers/26/node_bob-inl.h +36 -0
  159. package/src/headers/26/node_bob.h +107 -0
  160. package/src/headers/26/node_buffer.h +92 -0
  161. package/src/headers/26/node_builtins.h +239 -0
  162. package/src/headers/26/node_concepts.h +46 -0
  163. package/src/headers/26/node_config_file.h +77 -0
  164. package/src/headers/26/node_constants.h +82 -0
  165. package/src/headers/26/node_context_data.h +171 -0
  166. package/src/headers/26/node_contextify.h +261 -0
  167. package/src/headers/26/node_crypto.h +66 -0
  168. package/src/headers/26/node_debug.h +30 -0
  169. package/src/headers/26/node_diagnostics_channel.h +121 -0
  170. package/src/headers/26/node_dir.h +52 -0
  171. package/src/headers/26/node_dotenv.h +45 -0
  172. package/src/headers/26/node_errors.h +378 -0
  173. package/src/headers/26/node_exit_code.h +54 -0
  174. package/src/headers/26/node_external_reference.h +171 -0
  175. package/src/headers/26/node_ffi.h +212 -0
  176. package/src/headers/26/node_file-inl.h +421 -0
  177. package/src/headers/26/node_file.h +561 -0
  178. package/src/headers/26/node_file_utils.h +39 -0
  179. package/src/headers/26/node_hash.h +212 -0
  180. package/src/headers/26/node_http2.h +1202 -0
  181. package/src/headers/26/node_http2_state.h +159 -0
  182. package/src/headers/26/node_http_common-inl.h +199 -0
  183. package/src/headers/26/node_http_common.h +535 -0
  184. package/src/headers/26/node_i18n.h +132 -0
  185. package/src/headers/26/node_internals.h +485 -0
  186. package/src/headers/26/node_locks.h +184 -0
  187. package/src/headers/26/node_main_instance.h +67 -0
  188. package/src/headers/26/node_mem-inl.h +113 -0
  189. package/src/headers/26/node_mem.h +45 -0
  190. package/src/headers/26/node_messaging.h +389 -0
  191. package/src/headers/26/node_metadata.h +172 -0
  192. package/src/headers/26/node_modules.h +102 -0
  193. package/src/headers/26/node_mutex.h +323 -0
  194. package/src/headers/26/node_object_wrap.h +145 -0
  195. package/src/headers/26/node_options-inl.h +524 -0
  196. package/src/headers/26/node_options.h +710 -0
  197. package/src/headers/26/node_perf.h +167 -0
  198. package/src/headers/26/node_perf_common.h +103 -0
  199. package/src/headers/26/node_platform.h +290 -0
  200. package/src/headers/26/node_process-inl.h +26 -0
  201. package/src/headers/26/node_process.h +112 -0
  202. package/src/headers/26/node_profiling.h +38 -0
  203. package/src/headers/26/node_realm-inl.h +156 -0
  204. package/src/headers/26/node_realm.h +236 -0
  205. package/src/headers/26/node_report.h +43 -0
  206. package/src/headers/26/node_revert.h +82 -0
  207. package/src/headers/26/node_root_certs.h +2937 -0
  208. package/src/headers/26/node_sea.h +101 -0
  209. package/src/headers/26/node_shadow_realm.h +46 -0
  210. package/src/headers/26/node_snapshot_builder.h +57 -0
  211. package/src/headers/26/node_snapshotable.h +167 -0
  212. package/src/headers/26/node_sockaddr-inl.h +248 -0
  213. package/src/headers/26/node_sockaddr.h +459 -0
  214. package/src/headers/26/node_sqlite.h +607 -0
  215. package/src/headers/26/node_stat_watcher.h +73 -0
  216. package/src/headers/26/node_task_runner.h +92 -0
  217. package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
  218. package/src/headers/26/node_threadsafe_cow.h +105 -0
  219. package/src/headers/26/node_union_bytes.h +81 -0
  220. package/src/headers/26/node_url.h +101 -0
  221. package/src/headers/26/node_url_pattern.h +118 -0
  222. package/src/headers/26/node_v8.h +78 -0
  223. package/src/headers/26/node_v8_embedder.h +26 -0
  224. package/src/headers/26/node_v8_platform-inl.h +96 -0
  225. package/src/headers/26/node_version.h +116 -0
  226. package/src/headers/26/node_wasi.h +184 -0
  227. package/src/headers/26/node_wasm_web_api.h +55 -0
  228. package/src/headers/26/node_watchdog.h +164 -0
  229. package/src/headers/26/node_webstorage.h +62 -0
  230. package/src/headers/26/node_worker.h +162 -0
  231. package/src/headers/26/path.h +36 -0
  232. package/src/headers/26/permission/boolean_permission.h +50 -0
  233. package/src/headers/26/permission/fs_permission.h +192 -0
  234. package/src/headers/26/permission/permission.h +155 -0
  235. package/src/headers/26/permission/permission_base.h +79 -0
  236. package/src/headers/26/pipe_wrap.h +80 -0
  237. package/src/headers/26/quic/application.h +279 -0
  238. package/src/headers/26/quic/arena.h +373 -0
  239. package/src/headers/26/quic/bindingdata.h +440 -0
  240. package/src/headers/26/quic/cid.h +127 -0
  241. package/src/headers/26/quic/data.h +358 -0
  242. package/src/headers/26/quic/defs.h +417 -0
  243. package/src/headers/26/quic/endpoint.h +519 -0
  244. package/src/headers/26/quic/guard.h +5 -0
  245. package/src/headers/26/quic/http3.h +25 -0
  246. package/src/headers/26/quic/packet.h +166 -0
  247. package/src/headers/26/quic/preferredaddress.h +72 -0
  248. package/src/headers/26/quic/session.h +770 -0
  249. package/src/headers/26/quic/session_manager.h +107 -0
  250. package/src/headers/26/quic/sessionticket.h +110 -0
  251. package/src/headers/26/quic/streams.h +518 -0
  252. package/src/headers/26/quic/tlscontext.h +353 -0
  253. package/src/headers/26/quic/tokens.h +263 -0
  254. package/src/headers/26/quic/transportparams.h +184 -0
  255. package/src/headers/26/req_wrap-inl.h +175 -0
  256. package/src/headers/26/req_wrap.h +79 -0
  257. package/src/headers/26/spawn_sync.h +243 -0
  258. package/src/headers/26/stream_base-inl.h +170 -0
  259. package/src/headers/26/stream_base.h +487 -0
  260. package/src/headers/26/stream_pipe.h +76 -0
  261. package/src/headers/26/stream_wrap.h +137 -0
  262. package/src/headers/26/string_bytes.h +114 -0
  263. package/src/headers/26/string_decoder-inl.h +31 -0
  264. package/src/headers/26/string_decoder.h +49 -0
  265. package/src/headers/26/tcp_wrap.h +138 -0
  266. package/src/headers/26/threadpoolwork-inl.h +70 -0
  267. package/src/headers/26/timer_wrap-inl.h +32 -0
  268. package/src/headers/26/timer_wrap.h +87 -0
  269. package/src/headers/26/timers.h +70 -0
  270. package/src/headers/26/tracing/agent.h +125 -0
  271. package/src/headers/26/tracing/agent_legacy.h +146 -0
  272. package/src/headers/26/tracing/agent_perfetto.h +145 -0
  273. package/src/headers/26/tracing/node_trace_buffer.h +91 -0
  274. package/src/headers/26/tracing/node_trace_writer.h +79 -0
  275. package/src/headers/26/tracing/trace_event.h +27 -0
  276. package/src/headers/26/tracing/trace_event_helper.h +40 -0
  277. package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
  278. package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
  279. package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
  280. package/src/headers/26/tracing/traced_value.h +167 -0
  281. package/src/headers/26/tty_wrap.h +65 -0
  282. package/src/headers/26/udp_wrap.h +231 -0
  283. package/src/headers/26/undici_version.h +6 -0
  284. package/src/headers/26/util-inl.h +788 -0
  285. package/src/headers/26/util.h +1207 -0
  286. package/src/headers/26/v8-cpp-heap-external.h +56 -0
  287. package/src/headers/26/v8-external-memory-accounter.h +60 -0
  288. package/src/headers/26/v8-fast-api-calls.h +784 -0
  289. package/src/headers/26/v8-inspector-protocol.h +13 -0
  290. package/src/headers/26/v8-inspector.h +458 -0
  291. package/src/headers/26/v8-metrics.h +273 -0
  292. package/src/headers/26/v8-trace-categories.h +28 -0
  293. package/src/headers/26/v8-unwinder-state.h +30 -0
  294. package/src/headers/26/v8-util.h +549 -0
  295. package/src/headers/26/v8-value-serializer-version.h +24 -0
  296. package/src/headers/26/v8-version-string.h +38 -0
  297. package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
  298. package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
  299. package/src/headers/26/zlib_version.h +6 -0
  300. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Info.plist +0 -20
  301. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node115.node +0 -0
  302. package/dist/bindings/cws_darwin_arm64_node115.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node115.node.yml +0 -931
  303. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Info.plist +0 -20
  304. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/DWARF/cws_darwin_arm64_node127.node +0 -0
  305. package/dist/bindings/cws_darwin_arm64_node127.node.dSYM/Contents/Resources/Relocations/aarch64/cws_darwin_arm64_node127.node.yml +0 -931
@@ -0,0 +1,1113 @@
1
+ // Copyright 2015 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef SRC_TRACING_TRACE_EVENT_LEGACY_H_
6
+ #define SRC_TRACING_TRACE_EVENT_LEGACY_H_
7
+
8
+ #ifdef V8_USE_PERFETTO
9
+ #error Perfetto is enabled.
10
+ #endif
11
+
12
+ // This header file defines the set of trace_event macros without specifying
13
+ // how the events actually get collected and stored. If you need to expose trace
14
+ // events to some other universe, you can copy-and-paste this file as well as
15
+ // trace_event.h, modifying the macros contained there as necessary for the
16
+ // target platform. The end result is that multiple libraries can funnel events
17
+ // through to a shared trace event collector.
18
+
19
+ // IMPORTANT: To avoid conflicts, if you need to modify this file for a library,
20
+ // land your change in base/ first, and then copy-and-paste it.
21
+
22
+ // Trace events are for tracking application performance and resource usage.
23
+ // Macros are provided to track:
24
+ // Begin and end of function calls
25
+ // Counters
26
+ //
27
+ // Events are issued against categories. Whereas LOG's
28
+ // categories are statically defined, TRACE categories are created
29
+ // implicitly with a string. For example:
30
+ // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent",
31
+ // TRACE_EVENT_SCOPE_THREAD)
32
+ //
33
+ // It is often the case that one trace may belong in multiple categories at the
34
+ // same time. The first argument to the trace can be a comma-separated list of
35
+ // categories, forming a category group, like:
36
+ //
37
+ // TRACE_EVENT_INSTANT0("input,views", "OnMouseOver", TRACE_EVENT_SCOPE_THREAD)
38
+ //
39
+ // We can enable/disable tracing of OnMouseOver by enabling/disabling either
40
+ // category.
41
+ //
42
+ // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
43
+ // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
44
+ // doSomethingCostly()
45
+ // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
46
+ // Note: our tools can't always determine the correct BEGIN/END pairs unless
47
+ // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
48
+ // need them to be in separate scopes.
49
+ //
50
+ // A common use case is to trace entire function scopes. This
51
+ // issues a trace BEGIN and END automatically:
52
+ // void doSomethingCostly() {
53
+ // TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
54
+ // ...
55
+ // }
56
+ //
57
+ // Additional parameters can be associated with an event:
58
+ // void doSomethingCostly2(int howMuch) {
59
+ // TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
60
+ // "howMuch", howMuch);
61
+ // ...
62
+ // }
63
+ //
64
+ // The trace system will automatically add to this information the
65
+ // current process id, thread id, and a timestamp in microseconds.
66
+ //
67
+ // To trace an asynchronous procedure such as an IPC send/receive, use
68
+ // ASYNC_BEGIN and ASYNC_END:
69
+ // [single threaded sender code]
70
+ // static int send_count = 0;
71
+ // ++send_count;
72
+ // TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
73
+ // Send(new MyMessage(send_count));
74
+ // [receive code]
75
+ // void OnMyMessage(send_count) {
76
+ // TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
77
+ // }
78
+ // The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
79
+ // ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
80
+ // Pointers can be used for the ID parameter, and they will be mangled
81
+ // internally so that the same pointer on two different processes will not
82
+ // match. For example:
83
+ // class MyTracedClass {
84
+ // public:
85
+ // MyTracedClass() {
86
+ // TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
87
+ // }
88
+ // ~MyTracedClass() {
89
+ // TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
90
+ // }
91
+ // }
92
+ //
93
+ // Trace event also supports counters, which is a way to track a quantity
94
+ // as it varies over time. Counters are created with the following macro:
95
+ // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
96
+ //
97
+ // Counters are process-specific. The macro itself can be issued from any
98
+ // thread, however.
99
+ //
100
+ // Sometimes, you want to track two counters at once. You can do this with two
101
+ // counter macros:
102
+ // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
103
+ // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
104
+ // Or you can do it with a combined macro:
105
+ // TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
106
+ // "bytesPinned", g_myCounterValue[0],
107
+ // "bytesAllocated", g_myCounterValue[1]);
108
+ // This indicates to the tracing UI that these counters should be displayed
109
+ // in a single graph, as a summed area chart.
110
+ //
111
+ // Since counters are in a global namespace, you may want to disambiguate with a
112
+ // unique ID, by using the TRACE_COUNTER_ID* variations.
113
+ //
114
+ // By default, trace collection is compiled in, but turned off at runtime.
115
+ // Collecting trace data is the responsibility of the embedding
116
+ // application. In Chrome's case, navigating to about:tracing will turn on
117
+ // tracing and display data collected across all active processes.
118
+ //
119
+ //
120
+ // Memory scoping note:
121
+ // Tracing copies the pointers, not the string content, of the strings passed
122
+ // in for category_group, name, and arg_names. Thus, the following code will
123
+ // cause problems:
124
+ // char* str = strdup("importantName");
125
+ // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
126
+ // free(str); // Trace system now has dangling pointer
127
+ //
128
+ // To avoid this issue with the |name| and |arg_name| parameters, use the
129
+ // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead.
130
+ // Notes: The category must always be in a long-lived char* (i.e. static const).
131
+ // The |arg_values|, when used, are always deep copied with the _COPY
132
+ // macros.
133
+ //
134
+ // When are string argument values copied:
135
+ // const char* arg_values are only referenced by default:
136
+ // TRACE_EVENT1("category", "name",
137
+ // "arg1", "literal string is only referenced");
138
+ // Use TRACE_STR_COPY to force copying of a const char*:
139
+ // TRACE_EVENT1("category", "name",
140
+ // "arg1", TRACE_STR_COPY("string will be copied"));
141
+ // std::string arg_values are always copied:
142
+ // TRACE_EVENT1("category", "name",
143
+ // "arg1", std::string("string will be copied"));
144
+ //
145
+ //
146
+ // Convertable notes:
147
+ // Converting a large data type to a string can be costly. To help with this,
148
+ // the trace framework provides an interface ConvertableToTraceFormat. If you
149
+ // inherit from it and implement the AppendAsTraceFormat method the trace
150
+ // framework will call back to your object to convert a trace output time. This
151
+ // means, if the category for the event is disabled, the conversion will not
152
+ // happen.
153
+ //
154
+ // class MyData : public base::trace_event::ConvertableToTraceFormat {
155
+ // public:
156
+ // MyData() {}
157
+ // void AppendAsTraceFormat(std::string* out) const override {
158
+ // out->append("{\"foo\":1}");
159
+ // }
160
+ // MyData(const MyData&) = delete;
161
+ // MyData& operator=(const MyData&) = delete;
162
+ //
163
+ // private:
164
+ // ~MyData() override {}
165
+ // };
166
+ //
167
+ // TRACE_EVENT1("foo", "bar", "data",
168
+ // std::unique_ptr<ConvertableToTraceFormat>(new MyData()));
169
+ //
170
+ // The trace framework will take ownership if the passed pointer and it will
171
+ // be free'd when the trace buffer is flushed.
172
+ //
173
+ // Note, we only do the conversion when the buffer is flushed, so the provided
174
+ // data object should not be modified after it's passed to the trace framework.
175
+ //
176
+ //
177
+ // Thread Safety:
178
+ // A thread safe singleton and mutex are used for thread safety. Category
179
+ // enabled flags are used to limit the performance impact when the system
180
+ // is not enabled.
181
+ //
182
+ // TRACE_EVENT macros first cache a pointer to a category. The categories are
183
+ // statically allocated and safe at all times, even after exit. Fetching a
184
+ // category is protected by the TraceLog::lock_. Multiple threads initializing
185
+ // the static variable is safe, as they will be serialized by the lock and
186
+ // multiple calls will return the same pointer to the category.
187
+ //
188
+ // Then the category_group_enabled flag is checked. This is a unsigned char, and
189
+ // not intended to be multithread safe. It optimizes access to AddTraceEvent
190
+ // which is threadsafe internally via TraceLog::lock_. The enabled flag may
191
+ // cause some threads to incorrectly call or skip calling AddTraceEvent near
192
+ // the time of the system being enabled or disabled. This is acceptable as
193
+ // we tolerate some data loss while the system is being enabled/disabled and
194
+ // because AddTraceEvent is threadsafe internally and checks the enabled state
195
+ // again under lock.
196
+ //
197
+ // Without the use of these static category pointers and enabled flags all
198
+ // trace points would carry a significant performance cost of acquiring a lock
199
+ // and resolving the category.
200
+
201
+ // Check that nobody includes this file directly. Clients are supposed to
202
+ // include the surrounding "trace_event.h" of their project instead.
203
+ #if defined(TRACE_EVENT0)
204
+ #error "Another copy of this file has already been included."
205
+ #endif
206
+
207
+ // This will mark the trace event as disabled by default. The user will need
208
+ // to explicitly enable the event.
209
+ #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
210
+
211
+ // Records a pair of begin and end events called "name" for the current
212
+ // scope, with 0, 1 or 2 associated arguments. If the category is not
213
+ // enabled, then this does nothing.
214
+ // - category and name strings must have application lifetime (statics or
215
+ // literals). They may not include " chars.
216
+ #define TRACE_EVENT0(category_group, name) \
217
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name)
218
+ #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_flags) \
219
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \
220
+ flow_flags)
221
+ #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
222
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val)
223
+ #define TRACE_EVENT_WITH_FLOW1(category_group, name, bind_id, flow_flags, \
224
+ arg1_name, arg1_val) \
225
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \
226
+ flow_flags, arg1_name, arg1_val)
227
+ #define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \
228
+ arg2_val) \
229
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, \
230
+ arg2_name, arg2_val)
231
+ #define TRACE_EVENT_WITH_FLOW2(category_group, name, bind_id, flow_flags, \
232
+ arg1_name, arg1_val, arg2_name, arg2_val) \
233
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \
234
+ flow_flags, arg1_name, arg1_val, \
235
+ arg2_name, arg2_val)
236
+
237
+ // Records a single event called "name" immediately, with 0, 1 or 2
238
+ // associated arguments. If the category is not enabled, then this
239
+ // does nothing.
240
+ // - category and name strings must have application lifetime (statics or
241
+ // literals). They may not include " chars.
242
+ #define TRACE_EVENT_INSTANT0(category_group, name, scope) \
243
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
244
+ TRACE_EVENT_FLAG_NONE | scope)
245
+ #define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \
246
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
247
+ TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val)
248
+ #define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \
249
+ arg2_name, arg2_val) \
250
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
251
+ TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val, \
252
+ arg2_name, arg2_val)
253
+ #define TRACE_EVENT_COPY_INSTANT0(category_group, name, scope) \
254
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
255
+ TRACE_EVENT_FLAG_COPY | scope)
256
+ #define TRACE_EVENT_COPY_INSTANT1(category_group, name, scope, arg1_name, \
257
+ arg1_val) \
258
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
259
+ TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val)
260
+ #define TRACE_EVENT_COPY_INSTANT2(category_group, name, scope, arg1_name, \
261
+ arg1_val, arg2_name, arg2_val) \
262
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \
263
+ TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val, \
264
+ arg2_name, arg2_val)
265
+
266
+ #define TRACE_EVENT_INSTANT_WITH_TIMESTAMP0(category_group, name, scope, \
267
+ timestamp) \
268
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
269
+ TRACE_EVENT_PHASE_INSTANT, category_group, name, timestamp, \
270
+ TRACE_EVENT_FLAG_NONE | scope)
271
+
272
+ #define TRACE_EVENT_INSTANT_WITH_TIMESTAMP1(category_group, name, scope, \
273
+ timestamp, arg_name, arg_val) \
274
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
275
+ TRACE_EVENT_PHASE_INSTANT, category_group, name, timestamp, \
276
+ TRACE_EVENT_FLAG_NONE | scope, arg_name, arg_val)
277
+
278
+ // Records a single BEGIN event called "name" immediately, with 0, 1 or 2
279
+ // associated arguments. If the category is not enabled, then this
280
+ // does nothing.
281
+ // - category and name strings must have application lifetime (statics or
282
+ // literals). They may not include " chars.
283
+ #define TRACE_EVENT_BEGIN(category_group, name, ...) \
284
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
285
+ TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__)
286
+ #define TRACE_EVENT_BEGIN0(category_group, name) \
287
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
288
+ TRACE_EVENT_FLAG_NONE)
289
+ #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \
290
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
291
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
292
+ #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \
293
+ arg2_name, arg2_val) \
294
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
295
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
296
+ arg2_name, arg2_val)
297
+ #define TRACE_EVENT_COPY_BEGIN0(category_group, name) \
298
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
299
+ TRACE_EVENT_FLAG_COPY)
300
+ #define TRACE_EVENT_COPY_BEGIN1(category_group, name, arg1_name, arg1_val) \
301
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
302
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
303
+ #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \
304
+ arg2_name, arg2_val) \
305
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \
306
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
307
+ arg2_name, arg2_val)
308
+
309
+ // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided.
310
+ // - |id| is used to match the _BEGIN event with the _END event.
311
+ // Events are considered to match if their category_group, name and id values
312
+ // all match. |id| must either be a pointer or an integer value up to 64 bits.
313
+ // If it's a pointer, the bits will be xored with a hash of the process ID so
314
+ // that the same pointer on two different processes will not collide.
315
+ #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category_group, name, id, \
316
+ thread_id, timestamp) \
317
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
318
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
319
+ timestamp, TRACE_EVENT_FLAG_NONE)
320
+ #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \
321
+ category_group, name, id, thread_id, timestamp) \
322
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
323
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
324
+ timestamp, TRACE_EVENT_FLAG_COPY)
325
+ #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP1( \
326
+ category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \
327
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
328
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
329
+ timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
330
+ #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP2( \
331
+ category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \
332
+ arg2_name, arg2_val) \
333
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
334
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
335
+ timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \
336
+ arg2_val)
337
+
338
+ // Records a single END event for "name" immediately. If the category
339
+ // is not enabled, then this does nothing.
340
+ // - category and name strings must have application lifetime (statics or
341
+ // literals). They may not include " chars.
342
+ #define TRACE_EVENT_END(category_group, name, ...) \
343
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
344
+ TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__)
345
+ #define TRACE_EVENT_END0(category_group, name) \
346
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
347
+ TRACE_EVENT_FLAG_NONE)
348
+ #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \
349
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
350
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
351
+ #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, arg2_name, \
352
+ arg2_val) \
353
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
354
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
355
+ arg2_name, arg2_val)
356
+ #define TRACE_EVENT_COPY_END0(category_group, name) \
357
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
358
+ TRACE_EVENT_FLAG_COPY)
359
+ #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \
360
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
361
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
362
+ #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \
363
+ arg2_name, arg2_val) \
364
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \
365
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
366
+ arg2_name, arg2_val)
367
+
368
+ #define TRACE_EVENT_MARK_WITH_TIMESTAMP0(category_group, name, timestamp) \
369
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
370
+ TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
371
+ TRACE_EVENT_FLAG_NONE)
372
+
373
+ #define TRACE_EVENT_MARK_WITH_TIMESTAMP1(category_group, name, timestamp, \
374
+ arg1_name, arg1_val) \
375
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
376
+ TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
377
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
378
+
379
+ #define TRACE_EVENT_MARK_WITH_TIMESTAMP2( \
380
+ category_group, name, timestamp, arg1_name, arg1_val, arg2_name, arg2_val) \
381
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
382
+ TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
383
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
384
+
385
+ #define TRACE_EVENT_COPY_MARK(category_group, name) \
386
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_MARK, category_group, name, \
387
+ TRACE_EVENT_FLAG_COPY)
388
+
389
+ #define TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(category_group, name, timestamp) \
390
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
391
+ TRACE_EVENT_PHASE_MARK, category_group, name, timestamp, \
392
+ TRACE_EVENT_FLAG_COPY)
393
+
394
+ // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided.
395
+ // - |id| is used to match the _BEGIN event with the _END event.
396
+ // Events are considered to match if their category_group, name and id values
397
+ // all match. |id| must either be a pointer or an integer value up to 64 bits.
398
+ // If it's a pointer, the bits will be xored with a hash of the process ID so
399
+ // that the same pointer on two different processes will not collide.
400
+ #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, name, id, \
401
+ thread_id, timestamp) \
402
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
403
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
404
+ timestamp, TRACE_EVENT_FLAG_NONE)
405
+ #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \
406
+ category_group, name, id, thread_id, timestamp) \
407
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
408
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
409
+ timestamp, TRACE_EVENT_FLAG_COPY)
410
+ #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP1( \
411
+ category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \
412
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
413
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
414
+ timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
415
+ #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP2( \
416
+ category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \
417
+ arg2_name, arg2_val) \
418
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
419
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
420
+ timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \
421
+ arg2_val)
422
+
423
+ // Records the value of a counter called "name" immediately. Value
424
+ // must be representable as a 32 bit integer.
425
+ // - category and name strings must have application lifetime (statics or
426
+ // literals). They may not include " chars.
427
+ #define TRACE_COUNTER1(category_group, name, value) \
428
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
429
+ TRACE_EVENT_FLAG_NONE, "value", \
430
+ static_cast<int>(value))
431
+ #define TRACE_COPY_COUNTER1(category_group, name, value) \
432
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
433
+ TRACE_EVENT_FLAG_COPY, "value", \
434
+ static_cast<int>(value))
435
+
436
+ // Records the values of a multi-parted counter called "name" immediately.
437
+ // The UI will treat value1 and value2 as parts of a whole, displaying their
438
+ // values as a stacked-bar chart.
439
+ // - category and name strings must have application lifetime (statics or
440
+ // literals). They may not include " chars.
441
+ #define TRACE_COUNTER2(category_group, name, value1_name, value1_val, \
442
+ value2_name, value2_val) \
443
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
444
+ TRACE_EVENT_FLAG_NONE, value1_name, \
445
+ static_cast<int>(value1_val), value2_name, \
446
+ static_cast<int>(value2_val))
447
+ #define TRACE_COPY_COUNTER2(category_group, name, value1_name, value1_val, \
448
+ value2_name, value2_val) \
449
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \
450
+ TRACE_EVENT_FLAG_COPY, value1_name, \
451
+ static_cast<int>(value1_val), value2_name, \
452
+ static_cast<int>(value2_val))
453
+
454
+ // Similar to TRACE_COUNTERx, but with a custom |timestamp| provided.
455
+ #define TRACE_COUNTER_WITH_TIMESTAMP1(category_group, name, timestamp, value) \
456
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
457
+ TRACE_EVENT_PHASE_COUNTER, category_group, name, timestamp, \
458
+ TRACE_EVENT_FLAG_NONE, "value", static_cast<int>(value))
459
+
460
+ #define TRACE_COUNTER_WITH_TIMESTAMP2(category_group, name, timestamp, \
461
+ value1_name, value1_val, value2_name, \
462
+ value2_val) \
463
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
464
+ TRACE_EVENT_PHASE_COUNTER, category_group, name, timestamp, \
465
+ TRACE_EVENT_FLAG_NONE, value1_name, static_cast<int>(value1_val), \
466
+ value2_name, static_cast<int>(value2_val))
467
+
468
+ // Records the value of a counter called "name" immediately. Value
469
+ // must be representable as a 32 bit integer.
470
+ // - category and name strings must have application lifetime (statics or
471
+ // literals). They may not include " chars.
472
+ // - |id| is used to disambiguate counters with the same name. It must either
473
+ // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
474
+ // will be xored with a hash of the process ID so that the same pointer on
475
+ // two different processes will not collide.
476
+ #define TRACE_COUNTER_ID1(category_group, name, id, value) \
477
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \
478
+ name, id, TRACE_EVENT_FLAG_NONE, "value", \
479
+ static_cast<int>(value))
480
+ #define TRACE_COPY_COUNTER_ID1(category_group, name, id, value) \
481
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \
482
+ name, id, TRACE_EVENT_FLAG_COPY, "value", \
483
+ static_cast<int>(value))
484
+
485
+ // Records the values of a multi-parted counter called "name" immediately.
486
+ // The UI will treat value1 and value2 as parts of a whole, displaying their
487
+ // values as a stacked-bar chart.
488
+ // - category and name strings must have application lifetime (statics or
489
+ // literals). They may not include " chars.
490
+ // - |id| is used to disambiguate counters with the same name. It must either
491
+ // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
492
+ // will be xored with a hash of the process ID so that the same pointer on
493
+ // two different processes will not collide.
494
+ #define TRACE_COUNTER_ID2(category_group, name, id, value1_name, value1_val, \
495
+ value2_name, value2_val) \
496
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \
497
+ name, id, TRACE_EVENT_FLAG_NONE, \
498
+ value1_name, static_cast<int>(value1_val), \
499
+ value2_name, static_cast<int>(value2_val))
500
+ #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \
501
+ value1_val, value2_name, value2_val) \
502
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \
503
+ name, id, TRACE_EVENT_FLAG_COPY, \
504
+ value1_name, static_cast<int>(value1_val), \
505
+ value2_name, static_cast<int>(value2_val))
506
+
507
+ // TRACE_EVENT_SAMPLE_* events are injected by the sampling profiler.
508
+ #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP0(category_group, name, \
509
+ thread_id, timestamp) \
510
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
511
+ TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
512
+ TRACE_EVENT_FLAG_NONE)
513
+
514
+ #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP1( \
515
+ category_group, name, thread_id, timestamp, arg1_name, arg1_val) \
516
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
517
+ TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
518
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
519
+
520
+ #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP2(category_group, name, \
521
+ thread_id, timestamp, \
522
+ arg1_name, arg1_val, \
523
+ arg2_name, arg2_val) \
524
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
525
+ TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
526
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
527
+
528
+ #define TRACE_EVENT_SAMPLE_WITH_ID1(category_group, name, id, arg1_name, \
529
+ arg1_val) \
530
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SAMPLE, category_group, \
531
+ name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
532
+ arg1_val)
533
+
534
+ // ASYNC_STEP_* APIs should be only used by legacy code. New code should
535
+ // consider using NESTABLE_ASYNC_* APIs to describe substeps within an async
536
+ // event.
537
+ // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
538
+ // associated arguments. If the category is not enabled, then this
539
+ // does nothing.
540
+ // - category and name strings must have application lifetime (statics or
541
+ // literals). They may not include " chars.
542
+ // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
543
+ // events are considered to match if their category_group, name and id values
544
+ // all match. |id| must either be a pointer or an integer value up to 64 bits.
545
+ // If it's a pointer, the bits will be xored with a hash of the process ID so
546
+ // that the same pointer on two different processes will not collide.
547
+ //
548
+ // An asynchronous operation can consist of multiple phases. The first phase is
549
+ // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
550
+ // ASYNC_STEP_INTO or ASYNC_STEP_PAST macros. The ASYNC_STEP_INTO macro will
551
+ // annotate the block following the call. The ASYNC_STEP_PAST macro will
552
+ // annotate the block prior to the call. Note that any particular event must use
553
+ // only STEP_INTO or STEP_PAST macros; they can not mix and match. When the
554
+ // operation completes, call ASYNC_END.
555
+ //
556
+ // An ASYNC trace typically occurs on a single thread (if not, they will only be
557
+ // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
558
+ // operation must use the same |name| and |id|. Each step can have its own
559
+ // args.
560
+ #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
561
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
562
+ category_group, name, id, \
563
+ TRACE_EVENT_FLAG_NONE)
564
+ #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
565
+ arg1_val) \
566
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
567
+ category_group, name, id, \
568
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
569
+ #define TRACE_EVENT_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
570
+ arg1_val, arg2_name, arg2_val) \
571
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
572
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
573
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
574
+ #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category_group, name, id) \
575
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
576
+ category_group, name, id, \
577
+ TRACE_EVENT_FLAG_COPY)
578
+ #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
579
+ arg1_val) \
580
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
581
+ category_group, name, id, \
582
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
583
+ #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
584
+ arg1_val, arg2_name, arg2_val) \
585
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
586
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
587
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val)
588
+
589
+ // Similar to TRACE_EVENT_ASYNC_BEGINx but with a custom |at| timestamp
590
+ // provided.
591
+ #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, id, \
592
+ timestamp) \
593
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
594
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
595
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
596
+ #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \
597
+ category_group, name, id, timestamp, arg1_name, arg1_val) \
598
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
599
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
600
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
601
+ arg1_name, arg1_val)
602
+ #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP2(category_group, name, id, \
603
+ timestamp, arg1_name, \
604
+ arg1_val, arg2_name, arg2_val) \
605
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
606
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
607
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
608
+ arg1_name, arg1_val, arg2_name, arg2_val)
609
+ #define TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, id, \
610
+ timestamp) \
611
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
612
+ TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
613
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY)
614
+
615
+ // Records a single ASYNC_STEP_INTO event for |step| immediately. If the
616
+ // category is not enabled, then this does nothing. The |name| and |id| must
617
+ // match the ASYNC_BEGIN event above. The |step| param identifies this step
618
+ // within the async event. This should be called at the beginning of the next
619
+ // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
620
+ // ASYNC_STEP_PAST events.
621
+ #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \
622
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \
623
+ category_group, name, id, \
624
+ TRACE_EVENT_FLAG_NONE, "step", step)
625
+ #define TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, \
626
+ arg1_name, arg1_val) \
627
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
628
+ TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \
629
+ TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val)
630
+
631
+ // Similar to TRACE_EVENT_ASYNC_STEP_INTOx but with a custom |at| timestamp
632
+ // provided.
633
+ #define TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(category_group, name, id, \
634
+ step, timestamp) \
635
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
636
+ TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \
637
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
638
+ "step", step)
639
+
640
+ // Records a single ASYNC_STEP_PAST event for |step| immediately. If the
641
+ // category is not enabled, then this does nothing. The |name| and |id| must
642
+ // match the ASYNC_BEGIN event above. The |step| param identifies this step
643
+ // within the async event. This should be called at the beginning of the next
644
+ // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
645
+ // ASYNC_STEP_INTO events.
646
+ #define TRACE_EVENT_ASYNC_STEP_PAST0(category_group, name, id, step) \
647
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \
648
+ category_group, name, id, \
649
+ TRACE_EVENT_FLAG_NONE, "step", step)
650
+ #define TRACE_EVENT_ASYNC_STEP_PAST1(category_group, name, id, step, \
651
+ arg1_name, arg1_val) \
652
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
653
+ TRACE_EVENT_PHASE_ASYNC_STEP_PAST, category_group, name, id, \
654
+ TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val)
655
+
656
+ // Records a single ASYNC_END event for "name" immediately. If the category
657
+ // is not enabled, then this does nothing.
658
+ #define TRACE_EVENT_ASYNC_END0(category_group, name, id) \
659
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
660
+ category_group, name, id, \
661
+ TRACE_EVENT_FLAG_NONE)
662
+ #define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \
663
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
664
+ category_group, name, id, \
665
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
666
+ #define TRACE_EVENT_ASYNC_END2(category_group, name, id, arg1_name, arg1_val, \
667
+ arg2_name, arg2_val) \
668
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
669
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
670
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
671
+ #define TRACE_EVENT_COPY_ASYNC_END0(category_group, name, id) \
672
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
673
+ category_group, name, id, \
674
+ TRACE_EVENT_FLAG_COPY)
675
+ #define TRACE_EVENT_COPY_ASYNC_END1(category_group, name, id, arg1_name, \
676
+ arg1_val) \
677
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
678
+ category_group, name, id, \
679
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
680
+ #define TRACE_EVENT_COPY_ASYNC_END2(category_group, name, id, arg1_name, \
681
+ arg1_val, arg2_name, arg2_val) \
682
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
683
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
684
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val)
685
+
686
+ // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided.
687
+ #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, name, id, \
688
+ timestamp) \
689
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
690
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
691
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
692
+ #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1(category_group, name, id, \
693
+ timestamp, arg1_name, arg1_val) \
694
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
695
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
696
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
697
+ arg1_name, arg1_val)
698
+ #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP2(category_group, name, id, \
699
+ timestamp, arg1_name, arg1_val, \
700
+ arg2_name, arg2_val) \
701
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
702
+ TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
703
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
704
+ arg1_name, arg1_val, arg2_name, arg2_val)
705
+
706
+ // NESTABLE_ASYNC_* APIs are used to describe an async operation, which can
707
+ // be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC
708
+ // events.
709
+ // - category and name strings must have application lifetime (statics or
710
+ // literals). They may not include " chars.
711
+ // - A pair of NESTABLE_ASYNC_BEGIN event and NESTABLE_ASYNC_END event is
712
+ // considered as a match if their category_group, name and id all match.
713
+ // - |id| must either be a pointer or an integer value up to 64 bits.
714
+ // If it's a pointer, the bits will be xored with a hash of the process ID so
715
+ // that the same pointer on two different processes will not collide.
716
+ // - |id| is used to match a child NESTABLE_ASYNC event with its parent
717
+ // NESTABLE_ASYNC event. Therefore, events in the same nested event tree must
718
+ // be logged using the same id and category_group.
719
+ //
720
+ // Unmatched NESTABLE_ASYNC_END event will be parsed as an event that starts
721
+ // at the first NESTABLE_ASYNC event of that id, and unmatched
722
+ // NESTABLE_ASYNC_BEGIN event will be parsed as an event that ends at the last
723
+ // NESTABLE_ASYNC event of that id. Corresponding warning messages for
724
+ // unmatched events will be shown in the analysis view.
725
+
726
+ // Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with
727
+ // 0, 1 or 2 associated arguments. If the category is not enabled, then this
728
+ // does nothing.
729
+ #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \
730
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
731
+ category_group, name, id, \
732
+ TRACE_EVENT_FLAG_NONE)
733
+ #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
734
+ arg1_val) \
735
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
736
+ category_group, name, id, \
737
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
738
+ #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
739
+ arg1_val, arg2_name, arg2_val) \
740
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
741
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
742
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
743
+ // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0
744
+ // or 2 associated arguments. If the category is not enabled, then this does
745
+ // nothing.
746
+ #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \
747
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
748
+ category_group, name, id, \
749
+ TRACE_EVENT_FLAG_NONE)
750
+ // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 1
751
+ // associated argument. If the category is not enabled, then this does nothing.
752
+ #define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \
753
+ arg1_val) \
754
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
755
+ category_group, name, id, \
756
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
757
+ #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
758
+ arg1_val, arg2_name, arg2_val) \
759
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
760
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
761
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
762
+
763
+ // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately,
764
+ // with none, one or two associated argument. If the category is not enabled,
765
+ // then this does nothing.
766
+ #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT0(category_group, name, id) \
767
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \
768
+ category_group, name, id, \
769
+ TRACE_EVENT_FLAG_NONE)
770
+
771
+ #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT1(category_group, name, id, \
772
+ arg1_name, arg1_val) \
773
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \
774
+ category_group, name, id, \
775
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
776
+
777
+ #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( \
778
+ category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \
779
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
780
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, category_group, name, id, \
781
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
782
+
783
+ #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2( \
784
+ category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \
785
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
786
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
787
+ TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
788
+ arg2_name, arg2_val)
789
+ #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2( \
790
+ category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \
791
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
792
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
793
+ TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
794
+ arg2_name, arg2_val)
795
+
796
+ // Similar to TRACE_EVENT_NESTABLE_ASYNC_{BEGIN,END}x but with a custom
797
+ // |timestamp| provided.
798
+ #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, \
799
+ id, timestamp) \
800
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
801
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
802
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
803
+ #define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \
804
+ id, timestamp) \
805
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
806
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
807
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
808
+ #define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP1( \
809
+ category_group, name, id, timestamp, arg1_name, arg1_val) \
810
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
811
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
812
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
813
+ arg1_name, arg1_val)
814
+ #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT_WITH_TIMESTAMP0( \
815
+ category_group, name, id, timestamp) \
816
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
817
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, category_group, name, id, \
818
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE)
819
+ #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( \
820
+ category_group, name, id, timestamp) \
821
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
822
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
823
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY)
824
+ #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( \
825
+ category_group, name, id, timestamp) \
826
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
827
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
828
+ TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY)
829
+
830
+ // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2
831
+ // associated arguments. If the category is not enabled, then this
832
+ // does nothing.
833
+ // - category and name strings must have application lifetime (statics or
834
+ // literals). They may not include " chars.
835
+ // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW
836
+ // events are considered to match if their category_group, name and id values
837
+ // all match. |id| must either be a pointer or an integer value up to 64 bits.
838
+ // If it's a pointer, the bits will be xored with a hash of the process ID so
839
+ // that the same pointer on two different processes will not collide.
840
+ // FLOW events are different from ASYNC events in how they are drawn by the
841
+ // tracing UI. A FLOW defines asynchronous data flow, such as posting a task
842
+ // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be
843
+ // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar
844
+ // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined
845
+ // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP
846
+ // macros. When the operation completes, call FLOW_END. An async operation can
847
+ // span threads and processes, but all events in that operation must use the
848
+ // same |name| and |id|. Each event can have its own args.
849
+ #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \
850
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
851
+ category_group, name, id, \
852
+ TRACE_EVENT_FLAG_NONE)
853
+ #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \
854
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
855
+ category_group, name, id, \
856
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
857
+ #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \
858
+ arg2_name, arg2_val) \
859
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
860
+ TRACE_EVENT_PHASE_FLOW_BEGIN, category_group, name, id, \
861
+ TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
862
+ #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \
863
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
864
+ category_group, name, id, \
865
+ TRACE_EVENT_FLAG_COPY)
866
+ #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \
867
+ arg1_val) \
868
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
869
+ category_group, name, id, \
870
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
871
+ #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \
872
+ arg1_val, arg2_name, arg2_val) \
873
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
874
+ TRACE_EVENT_PHASE_FLOW_BEGIN, category_group, name, id, \
875
+ TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val)
876
+
877
+ // Records a single FLOW_STEP event for |step| immediately. If the category
878
+ // is not enabled, then this does nothing. The |name| and |id| must match the
879
+ // FLOW_BEGIN event above. The |step| param identifies this step within the
880
+ // async event. This should be called at the beginning of the next phase of an
881
+ // asynchronous operation.
882
+ #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \
883
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
884
+ category_group, name, id, \
885
+ TRACE_EVENT_FLAG_NONE, "step", step)
886
+ #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, arg1_name, \
887
+ arg1_val) \
888
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
889
+ TRACE_EVENT_PHASE_FLOW_STEP, category_group, name, id, \
890
+ TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val)
891
+ #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \
892
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
893
+ category_group, name, id, \
894
+ TRACE_EVENT_FLAG_COPY, "step", step)
895
+ #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, arg1_name, \
896
+ arg1_val) \
897
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
898
+ TRACE_EVENT_PHASE_FLOW_STEP, category_group, name, id, \
899
+ TRACE_EVENT_FLAG_COPY, "step", step, arg1_name, arg1_val)
900
+
901
+ // Records a single FLOW_END event for "name" immediately. If the category
902
+ // is not enabled, then this does nothing.
903
+ #define TRACE_EVENT_FLOW_END0(category_group, name, id) \
904
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
905
+ name, id, TRACE_EVENT_FLAG_NONE)
906
+ #define TRACE_EVENT_FLOW_END_BIND_TO_ENCLOSING0(category_group, name, id) \
907
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
908
+ name, id, \
909
+ TRACE_EVENT_FLAG_BIND_TO_ENCLOSING)
910
+ #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \
911
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
912
+ name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
913
+ arg1_val)
914
+ #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \
915
+ arg2_name, arg2_val) \
916
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
917
+ name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \
918
+ arg1_val, arg2_name, arg2_val)
919
+ #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \
920
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
921
+ name, id, TRACE_EVENT_FLAG_COPY)
922
+ #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \
923
+ arg1_val) \
924
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
925
+ name, id, TRACE_EVENT_FLAG_COPY, arg1_name, \
926
+ arg1_val)
927
+ #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \
928
+ arg1_val, arg2_name, arg2_val) \
929
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \
930
+ name, id, TRACE_EVENT_FLAG_COPY, arg1_name, \
931
+ arg1_val, arg2_name, arg2_val)
932
+
933
+ // Special trace event macro to trace task execution with the location where it
934
+ // was posted from.
935
+ #define TRACE_TASK_EXECUTION(run_function, task) \
936
+ INTERNAL_TRACE_TASK_EXECUTION(run_function, task)
937
+
938
+ // TRACE_EVENT_METADATA* events are information related to other
939
+ // injected events, not events in their own right.
940
+ #define TRACE_EVENT_METADATA1(category_group, name, arg1_name, arg1_val) \
941
+ INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, arg1_name, arg1_val)
942
+
943
+ // Records a clock sync event.
944
+ #define TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id) \
945
+ INTERNAL_TRACE_EVENT_ADD( \
946
+ TRACE_EVENT_PHASE_CLOCK_SYNC, "__metadata", "clock_sync", \
947
+ TRACE_EVENT_FLAG_NONE, "sync_id", sync_id)
948
+ #define TRACE_EVENT_CLOCK_SYNC_ISSUER(sync_id, issue_ts, issue_end_ts) \
949
+ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \
950
+ TRACE_EVENT_PHASE_CLOCK_SYNC, "__metadata", "clock_sync", \
951
+ issue_end_ts, TRACE_EVENT_FLAG_NONE, \
952
+ "sync_id", sync_id, "issue_ts", issue_ts)
953
+
954
+ // Macros to track the life time and value of arbitrary client objects.
955
+ // See also TraceTrackableObject.
956
+ #define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) \
957
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
958
+ TRACE_EVENT_PHASE_CREATE_OBJECT, category_group, name, id, \
959
+ TRACE_EVENT_FLAG_NONE)
960
+
961
+ #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, \
962
+ snapshot) \
963
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
964
+ TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name, \
965
+ id, TRACE_EVENT_FLAG_NONE, "snapshot", snapshot)
966
+
967
+ #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( \
968
+ category_group, name, id, timestamp, snapshot) \
969
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
970
+ TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name, \
971
+ id, TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \
972
+ "snapshot", snapshot)
973
+
974
+ #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \
975
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
976
+ TRACE_EVENT_PHASE_DELETE_OBJECT, category_group, name, id, \
977
+ TRACE_EVENT_FLAG_NONE)
978
+
979
+ // Records entering and leaving trace event contexts. |category_group| and
980
+ // |name| specify the context category and type. |context| is a
981
+ // snapshotted context object id.
982
+ #define TRACE_EVENT_ENTER_CONTEXT(category_group, name, context) \
983
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
984
+ TRACE_EVENT_PHASE_ENTER_CONTEXT, category_group, name, context, \
985
+ TRACE_EVENT_FLAG_NONE)
986
+ #define TRACE_EVENT_LEAVE_CONTEXT(category_group, name, context) \
987
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID( \
988
+ TRACE_EVENT_PHASE_LEAVE_CONTEXT, category_group, name, context, \
989
+ TRACE_EVENT_FLAG_NONE)
990
+ #define TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \
991
+ INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context)
992
+
993
+ // Macro to specify that two trace IDs are identical. For example,
994
+ // TRACE_LINK_IDS(
995
+ // "category", "name",
996
+ // TRACE_ID_WITH_SCOPE("net::URLRequest", 0x1000),
997
+ // TRACE_ID_WITH_SCOPE("blink::ResourceFetcher::FetchRequest", 0x2000))
998
+ // tells the trace consumer that events with ID ("net::URLRequest", 0x1000) from
999
+ // the current process have the same ID as events with ID
1000
+ // ("blink::ResourceFetcher::FetchRequest", 0x2000).
1001
+ #define TRACE_LINK_IDS(category_group, name, id, linked_id) \
1002
+ INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id, linked_id);
1003
+
1004
+ // Macro to efficiently determine if a given category group is enabled.
1005
+ #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \
1006
+ do { \
1007
+ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
1008
+ if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
1009
+ *ret = true; \
1010
+ } else { \
1011
+ *ret = false; \
1012
+ } \
1013
+ } while (0)
1014
+
1015
+ // Macro to explicitly warm up a given category group. This could be useful in
1016
+ // cases where we want to initialize a category group before any trace events
1017
+ // for that category group is reported. For example, to have a category group
1018
+ // always show up in the "record categories" list for manually selecting
1019
+ // settings in about://tracing.
1020
+ #define TRACE_EVENT_WARMUP_CATEGORY(category_group) \
1021
+ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group)
1022
+
1023
+ // Macro to efficiently determine, through polling, if a new trace has begun.
1024
+ #define TRACE_EVENT_IS_NEW_TRACE(ret) \
1025
+ do { \
1026
+ static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \
1027
+ int num_traces_recorded = TRACE_EVENT_API_GET_NUM_TRACES_RECORDED(); \
1028
+ if (num_traces_recorded != -1 && \
1029
+ num_traces_recorded != \
1030
+ INTERNAL_TRACE_EVENT_UID(lastRecordingNumber)) { \
1031
+ INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = num_traces_recorded; \
1032
+ *ret = true; \
1033
+ } else { \
1034
+ *ret = false; \
1035
+ } \
1036
+ } while (0)
1037
+
1038
+ // Notes regarding the following definitions:
1039
+ // New values can be added and propagated to third party libraries, but existing
1040
+ // definitions must never be changed, because third party libraries may use old
1041
+ // definitions.
1042
+
1043
+ // Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
1044
+ #define TRACE_EVENT_PHASE_BEGIN ('B')
1045
+ #define TRACE_EVENT_PHASE_END ('E')
1046
+ #define TRACE_EVENT_PHASE_COMPLETE ('X')
1047
+ #define TRACE_EVENT_PHASE_INSTANT ('I')
1048
+ #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
1049
+ #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T')
1050
+ #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p')
1051
+ #define TRACE_EVENT_PHASE_ASYNC_END ('F')
1052
+ #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b')
1053
+ #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e')
1054
+ #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n')
1055
+ #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s')
1056
+ #define TRACE_EVENT_PHASE_FLOW_STEP ('t')
1057
+ #define TRACE_EVENT_PHASE_FLOW_END ('f')
1058
+ #define TRACE_EVENT_PHASE_METADATA ('M')
1059
+ #define TRACE_EVENT_PHASE_COUNTER ('C')
1060
+ #define TRACE_EVENT_PHASE_SAMPLE ('P')
1061
+ #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N')
1062
+ #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O')
1063
+ #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D')
1064
+ #define TRACE_EVENT_PHASE_MEMORY_DUMP ('v')
1065
+ #define TRACE_EVENT_PHASE_MARK ('R')
1066
+ #define TRACE_EVENT_PHASE_CLOCK_SYNC ('c')
1067
+ #define TRACE_EVENT_PHASE_ENTER_CONTEXT ('(')
1068
+ #define TRACE_EVENT_PHASE_LEAVE_CONTEXT (')')
1069
+ #define TRACE_EVENT_PHASE_LINK_IDS ('=')
1070
+
1071
+ // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
1072
+ #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0))
1073
+ #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0))
1074
+ #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1))
1075
+ // TODO(crbug.com/639003): Free this bit after ID mangling is deprecated.
1076
+ #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2))
1077
+ #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3))
1078
+ #define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4))
1079
+ #define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5))
1080
+ #define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6))
1081
+ #define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7))
1082
+ #define TRACE_EVENT_FLAG_FLOW_IN (static_cast<unsigned int>(1 << 8))
1083
+ #define TRACE_EVENT_FLAG_FLOW_OUT (static_cast<unsigned int>(1 << 9))
1084
+ #define TRACE_EVENT_FLAG_HAS_CONTEXT_ID (static_cast<unsigned int>(1 << 10))
1085
+ #define TRACE_EVENT_FLAG_HAS_PROCESS_ID (static_cast<unsigned int>(1 << 11))
1086
+ #define TRACE_EVENT_FLAG_HAS_LOCAL_ID (static_cast<unsigned int>(1 << 12))
1087
+ #define TRACE_EVENT_FLAG_HAS_GLOBAL_ID (static_cast<unsigned int>(1 << 13))
1088
+
1089
+ #define TRACE_EVENT_FLAG_SCOPE_MASK \
1090
+ (static_cast<unsigned int>(TRACE_EVENT_FLAG_SCOPE_OFFSET | \
1091
+ TRACE_EVENT_FLAG_SCOPE_EXTRA))
1092
+
1093
+ // Type values for identifying types in the TraceValue union.
1094
+ #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
1095
+ #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
1096
+ #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
1097
+ #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
1098
+ #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
1099
+ #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
1100
+ #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
1101
+ #define TRACE_VALUE_TYPE_CONVERTABLE (static_cast<unsigned char>(8))
1102
+
1103
+ // Enum reflecting the scope of an INSTANT event. Must fit within
1104
+ // TRACE_EVENT_FLAG_SCOPE_MASK.
1105
+ #define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3))
1106
+ #define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3))
1107
+ #define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3))
1108
+
1109
+ #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
1110
+ #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
1111
+ #define TRACE_EVENT_SCOPE_NAME_THREAD ('t')
1112
+
1113
+ #endif // SRC_TRACING_TRACE_EVENT_LEGACY_H_