| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "platform.h" | 34 #include "platform.h" |
| 35 #include "stub-cache.h" | 35 #include "stub-cache.h" |
| 36 #include "cctest.h" | 36 #include "cctest.h" |
| 37 | 37 |
| 38 | 38 |
| 39 using ::v8::internal::EmbeddedVector; | 39 using ::v8::internal::EmbeddedVector; |
| 40 using ::v8::internal::Object; | 40 using ::v8::internal::Object; |
| 41 using ::v8::internal::OS; | 41 using ::v8::internal::OS; |
| 42 using ::v8::internal::Handle; | 42 using ::v8::internal::Handle; |
| 43 using ::v8::internal::Heap; | 43 using ::v8::internal::Heap; |
| 44 using ::v8::internal::JSGlobalObject; | 44 using ::v8::internal::JSGlobalProxy; |
| 45 using ::v8::internal::Code; | 45 using ::v8::internal::Code; |
| 46 using ::v8::internal::Debug; | 46 using ::v8::internal::Debug; |
| 47 using ::v8::internal::Debugger; | 47 using ::v8::internal::Debugger; |
| 48 using ::v8::internal::StepAction; | 48 using ::v8::internal::StepAction; |
| 49 using ::v8::internal::StepIn; // From StepAction enum | 49 using ::v8::internal::StepIn; // From StepAction enum |
| 50 using ::v8::internal::StepNext; // From StepAction enum | 50 using ::v8::internal::StepNext; // From StepAction enum |
| 51 using ::v8::internal::StepOut; // From StepAction enum | 51 using ::v8::internal::StepOut; // From StepAction enum |
| 52 | 52 |
| 53 | 53 |
| 54 // Size of temp buffer for formatting small strings. | 54 // Size of temp buffer for formatting small strings. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 inline ~DebugLocalContext() { | 130 inline ~DebugLocalContext() { |
| 131 context_->Exit(); | 131 context_->Exit(); |
| 132 context_.Dispose(); | 132 context_.Dispose(); |
| 133 } | 133 } |
| 134 inline v8::Context* operator->() { return *context_; } | 134 inline v8::Context* operator->() { return *context_; } |
| 135 inline v8::Context* operator*() { return *context_; } | 135 inline v8::Context* operator*() { return *context_; } |
| 136 inline bool IsReady() { return !context_.IsEmpty(); } | 136 inline bool IsReady() { return !context_.IsEmpty(); } |
| 137 void ExposeDebug() { | 137 void ExposeDebug() { |
| 138 // Expose the debug context global object in the global object for testing. | 138 // Expose the debug context global object in the global object for testing. |
| 139 Debug::Load(); | 139 Debug::Load(); |
| 140 Handle<JSGlobalObject> global(Handle<JSGlobalObject>::cast( | 140 Debug::debug_context()->set_security_token( |
| 141 v8::Utils::OpenHandle(*context_)->security_token()); |
| 142 |
| 143 Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( |
| 141 v8::Utils::OpenHandle(*context_->Global()))); | 144 v8::Utils::OpenHandle(*context_->Global()))); |
| 142 Handle<JSGlobalObject> debug_global(JSGlobalObject::cast( | |
| 143 Debug::debug_context()->global())); | |
| 144 debug_global->set_security_token(global->security_token()); | |
| 145 Handle<v8::internal::String> debug_string = | 145 Handle<v8::internal::String> debug_string = |
| 146 v8::internal::Factory::LookupAsciiSymbol("debug"); | 146 v8::internal::Factory::LookupAsciiSymbol("debug"); |
| 147 SetProperty(global, debug_string, debug_global, DONT_ENUM); | 147 SetProperty(global, debug_string, |
| 148 Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM); |
| 148 } | 149 } |
| 149 private: | 150 private: |
| 150 v8::Persistent<v8::Context> context_; | 151 v8::Persistent<v8::Context> context_; |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 | 154 |
| 154 // --- H e l p e r F u n c t i o n s | 155 // --- H e l p e r F u n c t i o n s |
| 155 | 156 |
| 156 | 157 |
| 157 // Compile and run the supplied source and return the fequested function. | 158 // Compile and run the supplied source and return the fequested function. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 OS::SNPrintF(buffer, | 219 OS::SNPrintF(buffer, |
| 219 "debug.Debug.setScriptBreakPoint(\"%s\",%d,%d)", | 220 "debug.Debug.setScriptBreakPoint(\"%s\",%d,%d)", |
| 220 script_data, line, column); | 221 script_data, line, column); |
| 221 } else { | 222 } else { |
| 222 // Column not specified set script break point on line. | 223 // Column not specified set script break point on line. |
| 223 OS::SNPrintF(buffer, | 224 OS::SNPrintF(buffer, |
| 224 "debug.Debug.setScriptBreakPoint(\"%s\",%d)", | 225 "debug.Debug.setScriptBreakPoint(\"%s\",%d)", |
| 225 script_data, line); | 226 script_data, line); |
| 226 } | 227 } |
| 227 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; | 228 buffer[SMALL_STRING_BUFFER_SIZE - 1] = '\0'; |
| 228 v8::Handle<v8::String> str = v8::String::New(buffer.start()); | 229 { |
| 229 return v8::Script::Compile(str)->Run()->Int32Value(); | 230 v8::TryCatch try_catch; |
| 231 v8::Handle<v8::String> str = v8::String::New(buffer.start()); |
| 232 v8::Handle<v8::Value> value = v8::Script::Compile(str)->Run(); |
| 233 ASSERT(!try_catch.HasCaught()); |
| 234 return value->Int32Value(); |
| 235 } |
| 230 } | 236 } |
| 231 | 237 |
| 232 | 238 |
| 233 // Clear a break point. | 239 // Clear a break point. |
| 234 static void ClearBreakPoint(int break_point) { | 240 static void ClearBreakPoint(int break_point) { |
| 235 Debug::ClearBreakPoint( | 241 Debug::ClearBreakPoint( |
| 236 Handle<Object>(v8::internal::Smi::FromInt(break_point))); | 242 Handle<Object>(v8::internal::Smi::FromInt(break_point))); |
| 237 } | 243 } |
| 238 | 244 |
| 239 | 245 |
| (...skipping 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 Barriers stack_allocated_breakpoints_barriers; | 3124 Barriers stack_allocated_breakpoints_barriers; |
| 3119 stack_allocated_breakpoints_barriers.Initialize(); | 3125 stack_allocated_breakpoints_barriers.Initialize(); |
| 3120 breakpoints_barriers = &stack_allocated_breakpoints_barriers; | 3126 breakpoints_barriers = &stack_allocated_breakpoints_barriers; |
| 3121 | 3127 |
| 3122 breakpoints_v8_thread.Start(); | 3128 breakpoints_v8_thread.Start(); |
| 3123 breakpoints_debugger_thread.Start(); | 3129 breakpoints_debugger_thread.Start(); |
| 3124 | 3130 |
| 3125 breakpoints_v8_thread.Join(); | 3131 breakpoints_v8_thread.Join(); |
| 3126 breakpoints_debugger_thread.Join(); | 3132 breakpoints_debugger_thread.Join(); |
| 3127 } | 3133 } |
| OLD | NEW |