diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 22:28:25 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-19 22:28:25 +0000 |
commit | fcb30f7bc726a11540d942deec17baf62511c2e0 (patch) | |
tree | a6f695de8a0f6689cd7a7565ae199277f151141b /base/message_loop.cc | |
parent | 216813957f67962e1c50fcbbad0d3e8fcd17760e (diff) | |
download | chromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.zip chromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.tar.gz chromium_src-fcb30f7bc726a11540d942deec17baf62511c2e0.tar.bz2 |
Tag all tracked objects, including Tasks, with the program counter at the site of FROM_HERE.
This is to make it easier to determine the site Tasks are posted from in release builds, especially when only a minidump is available. It should help diagnose http://crbug.com/81499.
I added a debug function to alias variables so that the optimizer will not strip them out if they are not live.
The semantics of the MessageLoop::PostTask functions is changed and it is wrong but I am not sure what semantics are intended. It seems location information was no longer being tracked for Tasks wrapped as Closures and I don't know if this was intended. PTAL. Update: this has since been fixed.
TEST=Set breakpoint in TaskClosureAdapter::Run and very that the post site can be located in an optimized build.
BUG=81499
Review URL: http://codereview.chromium.org/7039020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.cc')
-rw-r--r-- | base/message_loop.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/base/message_loop.cc b/base/message_loop.cc index 059cdc25..e6b49ac8 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -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 @@ void MessageLoop::RunTask(const PendingTask& pending_task) { // 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); + HistogramEvent(kTaskRunEvent); FOR_EACH_OBSERVER(TaskObserver, task_observers_, WillProcessTask(pending_task.time_posted)); @@ -766,7 +775,8 @@ MessageLoop::PendingTask::PendingTask( 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 = |