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

Unified Diff: base/debug/activity_tracker.h

Issue 2702413006: Enable storing last-dispatched exception per-thread. (Closed)
Patch Set: addressed review comments by manzagop Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/activity_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/activity_tracker.h
diff --git a/base/debug/activity_tracker.h b/base/debug/activity_tracker.h
index 922528fb38702fdd023eeec906bba6fb8d7cb22c..3dd834fbfc3c343c1fa717ee7258051146c84b3d 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,9 @@ class BASE_EXPORT ActivityUserData {
using Snapshot = std::map<std::string, TypedValue>;
+ // Initialize the object either as a "sink" that just accepts and discards
+ // data or an active one that writes to a given (zeroed) memory block.
+ ActivityUserData();
ActivityUserData(void* memory, size_t size);
virtual ~ActivityUserData();
@@ -579,6 +589,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 +675,12 @@ class BASE_EXPORT ThreadActivityTracker {
void ReleaseUserData(ActivityId id,
ActivityTrackerMemoryAllocator* allocator);
+ // Save an exception.
+ void RecordExceptionActivity(const void* program_counter,
+ 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 +711,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 +943,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 +982,13 @@ class BASE_EXPORT GlobalActivityTracker {
tracker->RecordFieldTrial(trial_name, group_name);
}
+ // Record exception information for the current thread.
+ // TODO(bcwhite): More parameters (space for 4 + 64 bits).
+ ALWAYS_INLINE
+ void RecordException(const void* origin) {
+ return RecordExceptionImpl(::tracked_objects::GetProgramCounter(), origin);
Sigurður Ásgeirsson 2017/03/21 14:15:06 Sorry, but I don't understand how this relates to
bcwhite 2017/03/21 14:40:40 I can add that.
Sigurður Ásgeirsson 2017/03/21 14:56:12 Cool.
bcwhite 2017/03/22 19:28:20 Done.
+ }
+
// 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 +1106,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.
« no previous file with comments | « no previous file | base/debug/activity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698