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

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') | runtime/include/dart_debugger_api.h » ('J')
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return true; 352 return true;
353 } 353 }
354 354
355 355
356 static void PrintUsage() { 356 static void PrintUsage() {
357 fprintf(stderr, 357 fprintf(stderr,
358 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); 358 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n");
359 } 359 }
360 360
361 361
362 static Dart_Handle SetBreakpoint(const char* breakpoint_at,
363 Dart_Handle library) {
siva 2012/01/18 01:32:03 indentation?
hausner 2012/01/18 23:26:38 Done.
364 Dart_Handle result;
365 if (strchr(breakpoint_at, ':')) {
366 Dart_Handle url;
367 Dart_Handle line_number;
368 char* bpt_line = strdup(breakpoint_at);
369 char* colon = strchr(bpt_line, ':');
370 ASSERT(colon != NULL);
371 *colon = '\0';
372 url = Dart_NewString(bpt_line);
siva 2012/01/18 01:32:03 Dart_Handle url = ....;
hausner 2012/01/18 23:26:38 Done.
373 line_number = Dart_NewInteger(atoi(colon + 1));
siva 2012/01/18 01:32:03 Dart_Handle line_number = ...; Also we may want t
hausner 2012/01/18 23:26:38 This is really just a make-shift UI for me to test
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);
siva 2012/01/18 01:32:03 We may want to protect against input strings of th
hausner 2012/01/18 23:26:38 Ditto
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
362 int main(int argc, char** argv) { 399 int main(int argc, char** argv) {
363 char* script_name; 400 char* script_name;
364 CommandLineOptions vm_options(argc); 401 CommandLineOptions vm_options(argc);
365 CommandLineOptions dart_options(argc); 402 CommandLineOptions dart_options(argc);
366 403
367 // Perform platform specific initialization. 404 // Perform platform specific initialization.
368 if (!Platform::Initialize()) { 405 if (!Platform::Initialize()) {
369 fprintf(stderr, "Initialization failed\n"); 406 fprintf(stderr, "Initialization failed\n");
370 } 407 }
371 408
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 Dart_Handle library = Dart_LookupLibrary(script_url); 483 Dart_Handle library = Dart_LookupLibrary(script_url);
447 if (Dart_IsError(library)) { 484 if (Dart_IsError(library)) {
448 fprintf(stderr, "%s\n", Dart_GetError(library)); 485 fprintf(stderr, "%s\n", Dart_GetError(library));
449 Dart_ExitScope(); 486 Dart_ExitScope();
450 Dart_ShutdownIsolate(); 487 Dart_ShutdownIsolate();
451 free(canonical_script_name); 488 free(canonical_script_name);
452 return 255; // Indicates we encountered an error. 489 return 255; // Indicates we encountered an error.
453 } 490 }
454 // Set debug breakpoint if specified on the command line. 491 // Set debug breakpoint if specified on the command line.
455 if (breakpoint_at != NULL) { 492 if (breakpoint_at != NULL) {
456 char* bpt_function = strdup(breakpoint_at); 493 result = SetBreakpoint(breakpoint_at, library);
457 Dart_Handle class_name;
458 Dart_Handle function_name;
459 char* dot = strchr(bpt_function, '.');
460 if (dot == NULL) {
461 class_name = Dart_NewString("");
462 function_name = Dart_NewString(breakpoint_at);
463 } else {
464 *dot = '\0';
465 class_name = Dart_NewString(bpt_function);
466 function_name = Dart_NewString(dot + 1);
467 }
468 free(bpt_function);
469 Dart_Breakpoint bpt;
470 result = Dart_SetBreakpointAtEntry(
471 library, class_name, function_name, &bpt);
472 if (Dart_IsError(result)) { 494 if (Dart_IsError(result)) {
473 fprintf(stderr, "Error setting breakpoint at '%s': %s\n", 495 fprintf(stderr, "Error setting breakpoint at '%s': %s\n",
474 breakpoint_at, 496 breakpoint_at,
475 Dart_GetError(result)); 497 Dart_GetError(result));
476 Dart_ExitScope(); 498 Dart_ExitScope();
477 Dart_ShutdownIsolate(); 499 Dart_ShutdownIsolate();
478 free(canonical_script_name); 500 free(canonical_script_name);
479 return 255; // Indicates we encountered an error. 501 return 255; // Indicates we encountered an error.
480 } 502 }
481 } 503 }
(...skipping 23 matching lines...) Expand all
505 Dart_ExitScope(); 527 Dart_ExitScope();
506 // Dump symbol information for the profiler. 528 // Dump symbol information for the profiler.
507 DumpPprofSymbolInfo(); 529 DumpPprofSymbolInfo();
508 // Shutdown the isolate. 530 // Shutdown the isolate.
509 Dart_ShutdownIsolate(); 531 Dart_ShutdownIsolate();
510 // Terminate event handler. 532 // Terminate event handler.
511 EventHandler::Terminate(); 533 EventHandler::Terminate();
512 534
513 return 0; 535 return 0;
514 } 536 }
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_debugger_api.h » ('j') | runtime/include/dart_debugger_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698