| 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 #include <cstdlib> | 5 #include <cstdlib> |
| 6 | 6 |
| 7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
| 8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { | 434 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { |
| 435 return; | 435 return; |
| 436 } | 436 } |
| 437 | 437 |
| 438 FinishGlobalBlock(); | 438 FinishGlobalBlock(); |
| 439 | 439 |
| 440 JSONStream js; | 440 JSONStream js; |
| 441 TimelineEventFilter filter; | 441 TimelineEventFilter filter; |
| 442 PrintJSON(&js, &filter); | 442 PrintJSON(&js, &filter); |
| 443 | 443 |
| 444 const char* format = "%s/dart-timeline-%" Pd ".json"; | |
| 445 intptr_t pid = OS::ProcessId(); | 444 intptr_t pid = OS::ProcessId(); |
| 446 intptr_t len = OS::SNPrint(NULL, 0, format, directory, pid); | 445 char* filename = NULL; |
| 447 char* filename = reinterpret_cast<char*>(malloc(len + 1)); | 446 SNPRINT(filename, malloc, "%s/dart-timeline-%" Pd ".json", directory, pid); |
| 448 OS::SNPrint(filename, len + 1, format, directory, pid); | |
| 449 void* file = (*file_open)(filename, true); | 447 void* file = (*file_open)(filename, true); |
| 450 if (file == NULL) { | 448 if (file == NULL) { |
| 451 OS::Print("Failed to write timeline file: %s\n", filename); | 449 OS::Print("Failed to write timeline file: %s\n", filename); |
| 452 free(filename); | 450 free(filename); |
| 453 return; | 451 return; |
| 454 } | 452 } |
| 455 free(filename); | 453 free(filename); |
| 456 (*file_write)(js.buffer()->buf(), js.buffer()->length(), file); | 454 (*file_write)(js.buffer()->buf(), js.buffer()->length(), file); |
| 457 (*file_close)(file); | 455 (*file_close)(file); |
| 458 } | 456 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 824 |
| 827 | 825 |
| 828 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 826 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
| 829 ASSERT(current_ != NULL); | 827 ASSERT(current_ != NULL); |
| 830 TimelineEventBlock* r = current_; | 828 TimelineEventBlock* r = current_; |
| 831 current_ = current_->next(); | 829 current_ = current_->next(); |
| 832 return r; | 830 return r; |
| 833 } | 831 } |
| 834 | 832 |
| 835 } // namespace dart | 833 } // namespace dart |
| OLD | NEW |