Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: runtime/vm/timeline.cc

Issue 1331623002: Uses SNPRINT macro where possible. Otherwise uses #define for format. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add missing include Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/version_in.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { 445 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) {
446 return; 446 return;
447 } 447 }
448 448
449 FinishGlobalBlock(); 449 FinishGlobalBlock();
450 450
451 JSONStream js; 451 JSONStream js;
452 TimelineEventFilter filter; 452 TimelineEventFilter filter;
453 PrintJSON(&js, &filter); 453 PrintJSON(&js, &filter);
454 454
455 const char* format = "%s/dart-timeline-%" Pd ".json";
456 intptr_t pid = OS::ProcessId(); 455 intptr_t pid = OS::ProcessId();
457 intptr_t len = OS::SNPrint(NULL, 0, format, directory, pid); 456 char* filename = OS::SCreate(NULL,
458 char* filename = reinterpret_cast<char*>(malloc(len + 1)); 457 "%s/dart-timeline-%" Pd ".json", directory, pid);
459 OS::SNPrint(filename, len + 1, format, directory, pid);
460 void* file = (*file_open)(filename, true); 458 void* file = (*file_open)(filename, true);
461 if (file == NULL) { 459 if (file == NULL) {
462 OS::Print("Failed to write timeline file: %s\n", filename); 460 OS::Print("Failed to write timeline file: %s\n", filename);
463 free(filename); 461 free(filename);
464 return; 462 return;
465 } 463 }
466 free(filename); 464 free(filename);
467 (*file_write)(js.buffer()->buf(), js.buffer()->length(), file); 465 (*file_write)(js.buffer()->buf(), js.buffer()->length(), file);
468 (*file_close)(file); 466 (*file_close)(file);
469 } 467 }
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 849
852 850
853 TimelineEventBlock* TimelineEventBlockIterator::Next() { 851 TimelineEventBlock* TimelineEventBlockIterator::Next() {
854 ASSERT(current_ != NULL); 852 ASSERT(current_ != NULL);
855 TimelineEventBlock* r = current_; 853 TimelineEventBlock* r = current_;
856 current_ = current_->next(); 854 current_ = current_->next();
857 return r; 855 return r;
858 } 856 }
859 857
860 } // namespace dart 858 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/version_in.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698