Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: base/trace_event/trace_event.h

Issue 2253973003: Add an explicit way of making IDs local or global (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: versioning the id field Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
7 7
8 // This header file defines implementation details of how the trace macros in 8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not 9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_event_common.h instead of here. 10 // implementation-specific should go in trace_event_common.h instead of here.
(...skipping 10 matching lines...) Expand all
21 #include "base/trace_event/heap_profiler.h" 21 #include "base/trace_event/heap_profiler.h"
22 #include "base/trace_event/trace_event_system_stats_monitor.h" 22 #include "base/trace_event/trace_event_system_stats_monitor.h"
23 #include "base/trace_event/trace_log.h" 23 #include "base/trace_event/trace_log.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 25
26 // By default, const char* argument values are assumed to have long-lived scope 26 // By default, const char* argument values are assumed to have long-lived scope
27 // and will not be copied. Use this macro to force a const char* to be copied. 27 // and will not be copied. Use this macro to force a const char* to be copied.
28 #define TRACE_STR_COPY(str) \ 28 #define TRACE_STR_COPY(str) \
29 trace_event_internal::TraceStringWithCopy(str) 29 trace_event_internal::TraceStringWithCopy(str)
30 30
31 // By default, uint64_t ID argument values are not mangled with the Process ID 31 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros,
32 // in TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. 32 // instead. By default, uint64_t ID argument values are not mangled with the
33 // Process ID in TRACE_EVENT_ASYNC macros. Use this macro to force Process ID
34 // mangling.
33 #define TRACE_ID_MANGLE(id) \ 35 #define TRACE_ID_MANGLE(id) \
34 trace_event_internal::TraceID::ForceMangle(id) 36 trace_event_internal::TraceID::ForceMangle(id)
35 37
36 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC 38 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros,
37 // macros. Use this macro to prevent Process ID mangling. 39 // instead. By default, pointers are mangled with the Process ID in
40 // TRACE_EVENT_ASYNC macros. Use this macro to prevent Process ID mangling.
38 #define TRACE_ID_DONT_MANGLE(id) \ 41 #define TRACE_ID_DONT_MANGLE(id) \
39 trace_event_internal::TraceID::DontMangle(id) 42 trace_event_internal::TraceID::DontMangle(id)
40 43
41 // By default, trace IDs are eventually converted to a single 64-bit number. Use 44 // By default, trace IDs are eventually converted to a single 64-bit number. Use
42 // this macro to add a scope string. 45 // this macro to add a scope string.
43 #define TRACE_ID_WITH_SCOPE(scope, id) \ 46 #define TRACE_ID_WITH_SCOPE(scope, id) \
44 trace_event_internal::TraceID::WithScope(scope, id) 47 trace_event_internal::TraceID::WithScope(scope, id)
45 48
49 #define TRACE_ID_GLOBAL(id) trace_event_internal::TraceID::GlobalId(id)
50 #define TRACE_ID_LOCAL(id) trace_event_internal::TraceID::LocalId(id)
51
46 // Sets the current sample state to the given category and name (both must be 52 // Sets the current sample state to the given category and name (both must be
47 // constant strings). These states are intended for a sampling profiler. 53 // constant strings). These states are intended for a sampling profiler.
48 // Implementation note: we store category and name together because we don't 54 // Implementation note: we store category and name together because we don't
49 // want the inconsistency/expense of storing two pointers. 55 // want the inconsistency/expense of storing two pointers.
50 // |thread_bucket| is [0..2] and is used to statically isolate samples in one 56 // |thread_bucket| is [0..2] and is used to statically isolate samples in one
51 // thread from others. 57 // thread from others.
52 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \ 58 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \
53 bucket_number, category, name) \ 59 bucket_number, category, name) \
54 trace_event_internal:: \ 60 trace_event_internal:: \
55 TraceEventSamplingStateScope<bucket_number>::Set(category "\0" name) 61 TraceEventSamplingStateScope<bucket_number>::Set(category "\0" name)
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 trace_event_internal::AddTraceEvent( \ 291 trace_event_internal::AddTraceEvent( \
286 TRACE_EVENT_PHASE_COMPLETE, \ 292 TRACE_EVENT_PHASE_COMPLETE, \
287 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 293 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
288 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \ 294 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \
289 TRACE_EVENT_FLAG_NONE, trace_event_internal::kNoId, \ 295 TRACE_EVENT_FLAG_NONE, trace_event_internal::kNoId, \
290 ##__VA_ARGS__); \ 296 ##__VA_ARGS__); \
291 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ 297 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \
292 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ 298 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \
293 } 299 }
294 300
295 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW( \ 301 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW( \
296 category_group, name, bind_id, flow_flags, ...) \ 302 category_group, name, bind_id, flow_flags, ...) \
297 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 303 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
298 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ 304 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \
299 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 305 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
300 unsigned int trace_event_flags = flow_flags; \ 306 trace_event_internal::TraceID trace_event_bind_id((bind_id)); \
301 trace_event_internal::TraceID trace_event_bind_id(bind_id, \ 307 unsigned int trace_event_flags = flow_flags | \
302 &trace_event_flags); \ 308 trace_event_bind_id.id_flags(); \
303 base::trace_event::TraceEventHandle h = \ 309 base::trace_event::TraceEventHandle h = \
304 trace_event_internal::AddTraceEvent( \ 310 trace_event_internal::AddTraceEvent( \
305 TRACE_EVENT_PHASE_COMPLETE, \ 311 TRACE_EVENT_PHASE_COMPLETE, \
306 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 312 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
307 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \ 313 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \
308 trace_event_flags, trace_event_bind_id.raw_id(), ##__VA_ARGS__); \ 314 trace_event_flags, trace_event_bind_id.raw_id(), ##__VA_ARGS__); \
309 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ 315 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \
310 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ 316 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \
311 } 317 }
312 318
313 // Implementation detail: internal macro to create static category and add 319 // Implementation detail: internal macro to create static category and add
314 // event if the category is enabled. 320 // event if the category is enabled.
315 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ 321 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \
316 flags, ...) \ 322 flags, ...) \
317 do { \ 323 do { \
318 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 324 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
319 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 325 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
320 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 326 trace_event_internal::TraceID trace_event_trace_id((id)); \
321 trace_event_internal::TraceID trace_event_trace_id( \ 327 unsigned int trace_event_flags = flags | \
322 id, &trace_event_flags); \ 328 trace_event_trace_id.id_flags(); \
323 trace_event_internal::AddTraceEvent( \ 329 trace_event_internal::AddTraceEvent( \
324 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 330 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
325 name, trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 331 name, trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \
326 trace_event_flags, trace_event_internal::kNoId, ##__VA_ARGS__); \ 332 trace_event_flags, trace_event_internal::kNoId, ##__VA_ARGS__); \
327 } \ 333 } \
328 } while (0) 334 } while (0)
329 335
330 // Implementation detail: internal macro to create static category and add 336 // Implementation detail: internal macro to create static category and add
331 // event if the category is enabled. 337 // event if the category is enabled.
332 #define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \ 338 #define INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP(phase, category_group, name, \
333 timestamp, flags, ...) \ 339 timestamp, flags, ...) \
334 do { \ 340 do { \
335 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 341 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
336 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 342 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
337 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 343 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
338 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 344 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
339 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \ 345 trace_event_internal::kGlobalScope, trace_event_internal::kNoId, \
340 TRACE_EVENT_API_CURRENT_THREAD_ID, \ 346 TRACE_EVENT_API_CURRENT_THREAD_ID, \
341 base::TimeTicks::FromInternalValue(timestamp), \ 347 base::TimeTicks::FromInternalValue(timestamp), \
342 flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 348 flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
343 trace_event_internal::kNoId, ##__VA_ARGS__); \ 349 trace_event_internal::kNoId, ##__VA_ARGS__); \
344 } \ 350 } \
345 } while (0) 351 } while (0)
346 352
347 // Implementation detail: internal macro to create static category and add 353 // Implementation detail: internal macro to create static category and add
348 // event if the category is enabled. 354 // event if the category is enabled.
349 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 355 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
350 phase, category_group, name, id, thread_id, timestamp, flags, ...) \ 356 phase, category_group, name, id, thread_id, timestamp, flags, ...) \
351 do { \ 357 do { \
352 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 358 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
353 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 359 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
354 unsigned int trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ 360 trace_event_internal::TraceID trace_event_trace_id((id)); \
355 trace_event_internal::TraceID trace_event_trace_id(id, \ 361 unsigned int trace_event_flags = flags | \
356 &trace_event_flags); \ 362 trace_event_trace_id.id_flags(); \
357 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 363 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
358 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 364 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
359 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 365 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \
360 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ 366 thread_id, base::TimeTicks::FromInternalValue(timestamp), \
361 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 367 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
362 trace_event_internal::kNoId, ##__VA_ARGS__); \ 368 trace_event_internal::kNoId, ##__VA_ARGS__); \
363 } \ 369 } \
364 } while (0) 370 } while (0)
365 371
366 // The trace ID and bind ID will never be mangled by this macro. 372 // This macro ignores whether the bind_id is local, global, or mangled.
367 #define INTERNAL_TRACE_EVENT_ADD_BIND_IDS(category_group, name, id, bind_id, \ 373 #define INTERNAL_TRACE_EVENT_ADD_BIND_IDS(category_group, name, id, bind_id, \
368 ...) \ 374 ...) \
369 do { \ 375 do { \
370 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 376 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
371 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 377 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
372 trace_event_internal::TraceID::DontMangle source_id(id); \ 378 trace_event_internal::TraceID source_id((id)); \
373 trace_event_internal::TraceID::DontMangle target_id(bind_id); \ 379 unsigned int source_flags = source_id.id_flags(); \
380 trace_event_internal::TraceID target_id((bind_id)); \
374 if (target_id.scope() == trace_event_internal::kGlobalScope) { \ 381 if (target_id.scope() == trace_event_internal::kGlobalScope) { \
375 trace_event_internal::AddTraceEvent( \ 382 trace_event_internal::AddTraceEvent( \
376 TRACE_EVENT_PHASE_BIND_IDS, \ 383 TRACE_EVENT_PHASE_BIND_IDS, \
377 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 384 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
378 name, source_id.scope(), source_id.raw_id(), \ 385 name, source_id.scope(), source_id.raw_id(), \
379 TRACE_EVENT_FLAG_HAS_ID, target_id.raw_id(), ##__VA_ARGS__); \ 386 source_flags, target_id.raw_id(), ##__VA_ARGS__); \
380 } else { \ 387 } else { \
381 trace_event_internal::AddTraceEvent( \ 388 trace_event_internal::AddTraceEvent( \
382 TRACE_EVENT_PHASE_BIND_IDS, \ 389 TRACE_EVENT_PHASE_BIND_IDS, \
383 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 390 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
384 name, source_id.scope(), source_id.raw_id(), \ 391 name, source_id.scope(), source_id.raw_id(), \
385 TRACE_EVENT_FLAG_HAS_ID, target_id.raw_id(), \ 392 source_flags, target_id.raw_id(), \
386 "bind_scope", target_id.scope(), ##__VA_ARGS__); \ 393 "bind_scope", target_id.scope(), ##__VA_ARGS__); \
387 } \ 394 } \
388 } \ 395 } \
389 } while (0) 396 } while (0)
390 397
391 // Implementation detail: internal macro to create static category and add 398 // Implementation detail: internal macro to create static category and add
392 // metadata event if the category is enabled. 399 // metadata event if the category is enabled.
393 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ 400 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \
394 do { \ 401 do { \
395 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 402 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
(...skipping 17 matching lines...) Expand all
413 } \ 420 } \
414 \ 421 \
415 private: \ 422 private: \
416 uint64_t cid_; \ 423 uint64_t cid_; \
417 /* Local class friendly DISALLOW_COPY_AND_ASSIGN */ \ 424 /* Local class friendly DISALLOW_COPY_AND_ASSIGN */ \
418 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ 425 INTERNAL_TRACE_EVENT_UID(ScopedContext) \
419 (const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ 426 (const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \
420 void operator=(const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ 427 void operator=(const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \
421 }; \ 428 }; \
422 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ 429 INTERNAL_TRACE_EVENT_UID(ScopedContext) \
423 INTERNAL_TRACE_EVENT_UID(scoped_context)(context.raw_id()); 430 INTERNAL_TRACE_EVENT_UID(scoped_context)(context);
424 431
425 // Implementation detail: internal macro to trace a task execution with the 432 // Implementation detail: internal macro to trace a task execution with the
426 // location where it was posted from. 433 // location where it was posted from.
427 #define INTERNAL_TRACE_TASK_EXECUTION(run_function, task) \ 434 #define INTERNAL_TRACE_TASK_EXECUTION(run_function, task) \
428 TRACE_EVENT2("toplevel", run_function, "src_file", \ 435 TRACE_EVENT2("toplevel", run_function, "src_file", \
429 (task).posted_from.file_name(), "src_func", \ 436 (task).posted_from.file_name(), "src_func", \
430 (task).posted_from.function_name()); \ 437 (task).posted_from.function_name()); \
431 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION INTERNAL_TRACE_EVENT_UID( \ 438 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION INTERNAL_TRACE_EVENT_UID( \
432 task_event)((task).posted_from.file_name()); 439 task_event)((task).posted_from.file_name());
433 440
434 namespace trace_event_internal { 441 namespace trace_event_internal {
435 442
436 // Specify these values when the corresponding argument of AddTraceEvent is not 443 // Specify these values when the corresponding argument of AddTraceEvent is not
437 // used. 444 // used.
438 const int kZeroNumArgs = 0; 445 const int kZeroNumArgs = 0;
439 const std::nullptr_t kGlobalScope = nullptr; 446 const std::nullptr_t kGlobalScope = nullptr;
440 const unsigned long long kNoId = 0; 447 const unsigned long long kNoId = 0;
441 448
442 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers 449 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers
443 // are by default mangled with the Process ID so that they are unlikely to 450 // are by default mangled with the Process ID so that they are unlikely to
444 // collide when the same pointer is used on different processes. 451 // collide when the same pointer is used on different processes.
445 class TraceID { 452 class TraceID {
446 public: 453 public:
454 // Can be combined with WithScope.
455 class LocalId {
456 public:
457 explicit LocalId(unsigned long long raw_id) : raw_id_(raw_id) {}
458 unsigned long long raw_id() const { return raw_id_; }
459 private:
460 unsigned long long raw_id_;
461 };
462
463 // Can be combined with WithScope.
464 class GlobalId {
465 public:
466 explicit GlobalId(unsigned long long raw_id) : raw_id_(raw_id) {}
467 unsigned long long raw_id() const { return raw_id_; }
468 private:
469 unsigned long long raw_id_;
470 };
471
447 class WithScope { 472 class WithScope {
448 public: 473 public:
449 WithScope(const char* scope, unsigned long long raw_id) 474 WithScope(const char* scope, unsigned long long raw_id)
450 : scope_(scope), raw_id_(raw_id) {} 475 : scope_(scope), raw_id_(raw_id) {}
476 WithScope(const char* scope, LocalId local_id)
477 : scope_(scope), raw_id_(local_id.raw_id()) {
478 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID;
479 }
480 WithScope(const char* scope, GlobalId global_id)
481 : scope_(scope), raw_id_(global_id.raw_id()) {
482 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
483 }
451 unsigned long long raw_id() const { return raw_id_; } 484 unsigned long long raw_id() const { return raw_id_; }
452 const char* scope() const { return scope_; } 485 const char* scope() const { return scope_; }
486 unsigned int id_flags() const { return id_flags_; }
453 private: 487 private:
454 const char* scope_ = nullptr; 488 const char* scope_ = nullptr;
455 unsigned long long raw_id_; 489 unsigned long long raw_id_;
490 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID;
456 }; 491 };
457 492
493 // DEPRECATED: consider using LocalId or GlobalId, instead.
458 class DontMangle { 494 class DontMangle {
459 public: 495 public:
460 explicit DontMangle(const void* raw_id) 496 explicit DontMangle(const void* raw_id)
461 : raw_id_(static_cast<unsigned long long>( 497 : raw_id_(static_cast<unsigned long long>(
462 reinterpret_cast<uintptr_t>(raw_id))) {} 498 reinterpret_cast<uintptr_t>(raw_id))) {}
463 explicit DontMangle(unsigned long long raw_id) : raw_id_(raw_id) {} 499 explicit DontMangle(unsigned long long raw_id) : raw_id_(raw_id) {}
464 explicit DontMangle(unsigned long raw_id) : raw_id_(raw_id) {} 500 explicit DontMangle(unsigned long raw_id) : raw_id_(raw_id) {}
465 explicit DontMangle(unsigned int raw_id) : raw_id_(raw_id) {} 501 explicit DontMangle(unsigned int raw_id) : raw_id_(raw_id) {}
466 explicit DontMangle(unsigned short raw_id) : raw_id_(raw_id) {} 502 explicit DontMangle(unsigned short raw_id) : raw_id_(raw_id) {}
467 explicit DontMangle(unsigned char raw_id) : raw_id_(raw_id) {} 503 explicit DontMangle(unsigned char raw_id) : raw_id_(raw_id) {}
468 explicit DontMangle(long long raw_id) 504 explicit DontMangle(long long raw_id)
469 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 505 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
470 explicit DontMangle(long raw_id) 506 explicit DontMangle(long raw_id)
471 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 507 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
472 explicit DontMangle(int raw_id) 508 explicit DontMangle(int raw_id)
473 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 509 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
474 explicit DontMangle(short raw_id) 510 explicit DontMangle(short raw_id)
475 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 511 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
476 explicit DontMangle(signed char raw_id) 512 explicit DontMangle(signed char raw_id)
477 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 513 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
478 explicit DontMangle(WithScope scoped_id)
479 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {}
480 const char* scope() const { return scope_; }
481 unsigned long long raw_id() const { return raw_id_; } 514 unsigned long long raw_id() const { return raw_id_; }
482 private: 515 private:
483 const char* scope_ = nullptr;
484 unsigned long long raw_id_; 516 unsigned long long raw_id_;
485 }; 517 };
486 518
519 // DEPRECATED: consider using LocalId or GlobalId, instead.
487 class ForceMangle { 520 class ForceMangle {
488 public: 521 public:
489 explicit ForceMangle(unsigned long long raw_id) : raw_id_(raw_id) {} 522 explicit ForceMangle(unsigned long long raw_id) : raw_id_(raw_id) {}
490 explicit ForceMangle(unsigned long raw_id) : raw_id_(raw_id) {} 523 explicit ForceMangle(unsigned long raw_id) : raw_id_(raw_id) {}
491 explicit ForceMangle(unsigned int raw_id) : raw_id_(raw_id) {} 524 explicit ForceMangle(unsigned int raw_id) : raw_id_(raw_id) {}
492 explicit ForceMangle(unsigned short raw_id) : raw_id_(raw_id) {} 525 explicit ForceMangle(unsigned short raw_id) : raw_id_(raw_id) {}
493 explicit ForceMangle(unsigned char raw_id) : raw_id_(raw_id) {} 526 explicit ForceMangle(unsigned char raw_id) : raw_id_(raw_id) {}
494 explicit ForceMangle(long long raw_id) 527 explicit ForceMangle(long long raw_id)
495 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 528 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
496 explicit ForceMangle(long raw_id) 529 explicit ForceMangle(long raw_id)
497 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 530 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
498 explicit ForceMangle(int raw_id) 531 explicit ForceMangle(int raw_id)
499 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 532 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
500 explicit ForceMangle(short raw_id) 533 explicit ForceMangle(short raw_id)
501 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 534 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
502 explicit ForceMangle(signed char raw_id) 535 explicit ForceMangle(signed char raw_id)
503 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 536 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
504 unsigned long long raw_id() const { return raw_id_; } 537 unsigned long long raw_id() const { return raw_id_; }
505 private: 538 private:
506 unsigned long long raw_id_; 539 unsigned long long raw_id_;
507 }; 540 };
508 TraceID(const void* raw_id, unsigned int* flags) 541
509 : raw_id_(static_cast<unsigned long long>( 542 TraceID(const void* raw_id) : raw_id_(static_cast<unsigned long long>(
510 reinterpret_cast<uintptr_t>(raw_id))) { 543 reinterpret_cast<uintptr_t>(raw_id))) {
511 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; 544 id_flags_ = TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_MANGLE_ID;
512 } 545 }
513 TraceID(ForceMangle raw_id, unsigned int* flags) : raw_id_(raw_id.raw_id()) { 546 TraceID(ForceMangle raw_id) : raw_id_(raw_id.raw_id()) {
514 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; 547 id_flags_ = TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_MANGLE_ID;
515 } 548 }
516 TraceID(DontMangle maybe_scoped_id, unsigned int* flags) 549 TraceID(DontMangle raw_id) : raw_id_(raw_id.raw_id()) {}
517 : scope_(maybe_scoped_id.scope()), raw_id_(maybe_scoped_id.raw_id()) { 550 TraceID(unsigned long long raw_id) : raw_id_(raw_id) {}
551 TraceID(unsigned long raw_id) : raw_id_(raw_id) {}
552 TraceID(unsigned int raw_id) : raw_id_(raw_id) {}
553 TraceID(unsigned short raw_id) : raw_id_(raw_id) {}
554 TraceID(unsigned char raw_id) : raw_id_(raw_id) {}
555 TraceID(long long raw_id)
556 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
557 TraceID(long raw_id)
558 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
559 TraceID(int raw_id)
560 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
561 TraceID(short raw_id)
562 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
563 TraceID(signed char raw_id)
564 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
565 TraceID(LocalId raw_id) : raw_id_(raw_id.raw_id()) {
566 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID;
518 } 567 }
519 TraceID(unsigned long long raw_id, unsigned int* flags) : raw_id_(raw_id) { 568 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) {
520 (void)flags; 569 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
521 } 570 }
522 TraceID(unsigned long raw_id, unsigned int* flags) : raw_id_(raw_id) { 571 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()),
523 (void)flags; 572 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {}
524 }
525 TraceID(unsigned int raw_id, unsigned int* flags) : raw_id_(raw_id) {
526 (void)flags;
527 }
528 TraceID(unsigned short raw_id, unsigned int* flags) : raw_id_(raw_id) {
529 (void)flags;
530 }
531 TraceID(unsigned char raw_id, unsigned int* flags) : raw_id_(raw_id) {
532 (void)flags;
533 }
534 TraceID(long long raw_id, unsigned int* flags)
535 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; }
536 TraceID(long raw_id, unsigned int* flags)
537 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; }
538 TraceID(int raw_id, unsigned int* flags)
539 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; }
540 TraceID(short raw_id, unsigned int* flags)
541 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; }
542 TraceID(signed char raw_id, unsigned int* flags)
543 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; }
544 TraceID(WithScope scoped_id, unsigned int* flags)
545 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {}
546 573
547 unsigned long long raw_id() const { return raw_id_; } 574 unsigned long long raw_id() const { return raw_id_; }
548 const char* scope() const { return scope_; } 575 const char* scope() const { return scope_; }
576 unsigned int id_flags() const { return id_flags_; }
549 577
550 private: 578 private:
551 const char* scope_ = nullptr; 579 const char* scope_ = nullptr;
552 unsigned long long raw_id_; 580 unsigned long long raw_id_;
581 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID;
553 }; 582 };
554 583
555 // Simple union to store various types as unsigned long long. 584 // Simple union to store various types as unsigned long long.
556 union TraceValueUnion { 585 union TraceValueUnion {
557 bool as_bool; 586 bool as_bool;
558 unsigned long long as_uint; 587 unsigned long long as_uint;
559 long long as_int; 588 long long as_int;
560 double as_double; 589 double as_double;
561 const void* as_pointer; 590 const void* as_pointer;
562 const char* as_string; 591 const char* as_string;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 const char* name_; 1157 const char* name_;
1129 IDType id_; 1158 IDType id_;
1130 1159
1131 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1160 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1132 }; 1161 };
1133 1162
1134 } // namespace trace_event 1163 } // namespace trace_event
1135 } // namespace base 1164 } // namespace base
1136 1165
1137 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1166 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698