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

Unified Diff: base/message_loop.cc

Issue 7039020: Tag all tracked objects, including Tasks, with the program counter at the site of FROM_HERE. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | « base/message_loop.h ('k') | base/tracked.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop.cc
===================================================================
--- base/message_loop.cc (revision 85540)
+++ base/message_loop.cc (working copy)
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
+#include "base/debug/alias.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/message_pump_default.h"
@@ -467,6 +468,14 @@
// Execute the task and assume the worst: It is probably not reentrant.
nestable_tasks_allowed_ = false;
+ // Before running the task, store the program counter where it was posted
+ // and deliberately alias it to ensure it is on the stack if the task
+ // crashes. Be careful not to assume that the variable itself will have the
+ // expected value when displayed by the optimizer in an optimized build.
+ // Look at a memory dump of the stack.
+ const void* program_counter = pending_task.birth_program_counter;
+ base::debug::Alias(&program_counter);
eroman%chromium.org 2011/05/18 20:52:44 Since you are only targeting MSVC anyway, how abou
apatrick_chromium 2011/05/18 21:09:47 Done.
+
HistogramEvent(kTaskRunEvent);
FOR_EACH_OBSERVER(TaskObserver, task_observers_,
WillProcessTask(pending_task.time_posted));
@@ -766,7 +775,8 @@
time_posted(TimeTicks::Now()),
delayed_run_time(delayed_run_time),
sequence_num(0),
- nestable(nestable) {
+ nestable(nestable),
+ birth_program_counter(posted_from.program_counter()) {
#if defined(TRACK_ALL_TASK_OBJECTS)
if (tracked_objects::ThreadData::IsActive()) {
tracked_objects::ThreadData* current_thread_data =
« no previous file with comments | « base/message_loop.h ('k') | base/tracked.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698