OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Activity tracking provides a low-overhead method of collecting information | 5 // Activity tracking provides a low-overhead method of collecting information |
6 // about the state of the application for analysis both while it is running | 6 // about the state of the application for analysis both while it is running |
7 // and after it has terminated unexpectedly. Its primary purpose is to help | 7 // and after it has terminated unexpectedly. Its primary purpose is to help |
8 // locate reasons the browser becomes unresponsive by providing insight into | 8 // locate reasons the browser becomes unresponsive by providing insight into |
9 // what all the various threads and processes are (or were) doing. | 9 // what all the various threads and processes are (or were) doing. |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 // cannot be changed without also changing the version number of the | 54 // cannot be changed without also changing the version number of the |
55 // structure. See kTypeIdActivityTracker in GlobalActivityTracker. | 55 // structure. See kTypeIdActivityTracker in GlobalActivityTracker. |
56 kActivityCallStackSize = 10, | 56 kActivityCallStackSize = 10, |
57 }; | 57 }; |
58 | 58 |
59 // The data associated with an activity is dependent upon the activity type. | 59 // The data associated with an activity is dependent upon the activity type. |
60 // This union defines all of the various fields. All fields must be explicitly | 60 // This union defines all of the various fields. All fields must be explicitly |
61 // sized types to ensure no interoperability problems between 32-bit and | 61 // sized types to ensure no interoperability problems between 32-bit and |
62 // 64-bit systems. | 62 // 64-bit systems. |
63 union ActivityData { | 63 union ActivityData { |
64 // SHA1(base::debug::ActivityData): Increment this if structure changes! | |
65 static constexpr uint32_t kPersistentTypeId = 0x72DC176D + 1; | |
66 // Expected size for 32/64-bit check. Update this if structure changes! | |
67 static constexpr size_t kExpectedInstanceSize = 8; | |
manzagop (departed)
2017/02/17 15:50:55
static_assert for this? Same below.
bcwhite
2017/02/17 15:52:11
These sizes are asserted by the PMA when using the
| |
68 | |
64 // Generic activities don't have any defined structure. | 69 // Generic activities don't have any defined structure. |
65 struct { | 70 struct { |
66 uint32_t id; // An arbitrary identifier used for association. | 71 uint32_t id; // An arbitrary identifier used for association. |
67 int32_t info; // An arbitrary value used for information purposes. | 72 int32_t info; // An arbitrary value used for information purposes. |
68 } generic; | 73 } generic; |
69 struct { | 74 struct { |
70 uint64_t sequence_id; // The sequence identifier of the posted task. | 75 uint64_t sequence_id; // The sequence identifier of the posted task. |
71 } task; | 76 } task; |
72 struct { | 77 struct { |
73 uint64_t lock_address; // The memory address of the lock object. | 78 uint64_t lock_address; // The memory address of the lock object. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // Gets a reference to an object of the configured type. This can return | 160 // Gets a reference to an object of the configured type. This can return |
156 // a null reference if it was not possible to allocate the memory. | 161 // a null reference if it was not possible to allocate the memory. |
157 Reference GetObjectReference(); | 162 Reference GetObjectReference(); |
158 | 163 |
159 // Returns an object to the "free" pool. | 164 // Returns an object to the "free" pool. |
160 void ReleaseObjectReference(Reference ref); | 165 void ReleaseObjectReference(Reference ref); |
161 | 166 |
162 // Helper function to access an object allocated using this instance. | 167 // Helper function to access an object allocated using this instance. |
163 template <typename T> | 168 template <typename T> |
164 T* GetAsObject(Reference ref) { | 169 T* GetAsObject(Reference ref) { |
165 return allocator_->GetAsObject<T>(ref, object_type_); | 170 return allocator_->GetAsObject<T>(ref); |
166 } | 171 } |
167 | 172 |
168 // Similar to GetAsObject() but converts references to arrays of objects. | 173 // Similar to GetAsObject() but converts references to arrays of objects. |
169 template <typename T> | 174 template <typename T> |
170 T* GetAsArray(Reference ref, size_t count) { | 175 T* GetAsArray(Reference ref, size_t count) { |
171 return allocator_->GetAsArray<T>(ref, object_type_, count); | 176 return allocator_->GetAsArray<T>(ref, object_type_, count); |
172 } | 177 } |
173 | 178 |
174 // The current "used size" of the internal cache, visible for testing. | 179 // The current "used size" of the internal cache, visible for testing. |
175 size_t cache_used() const { return cache_used_; } | 180 size_t cache_used() const { return cache_used_; } |
(...skipping 15 matching lines...) Expand all Loading... | |
191 | 196 |
192 DISALLOW_COPY_AND_ASSIGN(ActivityTrackerMemoryAllocator); | 197 DISALLOW_COPY_AND_ASSIGN(ActivityTrackerMemoryAllocator); |
193 }; | 198 }; |
194 | 199 |
195 | 200 |
196 // This structure is the full contents recorded for every activity pushed | 201 // This structure is the full contents recorded for every activity pushed |
197 // onto the stack. The |activity_type| indicates what is actually stored in | 202 // onto the stack. The |activity_type| indicates what is actually stored in |
198 // the |data| field. All fields must be explicitly sized types to ensure no | 203 // the |data| field. All fields must be explicitly sized types to ensure no |
199 // interoperability problems between 32-bit and 64-bit systems. | 204 // interoperability problems between 32-bit and 64-bit systems. |
200 struct Activity { | 205 struct Activity { |
206 // SHA1(base::debug::Activity): Increment this if structure changes! | |
207 static constexpr uint32_t kPersistentTypeId = 0x99425159 + 1; | |
208 // Expected size for 32/64-bit check. Update this if structure changes! | |
209 static constexpr size_t kExpectedInstanceSize = | |
210 48 + ActivityData::kExpectedInstanceSize; | |
211 | |
201 // The type of an activity on the stack. Activities are broken into | 212 // The type of an activity on the stack. Activities are broken into |
202 // categories with the category ID taking the top 4 bits and the lower | 213 // categories with the category ID taking the top 4 bits and the lower |
203 // bits representing an action within that category. This combination | 214 // bits representing an action within that category. This combination |
204 // makes it easy to "switch" based on the type during analysis. | 215 // makes it easy to "switch" based on the type during analysis. |
205 enum Type : uint8_t { | 216 enum Type : uint8_t { |
206 // This "null" constant is used to indicate "do not change" in calls. | 217 // This "null" constant is used to indicate "do not change" in calls. |
207 ACT_NULL = 0, | 218 ACT_NULL = 0, |
208 | 219 |
209 // Task activities involve callbacks posted to a thread or thread-pool | 220 // Task activities involve callbacks posted to a thread or thread-pool |
210 // using the PostTask() method or any of its friends. | 221 // using the PostTask() method or any of its friends. |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 ScopedProcessWaitActivity(const void* program_counter, | 1079 ScopedProcessWaitActivity(const void* program_counter, |
1069 const base::Process* process); | 1080 const base::Process* process); |
1070 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); | 1081 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); |
1071 }; | 1082 }; |
1072 #endif | 1083 #endif |
1073 | 1084 |
1074 } // namespace debug | 1085 } // namespace debug |
1075 } // namespace base | 1086 } // namespace base |
1076 | 1087 |
1077 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ | 1088 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ |
OLD | NEW |