| 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 <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 8 | 10 |
| 9 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
| 12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 13 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 15 | 17 |
| 16 namespace base { | 18 namespace base { |
| 17 namespace trace_event { | 19 namespace trace_event { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 41 const char* category_group, | 43 const char* category_group, |
| 42 const char* name, | 44 const char* name, |
| 43 unsigned long long id, | 45 unsigned long long id, |
| 44 const char** arg_names, | 46 const char** arg_names, |
| 45 const unsigned char* arg_types, | 47 const unsigned char* arg_types, |
| 46 const TraceEvent::TraceValue* arg_values, | 48 const TraceEvent::TraceValue* arg_values, |
| 47 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, | 49 const scoped_refptr<ConvertableToTraceFormat>* convertable_values, |
| 48 unsigned int flags) { | 50 unsigned int flags) { |
| 49 std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name); | 51 std::string out = StringPrintf("%c|%d|%s", phase, getpid(), name); |
| 50 if (flags & TRACE_EVENT_FLAG_HAS_ID) | 52 if (flags & TRACE_EVENT_FLAG_HAS_ID) |
| 51 StringAppendF(&out, "-%" PRIx64, static_cast<uint64>(id)); | 53 StringAppendF(&out, "-%" PRIx64, static_cast<uint64_t>(id)); |
| 52 out += '|'; | 54 out += '|'; |
| 53 | 55 |
| 54 for (int i = 0; i < kTraceMaxNumArgs && arg_names[i]; | 56 for (int i = 0; i < kTraceMaxNumArgs && arg_names[i]; |
| 55 ++i) { | 57 ++i) { |
| 56 if (i) | 58 if (i) |
| 57 out += ';'; | 59 out += ';'; |
| 58 out += arg_names[i]; | 60 out += arg_names[i]; |
| 59 out += '='; | 61 out += '='; |
| 60 std::string::size_type value_start = out.length(); | 62 std::string::size_type value_start = out.length(); |
| 61 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) | 63 if (arg_types[i] == TRACE_VALUE_TYPE_CONVERTABLE) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 flags_); | 172 flags_); |
| 171 WriteToATrace(g_atrace_fd, "E", 1); | 173 WriteToATrace(g_atrace_fd, "E", 1); |
| 172 break; | 174 break; |
| 173 | 175 |
| 174 case TRACE_EVENT_PHASE_COUNTER: | 176 case TRACE_EVENT_PHASE_COUNTER: |
| 175 for (int i = 0; i < kTraceMaxNumArgs && arg_names_[i]; ++i) { | 177 for (int i = 0; i < kTraceMaxNumArgs && arg_names_[i]; ++i) { |
| 176 DCHECK(arg_types_[i] == TRACE_VALUE_TYPE_INT); | 178 DCHECK(arg_types_[i] == TRACE_VALUE_TYPE_INT); |
| 177 std::string out = base::StringPrintf( | 179 std::string out = base::StringPrintf( |
| 178 "C|%d|%s-%s", getpid(), name_, arg_names_[i]); | 180 "C|%d|%s-%s", getpid(), name_, arg_names_[i]); |
| 179 if (flags_ & TRACE_EVENT_FLAG_HAS_ID) | 181 if (flags_ & TRACE_EVENT_FLAG_HAS_ID) |
| 180 StringAppendF(&out, "-%" PRIx64, static_cast<uint64>(id_)); | 182 StringAppendF(&out, "-%" PRIx64, static_cast<uint64_t>(id_)); |
| 181 StringAppendF(&out, "|%d|%s", | 183 StringAppendF(&out, "|%d|%s", |
| 182 static_cast<int>(arg_values_[i].as_int), category_group); | 184 static_cast<int>(arg_values_[i].as_int), category_group); |
| 183 WriteToATrace(g_atrace_fd, out.c_str(), out.size()); | 185 WriteToATrace(g_atrace_fd, out.c_str(), out.size()); |
| 184 } | 186 } |
| 185 break; | 187 break; |
| 186 | 188 |
| 187 default: | 189 default: |
| 188 // Do nothing. | 190 // Do nothing. |
| 189 break; | 191 break; |
| 190 } | 192 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 203 // trace buffer. | 205 // trace buffer. |
| 204 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); | 206 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); |
| 205 std::string marker = StringPrintf( | 207 std::string marker = StringPrintf( |
| 206 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); | 208 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); |
| 207 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); | 209 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); |
| 208 close(atrace_fd); | 210 close(atrace_fd); |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace trace_event | 213 } // namespace trace_event |
| 212 } // namespace base | 214 } // namespace base |
| OLD | NEW |