v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
recorder-win.cc
Go to the documentation of this file.
1// Copyright 2020 the V8 project 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
5#ifndef V8_LIBPLATFORM_TRACING_RECORDER_WIN_H_
6#define V8_LIBPLATFORM_TRACING_RECORDER_WIN_H_
7
10
11namespace v8 {
12namespace platform {
13namespace tracing {
14
17
18Recorder::Recorder() { TraceLoggingRegister(g_v8LibProvider); }
19
21 if (g_v8LibProvider) {
22 TraceLoggingUnregister(g_v8LibProvider);
23 }
24}
25
27 return TraceLoggingProviderEnabled(g_v8LibProvider, 0, 0);
28}
29
30bool Recorder::IsEnabled(const uint8_t level) {
31 return TraceLoggingProviderEnabled(g_v8LibProvider, level, 0);
32}
33
34void Recorder::AddEvent(TraceObject* trace_event) {
35 // TODO(sartang@microsoft.com): Figure out how to write the conditional
36 // arguments
37 wchar_t wName[4096];
38 MultiByteToWideChar(CP_ACP, 0, trace_event->name(), -1, wName, 4096);
39
40#if defined(V8_USE_PERFETTO)
41 const wchar_t* wCategoryGroupName = L"";
42#else // defined(V8_USE_PERFETTO)
43 wchar_t wCategoryGroupName[4096];
44 MultiByteToWideChar(CP_ACP, 0,
46 trace_event->category_enabled_flag()),
47 -1, wCategoryGroupName, 4096);
48#endif // !defined(V8_USE_PERFETTO)
49
50 TraceLoggingWrite(g_v8LibProvider, "", TraceLoggingValue(wName, "Event Name"),
51 TraceLoggingValue(trace_event->pid(), "pid"),
52 TraceLoggingValue(trace_event->tid(), "tid"),
53 TraceLoggingValue(trace_event->ts(), "ts"),
54 TraceLoggingValue(trace_event->tts(), "tts"),
55 TraceLoggingValue(trace_event->phase(), "phase"),
56 TraceLoggingValue(wCategoryGroupName, "category"),
57 TraceLoggingValue(trace_event->duration(), "dur"),
58 TraceLoggingValue(trace_event->cpu_duration(), "tdur"));
59}
60
61} // namespace tracing
62} // namespace platform
63} // namespace v8
64
65#endif // V8_LIBPLATFORM_TRACING_RECORDER_WIN_H_
void AddEvent(TraceObject *trace_event)
static const char * GetCategoryGroupName(const uint8_t *category_enabled_flag)
#define V8_DEFINE_TRACELOGGING_PROVIDER(v8Provider)
#define V8_DECLARE_TRACELOGGING_PROVIDER(v8Provider)
constexpr int L