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

Side by Side Diff: runtime/vm/coverage.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: 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "vm/coverage.h" 5 #include "vm/coverage.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); 240 Dart_FileOpenCallback file_open = Isolate::file_open_callback();
241 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); 241 Dart_FileWriteCallback file_write = Isolate::file_write_callback();
242 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); 242 Dart_FileCloseCallback file_close = Isolate::file_close_callback();
243 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { 243 if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) {
244 return; 244 return;
245 } 245 }
246 246
247 JSONStream stream; 247 JSONStream stream;
248 PrintJSON(isolate, &stream, NULL, false); 248 PrintJSON(isolate, &stream, NULL, false);
249 249
250 const char* format = "%s/dart-cov-%" Pd "-%" Pd64 ".json"; 250 char* filename = NULL;
251 intptr_t pid = OS::ProcessId(); 251 intptr_t pid = OS::ProcessId();
252 intptr_t len = OS::SNPrint(NULL, 0, format, 252 SNPRINT(filename, Thread::Current()->zone()->Alloc<char>,
253 FLAG_coverage_dir, pid, isolate->main_port()); 253 "%s/dart-cov-%" Pd "-%" Pd64 ".json",
254 char* filename = Thread::Current()->zone()->Alloc<char>(len + 1); 254 FLAG_coverage_dir, pid, isolate->main_port());
255 OS::SNPrint(filename, len + 1, format,
256 FLAG_coverage_dir, pid, isolate->main_port());
257 void* file = (*file_open)(filename, true); 255 void* file = (*file_open)(filename, true);
258 if (file == NULL) { 256 if (file == NULL) {
259 OS::Print("Failed to write coverage file: %s\n", filename); 257 OS::Print("Failed to write coverage file: %s\n", filename);
260 return; 258 return;
261 } 259 }
262 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file); 260 (*file_write)(stream.buffer()->buf(), stream.buffer()->length(), file);
263 (*file_close)(file); 261 (*file_close)(file);
264 } 262 }
265 263
266 264
(...skipping 20 matching lines...) Expand all
287 cls = it.GetNextClass(); 285 cls = it.GetNextClass();
288 ASSERT(!cls.IsNull()); 286 ASSERT(!cls.IsNull());
289 PrintClass(lib, cls, jsarr, filter, as_call_sites); 287 PrintClass(lib, cls, jsarr, filter, as_call_sites);
290 } 288 }
291 } 289 }
292 } 290 }
293 } 291 }
294 292
295 293
296 } // namespace dart 294 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698