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