Index: base/debug/task_annotator.cc |
diff --git a/base/debug/task_annotator.cc b/base/debug/task_annotator.cc |
index 437d69a7f8be025b17dabe29adb12c7dedc63816..c5778cc024414a70bb9f27b3f7ce65df9dbd23c5 100644 |
--- a/base/debug/task_annotator.cc |
+++ b/base/debug/task_annotator.cc |
@@ -41,13 +41,16 @@ 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. |
+ const void* task_backtrace[arraysize(pending_task->task_backtrace) + 1]; |
+ task_backtrace[0] = pending_task->posted_from.program_counter(); |
+ memcpy(&task_backtrace[1], &pending_task->task_backtrace[0], |
+ sizeof(task_backtrace)); |
danakj
2017/02/08 23:40:28
The compiler disagrees with me, you want size of p
danakj
2017/02/08 23:41:04
Possibly consider using std::array and STL things
awong
2017/02/09 00:23:38
EEk. Good catch. STLed everything.
|
+ debug::Alias(&task_backtrace); |
std::move(pending_task->task).Run(); |