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

Unified Diff: base/debug/task_annotator.cc

Issue 1044413002: Record async "task backtraces" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now with unittests! Created 3 years, 10 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
Index: base/debug/task_annotator.cc
diff --git a/base/debug/task_annotator.cc b/base/debug/task_annotator.cc
index 437d69a7f8be025b17dabe29adb12c7dedc63816..a6c3e83595626756302540c86702a6aab5a97895 100644
--- a/base/debug/task_annotator.cc
+++ b/base/debug/task_annotator.cc
@@ -41,13 +41,15 @@ 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[4];
danakj 2017/02/08 18:06:22 can you static assert that this is the same size a
awong 2017/02/08 23:20:38 good idea. done. Actually did better and just tied
+ memcpy(&task_backtrace[0], &pending_task->task_backtrace[0],
+ sizeof(task_backtrace));
+ debug::Alias(&task_backtrace);
std::move(pending_task->task).Run();

Powered by Google App Engine
This is Rietveld 408576698