• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H_
6 #define V8_LIBPLATFORM_TRACING_RECORDER_H_
7 
8 #include <stdint.h>
9 
10 #include "include/libplatform/v8-tracing.h"
11 
12 #if !defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
13 #error "only include this file if V8_ENABLE_SYSTEM_INSTRUMENTATION"
14 #endif
15 
16 #if V8_OS_DARWIN
17 #include <os/signpost.h>
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wunguarded-availability"
20 #endif
21 
22 #if V8_OS_WIN
23 #ifndef V8_ETW_GUID
24 #define V8_ETW_GUID \
25   0x57277741, 0x3638, 0x4A4B, 0xBD, 0xBA, 0x0A, 0xC6, 0xE4, 0x5D, 0xA5, 0x6C
26 #endif
27 #endif
28 
29 namespace v8 {
30 namespace platform {
31 namespace tracing {
32 
33 // This class serves as a base class for emitting events to system event
34 // controllers: ETW for Windows, Signposts on Mac (to be implemented). It is
35 // enabled by turning on both the ENABLE_SYSTEM_INSTRUMENTATION build flag and
36 // the --enable-system-instrumentation command line flag. When enabled, it is
37 // called from within SystemInstrumentationTraceWriter and replaces the
38 // JSONTraceWriter for event-tracing.
39 class V8_PLATFORM_EXPORT Recorder {
40  public:
41   Recorder();
42   ~Recorder();
43 
44   bool IsEnabled();
45   bool IsEnabled(const uint8_t level);
46 
47   void AddEvent(TraceObject* trace_event);
48 
49  private:
50 #if V8_OS_DARWIN
51   os_log_t v8Provider;
52 #endif
53 };
54 
55 }  // namespace tracing
56 }  // namespace platform
57 }  // namespace v8
58 
59 #if V8_OS_DARWIN
60 #pragma clang diagnostic pop
61 #endif
62 
63 #endif  // V8_LIBPLATFORM_TRACING_RECORDER_H_
64