Fix remote debugger crash.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 19 Jan 2012 16:52:16 +0000 (16:52 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 19 Jan 2012 16:52:16 +0000 (16:52 +0000)
Review URL: https://chromiumcodereview.appspot.com/9200006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10449 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/d8-debug.cc
src/d8.cc

index 1cbc0b3..de0faa8 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -310,9 +310,7 @@ void RemoteDebugger::HandleKeyboardCommand(char* command) {
   Handle<Value> request =
       Shell::DebugCommandToJSONRequest(String::New(command));
   if (try_catch.HasCaught()) {
-    v8::String::Utf8Value exception(try_catch.Exception());
-    const char* exception_string = Shell::ToCString(exception);
-    printf("%s\n", exception_string);
+    Shell::ReportException(&try_catch);
     PrintPrompt();
     return;
   }
index b612c48..1067a38 100644 (file)
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -526,6 +526,8 @@ Handle<Value> Shell::Version(const Arguments& args) {
 
 void Shell::ReportException(v8::TryCatch* try_catch) {
   HandleScope handle_scope;
+  bool enter_context = !Context::InContext();
+  if (enter_context) utility_context_->Enter();
   v8::String::Utf8Value exception(try_catch->Exception());
   const char* exception_string = ToCString(exception);
   Handle<Message> message = try_catch->Message();
@@ -560,6 +562,7 @@ void Shell::ReportException(v8::TryCatch* try_catch) {
     }
   }
   printf("\n");
+  if (enter_context) utility_context_->Exit();
 }