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 "base/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // trace. | 60 // trace. |
61 const int kOverheadReportThresholdInMicroseconds = 50; | 61 const int kOverheadReportThresholdInMicroseconds = 50; |
62 | 62 |
63 // String options that can be used to initialize TraceOptions. | 63 // String options that can be used to initialize TraceOptions. |
64 const char kRecordUntilFull[] = "record-until-full"; | 64 const char kRecordUntilFull[] = "record-until-full"; |
65 const char kRecordContinuously[] = "record-continuously"; | 65 const char kRecordContinuously[] = "record-continuously"; |
66 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible"; | 66 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible"; |
67 const char kTraceToConsole[] = "trace-to-console"; | 67 const char kTraceToConsole[] = "trace-to-console"; |
68 const char kEnableSampling[] = "enable-sampling"; | 68 const char kEnableSampling[] = "enable-sampling"; |
69 const char kEnableSystrace[] = "enable-systrace"; | 69 const char kEnableSystrace[] = "enable-systrace"; |
| 70 const char kEnableArgsWhitelist[] = "enable-args-whitelist"; |
70 | 71 |
71 // Controls the number of trace events we will buffer in-memory | 72 // Controls the number of trace events we will buffer in-memory |
72 // before throwing them away. | 73 // before throwing them away. |
73 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; | 74 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; |
74 const size_t kTraceEventVectorBigBufferChunks = | 75 const size_t kTraceEventVectorBigBufferChunks = |
75 512000000 / kTraceBufferChunkSize; | 76 512000000 / kTraceBufferChunkSize; |
76 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; | 77 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; |
77 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; | 78 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; |
78 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; | 79 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; |
79 // Can store results for 30 seconds with 1 ms sampling interval. | 80 // Can store results for 30 seconds with 1 ms sampling interval. |
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 } else if (*iter == kRecordContinuously) { | 1002 } else if (*iter == kRecordContinuously) { |
1002 record_mode = RECORD_CONTINUOUSLY; | 1003 record_mode = RECORD_CONTINUOUSLY; |
1003 } else if (*iter == kTraceToConsole) { | 1004 } else if (*iter == kTraceToConsole) { |
1004 record_mode = ECHO_TO_CONSOLE; | 1005 record_mode = ECHO_TO_CONSOLE; |
1005 } else if (*iter == kRecordAsMuchAsPossible) { | 1006 } else if (*iter == kRecordAsMuchAsPossible) { |
1006 record_mode = RECORD_AS_MUCH_AS_POSSIBLE; | 1007 record_mode = RECORD_AS_MUCH_AS_POSSIBLE; |
1007 } else if (*iter == kEnableSampling) { | 1008 } else if (*iter == kEnableSampling) { |
1008 enable_sampling = true; | 1009 enable_sampling = true; |
1009 } else if (*iter == kEnableSystrace) { | 1010 } else if (*iter == kEnableSystrace) { |
1010 enable_systrace = true; | 1011 enable_systrace = true; |
| 1012 } else if (*iter == kEnableArgsWhitelist) { |
| 1013 enable_args_whitelist = true; |
1011 } else { | 1014 } else { |
1012 return false; | 1015 return false; |
1013 } | 1016 } |
1014 } | 1017 } |
1015 return true; | 1018 return true; |
1016 } | 1019 } |
1017 | 1020 |
1018 std::string TraceOptions::ToString() const { | 1021 std::string TraceOptions::ToString() const { |
1019 std::string ret; | 1022 std::string ret; |
1020 switch (record_mode) { | 1023 switch (record_mode) { |
1021 case RECORD_UNTIL_FULL: | 1024 case RECORD_UNTIL_FULL: |
1022 ret = kRecordUntilFull; | 1025 ret = kRecordUntilFull; |
1023 break; | 1026 break; |
1024 case RECORD_CONTINUOUSLY: | 1027 case RECORD_CONTINUOUSLY: |
1025 ret = kRecordContinuously; | 1028 ret = kRecordContinuously; |
1026 break; | 1029 break; |
1027 case ECHO_TO_CONSOLE: | 1030 case ECHO_TO_CONSOLE: |
1028 ret = kTraceToConsole; | 1031 ret = kTraceToConsole; |
1029 break; | 1032 break; |
1030 case RECORD_AS_MUCH_AS_POSSIBLE: | 1033 case RECORD_AS_MUCH_AS_POSSIBLE: |
1031 ret = kRecordAsMuchAsPossible; | 1034 ret = kRecordAsMuchAsPossible; |
1032 break; | 1035 break; |
1033 default: | 1036 default: |
1034 NOTREACHED(); | 1037 NOTREACHED(); |
1035 } | 1038 } |
1036 if (enable_sampling) | 1039 if (enable_sampling) |
1037 ret = ret + "," + kEnableSampling; | 1040 ret = ret + "," + kEnableSampling; |
1038 if (enable_systrace) | 1041 if (enable_systrace) |
1039 ret = ret + "," + kEnableSystrace; | 1042 ret = ret + "," + kEnableSystrace; |
| 1043 if (enable_args_whitelist) |
| 1044 ret = ret + "," + kEnableArgsWhitelist; |
1040 return ret; | 1045 return ret; |
1041 } | 1046 } |
1042 | 1047 |
1043 //////////////////////////////////////////////////////////////////////////////// | 1048 //////////////////////////////////////////////////////////////////////////////// |
1044 // | 1049 // |
1045 // TraceLog | 1050 // TraceLog |
1046 // | 1051 // |
1047 //////////////////////////////////////////////////////////////////////////////// | 1052 //////////////////////////////////////////////////////////////////////////////// |
1048 | 1053 |
1049 class TraceLog::ThreadLocalEventBuffer | 1054 class TraceLog::ThreadLocalEventBuffer |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 void TraceLog::SetEventFilterPredicate( | 1499 void TraceLog::SetEventFilterPredicate( |
1495 const TraceEvent::EventFilterPredicate& event_filter_predicate) { | 1500 const TraceEvent::EventFilterPredicate& event_filter_predicate) { |
1496 AutoLock lock(lock_); | 1501 AutoLock lock(lock_); |
1497 event_filter_predicate_ = event_filter_predicate; | 1502 event_filter_predicate_ = event_filter_predicate; |
1498 } | 1503 } |
1499 | 1504 |
1500 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions( | 1505 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions( |
1501 const TraceOptions& options) { | 1506 const TraceOptions& options) { |
1502 InternalTraceOptions ret = | 1507 InternalTraceOptions ret = |
1503 options.enable_sampling ? kInternalEnableSampling : kInternalNone; | 1508 options.enable_sampling ? kInternalEnableSampling : kInternalNone; |
| 1509 if (options.enable_args_whitelist) |
| 1510 ret |= kInternalEnableArgsWhitelist; |
1504 switch (options.record_mode) { | 1511 switch (options.record_mode) { |
1505 case RECORD_UNTIL_FULL: | 1512 case RECORD_UNTIL_FULL: |
1506 return ret | kInternalRecordUntilFull; | 1513 return ret | kInternalRecordUntilFull; |
1507 case RECORD_CONTINUOUSLY: | 1514 case RECORD_CONTINUOUSLY: |
1508 return ret | kInternalRecordContinuously; | 1515 return ret | kInternalRecordContinuously; |
1509 case ECHO_TO_CONSOLE: | 1516 case ECHO_TO_CONSOLE: |
1510 return ret | kInternalEchoToConsole; | 1517 return ret | kInternalEchoToConsole; |
1511 case RECORD_AS_MUCH_AS_POSSIBLE: | 1518 case RECORD_AS_MUCH_AS_POSSIBLE: |
1512 return ret | kInternalRecordAsMuchAsPossible; | 1519 return ret | kInternalRecordAsMuchAsPossible; |
1513 } | 1520 } |
1514 NOTREACHED(); | 1521 NOTREACHED(); |
1515 return kInternalNone; | 1522 return kInternalNone; |
1516 } | 1523 } |
1517 | 1524 |
1518 CategoryFilter TraceLog::GetCurrentCategoryFilter() { | 1525 CategoryFilter TraceLog::GetCurrentCategoryFilter() { |
1519 AutoLock lock(lock_); | 1526 AutoLock lock(lock_); |
1520 return category_filter_; | 1527 return category_filter_; |
1521 } | 1528 } |
1522 | 1529 |
1523 TraceOptions TraceLog::GetCurrentTraceOptions() const { | 1530 TraceOptions TraceLog::GetCurrentTraceOptions() const { |
1524 TraceOptions ret; | 1531 TraceOptions ret; |
1525 InternalTraceOptions option = trace_options(); | 1532 InternalTraceOptions option = trace_options(); |
1526 ret.enable_sampling = (option & kInternalEnableSampling) != 0; | 1533 ret.enable_sampling = (option & kInternalEnableSampling) != 0; |
| 1534 ret.enable_args_whitelist = (option & kInternalEnableArgsWhitelist) != 0; |
1527 if (option & kInternalRecordUntilFull) | 1535 if (option & kInternalRecordUntilFull) |
1528 ret.record_mode = RECORD_UNTIL_FULL; | 1536 ret.record_mode = RECORD_UNTIL_FULL; |
1529 else if (option & kInternalRecordContinuously) | 1537 else if (option & kInternalRecordContinuously) |
1530 ret.record_mode = RECORD_CONTINUOUSLY; | 1538 ret.record_mode = RECORD_CONTINUOUSLY; |
1531 else if (option & kInternalEchoToConsole) | 1539 else if (option & kInternalEchoToConsole) |
1532 ret.record_mode = ECHO_TO_CONSOLE; | 1540 ret.record_mode = ECHO_TO_CONSOLE; |
1533 else if (option & kInternalRecordAsMuchAsPossible) | 1541 else if (option & kInternalRecordAsMuchAsPossible) |
1534 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE; | 1542 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE; |
1535 else | 1543 else |
1536 NOTREACHED(); | 1544 NOTREACHED(); |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2659 } | 2667 } |
2660 | 2668 |
2661 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2669 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2662 if (*category_group_enabled_) { | 2670 if (*category_group_enabled_) { |
2663 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2671 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2664 name_, event_handle_); | 2672 name_, event_handle_); |
2665 } | 2673 } |
2666 } | 2674 } |
2667 | 2675 |
2668 } // namespace trace_event_internal | 2676 } // namespace trace_event_internal |
OLD | NEW |