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 #include <limits> | 4 #include <limits> |
5 | 5 |
6 #include "include/libplatform/v8-tracing.h" | 6 #include "include/libplatform/v8-tracing.h" |
7 #include "src/tracing/trace-event.h" | 7 #include "src/tracing/trace-event.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 int16_t gg = -77; | 210 int16_t gg = -77; |
211 signed char hh = -88; | 211 signed char hh = -88; |
212 bool ii1 = true; | 212 bool ii1 = true; |
213 bool ii2 = false; | 213 bool ii2 = false; |
214 double jj1 = 99.0; | 214 double jj1 = 99.0; |
215 double jj2 = 1e100; | 215 double jj2 = 1e100; |
216 double jj3 = std::numeric_limits<double>::quiet_NaN(); | 216 double jj3 = std::numeric_limits<double>::quiet_NaN(); |
217 double jj4 = std::numeric_limits<double>::infinity(); | 217 double jj4 = std::numeric_limits<double>::infinity(); |
218 double jj5 = -std::numeric_limits<double>::infinity(); | 218 double jj5 = -std::numeric_limits<double>::infinity(); |
219 void* kk = &aa; | 219 void* kk = &aa; |
220 const char* ll = "100"; | 220 const char* ll = "\"100\""; |
221 std::string mm = "INIT"; | 221 std::string mm = "INIT"; |
| 222 std::string mmm = "\"INIT\""; |
222 | 223 |
223 // Create a scope for the tracing controller to terminate the trace writer. | 224 // Create a scope for the tracing controller to terminate the trace writer. |
224 { | 225 { |
225 TracingController tracing_controller; | 226 TracingController tracing_controller; |
226 platform::SetTracingController(default_platform, &tracing_controller); | 227 platform::SetTracingController(default_platform, &tracing_controller); |
227 TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream); | 228 TraceWriter* writer = TraceWriter::CreateJSONTraceWriter(stream); |
228 | 229 |
229 TraceBuffer* ring_buffer = | 230 TraceBuffer* ring_buffer = |
230 TraceBuffer::CreateTraceBufferRingBuffer(1, writer); | 231 TraceBuffer::CreateTraceBufferRingBuffer(1, writer); |
231 tracing_controller.Initialize(ring_buffer); | 232 tracing_controller.Initialize(ring_buffer); |
(...skipping 11 matching lines...) Expand all Loading... |
243 TRACE_EVENT1("v8", "v8.Test.hh", "hh", hh); | 244 TRACE_EVENT1("v8", "v8.Test.hh", "hh", hh); |
244 TRACE_EVENT1("v8", "v8.Test.ii", "ii1", ii1); | 245 TRACE_EVENT1("v8", "v8.Test.ii", "ii1", ii1); |
245 TRACE_EVENT1("v8", "v8.Test.ii", "ii2", ii2); | 246 TRACE_EVENT1("v8", "v8.Test.ii", "ii2", ii2); |
246 TRACE_EVENT1("v8", "v8.Test.jj1", "jj1", jj1); | 247 TRACE_EVENT1("v8", "v8.Test.jj1", "jj1", jj1); |
247 TRACE_EVENT1("v8", "v8.Test.jj2", "jj2", jj2); | 248 TRACE_EVENT1("v8", "v8.Test.jj2", "jj2", jj2); |
248 TRACE_EVENT1("v8", "v8.Test.jj3", "jj3", jj3); | 249 TRACE_EVENT1("v8", "v8.Test.jj3", "jj3", jj3); |
249 TRACE_EVENT1("v8", "v8.Test.jj4", "jj4", jj4); | 250 TRACE_EVENT1("v8", "v8.Test.jj4", "jj4", jj4); |
250 TRACE_EVENT1("v8", "v8.Test.jj5", "jj5", jj5); | 251 TRACE_EVENT1("v8", "v8.Test.jj5", "jj5", jj5); |
251 TRACE_EVENT1("v8", "v8.Test.kk", "kk", kk); | 252 TRACE_EVENT1("v8", "v8.Test.kk", "kk", kk); |
252 TRACE_EVENT1("v8", "v8.Test.ll", "ll", ll); | 253 TRACE_EVENT1("v8", "v8.Test.ll", "ll", ll); |
253 TRACE_EVENT1("v8", "v8.Test.mm", "mm", TRACE_STR_COPY(mm.c_str())); | 254 TRACE_EVENT1("v8", "v8.Test.mm", "mm", TRACE_STR_COPY(mmm.c_str())); |
254 | 255 |
255 TRACE_EVENT2("v8", "v8.Test2.1", "aa", aa, "ll", ll); | 256 TRACE_EVENT2("v8", "v8.Test2.1", "aa", aa, "ll", ll); |
256 TRACE_EVENT2("v8", "v8.Test2.2", "mm1", TRACE_STR_COPY(mm.c_str()), "mm2", | 257 TRACE_EVENT2("v8", "v8.Test2.2", "mm1", TRACE_STR_COPY(mmm.c_str()), "mm2", |
257 TRACE_STR_COPY(mm.c_str())); | 258 TRACE_STR_COPY(mmm.c_str())); |
258 | 259 |
259 // Check copies are correct. | 260 // Check copies are correct. |
260 TRACE_EVENT_COPY_INSTANT0("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD); | 261 TRACE_EVENT_COPY_INSTANT0("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD); |
261 TRACE_EVENT_COPY_INSTANT1("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, | 262 TRACE_EVENT_COPY_INSTANT1("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, |
262 mm.c_str(), mm.c_str()); | 263 mm.c_str(), mmm.c_str()); |
263 TRACE_EVENT_COPY_INSTANT2("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, | 264 TRACE_EVENT_COPY_INSTANT2("v8", mm.c_str(), TRACE_EVENT_SCOPE_THREAD, |
264 mm.c_str(), mm.c_str(), mm.c_str(), mm.c_str()); | 265 mm.c_str(), mmm.c_str(), mm.c_str(), mmm.c_str()); |
265 mm = "CHANGED"; | 266 mm = "CHANGED"; |
| 267 mmm = "CHANGED"; |
266 | 268 |
267 tracing_controller.StopTracing(); | 269 tracing_controller.StopTracing(); |
268 } | 270 } |
269 | 271 |
270 std::string trace_str = stream.str(); | 272 std::string trace_str = stream.str(); |
271 | 273 |
272 std::vector<std::string> all_args, all_names, all_cats; | 274 std::vector<std::string> all_args, all_names, all_cats; |
273 GetJSONStrings(all_args, trace_str, "\"args\"", "{", "}"); | 275 GetJSONStrings(all_args, trace_str, "\"args\"", "{", "}"); |
274 GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\""); | 276 GetJSONStrings(all_names, trace_str, "\"name\"", "\"", "\""); |
275 GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\""); | 277 GetJSONStrings(all_cats, trace_str, "\"cat\"", "\"", "\""); |
(...skipping 29 matching lines...) Expand all Loading... |
305 CHECK_EQ(all_args[21], "\"INIT\":\"INIT\""); | 307 CHECK_EQ(all_args[21], "\"INIT\":\"INIT\""); |
306 CHECK_EQ(all_names[22], "INIT"); | 308 CHECK_EQ(all_names[22], "INIT"); |
307 CHECK_EQ(all_args[22], "\"INIT\":\"INIT\",\"INIT\":\"INIT\""); | 309 CHECK_EQ(all_args[22], "\"INIT\":\"INIT\",\"INIT\":\"INIT\""); |
308 | 310 |
309 i::V8::SetPlatformForTesting(old_platform); | 311 i::V8::SetPlatformForTesting(old_platform); |
310 } | 312 } |
311 | 313 |
312 } // namespace tracing | 314 } // namespace tracing |
313 } // namespace platform | 315 } // namespace platform |
314 } // namespace v8 | 316 } // namespace v8 |
OLD | NEW |