| Index: src/d8.cc
 | 
| ===================================================================
 | 
| --- src/d8.cc	(revision 993)
 | 
| +++ src/d8.cc	(working copy)
 | 
| @@ -29,6 +29,7 @@
 | 
|  #include <stdlib.h>
 | 
|  
 | 
|  #include "d8.h"
 | 
| +#include "d8-debug.h"
 | 
|  #include "debug.h"
 | 
|  #include "api.h"
 | 
|  #include "natives.h"
 | 
| @@ -98,6 +99,10 @@
 | 
|                            bool report_exceptions) {
 | 
|    HandleScope handle_scope;
 | 
|    TryCatch try_catch;
 | 
| +  if (i::FLAG_debugger) {
 | 
| +    // When debugging make exceptions appear to be uncaught.
 | 
| +    try_catch.SetVerbose(true);
 | 
| +  }
 | 
|    Handle<Script> script = Script::Compile(source, name);
 | 
|    if (script.IsEmpty()) {
 | 
|      // Print errors that happened during compilation.
 | 
| @@ -212,6 +217,46 @@
 | 
|  }
 | 
|  
 | 
|  
 | 
| +Handle<String> Shell::DebugEventToText(Handle<Object> event) {
 | 
| +  HandleScope handle_scope;
 | 
| +  Context::Scope context_scope(utility_context_);
 | 
| +  Handle<Object> global = utility_context_->Global();
 | 
| +  Handle<Value> fun = global->Get(String::New("DebugEventToText"));
 | 
| +  TryCatch try_catch;
 | 
| +  try_catch.SetVerbose(true);
 | 
| +  static const int kArgc = 1;
 | 
| +  Handle<Value> argv[kArgc] = { event };
 | 
| +  Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
 | 
| +  if (try_catch.HasCaught()) {
 | 
| +    return handle_scope.Close(try_catch.Exception()->ToString());
 | 
| +  } else {
 | 
| +    return handle_scope.Close(Handle<String>::Cast(val));
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| +
 | 
| +Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) {
 | 
| +  Context::Scope context_scope(utility_context_);
 | 
| +  Handle<Object> global = utility_context_->Global();
 | 
| +  Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest"));
 | 
| +  static const int kArgc = 1;
 | 
| +  Handle<Value> argv[kArgc] = { command };
 | 
| +  Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
 | 
| +  return val;
 | 
| +}
 | 
| +
 | 
| +
 | 
| +Handle<Object> Shell::DebugResponseDetails(Handle<String> response) {
 | 
| +  Context::Scope context_scope(utility_context_);
 | 
| +  Handle<Object> global = utility_context_->Global();
 | 
| +  Handle<Value> fun = global->Get(String::New("DebugResponseDetails"));
 | 
| +  static const int kArgc = 1;
 | 
| +  Handle<Value> argv[kArgc] = { response };
 | 
| +  Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
 | 
| +  return Handle<Object>::Cast(val);
 | 
| +}
 | 
| +
 | 
| +
 | 
|  int32_t* Counter::Bind(const char* name) {
 | 
|    int i;
 | 
|    for (i = 0; i < kMaxNameSize - 1 && name[i]; i++)
 | 
| @@ -415,6 +460,8 @@
 | 
|          return 1;
 | 
|      }
 | 
|    }
 | 
| +  if (i::FLAG_debugger)
 | 
| +    v8::Debug::AddDebugEventListener(HandleDebugEvent);
 | 
|    if (run_shell)
 | 
|      RunShell();
 | 
|    OnExit();
 | 
| 
 |