task_execution_macros.h 1.5 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_TRACE_EVENT_TASK_EXECUTION_MACROS_H_
  5. #define BASE_TRACE_EVENT_TASK_EXECUTION_MACROS_H_
  6. #include "base/location.h"
  7. #include "base/trace_event/heap_profiler.h"
  8. #include "base/trace_event/interned_args_helper.h"
  9. #include "base/trace_event/typed_macros.h"
  10. #include "third_party/perfetto/protos/perfetto/trace/track_event/log_message.pbzero.h"
  11. #include "third_party/perfetto/protos/perfetto/trace/track_event/task_execution.pbzero.h"
  12. // Implementation detail: internal macro to trace a log message, with the source
  13. // location of the log statement.
  14. #define INTERNAL_TRACE_LOG_MESSAGE(file, message, line) \
  15. TRACE_EVENT_INSTANT("log", "LogMessage", [&](perfetto::EventContext ctx) { \
  16. perfetto::protos::pbzero::LogMessage* log = \
  17. ctx.event()->set_log_message(); \
  18. log->set_source_location_iid( \
  19. base::trace_event::InternedSourceLocation::Get( \
  20. &ctx, base::trace_event::TraceSourceLocation( \
  21. /*function_name=*/nullptr, file, line))); \
  22. log->set_body_iid(base::trace_event::InternedLogMessage::Get( \
  23. &ctx, std::string(message))); \
  24. });
  25. #endif // BASE_TRACE_EVENT_TASK_EXECUTION_MACROS_H_