Chromium Code Reviews| Index: base/debug/task_annotator.cc |
| diff --git a/base/debug/task_annotator.cc b/base/debug/task_annotator.cc |
| index 437d69a7f8be025b17dabe29adb12c7dedc63816..0963fdec862eb3f57001b4a37989f7a5a8c07802 100644 |
| --- a/base/debug/task_annotator.cc |
| +++ b/base/debug/task_annotator.cc |
| @@ -4,6 +4,8 @@ |
| #include "base/debug/task_annotator.h" |
| +#include <array> |
| + |
| #include "base/debug/activity_tracker.h" |
| #include "base/debug/alias.h" |
| #include "base/pending_task.h" |
| @@ -41,13 +43,18 @@ void TaskAnnotator::RunTask(const char* queue_function, |
| TRACE_ID_MANGLE(GetTaskTraceID(*pending_task)), TRACE_EVENT_FLAG_FLOW_IN, |
| "queue_duration", queue_duration.InMilliseconds()); |
| - // 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->posted_from.program_counter(); |
| - debug::Alias(&program_counter); |
| + // Before running the task, store the task backtrace with the chain of |
| + // PostTasks that resulted in this call 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. |
| + std::array<const void*, |
| + std::tuple_size<decltype(pending_task->task_backtrace)>::value + 1> |
|
danakj
2017/02/09 16:39:50
can you pull the std::tuple_size<decltype(pending_
awong
2017/02/09 19:49:02
done.
|
| + task_backtrace; |
| + task_backtrace[0] = pending_task->posted_from.program_counter(); |
| + std::copy(pending_task->task_backtrace.begin(), |
| + pending_task->task_backtrace.end(), task_backtrace.begin() + 1); |
| + debug::Alias(&task_backtrace); |
| std::move(pending_task->task).Run(); |