Chromium Code Reviews| Index: base/debug/activity_tracker.h |
| diff --git a/base/debug/activity_tracker.h b/base/debug/activity_tracker.h |
| index 922528fb38702fdd023eeec906bba6fb8d7cb22c..bf954f5fb08696ba478060b58d14f10d2285e17a 100644 |
| --- a/base/debug/activity_tracker.h |
| +++ b/base/debug/activity_tracker.h |
| @@ -96,6 +96,10 @@ struct OwningProcess { |
| // sized types to ensure no interoperability problems between 32-bit and |
| // 64-bit systems. |
| union ActivityData { |
| + // Expected size for 32/64-bit check. |
| + // TODO(bcwhite): VC2015 doesn't allow statics in unions. Fix when it does. |
| + // static constexpr size_t kExpectedInstanceSize = 8; |
| + |
| // Generic activities don't have any defined structure. |
| struct { |
| uint32_t id; // An arbitrary identifier used for association. |
| @@ -272,6 +276,9 @@ struct Activity { |
| ACT_PROCESS_START = ACT_PROCESS, |
| ACT_PROCESS_WAIT, |
| + // Exception activities indicate the occurence of something unexpected. |
| + ACT_EXCEPTION = 14 << 4, |
| + |
| // Generic activities are user defined and can be anything. |
| ACT_GENERIC = 15 << 4, |
| @@ -385,6 +392,7 @@ class BASE_EXPORT ActivityUserData { |
| using Snapshot = std::map<std::string, TypedValue>; |
| + ActivityUserData(); |
| ActivityUserData(void* memory, size_t size); |
| virtual ~ActivityUserData(); |
| @@ -579,6 +587,9 @@ class BASE_EXPORT ThreadActivityTracker { |
| // The current total depth of the activity stack, including those later |
| // entries not recorded in the |activity_stack| vector. |
| uint32_t activity_stack_depth = 0; |
| + |
| + // The last recorded "exception" activity. |
| + Activity last_exception; |
| }; |
| // This is the base class for having the compiler manage an activity on the |
| @@ -662,6 +673,12 @@ class BASE_EXPORT ThreadActivityTracker { |
| void ReleaseUserData(ActivityId id, |
| ActivityTrackerMemoryAllocator* allocator); |
| + // Save an exception. |
| + void ExceptionActivity(const void* program_counter, |
|
manzagop (departed)
2017/03/20 14:29:55
nit: add a verb, eg [Store/Record/Save]ExceptionAc
bcwhite
2017/03/21 12:25:06
Done.
|
| + const void* origin, |
| + Activity::Type type, |
| + const ActivityData& data); |
| + |
| // Returns whether the current data is valid or not. It is not valid if |
| // corruption has been detected in the header or other data structures. |
| bool IsValid() const; |
| @@ -692,6 +709,10 @@ class BASE_EXPORT ThreadActivityTracker { |
| private: |
| friend class ActivityTrackerTest; |
| + std::unique_ptr<ActivityUserData> CreateUserDataForActivity( |
| + Activity* activity, |
| + ActivityTrackerMemoryAllocator* allocator); |
| + |
| Header* const header_; // Pointer to the Header structure. |
| Activity* const stack_; // The stack of activities. |
| const uint32_t stack_slots_; // The total number of stack slots. |
| @@ -920,6 +941,7 @@ class BASE_EXPORT GlobalActivityTracker { |
| if (tracker) |
| tracker->RecordProcessExit(process_id, exit_code); |
| } |
| + |
| // Sets the "phase" of the current process, useful for knowing what it was |
| // doing when it last reported. |
| void SetProcessPhase(ProcessPhase phase); |
| @@ -958,6 +980,14 @@ class BASE_EXPORT GlobalActivityTracker { |
| tracker->RecordFieldTrial(trial_name, group_name); |
| } |
| + // Record exception information for the current thread and return space where |
|
manzagop (departed)
2017/03/20 14:29:55
No space is returned?
bcwhite
2017/03/21 12:25:06
Done.
|
| + // additional information may be recorded. |
| + // TODO(bcwhite): More parameters (space for 4 + 64 bits). |
| + ALWAYS_INLINE |
| + void RecordException(const void* origin) { |
| + return RecordExceptionImpl(::tracked_objects::GetProgramCounter(), origin); |
| + } |
| + |
| // Accesses the process data record for storing arbitrary key/value pairs. |
| // Updates to this are thread-safe. |
| ActivityUserData& process_data() { return process_data_; } |
| @@ -1075,6 +1105,9 @@ class BASE_EXPORT GlobalActivityTracker { |
| // It is called during the destruction of a ManagedActivityTracker object. |
| void ReturnTrackerMemory(ManagedActivityTracker* tracker); |
| + // Records exception information. |
| + void RecordExceptionImpl(const void* pc, const void* origin); |
| + |
| // Releases the activity-tracker associcated with thread. It is called |
| // automatically when a thread is joined and thus there is nothing more to |
| // be tracked. |value| is a pointer to a ManagedActivityTracker. |