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

Unified Diff: runtime/bin/main.cc

Issue 8826007: First bits of external debugger API (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/dart-runtime.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
===================================================================
--- runtime/bin/main.cc (revision 2184)
+++ runtime/bin/main.cc (working copy)
@@ -7,6 +7,7 @@
#include <stdio.h>
#include "include/dart_api.h"
+#include "include/dart_debugger_api.h"
#include "bin/builtin.h"
#include "bin/dartutils.h"
@@ -28,6 +29,12 @@
static const char* generate_pprof_symbols_filename = NULL;
+// Global state that indicates whether there is a debug breakpoint.
+// This pointer points into an argv buffer and does not need to be
+// free'd.
+static const char* breakpoint_at = NULL;
+
+
static bool IsValidFlag(const char* name,
const char* prefix,
intptr_t prefix_length) {
@@ -56,6 +63,16 @@
}
+static bool ProcessDebugOption(const char* option) {
+ const char* kDebugOption = "--break_at=";
+ const char* func_name = ProcessOption(option, kDebugOption);
+ if (func_name != NULL) {
+ breakpoint_at = func_name;
+ }
+ return func_name != NULL;
+}
+
+
// Parse out the command line arguments. Returns -1 if the arguments
// are incorrect, 0 otherwise.
static int ParseArguments(int argc,
@@ -73,10 +90,12 @@
while ((i < argc) && IsValidFlag(argv[i], kPrefix, kPrefixLen)) {
if (ProcessPprofOption(argv[i])) {
i += 1;
- continue;
+ } else if (ProcessDebugOption(argv[i])) {
+ i += 1;
+ } else {
+ vm_options->AddArgument(argv[i]);
+ i += 1;
}
- vm_options->AddArgument(argv[i]);
- i += 1;
}
if (generate_pprof_symbols_filename != NULL) {
Dart_InitPprofSupport();
@@ -329,7 +348,7 @@
return 255; // Indicates we encountered an error.
}
- // Lookup and invoke the top level main function.
+ // Lookup the library of the main script.
Dart_Handle script_url = Dart_NewString(canonical_script_name);
Dart_Handle library = Dart_LookupLibrary(script_url);
if (Dart_IsError(library)) {
@@ -339,6 +358,35 @@
free(canonical_script_name);
return 255; // Indicates we encountered an error.
}
+ // Set debug breakpoint if specified on the command line.
+ if (breakpoint_at != NULL) {
+ char* bpt_function = strdup(breakpoint_at);
+ Dart_Handle class_name;
+ Dart_Handle function_name;
+ char* dot = strchr(bpt_function, '.');
+ if (dot == NULL) {
+ class_name = Dart_NewString("");
+ function_name = Dart_NewString(breakpoint_at);
+ } else {
+ *dot = '\0';
+ class_name = Dart_NewString(bpt_function);
+ function_name = Dart_NewString(dot + 1);
+ }
+ free(bpt_function);
+ Dart_Breakpoint bpt;
+ result = Dart_SetBreakpointAtEntry(
+ library, class_name, function_name, &bpt);
+ if (Dart_IsError(result)) {
+ fprintf(stderr, "Error setting breakpoint at '%s': %s\n",
+ breakpoint_at,
+ Dart_GetError(result));
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+ free(canonical_script_name);
+ return 255; // Indicates we encountered an error.
+ }
+ }
+ // Lookup and invoke the top level main function.
result = Dart_InvokeStatic(library,
Dart_NewString(""),
Dart_NewString("main"),
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/dart-runtime.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698