Chromium Code Reviews| 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 | 4 |
| 5 #include "include/libplatform/v8-tracing.h" | 5 #include "include/libplatform/v8-tracing.h" |
| 6 | 6 |
| 7 #include "base/trace_event/common/trace_event_common.h" | 7 #include "base/trace_event/common/trace_event_common.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/base/platform/time.h" | 9 #include "src/base/platform/time.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace platform { | 12 namespace platform { |
| 13 namespace tracing { | 13 namespace tracing { |
| 14 | 14 |
| 15 // We perform checks for NULL strings since it is possible that a string arg | 15 // We perform checks for NULL strings since it is possible that a string arg |
| 16 // value is NULL. | 16 // value is NULL. |
| 17 V8_INLINE static size_t GetAllocLength(const char* str) { | 17 V8_INLINE static size_t GetAllocLength(const char* str) { |
| 18 return str ? strlen(str) + 1 : 0; | 18 return str ? strlen(str) + 1 : 0; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // Copies |*member| into |*buffer|, sets |*member| to point to this new | 21 // Copies |*member| into |*buffer|, sets |*member| to point to this new |
| 22 // location, and then advances |*buffer| by the amount written. | 22 // location, and then advances |*buffer| by the amount written. |
| 23 V8_INLINE static void CopyTraceObjectParameter(char** buffer, | 23 V8_INLINE static void CopyTraceObjectParameter(char** buffer, |
| 24 const char** member, | 24 const char** member, |
| 25 const char* end) { | 25 const char* end) { |
| 26 if (*member) { | 26 if (*member) { |
| 27 strncpy(*buffer, *member, end - *buffer); | 27 size_t length = strlen(*member) + 1; |
| 28 strncpy(*buffer, *member, length); | |
|
mattloring
2016/08/10 00:41:54
How does this behave when there is not enough spac
| |
| 28 *member = *buffer; | 29 *member = *buffer; |
| 29 *buffer += strlen(*member) + 1; | 30 *buffer += length; |
| 30 } | 31 } |
| 31 } | 32 } |
| 32 | 33 |
| 33 void TraceObject::Initialize(char phase, const uint8_t* category_enabled_flag, | 34 void TraceObject::Initialize(char phase, const uint8_t* category_enabled_flag, |
| 34 const char* name, const char* scope, uint64_t id, | 35 const char* name, const char* scope, uint64_t id, |
| 35 uint64_t bind_id, int num_args, | 36 uint64_t bind_id, int num_args, |
| 36 const char** arg_names, const uint8_t* arg_types, | 37 const char** arg_names, const uint8_t* arg_types, |
| 37 const uint64_t* arg_values, unsigned int flags) { | 38 const uint64_t* arg_values, unsigned int flags) { |
| 38 pid_ = base::OS::GetCurrentProcessId(); | 39 pid_ = base::OS::GetCurrentProcessId(); |
| 39 tid_ = base::OS::GetCurrentThreadId(); | 40 tid_ = base::OS::GetCurrentThreadId(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 flags_ = flags; | 123 flags_ = flags; |
| 123 ts_ = ts; | 124 ts_ = ts; |
| 124 tts_ = tts; | 125 tts_ = tts; |
| 125 duration_ = duration; | 126 duration_ = duration; |
| 126 cpu_duration_ = cpu_duration; | 127 cpu_duration_ = cpu_duration; |
| 127 } | 128 } |
| 128 | 129 |
| 129 } // namespace tracing | 130 } // namespace tracing |
| 130 } // namespace platform | 131 } // namespace platform |
| 131 } // namespace v8 | 132 } // namespace v8 |
| OLD | NEW |