OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include <math.h> | 5 #include <math.h> |
6 #include <cstdlib> | 6 #include <cstdlib> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 491 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
492 "all", "tracked object 1", 0x42, "hello"); | 492 "all", "tracked object 1", 0x42, "hello"); |
493 TRACE_EVENT_OBJECT_DELETED_WITH_ID("all", "tracked object 1", 0x42); | 493 TRACE_EVENT_OBJECT_DELETED_WITH_ID("all", "tracked object 1", 0x42); |
494 | 494 |
495 TraceScopedTrackableObject<int> trackable("all", "tracked object 2", | 495 TraceScopedTrackableObject<int> trackable("all", "tracked object 2", |
496 0x2128506); | 496 0x2128506); |
497 trackable.snapshot("world"); | 497 trackable.snapshot("world"); |
498 | 498 |
499 TRACE_EVENT1(kControlCharacters, kControlCharacters, | 499 TRACE_EVENT1(kControlCharacters, kControlCharacters, |
500 kControlCharacters, kControlCharacters); | 500 kControlCharacters, kControlCharacters); |
| 501 |
| 502 TraceContext context(reinterpret_cast<TraceContext>(0x20151021)); |
| 503 TRACE_EVENT_ENTER_CONTEXT("all", "TRACE_EVENT_ENTER_CONTEXT call", context); |
| 504 TRACE_EVENT_LEAVE_CONTEXT("all", "TRACE_EVENT_LEAVE_CONTEXT call", context); |
| 505 TRACE_EVENT_SCOPED_CONTEXT("all", "TRACE_EVENT_SCOPED_CONTEXT call", |
| 506 context); |
501 } // Scope close causes TRACE_EVENT0 etc to send their END events. | 507 } // Scope close causes TRACE_EVENT0 etc to send their END events. |
502 | 508 |
503 if (task_complete_event) | 509 if (task_complete_event) |
504 task_complete_event->Signal(); | 510 task_complete_event->Signal(); |
505 } | 511 } |
506 | 512 |
507 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { | 513 void ValidateAllTraceMacrosCreatedData(const ListValue& trace_parsed) { |
508 const DictionaryValue* item = NULL; | 514 const DictionaryValue* item = NULL; |
509 | 515 |
510 #define EXPECT_FIND_(string) \ | 516 #define EXPECT_FIND_(string) \ |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 item = FindTraceEntry(trace_parsed, "tracked object 2", item); | 844 item = FindTraceEntry(trace_parsed, "tracked object 2", item); |
839 EXPECT_TRUE(item); | 845 EXPECT_TRUE(item); |
840 EXPECT_TRUE(item && item->GetString("ph", &phase)); | 846 EXPECT_TRUE(item && item->GetString("ph", &phase)); |
841 EXPECT_EQ("D", phase); | 847 EXPECT_EQ("D", phase); |
842 EXPECT_TRUE(item && item->GetString("id", &id)); | 848 EXPECT_TRUE(item && item->GetString("id", &id)); |
843 EXPECT_EQ("0x2128506", id); | 849 EXPECT_EQ("0x2128506", id); |
844 } | 850 } |
845 | 851 |
846 EXPECT_FIND_(kControlCharacters); | 852 EXPECT_FIND_(kControlCharacters); |
847 EXPECT_SUB_FIND_(kControlCharacters); | 853 EXPECT_SUB_FIND_(kControlCharacters); |
| 854 |
| 855 EXPECT_FIND_("TRACE_EVENT_ENTER_CONTEXT call"); |
| 856 { |
| 857 std::string ph; |
| 858 EXPECT_TRUE((item && item->GetString("ph", &ph))); |
| 859 EXPECT_EQ("(", ph); |
| 860 |
| 861 std::string id; |
| 862 EXPECT_TRUE((item && item->GetString("id", &id))); |
| 863 EXPECT_EQ("0x20151021", id); |
| 864 } |
| 865 |
| 866 EXPECT_FIND_("TRACE_EVENT_LEAVE_CONTEXT call"); |
| 867 { |
| 868 std::string ph; |
| 869 EXPECT_TRUE((item && item->GetString("ph", &ph))); |
| 870 EXPECT_EQ(")", ph); |
| 871 |
| 872 std::string id; |
| 873 EXPECT_TRUE((item && item->GetString("id", &id))); |
| 874 EXPECT_EQ("0x20151021", id); |
| 875 } |
| 876 |
| 877 std::vector<const DictionaryValue*> scoped_context_calls = |
| 878 FindTraceEntries(trace_parsed, "TRACE_EVENT_SCOPED_CONTEXT call"); |
| 879 EXPECT_EQ(2u, scoped_context_calls.size()); |
| 880 { |
| 881 item = scoped_context_calls[0]; |
| 882 std::string ph; |
| 883 EXPECT_TRUE((item && item->GetString("ph", &ph))); |
| 884 EXPECT_EQ("(", ph); |
| 885 |
| 886 std::string id; |
| 887 EXPECT_TRUE((item && item->GetString("id", &id))); |
| 888 EXPECT_EQ("0x20151021", id); |
| 889 } |
| 890 |
| 891 { |
| 892 item = scoped_context_calls[1]; |
| 893 std::string ph; |
| 894 EXPECT_TRUE((item && item->GetString("ph", &ph))); |
| 895 EXPECT_EQ(")", ph); |
| 896 |
| 897 std::string id; |
| 898 EXPECT_TRUE((item && item->GetString("id", &id))); |
| 899 EXPECT_EQ("0x20151021", id); |
| 900 } |
848 } | 901 } |
849 | 902 |
850 void TraceManyInstantEvents(int thread_id, int num_events, | 903 void TraceManyInstantEvents(int thread_id, int num_events, |
851 WaitableEvent* task_complete_event) { | 904 WaitableEvent* task_complete_event) { |
852 for (int i = 0; i < num_events; i++) { | 905 for (int i = 0; i < num_events; i++) { |
853 TRACE_EVENT_INSTANT2("all", "multi thread event", | 906 TRACE_EVENT_INSTANT2("all", "multi thread event", |
854 TRACE_EVENT_SCOPE_THREAD, | 907 TRACE_EVENT_SCOPE_THREAD, |
855 "thread", thread_id, | 908 "thread", thread_id, |
856 "event", i); | 909 "event", i); |
857 } | 910 } |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 } | 3084 } |
3032 | 3085 |
3033 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { | 3086 TEST_F(TraceEventTestFixture, SyntheticDelayConfigurationToString) { |
3034 const char filter[] = "DELAY(test.Delay;16;oneshot)"; | 3087 const char filter[] = "DELAY(test.Delay;16;oneshot)"; |
3035 TraceConfig config(filter, ""); | 3088 TraceConfig config(filter, ""); |
3036 EXPECT_EQ(filter, config.ToCategoryFilterString()); | 3089 EXPECT_EQ(filter, config.ToCategoryFilterString()); |
3037 } | 3090 } |
3038 | 3091 |
3039 } // namespace trace_event | 3092 } // namespace trace_event |
3040 } // namespace base | 3093 } // namespace base |
OLD | NEW |