Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: include/libplatform/v8-tracing.h

Issue 2190973003: [Tracing] V8 Tracing Controller - Add args and copy support (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More fixes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/d8.cc » ('j') | src/libplatform/tracing/trace-object.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "include/v8.h"
lpy 2016/07/28 21:18:20 Please do not include v8.h here.
rskang 2016/07/28 22:44:27 Done.
13
12 namespace v8 { 14 namespace v8 {
13 namespace platform { 15 namespace platform {
14 namespace tracing { 16 namespace tracing {
15 17
18 const int kTraceMaxNumArgs = 2;
19
16 class TraceObject { 20 class TraceObject {
17 public: 21 public:
22 union TraceValue {
23 bool as_bool;
24 uint64_t as_uint;
25 int64_t as_int;
26 double as_double;
27 const void* as_pointer;
28 const char* as_string;
29 };
30
18 TraceObject() {} 31 TraceObject() {}
32 ~TraceObject();
19 void Initialize(char phase, const uint8_t* category_enabled_flag, 33 void Initialize(char phase, const uint8_t* category_enabled_flag,
20 const char* name, const char* scope, uint64_t id, 34 const char* name, const char* scope, uint64_t id,
21 uint64_t bind_id, int num_args, const char** arg_names, 35 uint64_t bind_id, int num_args, const char** arg_names,
22 const uint8_t* arg_types, const uint64_t* arg_values, 36 const uint8_t* arg_types, const uint64_t* arg_values,
23 unsigned int flags); 37 unsigned int flags);
24 void UpdateDuration(); 38 void UpdateDuration();
25 void InitializeForTesting(char phase, const uint8_t* category_enabled_flag, 39 void InitializeForTesting(char phase, const uint8_t* category_enabled_flag,
26 const char* name, const char* scope, uint64_t id, 40 const char* name, const char* scope, uint64_t id,
27 uint64_t bind_id, int num_args, 41 uint64_t bind_id, int num_args,
28 const char** arg_names, const uint8_t* arg_types, 42 const char** arg_names, const uint8_t* arg_types,
29 const uint64_t* arg_values, unsigned int flags, 43 const uint64_t* arg_values, unsigned int flags,
30 int pid, int tid, int64_t ts, int64_t tts, 44 int pid, int tid, int64_t ts, int64_t tts,
31 uint64_t duration, uint64_t cpu_duration); 45 uint64_t duration, uint64_t cpu_duration);
32 46
33 int pid() const { return pid_; } 47 int pid() const { return pid_; }
34 int tid() const { return tid_; } 48 int tid() const { return tid_; }
35 char phase() const { return phase_; } 49 char phase() const { return phase_; }
36 const uint8_t* category_enabled_flag() const { 50 const uint8_t* category_enabled_flag() const {
37 return category_enabled_flag_; 51 return category_enabled_flag_;
38 } 52 }
39 const char* name() const { return name_; } 53 const char* name() const { return name_; }
40 const char* scope() const { return scope_; } 54 const char* scope() const { return scope_; }
41 uint64_t id() const { return id_; } 55 uint64_t id() const { return id_; }
42 uint64_t bind_id() const { return bind_id_; } 56 uint64_t bind_id() const { return bind_id_; }
57 TraceValue* arg_values() { return arg_values_; }
58 const char** arg_names() { return arg_names_; }
59 uint8_t* arg_types() { return arg_types_; }
43 unsigned int flags() const { return flags_; } 60 unsigned int flags() const { return flags_; }
44 int64_t ts() { return ts_; } 61 int64_t ts() { return ts_; }
45 int64_t tts() { return tts_; } 62 int64_t tts() { return tts_; }
46 uint64_t duration() { return duration_; } 63 uint64_t duration() { return duration_; }
47 uint64_t cpu_duration() { return cpu_duration_; } 64 uint64_t cpu_duration() { return cpu_duration_; }
48 65
49 private: 66 private:
50 int pid_; 67 int pid_;
51 int tid_; 68 int tid_;
52 char phase_; 69 char phase_;
53 const char* name_; 70 const char* name_;
54 const char* scope_; 71 const char* scope_;
55 const uint8_t* category_enabled_flag_; 72 const uint8_t* category_enabled_flag_;
56 uint64_t id_; 73 uint64_t id_;
57 uint64_t bind_id_; 74 uint64_t bind_id_;
58 int num_args_; 75 TraceValue arg_values_[kTraceMaxNumArgs];
76 const char* arg_names_[kTraceMaxNumArgs];
77 uint8_t arg_types_[kTraceMaxNumArgs];
78 char* parameter_copy_storage_ = nullptr;
59 unsigned int flags_; 79 unsigned int flags_;
60 int64_t ts_; 80 int64_t ts_;
61 int64_t tts_; 81 int64_t tts_;
62 uint64_t duration_; 82 uint64_t duration_;
63 uint64_t cpu_duration_; 83 uint64_t cpu_duration_;
64 // TODO(fmeawad): Add args support.
65 84
66 // Disallow copy and assign 85 // Disallow copy and assign
67 TraceObject(const TraceObject&) = delete; 86 TraceObject(const TraceObject&) = delete;
68 void operator=(const TraceObject&) = delete; 87 void operator=(const TraceObject&) = delete;
69 }; 88 };
70 89
71 class TraceWriter { 90 class TraceWriter {
72 public: 91 public:
73 TraceWriter() {} 92 TraceWriter() {}
74 virtual ~TraceWriter() {} 93 virtual ~TraceWriter() {}
75 virtual void AppendTraceEvent(TraceObject* trace_event) = 0; 94 virtual void AppendTraceEvent(TraceObject* trace_event) = 0;
76 virtual void Flush() = 0; 95 virtual void Flush() = 0;
77 96
78 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream); 97 static TraceWriter* CreateJSONTraceWriter(Isolate* isolate,
98 std::ostream& stream);
79 99
80 private: 100 private:
81 // Disallow copy and assign 101 // Disallow copy and assign
82 TraceWriter(const TraceWriter&) = delete; 102 TraceWriter(const TraceWriter&) = delete;
83 void operator=(const TraceWriter&) = delete; 103 void operator=(const TraceWriter&) = delete;
84 }; 104 };
85 105
86 class TraceBufferChunk { 106 class TraceBufferChunk {
87 public: 107 public:
88 explicit TraceBufferChunk(uint32_t seq); 108 explicit TraceBufferChunk(uint32_t seq);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Disallow copy and assign 243 // Disallow copy and assign
224 TracingController(const TracingController&) = delete; 244 TracingController(const TracingController&) = delete;
225 void operator=(const TracingController&) = delete; 245 void operator=(const TracingController&) = delete;
226 }; 246 };
227 247
228 } // namespace tracing 248 } // namespace tracing
229 } // namespace platform 249 } // namespace platform
230 } // namespace v8 250 } // namespace v8
231 251
232 #endif // V8_LIBPLATFORM_V8_TRACING_H_ 252 #endif // V8_LIBPLATFORM_V8_TRACING_H_
OLDNEW
« no previous file with comments | « no previous file | src/d8.cc » ('j') | src/libplatform/tracing/trace-object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698