From 1f17c249692da535e2fa7a5a81fd85044586458f Mon Sep 17 00:00:00 2001 From: "wfh@chromium.org" Date: Tue, 8 Jul 2014 14:21:16 +0000 Subject: Fix tracing 64-bit to 32-bit truncations. BUG=392035 Review URL: https://codereview.chromium.org/374043002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281745 0039d316-1c4b-4281-b951-d872f2087c98 --- base/debug/trace_event.h | 5 ++--- base/debug/trace_event_impl.cc | 18 +++++++++--------- base/debug/trace_event_impl.h | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'base/debug') diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h index 686bd38..dcb332d 100644 --- a/base/debug/trace_event.h +++ b/base/debug/trace_event.h @@ -1003,7 +1003,7 @@ class TraceID { public: explicit DontMangle(const void* id) : data_(static_cast( - reinterpret_cast(id))) {} + reinterpret_cast(id))) {} explicit DontMangle(unsigned long long id) : data_(id) {} explicit DontMangle(unsigned long id) : data_(id) {} explicit DontMangle(unsigned int id) : data_(id) {} @@ -1045,10 +1045,9 @@ class TraceID { private: unsigned long long data_; }; - TraceID(const void* id, unsigned char* flags) : data_(static_cast( - reinterpret_cast(id))) { + reinterpret_cast(id))) { *flags |= TRACE_EVENT_FLAG_MANGLE_ID; } TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) { diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc index 8bcbe0e..3c12453 100644 --- a/base/debug/trace_event_impl.cc +++ b/base/debug/trace_event_impl.cc @@ -1209,7 +1209,7 @@ const char* TraceLog::GetCategoryGroupName( return g_category_groups[category_index]; } -void TraceLog::UpdateCategoryGroupEnabledFlag(int category_index) { +void TraceLog::UpdateCategoryGroupEnabledFlag(size_t category_index) { unsigned char enabled_flag = 0; const char* category_group = g_category_groups[category_index]; if (mode_ == RECORDING_MODE && @@ -1225,8 +1225,8 @@ void TraceLog::UpdateCategoryGroupEnabledFlag(int category_index) { } void TraceLog::UpdateCategoryGroupEnabledFlags() { - int category_index = base::subtle::NoBarrier_Load(&g_category_index); - for (int i = 0; i < category_index; i++) + size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); + for (size_t i = 0; i < category_index; i++) UpdateCategoryGroupEnabledFlag(i); } @@ -1264,10 +1264,10 @@ const unsigned char* TraceLog::GetCategoryGroupEnabledInternal( DCHECK(!strchr(category_group, '"')) << "Category groups may not contain double quote"; // The g_category_groups is append only, avoid using a lock for the fast path. - int current_category_index = base::subtle::Acquire_Load(&g_category_index); + size_t current_category_index = base::subtle::Acquire_Load(&g_category_index); // Search for pre-existing category group. - for (int i = 0; i < current_category_index; ++i) { + for (size_t i = 0; i < current_category_index; ++i) { if (strcmp(g_category_groups[i], category_group) == 0) { return &g_category_group_enabled[i]; } @@ -1279,8 +1279,8 @@ const unsigned char* TraceLog::GetCategoryGroupEnabledInternal( // Only hold to lock when actually appending a new category, and // check the categories groups again. AutoLock lock(lock_); - int category_index = base::subtle::Acquire_Load(&g_category_index); - for (int i = 0; i < category_index; ++i) { + size_t category_index = base::subtle::Acquire_Load(&g_category_index); + for (size_t i = 0; i < category_index; ++i) { if (strcmp(g_category_groups[i], category_group) == 0) { return &g_category_group_enabled[i]; } @@ -1316,8 +1316,8 @@ void TraceLog::GetKnownCategoryGroups( AutoLock lock(lock_); category_groups->push_back( g_category_groups[g_category_trace_event_overhead]); - int category_index = base::subtle::NoBarrier_Load(&g_category_index); - for (int i = g_num_builtin_categories; i < category_index; i++) + size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); + for (size_t i = g_num_builtin_categories; i < category_index; i++) category_groups->push_back(g_category_groups[i]); } diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h index e5a6dbd..7f65303 100644 --- a/base/debug/trace_event_impl.h +++ b/base/debug/trace_event_impl.h @@ -616,7 +616,7 @@ class BASE_EXPORT TraceLog { // the category group, or event_callback_ is not null and // event_callback_category_filter_ matches the category group. void UpdateCategoryGroupEnabledFlags(); - void UpdateCategoryGroupEnabledFlag(int category_index); + void UpdateCategoryGroupEnabledFlag(size_t category_index); // Configure synthetic delays based on the values set in the current // category filter. -- cgit v1.1