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

Side by Side Diff: runtime/bin/main.cc

Issue 9240014: Set breakpoint at url, line number (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return true; 354 return true;
355 } 355 }
356 356
357 357
358 static void PrintUsage() { 358 static void PrintUsage() {
359 fprintf(stderr, 359 fprintf(stderr,
360 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); 360 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n");
361 } 361 }
362 362
363 363
364 static Dart_Handle SetBreakpoint(const char* breakpoint_at,
365 Dart_Handle library) {
366 Dart_Handle result;
367 if (strchr(breakpoint_at, ':')) {
368 char* bpt_line = strdup(breakpoint_at);
369 char* colon = strchr(bpt_line, ':');
370 ASSERT(colon != NULL);
371 *colon = '\0';
372 Dart_Handle url = Dart_NewString(bpt_line);
373 Dart_Handle line_number = Dart_NewInteger(atoi(colon + 1));
374 free(bpt_line);
375 Dart_Breakpoint bpt;
376 result = Dart_SetBreakpointAtLine(url, line_number, &bpt);
377 } else {
378 char* bpt_function = strdup(breakpoint_at);
379 Dart_Handle class_name;
380 Dart_Handle function_name;
381 char* dot = strchr(bpt_function, '.');
382 if (dot == NULL) {
383 class_name = Dart_NewString("");
384 function_name = Dart_NewString(breakpoint_at);
385 } else {
386 *dot = '\0';
387 class_name = Dart_NewString(bpt_function);
388 function_name = Dart_NewString(dot + 1);
389 }
390 free(bpt_function);
391 Dart_Breakpoint bpt;
392 result = Dart_SetBreakpointAtEntry(
393 library, class_name, function_name, &bpt);
394 }
395 return result;
396 }
397
398
364 char* BuildIsolateName(const char* script_name, 399 char* BuildIsolateName(const char* script_name,
365 const char* func_name) { 400 const char* func_name) {
366 // Skip past any slashes in the script name. 401 // Skip past any slashes in the script name.
367 const char* last_slash = strrchr(script_name, '/'); 402 const char* last_slash = strrchr(script_name, '/');
368 if (last_slash != NULL) { 403 if (last_slash != NULL) {
369 script_name = last_slash + 1; 404 script_name = last_slash + 1;
370 } 405 }
371 406
372 const char* kFormat = "%s/%s"; 407 const char* kFormat = "%s/%s";
373 intptr_t len = strlen(script_name) + strlen(func_name) + 2; 408 intptr_t len = strlen(script_name) + strlen(func_name) + 2;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 Dart_Handle library = Dart_LookupLibrary(script_url); 502 Dart_Handle library = Dart_LookupLibrary(script_url);
468 if (Dart_IsError(library)) { 503 if (Dart_IsError(library)) {
469 fprintf(stderr, "%s\n", Dart_GetError(library)); 504 fprintf(stderr, "%s\n", Dart_GetError(library));
470 Dart_ExitScope(); 505 Dart_ExitScope();
471 Dart_ShutdownIsolate(); 506 Dart_ShutdownIsolate();
472 free(canonical_script_name); 507 free(canonical_script_name);
473 return 255; // Indicates we encountered an error. 508 return 255; // Indicates we encountered an error.
474 } 509 }
475 // Set debug breakpoint if specified on the command line. 510 // Set debug breakpoint if specified on the command line.
476 if (breakpoint_at != NULL) { 511 if (breakpoint_at != NULL) {
477 char* bpt_function = strdup(breakpoint_at); 512 result = SetBreakpoint(breakpoint_at, library);
478 Dart_Handle class_name;
479 Dart_Handle function_name;
480 char* dot = strchr(bpt_function, '.');
481 if (dot == NULL) {
482 class_name = Dart_NewString("");
483 function_name = Dart_NewString(breakpoint_at);
484 } else {
485 *dot = '\0';
486 class_name = Dart_NewString(bpt_function);
487 function_name = Dart_NewString(dot + 1);
488 }
489 free(bpt_function);
490 Dart_Breakpoint bpt;
491 result = Dart_SetBreakpointAtEntry(
492 library, class_name, function_name, &bpt);
493 if (Dart_IsError(result)) { 513 if (Dart_IsError(result)) {
494 fprintf(stderr, "Error setting breakpoint at '%s': %s\n", 514 fprintf(stderr, "Error setting breakpoint at '%s': %s\n",
495 breakpoint_at, 515 breakpoint_at,
496 Dart_GetError(result)); 516 Dart_GetError(result));
497 Dart_ExitScope(); 517 Dart_ExitScope();
498 Dart_ShutdownIsolate(); 518 Dart_ShutdownIsolate();
499 free(canonical_script_name); 519 free(canonical_script_name);
500 return 255; // Indicates we encountered an error. 520 return 255; // Indicates we encountered an error.
501 } 521 }
502 } 522 }
(...skipping 23 matching lines...) Expand all
526 Dart_ExitScope(); 546 Dart_ExitScope();
527 // Dump symbol information for the profiler. 547 // Dump symbol information for the profiler.
528 DumpPprofSymbolInfo(); 548 DumpPprofSymbolInfo();
529 // Shutdown the isolate. 549 // Shutdown the isolate.
530 Dart_ShutdownIsolate(); 550 Dart_ShutdownIsolate();
531 // Terminate event handler. 551 // Terminate event handler.
532 EventHandler::Terminate(); 552 EventHandler::Terminate();
533 553
534 return 0; 554 return 0;
535 } 555 }
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698