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

Side by Side Diff: src/api.cc

Issue 2685163006: [inspector] migrate set/remove BreakPoint to debug-interface.h (Closed)
Patch Set: added comment about inlined jsframe index Created 3 years, 10 months 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 unified diff | Download patch
« no previous file with comments | « src/api.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9067 matching lines...) Expand 10 before | Expand all | Expand 10 after
9078 i::HandleScope scope(isolate); 9078 i::HandleScope scope(isolate);
9079 for (i::StackTraceFrameIterator it(isolate); !it.done(); it.Advance()) { 9079 for (i::StackTraceFrameIterator it(isolate); !it.done(); it.Advance()) {
9080 if (!it.is_javascript()) continue; 9080 if (!it.is_javascript()) continue;
9081 if (!isolate->debug()->IsFrameBlackboxed(it.javascript_frame())) { 9081 if (!isolate->debug()->IsFrameBlackboxed(it.javascript_frame())) {
9082 return true; 9082 return true;
9083 } 9083 }
9084 } 9084 }
9085 return false; 9085 return false;
9086 } 9086 }
9087 9087
9088 Local<debug::BreakPoint> debug::BreakPoint::New(Isolate* v8_isolate,
9089 Local<String> condition,
9090 Local<Value> data) {
9091 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9092 ENTER_V8(isolate);
9093 i::HandleScope handle_scope(isolate);
9094 i::Handle<i::BreakPoint> break_point = isolate->factory()->NewBreakPoint(
9095 Utils::OpenHandle(*condition), Utils::OpenHandle(*data));
9096 return ToApiHandle<debug::BreakPoint>(
9097 handle_scope.CloseAndEscape(break_point));
9098 }
9099
9100 MaybeLocal<debug::BreakPoint> debug::BreakPoint::Cast(
9101 Isolate* v8_isolate, v8::Local<v8::Value> value) {
9102 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9103 ENTER_V8(isolate);
9104 i::HandleScope handle_scope(isolate);
9105 i::Handle<i::Object> break_point_obj = Utils::OpenHandle(*value);
9106 if (!break_point_obj->IsBreakPoint()) return MaybeLocal<debug::BreakPoint>();
9107 i::Handle<i::BreakPoint> break_point(i::BreakPoint::cast(*break_point_obj),
9108 isolate);
9109 return ToApiHandle<debug::BreakPoint>(
9110 handle_scope.CloseAndEscape(break_point));
9111 }
9112
9113 v8::Local<v8::Value> debug::BreakPoint::Data() const {
9114 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
9115 i::HandleScope handle_scope(isolate);
9116 i::Handle<i::BreakPoint> break_point = Utils::OpenHandle(this);
9117 i::Handle<i::Object> data_obj(break_point->data(), isolate);
9118 return Utils::ToLocal(handle_scope.CloseAndEscape(data_obj));
9119 }
9120
9088 v8::Isolate* debug::Script::GetIsolate() const { 9121 v8::Isolate* debug::Script::GetIsolate() const {
9089 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); 9122 return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate());
9090 } 9123 }
9091 9124
9092 ScriptOriginOptions debug::Script::OriginOptions() const { 9125 ScriptOriginOptions debug::Script::OriginOptions() const {
9093 return Utils::OpenHandle(this)->origin_options(); 9126 return Utils::OpenHandle(this)->origin_options();
9094 } 9127 }
9095 9128
9096 bool debug::Script::WasCompiled() const { 9129 bool debug::Script::WasCompiled() const {
9097 return Utils::OpenHandle(this)->compilation_state() == 9130 return Utils::OpenHandle(this)->compilation_state() ==
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
9232 line_offset = GetSmiValue(line_ends, current_line_end_index - 1) + 1; 9265 line_offset = GetSmiValue(line_ends, current_line_end_index - 1) + 1;
9233 } 9266 }
9234 locations->push_back(debug::Location( 9267 locations->push_back(debug::Location(
9235 current_line_end_index + script->line_offset(), 9268 current_line_end_index + script->line_offset(),
9236 offset - line_offset + 9269 offset - line_offset +
9237 (current_line_end_index == 0 ? script->column_offset() : 0))); 9270 (current_line_end_index == 0 ? script->column_offset() : 0)));
9238 } 9271 }
9239 return true; 9272 return true;
9240 } 9273 }
9241 9274
9275 debug::Location debug::Script::SetBreakPoint(
9276 const debug::Location& position,
9277 Local<debug::BreakPoint> break_point) const {
9278 i::Handle<i::Script> script = Utils::OpenHandle(this);
9279 i::Isolate* isolate = script->GetIsolate();
9280 int offset = GetSourcePosition(position);
9281 i::Handle<i::BreakPoint> break_point_obj = Utils::OpenHandle(*break_point);
9282 int result_offset = offset;
9283 if (!isolate->debug()->SetBreakPointForScript(
9284 script, break_point_obj, &result_offset, i::BREAK_POSITION_ALIGNED)) {
9285 return debug::Location();
9286 }
9287 i::Script::PositionInfo info;
9288 i::Script::GetPositionInfo(script, result_offset, &info,
9289 i::Script::WITH_OFFSET);
9290 return debug::Location(info.line, info.column);
9291 }
9292
9242 int debug::Script::GetSourcePosition(const debug::Location& location) const { 9293 int debug::Script::GetSourcePosition(const debug::Location& location) const {
9243 i::Handle<i::Script> script = Utils::OpenHandle(this); 9294 i::Handle<i::Script> script = Utils::OpenHandle(this);
9244 if (script->type() == i::Script::TYPE_WASM) { 9295 if (script->type() == i::Script::TYPE_WASM) {
9245 // TODO(clemensh): Return the proper thing for wasm. 9296 return i::WasmCompiledModule::cast(script->wasm_compiled_module())
9246 return 0; 9297 ->GetFunctionOffset(location.GetLineNumber()) +
9298 location.GetColumnNumber();
9247 } 9299 }
9248 9300
9249 int line = std::max(location.GetLineNumber() - script->line_offset(), 0); 9301 int line = std::max(location.GetLineNumber() - script->line_offset(), 0);
9250 int column = location.GetColumnNumber(); 9302 int column = location.GetColumnNumber();
9251 if (line == 0) { 9303 if (line == 0) {
9252 column = std::max(0, column - script->column_offset()); 9304 column = std::max(0, column - script->column_offset());
9253 } 9305 }
9254 9306
9255 i::Script::InitLineEnds(script); 9307 i::Script::InitLineEnds(script);
9256 CHECK(script->line_ends()->IsFixedArray()); 9308 CHECK(script->line_ends()->IsFixedArray());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
9310 debug::WasmDisassembly debug::WasmScript::DisassembleFunction( 9362 debug::WasmDisassembly debug::WasmScript::DisassembleFunction(
9311 int function_index) const { 9363 int function_index) const {
9312 i::DisallowHeapAllocation no_gc; 9364 i::DisallowHeapAllocation no_gc;
9313 i::Handle<i::Script> script = Utils::OpenHandle(this); 9365 i::Handle<i::Script> script = Utils::OpenHandle(this);
9314 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); 9366 DCHECK_EQ(i::Script::TYPE_WASM, script->type());
9315 i::WasmCompiledModule* compiled_module = 9367 i::WasmCompiledModule* compiled_module =
9316 i::WasmCompiledModule::cast(script->wasm_compiled_module()); 9368 i::WasmCompiledModule::cast(script->wasm_compiled_module());
9317 return compiled_module->DisassembleFunction(function_index); 9369 return compiled_module->DisassembleFunction(function_index);
9318 } 9370 }
9319 9371
9372 void debug::ClearBreakPoint(v8::Isolate* v8_isolate,
9373 Local<BreakPoint> break_point) {
9374 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9375 ENTER_V8(isolate);
9376 i::Handle<i::Object> break_point_obj = Utils::OpenHandle(*break_point);
9377 isolate->debug()->ClearBreakPoint(break_point_obj);
9378 }
9379
9320 debug::Location::Location(int line_number, int column_number) 9380 debug::Location::Location(int line_number, int column_number)
9321 : line_number_(line_number), column_number_(column_number) { 9381 : line_number_(line_number), column_number_(column_number) {
9322 CHECK(line_number >= 0); 9382 CHECK(line_number >= 0);
9323 CHECK(column_number >= 0); 9383 CHECK(column_number >= 0);
9324 } 9384 }
9325 9385
9326 debug::Location::Location() 9386 debug::Location::Location()
9327 : line_number_(v8::Function::kLineOffsetNotFound), 9387 : line_number_(v8::Function::kLineOffsetNotFound),
9328 column_number_(v8::Function::kLineOffsetNotFound) {} 9388 column_number_(v8::Function::kLineOffsetNotFound) {}
9329 9389
9330 int debug::Location::GetLineNumber() const { 9390 int debug::Location::GetLineNumber() const {
9331 CHECK(line_number_ >= 0); 9391 CHECK(line_number_ >= 0);
9332 return line_number_; 9392 return line_number_;
9333 } 9393 }
9334 9394
9335 int debug::Location::GetColumnNumber() const { 9395 int debug::Location::GetColumnNumber() const {
9336 CHECK(column_number_ >= 0); 9396 CHECK(column_number_ >= 0);
9337 return column_number_; 9397 return column_number_;
9338 } 9398 }
9339 9399
9340 bool debug::Location::IsEmpty() const { 9400 bool debug::Location::IsEmpty() const {
9341 return line_number_ == -1 && column_number_ == -1; 9401 return line_number_ == v8::Function::kLineOffsetNotFound &&
9402 column_number_ == v8::Function::kLineOffsetNotFound;
9342 } 9403 }
9343 9404
9344 void debug::GetLoadedScripts(v8::Isolate* v8_isolate, 9405 void debug::GetLoadedScripts(v8::Isolate* v8_isolate,
9345 PersistentValueVector<debug::Script>& scripts) { 9406 PersistentValueVector<debug::Script>& scripts) {
9346 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9407 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9347 ENTER_V8(isolate); 9408 ENTER_V8(isolate);
9348 // TODO(kozyatinskiy): remove this GC once tests are dealt with. 9409 // TODO(kozyatinskiy): remove this GC once tests are dealt with.
9349 isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask, 9410 isolate->heap()->CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask,
9350 i::GarbageCollectionReason::kDebugger); 9411 i::GarbageCollectionReason::kDebugger);
9351 { 9412 {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
10169 Address callback_address = 10230 Address callback_address =
10170 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10231 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10171 VMState<EXTERNAL> state(isolate); 10232 VMState<EXTERNAL> state(isolate);
10172 ExternalCallbackScope call_scope(isolate, callback_address); 10233 ExternalCallbackScope call_scope(isolate, callback_address);
10173 callback(info); 10234 callback(info);
10174 } 10235 }
10175 10236
10176 10237
10177 } // namespace internal 10238 } // namespace internal
10178 } // namespace v8 10239 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/ast/ast-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698