Commit 88808531 authored by Chris Hamilton's avatar Chris Hamilton Committed by Commit Bot

Migrate TaskAnnotator IPC decoration to use constexpr hashes.

This vastly simplifies the backend pipeline needed to symbolize IPC
messages, requiring a simple lookup table rather than symbolization
followed by source code parsing. It also means the raw IPC message
IDs are constant across Chrome versions/builds/platforms, which
facilitates aggregation.

The impact on binary size is roughly a nop; on some platforms slightly
better, on some slightly worse. The overall impact is still about
the same.

BUG=950668

Change-Id: I13661059db79c1b091afdf68daed14325a18f26a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1615386Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avataroysteine <oysteine@chromium.org>
Commit-Queue: Chris Hamilton <chrisha@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664578}
parent 481ed7e6
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef BASE_HASH_MD5_CONSTEXPR_H_ #ifndef BASE_HASH_MD5_CONSTEXPR_H_
#define BASE_HASH_MD5_CONSTEXPR_H_ #define BASE_HASH_MD5_CONSTEXPR_H_
#include <array>
#include "base/hash/md5.h" #include "base/hash/md5.h"
#include "base/hash/md5_constexpr_internal.h" #include "base/hash/md5_constexpr_internal.h"
...@@ -25,11 +23,21 @@ namespace base { ...@@ -25,11 +23,21 @@ namespace base {
constexpr MD5Digest MD5SumConstexpr(const char* string); constexpr MD5Digest MD5SumConstexpr(const char* string);
constexpr MD5Digest MD5SumConstexpr(const char* data, uint32_t length); constexpr MD5Digest MD5SumConstexpr(const char* data, uint32_t length);
// Calculates the first 64 bits of the MD5 digest of the provided data, returned // Calculates the first 32/64 bits of the MD5 digest of the provided data,
// as a uint64_t. When passing |string| with no explicit length the terminating // returned as a uint32_t/uint64_t. When passing |string| with no explicit
// null will not be processed. // length the terminating null will not be processed. This abstracts away
constexpr uint64_t MD5HashConstexpr(const char* string); // endianness so that the integer will read as the first 4 or 8 bytes of the
constexpr uint64_t MD5HashConstexpr(const char* data, uint32_t length); // MD5 sum, ensuring that the following outputs are equivalent for
// convenience:
//
// printf("%08x\n", MD5HashConstexpr32("foo"));
//
// MD5Digest d = MD5SumConstexpr("foo");
// printf("%02x%02x%02x%02x\n", d.a[0], d.a[1], d.a[2], d.a[3]);
constexpr uint64_t MD5Hash64Constexpr(const char* string);
constexpr uint64_t MD5Hash64Constexpr(const char* data, uint32_t length);
constexpr uint32_t MD5Hash32Constexpr(const char* string);
constexpr uint32_t MD5Hash32Constexpr(const char* data, uint32_t length);
} // namespace base } // namespace base
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define BASE_HASH_MD5_CONSTEXPR_INTERNAL_H_ #define BASE_HASH_MD5_CONSTEXPR_INTERNAL_H_
#include <array> #include <array>
#include <cstddef>
#include <cstdint> #include <cstdint>
#include "base/hash/md5.h" #include "base/hash/md5.h"
...@@ -239,29 +240,38 @@ struct MD5CE { ...@@ -239,29 +240,38 @@ struct MD5CE {
// Converts an IntermediateData to a final digest. // Converts an IntermediateData to a final digest.
static constexpr MD5Digest IntermediateDataToMD5Digest( static constexpr MD5Digest IntermediateDataToMD5Digest(
const IntermediateData& intermediate) { const IntermediateData& intermediate) {
return MD5Digest{static_cast<uint8_t>((intermediate.a >> 0) & 0xff), return MD5Digest{{static_cast<uint8_t>((intermediate.a >> 0) & 0xff),
static_cast<uint8_t>((intermediate.a >> 8) & 0xff), static_cast<uint8_t>((intermediate.a >> 8) & 0xff),
static_cast<uint8_t>((intermediate.a >> 16) & 0xff), static_cast<uint8_t>((intermediate.a >> 16) & 0xff),
static_cast<uint8_t>((intermediate.a >> 24) & 0xff), static_cast<uint8_t>((intermediate.a >> 24) & 0xff),
static_cast<uint8_t>((intermediate.b >> 0) & 0xff), static_cast<uint8_t>((intermediate.b >> 0) & 0xff),
static_cast<uint8_t>((intermediate.b >> 8) & 0xff), static_cast<uint8_t>((intermediate.b >> 8) & 0xff),
static_cast<uint8_t>((intermediate.b >> 16) & 0xff), static_cast<uint8_t>((intermediate.b >> 16) & 0xff),
static_cast<uint8_t>((intermediate.b >> 24) & 0xff), static_cast<uint8_t>((intermediate.b >> 24) & 0xff),
static_cast<uint8_t>((intermediate.c >> 0) & 0xff), static_cast<uint8_t>((intermediate.c >> 0) & 0xff),
static_cast<uint8_t>((intermediate.c >> 8) & 0xff), static_cast<uint8_t>((intermediate.c >> 8) & 0xff),
static_cast<uint8_t>((intermediate.c >> 16) & 0xff), static_cast<uint8_t>((intermediate.c >> 16) & 0xff),
static_cast<uint8_t>((intermediate.c >> 24) & 0xff), static_cast<uint8_t>((intermediate.c >> 24) & 0xff),
static_cast<uint8_t>((intermediate.d >> 0) & 0xff), static_cast<uint8_t>((intermediate.d >> 0) & 0xff),
static_cast<uint8_t>((intermediate.d >> 8) & 0xff), static_cast<uint8_t>((intermediate.d >> 8) & 0xff),
static_cast<uint8_t>((intermediate.d >> 16) & 0xff), static_cast<uint8_t>((intermediate.d >> 16) & 0xff),
static_cast<uint8_t>((intermediate.d >> 24) & 0xff)}; static_cast<uint8_t>((intermediate.d >> 24) & 0xff)}};
} }
static constexpr uint32_t StringLength(const char* string) { static constexpr uint32_t StringLength(const char* string) {
const char* end = string; const char* end = string;
while (*end != 0) while (*end != 0)
++end; ++end;
return end - string; // Double check that the precision losing conversion is safe.
DCHECK(end >= string);
DCHECK(static_cast<std::ptrdiff_t>(static_cast<uint32_t>(end - string)) ==
(end - string));
return static_cast<uint32_t>(end - string);
}
static constexpr uint32_t SwapEndian(uint32_t a) {
return ((a & 0xff) << 24) | (((a >> 8) & 0xff) << 16) |
(((a >> 16) & 0xff) << 8) | ((a >> 24) & 0xff);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
...@@ -271,10 +281,15 @@ struct MD5CE { ...@@ -271,10 +281,15 @@ struct MD5CE {
return IntermediateDataToMD5Digest(ProcessMessage(data, n)); return IntermediateDataToMD5Digest(ProcessMessage(data, n));
} }
static constexpr uint64_t Hash(const char* data, uint32_t n) { static constexpr uint64_t Hash64(const char* data, uint32_t n) {
IntermediateData intermediate = ProcessMessage(data, n);
return (static_cast<uint64_t>(SwapEndian(intermediate.a)) << 32) |
static_cast<uint64_t>(SwapEndian(intermediate.b));
}
static constexpr uint32_t Hash32(const char* data, uint32_t n) {
IntermediateData intermediate = ProcessMessage(data, n); IntermediateData intermediate = ProcessMessage(data, n);
return (static_cast<uint64_t>(intermediate.b) << 32) | return SwapEndian(intermediate.a);
static_cast<uint64_t>(intermediate.a);
} }
}; };
...@@ -290,12 +305,20 @@ constexpr MD5Digest MD5SumConstexpr(const char* string, uint32_t length) { ...@@ -290,12 +305,20 @@ constexpr MD5Digest MD5SumConstexpr(const char* string, uint32_t length) {
return internal::MD5CE::Sum(string, length); return internal::MD5CE::Sum(string, length);
} }
constexpr uint64_t MD5HashConstexpr(const char* string) { constexpr uint64_t MD5Hash64Constexpr(const char* string) {
return internal::MD5CE::Hash(string, internal::MD5CE::StringLength(string)); return internal::MD5CE::Hash64(string, internal::MD5CE::StringLength(string));
}
constexpr uint64_t MD5Hash64Constexpr(const char* string, uint32_t length) {
return internal::MD5CE::Hash64(string, length);
}
constexpr uint32_t MD5Hash32Constexpr(const char* string) {
return internal::MD5CE::Hash32(string, internal::MD5CE::StringLength(string));
} }
constexpr uint64_t MD5HashConstexpr(const char* string, uint32_t length) { constexpr uint32_t MD5Hash32Constexpr(const char* string, uint32_t length) {
return internal::MD5CE::Hash(string, length); return internal::MD5CE::Hash32(string, length);
} }
} // namespace base } // namespace base
......
...@@ -36,8 +36,11 @@ static_assert(Equal(MD5SumConstexpr(kMessage0), ...@@ -36,8 +36,11 @@ static_assert(Equal(MD5SumConstexpr(kMessage0),
0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0}), 0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0}),
"incorrect MD5Sum implementation"); "incorrect MD5Sum implementation");
static_assert(MD5HashConstexpr(kMessage0) == 0x8D93B77C7D696BF9ull, static_assert(MD5Hash64Constexpr(kMessage0) == 0xF96B697D7CB7938Dull,
"incorrect MD5Hash implementation"); "incorrect MD5Hash64 implementation");
static_assert(MD5Hash32Constexpr(kMessage0) == 0xF96B697Dul,
"incorrect MD5Hash32 implementation");
constexpr char kMessage1[] = "The quick brown fox jumps over the lazy dog"; constexpr char kMessage1[] = "The quick brown fox jumps over the lazy dog";
static_assert(Equal(MD5SumConstexpr(kMessage1, base::size(kMessage1) - 1), static_assert(Equal(MD5SumConstexpr(kMessage1, base::size(kMessage1) - 1),
...@@ -45,9 +48,13 @@ static_assert(Equal(MD5SumConstexpr(kMessage1, base::size(kMessage1) - 1), ...@@ -45,9 +48,13 @@ static_assert(Equal(MD5SumConstexpr(kMessage1, base::size(kMessage1) - 1),
0x6b, 0xd8, 0x1d, 0x35, 0x42, 0xa4, 0x19, 0xd6}), 0x6b, 0xd8, 0x1d, 0x35, 0x42, 0xa4, 0x19, 0xd6}),
"incorrect MD5Sum implementation"); "incorrect MD5Sum implementation");
static_assert(MD5HashConstexpr(kMessage1, base::size(kMessage1) - 1) == static_assert(MD5Hash64Constexpr(kMessage1, base::size(kMessage1) - 1) ==
0x82b62b379d7d109eull, 0x9E107D9D372BB682ull,
"incorrect MD5Hash implementation"); "incorrect MD5Hash64 implementation");
static_assert(MD5Hash32Constexpr(kMessage1, base::size(kMessage1) - 1) ==
0x9E107D9Dul,
"incorrect MD5Hash32 implementation");
// Comparison operator for checking that the constexpr MD5 implementation // Comparison operator for checking that the constexpr MD5 implementation
// matches the default implementation. // matches the default implementation.
......
...@@ -617,13 +617,12 @@ LogMessage::~LogMessage() { ...@@ -617,13 +617,12 @@ LogMessage::~LogMessage() {
if (!task_trace.empty()) if (!task_trace.empty())
task_trace.OutputToStream(&stream_); task_trace.OutputToStream(&stream_);
// Include the IPC context, if any. This is output as a stack trace with a // Include the IPC context, if any.
// single frame. // TODO(chrisha): Integrate with symbolization once those tools exist!
const auto* task = base::TaskAnnotator::CurrentTaskForThread(); const auto* task = base::TaskAnnotator::CurrentTaskForThread();
if (task && task->ipc_program_counter) { if (task && task->ipc_hash) {
stream_ << "IPC message handler context:" << std::endl; stream_ << "IPC message handler context: "
base::debug::StackTrace ipc_trace(&task->ipc_program_counter, 1); << base::StringPrintf("0x%08X", task->ipc_hash) << std::endl;
ipc_trace.OutputToStream(&stream_);
} }
} }
#endif #endif
......
...@@ -59,14 +59,14 @@ struct BASE_EXPORT PendingTask { ...@@ -59,14 +59,14 @@ struct BASE_EXPORT PendingTask {
std::array<const void*, kTaskBacktraceLength> task_backtrace = {}; std::array<const void*, kTaskBacktraceLength> task_backtrace = {};
// The context of the IPC message that was being handled when this task was // The context of the IPC message that was being handled when this task was
// posted. This is a program counter that is set within the scope of an IPC // posted. This is a hash of the IPC message name that is set within the scope
// handler and when symbolized uniquely identifies the message being // of an IPC handler and when symbolized uniquely identifies the message being
// processed. This property is also propagated from one PendingTask to the // processed. This property is also propagated from one PendingTask to the
// next. For example, if pending task A was posted while handling an IPC, // next. For example, if pending task A was posted while handling an IPC,
// and pending task B was posted from within pending task A, then pending task // and pending task B was posted from within pending task A, then pending task
// B will inherit the |ipc_program_counter| of pending task A. In some sense // B will inherit the |ipc_hash| of pending task A. In some sense this can be
// this can be interpreted as a "root" task backtrace frame. // interpreted as a "root" task backtrace frame.
const void* ipc_program_counter = nullptr; uint32_t ipc_hash = 0;
// Secondary sort key for run time. // Secondary sort key for run time.
int sequence_num = 0; int sequence_num = 0;
......
...@@ -31,7 +31,7 @@ ThreadLocalPointer<PendingTask>* GetTLSForCurrentPendingTask() { ...@@ -31,7 +31,7 @@ ThreadLocalPointer<PendingTask>* GetTLSForCurrentPendingTask() {
} }
// Determines whether or not the given |task| is a dummy pending task that has // Determines whether or not the given |task| is a dummy pending task that has
// been injected by ScopedSetIpcProgramCounter solely for the purposes of // been injected by ScopedSetIpcHash solely for the purposes of
// tracking IPC context. // tracking IPC context.
bool IsDummyPendingTask(const PendingTask* task) { bool IsDummyPendingTask(const PendingTask* task) {
if (task->sequence_num == kSentinelSequenceNum && if (task->sequence_num == kSentinelSequenceNum &&
...@@ -78,7 +78,7 @@ void TaskAnnotator::WillQueueTask(const char* trace_event_name, ...@@ -78,7 +78,7 @@ void TaskAnnotator::WillQueueTask(const char* trace_event_name,
if (!parent_task) if (!parent_task)
return; return;
pending_task->ipc_program_counter = parent_task->ipc_program_counter; pending_task->ipc_hash = parent_task->ipc_hash;
pending_task->task_backtrace[0] = parent_task->posted_from.program_counter(); pending_task->task_backtrace[0] = parent_task->posted_from.program_counter();
std::copy(parent_task->task_backtrace.begin(), std::copy(parent_task->task_backtrace.begin(),
parent_task->task_backtrace.end() - 1, parent_task->task_backtrace.end() - 1,
...@@ -96,8 +96,7 @@ void TaskAnnotator::RunTask(const char* trace_event_name, ...@@ -96,8 +96,7 @@ void TaskAnnotator::RunTask(const char* trace_event_name,
debug::ScopedTaskRunActivity task_activity(*pending_task); debug::ScopedTaskRunActivity task_activity(*pending_task);
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("toplevel.ipc"), TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("toplevel.ipc"),
"TaskAnnotator::RunTask", "ipc_program_counter", "TaskAnnotator::RunTask", "ipc_hash", pending_task->ipc_hash);
pending_task->ipc_program_counter);
TRACE_EVENT_WITH_FLOW0( TRACE_EVENT_WITH_FLOW0(
TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), trace_event_name, TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), trace_event_name,
...@@ -115,9 +114,9 @@ void TaskAnnotator::RunTask(const char* trace_event_name, ...@@ -115,9 +114,9 @@ void TaskAnnotator::RunTask(const char* trace_event_name,
// Store a marker to locate |task_backtrace| content easily on a memory // Store a marker to locate |task_backtrace| content easily on a memory
// dump. The layout is as follows: // dump. The layout is as follows:
// //
// +------------ +----+---------+-----+-----------+--------+-------------+ // +------------ +----+---------+-----+-----------+----------+-------------+
// | Head Marker | PC | frame 0 | ... | frame N-1 | IPC PC | Tail Marker | // | Head Marker | PC | frame 0 | ... | frame N-1 | IPC hash | Tail Marker |
// +------------ +----+---------+-----+-----------+--------+-------------+ // +------------ +----+---------+-----+-----------+----------+-------------+
// //
// Markers glossary (compliments of wez): // Markers glossary (compliments of wez):
// cool code,do it dude! // cool code,do it dude!
...@@ -131,7 +130,7 @@ void TaskAnnotator::RunTask(const char* trace_event_name, ...@@ -131,7 +130,7 @@ void TaskAnnotator::RunTask(const char* trace_event_name,
std::copy(pending_task->task_backtrace.begin(), std::copy(pending_task->task_backtrace.begin(),
pending_task->task_backtrace.end(), task_backtrace.begin() + 2); pending_task->task_backtrace.end(), task_backtrace.begin() + 2);
task_backtrace[kStackTaskTraceSnapshotSize - 2] = task_backtrace[kStackTaskTraceSnapshotSize - 2] =
pending_task->ipc_program_counter; reinterpret_cast<void*>(pending_task->ipc_hash);
debug::Alias(&task_backtrace); debug::Alias(&task_backtrace);
auto* tls = GetTLSForCurrentPendingTask(); auto* tls = GetTLSForCurrentPendingTask();
...@@ -162,8 +161,7 @@ void TaskAnnotator::ClearObserverForTesting() { ...@@ -162,8 +161,7 @@ void TaskAnnotator::ClearObserverForTesting() {
g_task_annotator_observer = nullptr; g_task_annotator_observer = nullptr;
} }
TaskAnnotator::ScopedSetIpcProgramCounter::ScopedSetIpcProgramCounter( TaskAnnotator::ScopedSetIpcHash::ScopedSetIpcHash(uint32_t ipc_hash) {
const void* program_counter) {
// We store the IPC context in the currently running task. If there is none // We store the IPC context in the currently running task. If there is none
// then introduce a dummy task. // then introduce a dummy task.
auto* tls = GetTLSForCurrentPendingTask(); auto* tls = GetTLSForCurrentPendingTask();
...@@ -175,18 +173,18 @@ TaskAnnotator::ScopedSetIpcProgramCounter::ScopedSetIpcProgramCounter( ...@@ -175,18 +173,18 @@ TaskAnnotator::ScopedSetIpcProgramCounter::ScopedSetIpcProgramCounter(
tls->Set(current_task); tls->Set(current_task);
} }
old_ipc_program_counter_ = current_task->ipc_program_counter; old_ipc_hash_ = current_task->ipc_hash;
current_task->ipc_program_counter = program_counter; current_task->ipc_hash = ipc_hash;
} }
TaskAnnotator::ScopedSetIpcProgramCounter::~ScopedSetIpcProgramCounter() { TaskAnnotator::ScopedSetIpcHash::~ScopedSetIpcHash() {
auto* tls = GetTLSForCurrentPendingTask(); auto* tls = GetTLSForCurrentPendingTask();
auto* current_task = tls->Get(); auto* current_task = tls->Get();
DCHECK(current_task); DCHECK(current_task);
if (current_task == dummy_pending_task_.get()) { if (current_task == dummy_pending_task_.get()) {
tls->Set(nullptr); tls->Set(nullptr);
} else { } else {
current_task->ipc_program_counter = old_ipc_program_counter_; current_task->ipc_hash = old_ipc_hash_;
} }
} }
......
...@@ -27,9 +27,9 @@ class BASE_EXPORT TaskAnnotator { ...@@ -27,9 +27,9 @@ class BASE_EXPORT TaskAnnotator {
virtual void BeforeRunTask(const PendingTask* pending_task) = 0; virtual void BeforeRunTask(const PendingTask* pending_task) = 0;
}; };
// This is used to set the |ipc_program_counter| field for PendingTasks. It is // This is used to set the |ipc_hash| field for PendingTasks. It is intended
// intended to be used only from within generated IPC handler dispatch code. // to be used only from within generated IPC handler dispatch code.
class ScopedSetIpcProgramCounter; class ScopedSetIpcHash;
static const PendingTask* CurrentTaskForThread(); static const PendingTask* CurrentTaskForThread();
...@@ -66,16 +66,16 @@ class BASE_EXPORT TaskAnnotator { ...@@ -66,16 +66,16 @@ class BASE_EXPORT TaskAnnotator {
DISALLOW_COPY_AND_ASSIGN(TaskAnnotator); DISALLOW_COPY_AND_ASSIGN(TaskAnnotator);
}; };
class BASE_EXPORT TaskAnnotator::ScopedSetIpcProgramCounter { class BASE_EXPORT TaskAnnotator::ScopedSetIpcHash {
public: public:
explicit ScopedSetIpcProgramCounter(const void* program_counter); explicit ScopedSetIpcHash(uint32_t ipc_hash);
~ScopedSetIpcProgramCounter(); ~ScopedSetIpcHash();
private: private:
std::unique_ptr<PendingTask> dummy_pending_task_; std::unique_ptr<PendingTask> dummy_pending_task_;
const void* old_ipc_program_counter_ = nullptr; uint32_t old_ipc_hash_ = 0;
DISALLOW_COPY_AND_ASSIGN(ScopedSetIpcProgramCounter); DISALLOW_COPY_AND_ASSIGN(ScopedSetIpcHash);
}; };
} // namespace base } // namespace base
......
...@@ -62,7 +62,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -62,7 +62,7 @@ class TaskAnnotatorBacktraceIntegrationTest
AutoLock auto_lock(on_before_run_task_lock_); AutoLock auto_lock(on_before_run_task_lock_);
last_posted_from_ = pending_task->posted_from; last_posted_from_ = pending_task->posted_from;
last_task_backtrace_ = pending_task->task_backtrace; last_task_backtrace_ = pending_task->task_backtrace;
last_ipc_pc_ = pending_task->ipc_program_counter; last_ipc_hash_ = pending_task->ipc_hash;
} }
void SetUp() override { TaskAnnotator::RegisterObserverForTesting(this); } void SetUp() override { TaskAnnotator::RegisterObserverForTesting(this); }
...@@ -73,7 +73,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -73,7 +73,7 @@ class TaskAnnotatorBacktraceIntegrationTest
const Location& posted_from, const Location& posted_from,
const Location& next_from_here, const Location& next_from_here,
const ExpectedTrace& expected_trace, const ExpectedTrace& expected_trace,
const void* expected_ipc_pc, uint32_t expected_ipc_hash,
OnceClosure task) { OnceClosure task) {
SCOPED_TRACE(StringPrintf("Callback Depth: %zu", expected_trace.size())); SCOPED_TRACE(StringPrintf("Callback Depth: %zu", expected_trace.size()));
...@@ -85,7 +85,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -85,7 +85,7 @@ class TaskAnnotatorBacktraceIntegrationTest
else else
EXPECT_EQ(nullptr, last_task_backtrace_[i]); EXPECT_EQ(nullptr, last_task_backtrace_[i]);
} }
EXPECT_EQ(expected_ipc_pc, last_ipc_pc_); EXPECT_EQ(expected_ipc_hash, last_ipc_hash_);
task_runner->PostTask(next_from_here, std::move(task)); task_runner->PostTask(next_from_here, std::move(task));
} }
...@@ -95,12 +95,12 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -95,12 +95,12 @@ class TaskAnnotatorBacktraceIntegrationTest
const Location& posted_from, const Location& posted_from,
const Location& next_from_here, const Location& next_from_here,
const ExpectedTrace& expected_trace, const ExpectedTrace& expected_trace,
const void* expected_ipc_pc, uint32_t expected_ipc_hash,
OnceClosure task, OnceClosure task,
const void* new_ipc_pc) { uint32_t new_ipc_hash) {
TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc(new_ipc_pc); TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(new_ipc_hash);
VerifyTraceAndPost(task_runner, posted_from, next_from_here, expected_trace, VerifyTraceAndPost(task_runner, posted_from, next_from_here, expected_trace,
expected_ipc_pc, std::move(task)); expected_ipc_hash, std::move(task));
} }
// Same as VerifyTraceAndPost() with the exception that it also posts a task // Same as VerifyTraceAndPost() with the exception that it also posts a task
...@@ -111,7 +111,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -111,7 +111,7 @@ class TaskAnnotatorBacktraceIntegrationTest
const Location& posted_from, const Location& posted_from,
const Location& next_from_here, const Location& next_from_here,
const ExpectedTrace& expected_trace, const ExpectedTrace& expected_trace,
const void* expected_ipc_pc, uint32_t expected_ipc_hash,
OnceClosure task, OnceClosure task,
WaitableEvent* wait_before_next_task) { WaitableEvent* wait_before_next_task) {
DCHECK(wait_before_next_task); DCHECK(wait_before_next_task);
...@@ -125,7 +125,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -125,7 +125,7 @@ class TaskAnnotatorBacktraceIntegrationTest
FROM_HERE, FROM_HERE,
BindOnce(&WaitableEvent::Wait, Unretained(wait_before_next_task))); BindOnce(&WaitableEvent::Wait, Unretained(wait_before_next_task)));
VerifyTraceAndPost(task_runner, posted_from, next_from_here, expected_trace, VerifyTraceAndPost(task_runner, posted_from, next_from_here, expected_trace,
expected_ipc_pc, std::move(task)); expected_ipc_hash, std::move(task));
} }
protected: protected:
...@@ -146,7 +146,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -146,7 +146,7 @@ class TaskAnnotatorBacktraceIntegrationTest
std::array<const void*, PendingTask::kTaskBacktraceLength> std::array<const void*, PendingTask::kTaskBacktraceLength>
last_task_backtrace_ = {}; last_task_backtrace_ = {};
const void* last_ipc_pc_ = nullptr; uint32_t last_ipc_hash_ = 0;
DISALLOW_COPY_AND_ASSIGN(TaskAnnotatorBacktraceIntegrationTest); DISALLOW_COPY_AND_ASSIGN(TaskAnnotatorBacktraceIntegrationTest);
}; };
...@@ -154,7 +154,7 @@ class TaskAnnotatorBacktraceIntegrationTest ...@@ -154,7 +154,7 @@ class TaskAnnotatorBacktraceIntegrationTest
// Ensure the task backtrace populates correctly. // Ensure the task backtrace populates correctly.
TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) { TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) {
test::ScopedTaskEnvironment scoped_task_environment; test::ScopedTaskEnvironment scoped_task_environment;
const void* dummy_ipc_pc = &dummy_ipc_pc; const uint32_t dummy_ipc_hash = 0xDEADBEEF;
const Location location0 = FROM_HERE; const Location location0 = FROM_HERE;
const Location location1 = FROM_HERE; const Location location1 = FROM_HERE;
const Location location2 = FROM_HERE; const Location location2 = FROM_HERE;
...@@ -174,7 +174,7 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) { ...@@ -174,7 +174,7 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) {
Unretained(this), ThreadTaskRunnerHandle::Get(), location5, FROM_HERE, Unretained(this), ThreadTaskRunnerHandle::Get(), location5, FROM_HERE,
ExpectedTrace({location4.program_counter(), location3.program_counter(), ExpectedTrace({location4.program_counter(), location3.program_counter(),
location2.program_counter(), location1.program_counter()}), location2.program_counter(), location1.program_counter()}),
dummy_ipc_pc, run_loop.QuitClosure()); dummy_ipc_hash, run_loop.QuitClosure());
// Task i=4/3/2/1/0 have tasks [0,i) as parents. // Task i=4/3/2/1/0 have tasks [0,i) as parents.
OnceClosure task4 = BindOnce( OnceClosure task4 = BindOnce(
...@@ -182,27 +182,27 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) { ...@@ -182,27 +182,27 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedSimple) {
Unretained(this), ThreadTaskRunnerHandle::Get(), location4, location5, Unretained(this), ThreadTaskRunnerHandle::Get(), location4, location5,
ExpectedTrace({location3.program_counter(), location2.program_counter(), ExpectedTrace({location3.program_counter(), location2.program_counter(),
location1.program_counter(), location0.program_counter()}), location1.program_counter(), location0.program_counter()}),
dummy_ipc_pc, std::move(task5)); dummy_ipc_hash, std::move(task5));
OnceClosure task3 = BindOnce( OnceClosure task3 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location3, location4, Unretained(this), ThreadTaskRunnerHandle::Get(), location3, location4,
ExpectedTrace({location2.program_counter(), location1.program_counter(), ExpectedTrace({location2.program_counter(), location1.program_counter(),
location0.program_counter()}), location0.program_counter()}),
dummy_ipc_pc, std::move(task4)); dummy_ipc_hash, std::move(task4));
OnceClosure task2 = BindOnce( OnceClosure task2 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location2, location3, Unretained(this), ThreadTaskRunnerHandle::Get(), location2, location3,
ExpectedTrace({location1.program_counter(), location0.program_counter()}), ExpectedTrace({location1.program_counter(), location0.program_counter()}),
dummy_ipc_pc, std::move(task3)); dummy_ipc_hash, std::move(task3));
OnceClosure task1 = BindOnce( OnceClosure task1 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext,
Unretained(this), ThreadTaskRunnerHandle::Get(), location1, location2, Unretained(this), ThreadTaskRunnerHandle::Get(), location1, location2,
ExpectedTrace({location0.program_counter()}), nullptr, std::move(task2), ExpectedTrace({location0.program_counter()}), 0, std::move(task2),
dummy_ipc_pc); dummy_ipc_hash);
OnceClosure task0 = OnceClosure task0 =
BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location0, Unretained(this), ThreadTaskRunnerHandle::Get(), location0,
location1, ExpectedTrace({}), nullptr, std::move(task1)); location1, ExpectedTrace({}), 0, std::move(task1));
ThreadTaskRunnerHandle::Get()->PostTask(location0, std::move(task0)); ThreadTaskRunnerHandle::Get()->PostTask(location0, std::move(task0));
...@@ -255,8 +255,8 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) { ...@@ -255,8 +255,8 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) {
// TB0F inherits no context. // TB0F inherits no context.
// TC0 is posted with a new IPC context from TB0L. // TC0 is posted with a new IPC context from TB0L.
// TA2 inherits that IPC context. // TA2 inherits that IPC context.
const void* dummy_ipc_pc0 = &dummy_ipc_pc0; const uint32_t dummy_ipc_hash0 = 0xDEADBEEF;
const void* dummy_ipc_pc1 = &dummy_ipc_pc1; const uint32_t dummy_ipc_hash1 = 0xBAADF00D;
// On task runner c, post a task back to main thread that verifies its trace // On task runner c, post a task back to main thread that verifies its trace
// and terminates after one more self-post. // and terminates after one more self-post.
...@@ -266,14 +266,14 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) { ...@@ -266,14 +266,14 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) {
ExpectedTrace( ExpectedTrace(
{location_c0.program_counter(), location_b0.program_counter(), {location_c0.program_counter(), location_b0.program_counter(),
location_a1.program_counter(), location_a0.program_counter()}), location_a1.program_counter(), location_a0.program_counter()}),
dummy_ipc_pc1, run_loop.QuitClosure()); dummy_ipc_hash1, run_loop.QuitClosure());
OnceClosure task_c0 = BindOnce( OnceClosure task_c0 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext,
Unretained(this), main_thread_a, location_c0, location_a2, Unretained(this), main_thread_a, location_c0, location_a2,
ExpectedTrace({location_b0.program_counter(), ExpectedTrace({location_b0.program_counter(),
location_a1.program_counter(), location_a1.program_counter(),
location_a0.program_counter()}), location_a0.program_counter()}),
nullptr, std::move(task_a2), dummy_ipc_pc1); 0, std::move(task_a2), dummy_ipc_hash1);
// On task runner b run two tasks that conceptually come from the same // On task runner b run two tasks that conceptually come from the same
// location (managed via RunTwo().) One will post back to task runner b and // location (managed via RunTwo().) One will post back to task runner b and
...@@ -285,25 +285,25 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) { ...@@ -285,25 +285,25 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) {
Unretained(this), task_runner_c, location_b0, location_c0, Unretained(this), task_runner_c, location_b0, location_c0,
ExpectedTrace( ExpectedTrace(
{location_a1.program_counter(), location_a0.program_counter()}), {location_a1.program_counter(), location_a0.program_counter()}),
nullptr, std::move(task_c0), &lock_step); 0, std::move(task_c0), &lock_step);
OnceClosure task_b0_local = BindOnce( OnceClosure task_b0_local = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext,
Unretained(this), task_runner_b, location_b0, location_b1, Unretained(this), task_runner_b, location_b0, location_b1,
ExpectedTrace( ExpectedTrace(
{location_a1.program_counter(), location_a0.program_counter()}), {location_a1.program_counter(), location_a0.program_counter()}),
nullptr, BindOnce(&WaitableEvent::Signal, Unretained(&lock_step)), 0, BindOnce(&WaitableEvent::Signal, Unretained(&lock_step)),
dummy_ipc_pc0); dummy_ipc_hash0);
OnceClosure task_a1 = OnceClosure task_a1 =
BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), task_runner_b, location_a1, location_b0, Unretained(this), task_runner_b, location_a1, location_b0,
ExpectedTrace({location_a0.program_counter()}), nullptr, ExpectedTrace({location_a0.program_counter()}), 0,
BindOnce(&TaskAnnotatorBacktraceIntegrationTest::RunTwo, BindOnce(&TaskAnnotatorBacktraceIntegrationTest::RunTwo,
std::move(task_b0_local), std::move(task_b0_fork))); std::move(task_b0_local), std::move(task_b0_fork)));
OnceClosure task_a0 = OnceClosure task_a0 =
BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, BindOnce(&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), main_thread_a, location_a0, location_a1, Unretained(this), main_thread_a, location_a0, location_a1,
ExpectedTrace({}), nullptr, std::move(task_a1)); ExpectedTrace({}), 0, std::move(task_a1));
main_thread_a->PostTask(location_a0, std::move(task_a0)); main_thread_a->PostTask(location_a0, std::move(task_a0));
...@@ -313,9 +313,9 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) { ...@@ -313,9 +313,9 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, MultipleThreads) {
// Ensure nesting doesn't break the chain. // Ensure nesting doesn't break the chain.
TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) { TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) {
test::ScopedTaskEnvironment scoped_task_environment; test::ScopedTaskEnvironment scoped_task_environment;
const void* dummy_ipc_pc = &dummy_ipc_pc; uint32_t dummy_ipc_hash = 0xDEADBEEF;
const void* dummy_ipc_pc1 = &dummy_ipc_pc1; uint32_t dummy_ipc_hash1 = 0xBAADF00D;
const void* dummy_ipc_pc2 = &dummy_ipc_pc2; uint32_t dummy_ipc_hash2 = 0x900DD099;
const Location location0 = FROM_HERE; const Location location0 = FROM_HERE;
const Location location1 = FROM_HERE; const Location location1 = FROM_HERE;
const Location location2 = FROM_HERE; const Location location2 = FROM_HERE;
...@@ -359,19 +359,19 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) { ...@@ -359,19 +359,19 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) {
Unretained(this), ThreadTaskRunnerHandle::Get(), location5, FROM_HERE, Unretained(this), ThreadTaskRunnerHandle::Get(), location5, FROM_HERE,
ExpectedTrace({location4.program_counter(), location3.program_counter(), ExpectedTrace({location4.program_counter(), location3.program_counter(),
location2.program_counter(), location1.program_counter()}), location2.program_counter(), location1.program_counter()}),
dummy_ipc_pc, run_loop.QuitClosure()); dummy_ipc_hash, run_loop.QuitClosure());
OnceClosure task4 = BindOnce( OnceClosure task4 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location4, location5, Unretained(this), ThreadTaskRunnerHandle::Get(), location4, location5,
ExpectedTrace({location3.program_counter(), location2.program_counter(), ExpectedTrace({location3.program_counter(), location2.program_counter(),
location1.program_counter(), location0.program_counter()}), location1.program_counter(), location0.program_counter()}),
dummy_ipc_pc, std::move(task5)); dummy_ipc_hash, std::move(task5));
OnceClosure task3 = BindOnce( OnceClosure task3 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location3, location4, Unretained(this), ThreadTaskRunnerHandle::Get(), location3, location4,
ExpectedTrace({location2.program_counter(), location1.program_counter(), ExpectedTrace({location2.program_counter(), location1.program_counter(),
location0.program_counter()}), location0.program_counter()}),
dummy_ipc_pc, std::move(task4)); dummy_ipc_hash, std::move(task4));
OnceClosure run_task_3_then_quit_nested_loop1 = OnceClosure run_task_3_then_quit_nested_loop1 =
BindOnce(&TaskAnnotatorBacktraceIntegrationTest::RunTwo, std::move(task3), BindOnce(&TaskAnnotatorBacktraceIntegrationTest::RunTwo, std::move(task3),
...@@ -381,22 +381,21 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) { ...@@ -381,22 +381,21 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) {
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPost,
Unretained(this), ThreadTaskRunnerHandle::Get(), location2, location3, Unretained(this), ThreadTaskRunnerHandle::Get(), location2, location3,
ExpectedTrace({location1.program_counter(), location0.program_counter()}), ExpectedTrace({location1.program_counter(), location0.program_counter()}),
dummy_ipc_pc, std::move(run_task_3_then_quit_nested_loop1)); dummy_ipc_hash, std::move(run_task_3_then_quit_nested_loop1));
// Task 1 is custom. It enters another nested RunLoop, has it do work and exit // Task 1 is custom. It enters another nested RunLoop, has it do work and exit
// before posting the next task. This confirms that |task1| is restored as the // before posting the next task. This confirms that |task1| is restored as the
// current task before posting |task2| after returning from the nested loop. // current task before posting |task2| after returning from the nested loop.
RunLoop nested_run_loop2(RunLoop::Type::kNestableTasksAllowed); RunLoop nested_run_loop2(RunLoop::Type::kNestableTasksAllowed);
OnceClosure task1 = BindOnce( OnceClosure task1 = BindOnce(
BindLambdaForTesting([dummy_ipc_pc1](RunLoop* nested_run_loop, BindLambdaForTesting([dummy_ipc_hash1](RunLoop* nested_run_loop,
const Location& location2, const Location& location2,
OnceClosure task2) { OnceClosure task2) {
{ {
// Run the nested message loop with an explicitly set IPC context. // Run the nested message loop with an explicitly set IPC context.
// This context should not leak out of the inner loop and color the // This context should not leak out of the inner loop and color the
// tasks in the outer loop. // tasks in the outer loop.
TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc( TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(dummy_ipc_hash1);
dummy_ipc_pc1);
ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, DoNothing()); ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, DoNothing());
nested_run_loop->RunUntilIdle(); nested_run_loop->RunUntilIdle();
} }
...@@ -407,12 +406,12 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) { ...@@ -407,12 +406,12 @@ TEST_F(TaskAnnotatorBacktraceIntegrationTest, SingleThreadedNested) {
OnceClosure task0 = BindOnce( OnceClosure task0 = BindOnce(
&TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext, &TaskAnnotatorBacktraceIntegrationTest::VerifyTraceAndPostWithIpcContext,
Unretained(this), ThreadTaskRunnerHandle::Get(), location0, location1, Unretained(this), ThreadTaskRunnerHandle::Get(), location0, location1,
ExpectedTrace({}), nullptr, std::move(task1), dummy_ipc_pc); ExpectedTrace({}), 0, std::move(task1), dummy_ipc_hash);
ThreadTaskRunnerHandle::Get()->PostTask(location0, std::move(task0)); ThreadTaskRunnerHandle::Get()->PostTask(location0, std::move(task0));
{ {
TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc(dummy_ipc_pc2); TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(dummy_ipc_hash2);
ThreadTaskRunnerHandle::Get()->PostTask( ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, BindOnce(&RunLoop::Run, Unretained(&nested_run_loop1))); FROM_HERE, BindOnce(&RunLoop::Run, Unretained(&nested_run_loop1)));
} }
......
...@@ -199,6 +199,7 @@ ...@@ -199,6 +199,7 @@
#include <tuple> #include <tuple>
#include "base/export_template.h" #include "base/export_template.h"
#include "base/hash/md5_constexpr.h"
#include "base/location.h" #include "base/location.h"
#include "base/task/common/task_annotator.h" #include "base/task/common/task_annotator.h"
#include "ipc/ipc_message_templates.h" #include "ipc/ipc_message_templates.h"
...@@ -325,12 +326,15 @@ ...@@ -325,12 +326,15 @@
// return handled; // return handled;
// } // }
#define IPC_TASK_ANNOTATOR_STRINGIFY(s) #s
// A macro to be used from within the IPC_MESSAGE_FORWARD macros, for providing // A macro to be used from within the IPC_MESSAGE_FORWARD macros, for providing
// the IPC message context to the TaskAnnotator. This allows posted tasks to be // the IPC message context to the TaskAnnotator. This allows posted tasks to be
// associated with the incoming IPC message that caused them to be posted. // associated with the incoming IPC message that caused them to be posted.
#define IPC_TASK_ANNOTATOR_CONTEXT(msg_class) \ #define IPC_TASK_ANNOTATOR_CONTEXT(msg_class) \
base::TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc( \ static constexpr uint32_t kMessageHash = \
base::GetProgramCounter()); base::MD5Hash32Constexpr(IPC_TASK_ANNOTATOR_STRINGIFY(msg_class)); \
base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash);
#define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \ #define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \
{ \ { \
......
...@@ -407,8 +407,9 @@ bool {{class_name}}StubDispatch::Accept( ...@@ -407,8 +407,9 @@ bool {{class_name}}StubDispatch::Accept(
"(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}", "(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}",
"message", message->name()); "message", message->name());
#endif #endif
base::TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc( static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr(
base::GetProgramCounter()); "(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}");
base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash);
mojo::internal::MessageDispatchContext context(message); mojo::internal::MessageDispatchContext context(message);
{%- if method|method_supports_lazy_serialization %} {%- if method|method_supports_lazy_serialization %}
if (!message->is_serialized()) { if (!message->is_serialized()) {
...@@ -464,8 +465,9 @@ bool {{class_name}}StubDispatch::AcceptWithResponder( ...@@ -464,8 +465,9 @@ bool {{class_name}}StubDispatch::AcceptWithResponder(
"(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}", "(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}",
"message", message->name()); "message", message->name());
#endif #endif
base::TaskAnnotator::ScopedSetIpcProgramCounter scoped_ipc_pc( static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr(
base::GetProgramCounter()); "(Impl){{namespace_as_string}}::{{class_name}}::{{method.name}}");
base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash);
mojo::internal::MessageDispatchContext context(message); mojo::internal::MessageDispatchContext context(message);
{%- if method|method_supports_lazy_serialization %} {%- if method|method_supports_lazy_serialization %}
if (!message->is_serialized()) { if (!message->is_serialized()) {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <stdint.h> #include <stdint.h>
#include <utility> #include <utility>
#include "base/location.h" #include "base/hash/md5_constexpr.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/task/common/task_annotator.h" #include "base/task/common/task_annotator.h"
......
...@@ -36,8 +36,7 @@ const char* const kRendererHostAllowedArgs[] = { ...@@ -36,8 +36,7 @@ const char* const kRendererHostAllowedArgs[] = {
"bytes_allocated", nullptr}; "bytes_allocated", nullptr};
const char* const kV8GCAllowedArgs[] = {"num_items", "num_tasks", nullptr}; const char* const kV8GCAllowedArgs[] = {"num_items", "num_tasks", nullptr};
const char* const kTopLevelFlowAllowedArgs[] = {"task_queue_name", nullptr}; const char* const kTopLevelFlowAllowedArgs[] = {"task_queue_name", nullptr};
const char* const kTopLevelIpcRunTaskAllowedArgs[] = {"ipc_program_counter", const char* const kTopLevelIpcRunTaskAllowedArgs[] = {"ipc_hash", nullptr};
nullptr};
const WhitelistEntry kEventArgsWhitelist[] = { const WhitelistEntry kEventArgsWhitelist[] = {
{"__metadata", "thread_name", nullptr}, {"__metadata", "thread_name", nullptr},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment