| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 9021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9032 void debug::PrepareStep(Isolate* v8_isolate, StepAction action) { | 9032 void debug::PrepareStep(Isolate* v8_isolate, StepAction action) { |
| 9033 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9033 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9034 ENTER_V8(isolate); | 9034 ENTER_V8(isolate); |
| 9035 CHECK(isolate->debug()->CheckExecutionState()); | 9035 CHECK(isolate->debug()->CheckExecutionState()); |
| 9036 // Clear all current stepping setup. | 9036 // Clear all current stepping setup. |
| 9037 isolate->debug()->ClearStepping(); | 9037 isolate->debug()->ClearStepping(); |
| 9038 // Prepare step. | 9038 // Prepare step. |
| 9039 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); | 9039 isolate->debug()->PrepareStep(static_cast<i::StepAction>(action)); |
| 9040 } | 9040 } |
| 9041 | 9041 |
| 9042 void debug::ClearStepping(Isolate* v8_isolate) { | |
| 9043 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
| 9044 ENTER_V8(isolate); | |
| 9045 // Clear all current stepping setup. | |
| 9046 isolate->debug()->ClearStepping(); | |
| 9047 } | |
| 9048 | |
| 9049 v8::Isolate* debug::Script::GetIsolate() const { | 9042 v8::Isolate* debug::Script::GetIsolate() const { |
| 9050 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); | 9043 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); |
| 9051 } | 9044 } |
| 9052 | 9045 |
| 9053 ScriptOriginOptions debug::Script::OriginOptions() const { | 9046 ScriptOriginOptions debug::Script::OriginOptions() const { |
| 9054 return Utils::OpenHandle(this)->origin_options(); | 9047 return Utils::OpenHandle(this)->origin_options(); |
| 9055 } | 9048 } |
| 9056 | 9049 |
| 9057 bool debug::Script::WasCompiled() const { | 9050 bool debug::Script::WasCompiled() const { |
| 9058 return Utils::OpenHandle(this)->compilation_state() == | 9051 return Utils::OpenHandle(this)->compilation_state() == |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9130 i::Handle<i::Object> value(script->source(), isolate); | 9123 i::Handle<i::Object> value(script->source(), isolate); |
| 9131 if (!value->IsString()) return MaybeLocal<String>(); | 9124 if (!value->IsString()) return MaybeLocal<String>(); |
| 9132 return Utils::ToLocal( | 9125 return Utils::ToLocal( |
| 9133 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); | 9126 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| 9134 } | 9127 } |
| 9135 | 9128 |
| 9136 bool debug::Script::IsWasm() const { | 9129 bool debug::Script::IsWasm() const { |
| 9137 return Utils::OpenHandle(this)->type() == i::Script::TYPE_WASM; | 9130 return Utils::OpenHandle(this)->type() == i::Script::TYPE_WASM; |
| 9138 } | 9131 } |
| 9139 | 9132 |
| 9133 void debug::Script::BlackboxStateChanged() const { |
| 9134 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 9135 i::HandleScope handle_scope(isolate); |
| 9136 i::Handle<i::Script> script = Utils::OpenHandle(this); |
| 9137 i::List<i::Handle<i::SharedFunctionInfo>> infos; |
| 9138 i::SharedFunctionInfo::ScriptIterator iterator(script); |
| 9139 for (i::SharedFunctionInfo* info = iterator.Next(); info != nullptr; |
| 9140 info = iterator.Next()) { |
| 9141 infos.Add(i::handle(info)); |
| 9142 } |
| 9143 for (int i = 0; i < infos.length(); ++i) { |
| 9144 isolate->debug()->OnNewSharedFunctionInfo(infos[i]); |
| 9145 } |
| 9146 } |
| 9147 |
| 9140 namespace { | 9148 namespace { |
| 9141 int GetSmiValue(i::Handle<i::FixedArray> array, int index) { | 9149 int GetSmiValue(i::Handle<i::FixedArray> array, int index) { |
| 9142 return i::Smi::cast(array->get(index))->value(); | 9150 return i::Smi::cast(array->get(index))->value(); |
| 9143 } | 9151 } |
| 9144 } // namespace | 9152 } // namespace |
| 9145 | 9153 |
| 9146 bool debug::Script::GetPossibleBreakpoints( | 9154 bool debug::Script::GetPossibleBreakpoints( |
| 9147 const debug::Location& start, const debug::Location& end, | 9155 const debug::Location& start, const debug::Location& end, |
| 9148 std::vector<debug::Location>* locations) const { | 9156 std::vector<debug::Location>* locations) const { |
| 9149 CHECK(!start.IsEmpty()); | 9157 CHECK(!start.IsEmpty()); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9318 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); | 9326 RETURN_ESCAPED(ToApiHandle<UnboundScript>(result)); |
| 9319 } | 9327 } |
| 9320 | 9328 |
| 9321 void debug::SetDebugEventListener(Isolate* v8_isolate, | 9329 void debug::SetDebugEventListener(Isolate* v8_isolate, |
| 9322 debug::DebugEventListener* listener) { | 9330 debug::DebugEventListener* listener) { |
| 9323 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9331 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9324 ENTER_V8(isolate); | 9332 ENTER_V8(isolate); |
| 9325 isolate->debug()->SetDebugEventListener(listener); | 9333 isolate->debug()->SetDebugEventListener(listener); |
| 9326 } | 9334 } |
| 9327 | 9335 |
| 9336 void debug::SetIsBlackboxedCallback(Isolate* v8_isolate, |
| 9337 IsBlackboxedCallback callback, void* data) { |
| 9338 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9339 ENTER_V8(isolate); |
| 9340 isolate->debug()->SetIsBlackboxedCallback(callback, data); |
| 9341 } |
| 9342 |
| 9343 bool debug::HasUserFrameOnStack(Isolate* v8_isolate) { |
| 9344 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9345 ENTER_V8(isolate); |
| 9346 for (i::StackTraceFrameIterator it(isolate); !it.done(); it.Advance()) { |
| 9347 if (!it.is_javascript()) continue; |
| 9348 if (!it.javascript_frame()->function()->shared()->debug_is_blackboxed()) |
| 9349 return true; |
| 9350 } |
| 9351 return false; |
| 9352 } |
| 9353 |
| 9328 Local<String> CpuProfileNode::GetFunctionName() const { | 9354 Local<String> CpuProfileNode::GetFunctionName() const { |
| 9329 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 9355 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 9330 i::Isolate* isolate = node->isolate(); | 9356 i::Isolate* isolate = node->isolate(); |
| 9331 const i::CodeEntry* entry = node->entry(); | 9357 const i::CodeEntry* entry = node->entry(); |
| 9332 i::Handle<i::String> name = | 9358 i::Handle<i::String> name = |
| 9333 isolate->factory()->InternalizeUtf8String(entry->name()); | 9359 isolate->factory()->InternalizeUtf8String(entry->name()); |
| 9334 if (!entry->has_name_prefix()) { | 9360 if (!entry->has_name_prefix()) { |
| 9335 return ToApiHandle<String>(name); | 9361 return ToApiHandle<String>(name); |
| 9336 } else { | 9362 } else { |
| 9337 // We do not expect this to fail. Change this if it does. | 9363 // We do not expect this to fail. Change this if it does. |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10005 Address callback_address = | 10031 Address callback_address = |
| 10006 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10032 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 10007 VMState<EXTERNAL> state(isolate); | 10033 VMState<EXTERNAL> state(isolate); |
| 10008 ExternalCallbackScope call_scope(isolate, callback_address); | 10034 ExternalCallbackScope call_scope(isolate, callback_address); |
| 10009 callback(info); | 10035 callback(info); |
| 10010 } | 10036 } |
| 10011 | 10037 |
| 10012 | 10038 |
| 10013 } // namespace internal | 10039 } // namespace internal |
| 10014 } // namespace v8 | 10040 } // namespace v8 |
| OLD | NEW |