OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef PRODUCT | 5 #ifndef PRODUCT |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 | 10 |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 void TimelineEventFixedBufferRecorder::CompleteEvent(TimelineEvent* event) { | 1368 void TimelineEventFixedBufferRecorder::CompleteEvent(TimelineEvent* event) { |
1369 if (event == NULL) { | 1369 if (event == NULL) { |
1370 return; | 1370 return; |
1371 } | 1371 } |
1372 ThreadBlockCompleteEvent(event); | 1372 ThreadBlockCompleteEvent(event); |
1373 } | 1373 } |
1374 | 1374 |
1375 | 1375 |
1376 TimelineEventSystraceRecorder::TimelineEventSystraceRecorder(intptr_t capacity) | 1376 TimelineEventSystraceRecorder::TimelineEventSystraceRecorder(intptr_t capacity) |
1377 : TimelineEventFixedBufferRecorder(capacity), systrace_fd_(-1) { | 1377 : TimelineEventFixedBufferRecorder(capacity), systrace_fd_(-1) { |
1378 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_LINUX) | 1378 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) |
1379 const char* kSystracePath = "/sys/kernel/debug/tracing/trace_marker"; | 1379 const char* kSystracePath = "/sys/kernel/debug/tracing/trace_marker"; |
1380 systrace_fd_ = open(kSystracePath, O_WRONLY); | 1380 systrace_fd_ = open(kSystracePath, O_WRONLY); |
1381 if ((systrace_fd_ < 0) && FLAG_trace_timeline) { | 1381 if ((systrace_fd_ < 0) && FLAG_trace_timeline) { |
1382 OS::PrintErr("TimelineEventSystraceRecorder: Could not open `%s`\n", | 1382 OS::PrintErr("TimelineEventSystraceRecorder: Could not open `%s`\n", |
1383 kSystracePath); | 1383 kSystracePath); |
1384 } | 1384 } |
1385 #else | 1385 #else |
1386 OS::PrintErr( | 1386 OS::PrintErr( |
1387 "Warning: The systrace timeline recorder is equivalent to the" | 1387 "Warning: The systrace timeline recorder is equivalent to the" |
1388 "ring recorder on this platform."); | 1388 "ring recorder on this platform."); |
1389 #endif | 1389 #endif |
1390 } | 1390 } |
1391 | 1391 |
1392 | 1392 |
1393 TimelineEventSystraceRecorder::~TimelineEventSystraceRecorder() { | 1393 TimelineEventSystraceRecorder::~TimelineEventSystraceRecorder() { |
1394 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_LINUX) | 1394 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) |
1395 if (systrace_fd_ >= 0) { | 1395 if (systrace_fd_ >= 0) { |
1396 close(systrace_fd_); | 1396 close(systrace_fd_); |
1397 } | 1397 } |
1398 #endif | 1398 #endif |
1399 } | 1399 } |
1400 | 1400 |
1401 | 1401 |
1402 TimelineEventBlock* TimelineEventSystraceRecorder::GetNewBlockLocked() { | 1402 TimelineEventBlock* TimelineEventSystraceRecorder::GetNewBlockLocked() { |
1403 // TODO(johnmccutchan): This function should only hand out blocks | 1403 // TODO(johnmccutchan): This function should only hand out blocks |
1404 // which have been marked as finished. | 1404 // which have been marked as finished. |
1405 if (block_cursor_ == num_blocks_) { | 1405 if (block_cursor_ == num_blocks_) { |
1406 block_cursor_ = 0; | 1406 block_cursor_ = 0; |
1407 } | 1407 } |
1408 TimelineEventBlock* block = blocks_[block_cursor_++]; | 1408 TimelineEventBlock* block = blocks_[block_cursor_++]; |
1409 block->Reset(); | 1409 block->Reset(); |
1410 block->Open(); | 1410 block->Open(); |
1411 return block; | 1411 return block; |
1412 } | 1412 } |
1413 | 1413 |
1414 | 1414 |
1415 void TimelineEventSystraceRecorder::CompleteEvent(TimelineEvent* event) { | 1415 void TimelineEventSystraceRecorder::CompleteEvent(TimelineEvent* event) { |
1416 if (event == NULL) { | 1416 if (event == NULL) { |
1417 return; | 1417 return; |
1418 } | 1418 } |
1419 #if defined(TARGET_OS_ANDROID) || defined(TARGET_OS_LINUX) | 1419 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX) |
1420 if (systrace_fd_ >= 0) { | 1420 if (systrace_fd_ >= 0) { |
1421 // Serialize to the systrace format. | 1421 // Serialize to the systrace format. |
1422 const intptr_t kBufferLength = 1024; | 1422 const intptr_t kBufferLength = 1024; |
1423 char buffer[kBufferLength]; | 1423 char buffer[kBufferLength]; |
1424 const intptr_t event_length = | 1424 const intptr_t event_length = |
1425 event->PrintSystrace(&buffer[0], kBufferLength); | 1425 event->PrintSystrace(&buffer[0], kBufferLength); |
1426 if (event_length > 0) { | 1426 if (event_length > 0) { |
1427 ssize_t __result; | 1427 ssize_t __result; |
1428 // Repeatedly attempt the write while we are being interrupted. | 1428 // Repeatedly attempt the write while we are being interrupted. |
1429 do { | 1429 do { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1774 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
1775 ASSERT(current_ != NULL); | 1775 ASSERT(current_ != NULL); |
1776 TimelineEventBlock* r = current_; | 1776 TimelineEventBlock* r = current_; |
1777 current_ = current_->next(); | 1777 current_ = current_->next(); |
1778 return r; | 1778 return r; |
1779 } | 1779 } |
1780 | 1780 |
1781 } // namespace dart | 1781 } // namespace dart |
1782 | 1782 |
1783 #endif // !PRODUCT | 1783 #endif // !PRODUCT |
OLD | NEW |