OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_LIBPLATFORM_V8_TRACING_H_ | 5 #ifndef V8_LIBPLATFORM_V8_TRACING_H_ |
6 #define V8_LIBPLATFORM_V8_TRACING_H_ | 6 #define V8_LIBPLATFORM_V8_TRACING_H_ |
7 | 7 |
8 #include <fstream> | 8 #include <fstream> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace platform { | 13 namespace platform { |
14 namespace tracing { | 14 namespace tracing { |
15 | 15 |
| 16 const int kTraceMaxNumArgs = 2; |
| 17 |
16 class TraceObject { | 18 class TraceObject { |
17 public: | 19 public: |
| 20 union TraceValue { |
| 21 bool as_bool; |
| 22 uint64_t as_uint; |
| 23 int64_t as_int; |
| 24 double as_double; |
| 25 const void* as_pointer; |
| 26 const char* as_string; |
| 27 }; |
| 28 |
18 TraceObject() {} | 29 TraceObject() {} |
| 30 ~TraceObject(); |
19 void Initialize(char phase, const uint8_t* category_enabled_flag, | 31 void Initialize(char phase, const uint8_t* category_enabled_flag, |
20 const char* name, const char* scope, uint64_t id, | 32 const char* name, const char* scope, uint64_t id, |
21 uint64_t bind_id, int num_args, const char** arg_names, | 33 uint64_t bind_id, int num_args, const char** arg_names, |
22 const uint8_t* arg_types, const uint64_t* arg_values, | 34 const uint8_t* arg_types, const uint64_t* arg_values, |
23 unsigned int flags); | 35 unsigned int flags); |
24 void UpdateDuration(); | 36 void UpdateDuration(); |
25 void InitializeForTesting(char phase, const uint8_t* category_enabled_flag, | 37 void InitializeForTesting(char phase, const uint8_t* category_enabled_flag, |
26 const char* name, const char* scope, uint64_t id, | 38 const char* name, const char* scope, uint64_t id, |
27 uint64_t bind_id, int num_args, | 39 uint64_t bind_id, int num_args, |
28 const char** arg_names, const uint8_t* arg_types, | 40 const char** arg_names, const uint8_t* arg_types, |
29 const uint64_t* arg_values, unsigned int flags, | 41 const uint64_t* arg_values, unsigned int flags, |
30 int pid, int tid, int64_t ts, int64_t tts, | 42 int pid, int tid, int64_t ts, int64_t tts, |
31 uint64_t duration, uint64_t cpu_duration); | 43 uint64_t duration, uint64_t cpu_duration); |
32 | 44 |
33 int pid() const { return pid_; } | 45 int pid() const { return pid_; } |
34 int tid() const { return tid_; } | 46 int tid() const { return tid_; } |
35 char phase() const { return phase_; } | 47 char phase() const { return phase_; } |
36 const uint8_t* category_enabled_flag() const { | 48 const uint8_t* category_enabled_flag() const { |
37 return category_enabled_flag_; | 49 return category_enabled_flag_; |
38 } | 50 } |
39 const char* name() const { return name_; } | 51 const char* name() const { return name_; } |
40 const char* scope() const { return scope_; } | 52 const char* scope() const { return scope_; } |
41 uint64_t id() const { return id_; } | 53 uint64_t id() const { return id_; } |
42 uint64_t bind_id() const { return bind_id_; } | 54 uint64_t bind_id() const { return bind_id_; } |
| 55 TraceValue* arg_values() { return arg_values_; } |
| 56 const char** arg_names() { return arg_names_; } |
| 57 uint8_t* arg_types() { return arg_types_; } |
43 unsigned int flags() const { return flags_; } | 58 unsigned int flags() const { return flags_; } |
44 int64_t ts() { return ts_; } | 59 int64_t ts() { return ts_; } |
45 int64_t tts() { return tts_; } | 60 int64_t tts() { return tts_; } |
46 uint64_t duration() { return duration_; } | 61 uint64_t duration() { return duration_; } |
47 uint64_t cpu_duration() { return cpu_duration_; } | 62 uint64_t cpu_duration() { return cpu_duration_; } |
48 | 63 |
49 private: | 64 private: |
50 int pid_; | 65 int pid_; |
51 int tid_; | 66 int tid_; |
52 char phase_; | 67 char phase_; |
53 const char* name_; | 68 const char* name_; |
54 const char* scope_; | 69 const char* scope_; |
55 const uint8_t* category_enabled_flag_; | 70 const uint8_t* category_enabled_flag_; |
56 uint64_t id_; | 71 uint64_t id_; |
57 uint64_t bind_id_; | 72 uint64_t bind_id_; |
58 int num_args_; | 73 TraceValue arg_values_[kTraceMaxNumArgs]; |
| 74 const char* arg_names_[kTraceMaxNumArgs]; |
| 75 uint8_t arg_types_[kTraceMaxNumArgs]; |
| 76 char* parameter_copy_storage_ = nullptr; |
59 unsigned int flags_; | 77 unsigned int flags_; |
60 int64_t ts_; | 78 int64_t ts_; |
61 int64_t tts_; | 79 int64_t tts_; |
62 uint64_t duration_; | 80 uint64_t duration_; |
63 uint64_t cpu_duration_; | 81 uint64_t cpu_duration_; |
64 // TODO(fmeawad): Add args support. | |
65 | 82 |
66 // Disallow copy and assign | 83 // Disallow copy and assign |
67 TraceObject(const TraceObject&) = delete; | 84 TraceObject(const TraceObject&) = delete; |
68 void operator=(const TraceObject&) = delete; | 85 void operator=(const TraceObject&) = delete; |
69 }; | 86 }; |
70 | 87 |
71 class TraceWriter { | 88 class TraceWriter { |
72 public: | 89 public: |
73 TraceWriter() {} | 90 TraceWriter() {} |
74 virtual ~TraceWriter() {} | 91 virtual ~TraceWriter() {} |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Disallow copy and assign | 240 // Disallow copy and assign |
224 TracingController(const TracingController&) = delete; | 241 TracingController(const TracingController&) = delete; |
225 void operator=(const TracingController&) = delete; | 242 void operator=(const TracingController&) = delete; |
226 }; | 243 }; |
227 | 244 |
228 } // namespace tracing | 245 } // namespace tracing |
229 } // namespace platform | 246 } // namespace platform |
230 } // namespace v8 | 247 } // namespace v8 |
231 | 248 |
232 #endif // V8_LIBPLATFORM_V8_TRACING_H_ | 249 #endif // V8_LIBPLATFORM_V8_TRACING_H_ |
OLD | NEW |