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

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

Issue 15774010: Add TRACE_EVENT_IS_NEW_TRACE as a way to snapshot objects at start of recording (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('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 // This header file defines the set of trace_event macros without specifying 5 // This header file defines the set of trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace 6 // how the events actually get collected and stored. If you need to expose trace
7 // events to some other universe, you can copy-and-paste this file as well as 7 // events to some other universe, you can copy-and-paste this file as well as
8 // trace_event.h, modifying the macros contained there as necessary for the 8 // trace_event.h, modifying the macros contained there as necessary for the
9 // target platform. The end result is that multiple libraries can funnel events 9 // target platform. The end result is that multiple libraries can funnel events
10 // through to a shared trace event collector. 10 // through to a shared trace event collector.
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ 671 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \
672 do { \ 672 do { \
673 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 673 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
674 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ 674 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
675 *ret = true; \ 675 *ret = true; \
676 } else { \ 676 } else { \
677 *ret = false; \ 677 *ret = false; \
678 } \ 678 } \
679 } while (0) 679 } while (0)
680 680
681 // Macro to efficiently determine, through polling, if a new trace has begun.
682 #define TRACE_EVENT_IS_NEW_TRACE(ret) \
683 do { \
684 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \
685 int num_traces_recorded = TRACE_EVENT_API_GET_NUM_TRACES_RECORDED(); \
686 if (num_traces_recorded != -1 && \
687 num_traces_recorded != \
688 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber)) { \
689 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = \
690 num_traces_recorded; \
691 *ret = true; \
692 } else { \
693 *ret = false; \
694 } \
695 } while (0)
696
681 //////////////////////////////////////////////////////////////////////////////// 697 ////////////////////////////////////////////////////////////////////////////////
682 // Implementation specific tracing API definitions. 698 // Implementation specific tracing API definitions.
683 699
684 // Get a pointer to the enabled state of the given trace category. Only 700 // Get a pointer to the enabled state of the given trace category. Only
685 // long-lived literal strings should be given as the category group. The 701 // long-lived literal strings should be given as the category group. The
686 // returned pointer can be held permanently in a local static for example. If 702 // returned pointer can be held permanently in a local static for example. If
687 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, 703 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
688 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled 704 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
689 // between the load of the tracing state and the call to 705 // between the load of the tracing state and the call to
690 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out 706 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
691 // for best performance when tracing is disabled. 707 // for best performance when tracing is disabled.
692 // const unsigned char* 708 // const unsigned char*
693 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) 709 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group)
694 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ 710 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
695 base::debug::TraceLog::GetCategoryGroupEnabled 711 base::debug::TraceLog::GetCategoryGroupEnabled
696 712
713 // Get the number of times traces have been recorded. This is used to implement
714 // the TRACE_EVENT_IS_NEW_TRACE facility.
715 // unsigned int TRACE_EVENT_API_GET_NUM_TRACES_RECORDED()
716 #define TRACE_EVENT_API_GET_NUM_TRACES_RECORDED \
717 base::debug::TraceLog::GetInstance()->GetNumTracesRecorded
718
697 // Add a trace event to the platform tracing system. 719 // Add a trace event to the platform tracing system.
698 // void TRACE_EVENT_API_ADD_TRACE_EVENT( 720 // void TRACE_EVENT_API_ADD_TRACE_EVENT(
699 // char phase, 721 // char phase,
700 // const unsigned char* category_group_enabled, 722 // const unsigned char* category_group_enabled,
701 // const char* name, 723 // const char* name,
702 // unsigned long long id, 724 // unsigned long long id,
703 // int num_args, 725 // int num_args,
704 // const char** arg_names, 726 // const char** arg_names,
705 // const unsigned char* arg_types, 727 // const unsigned char* arg_types,
706 // const unsigned long long* arg_values, 728 // const unsigned long long* arg_values,
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 const char* name_; 1467 const char* name_;
1446 IDType id_; 1468 IDType id_;
1447 1469
1448 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1470 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1449 }; 1471 };
1450 1472
1451 } // namespace debug 1473 } // namespace debug
1452 } // namespace base 1474 } // namespace base
1453 1475
1454 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ 1476 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698