Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 9e242382c3fec54e159b723aa51c516dc8cee6f1..5946c237a70aa7b5fc7ac74e7320e137226d6f5f 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -9085,6 +9085,39 @@ bool debug::HasNonBlackboxedFrameOnStack(Isolate* v8_isolate) { |
return false; |
} |
+Local<debug::BreakPoint> debug::BreakPoint::New(Isolate* v8_isolate, |
+ Local<String> condition, |
+ Local<Value> data) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ ENTER_V8(isolate); |
+ i::HandleScope handle_scope(isolate); |
+ i::Handle<i::BreakPoint> break_point = isolate->factory()->NewBreakPoint( |
+ Utils::OpenHandle(*condition), Utils::OpenHandle(*data)); |
+ return ToApiHandle<debug::BreakPoint>( |
+ handle_scope.CloseAndEscape(break_point)); |
+} |
+ |
+MaybeLocal<debug::BreakPoint> debug::BreakPoint::Cast( |
+ Isolate* v8_isolate, v8::Local<v8::Value> value) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ ENTER_V8(isolate); |
+ i::HandleScope handle_scope(isolate); |
+ i::Handle<i::Object> break_point_obj = Utils::OpenHandle(*value); |
+ if (!break_point_obj->IsBreakPoint()) return MaybeLocal<debug::BreakPoint>(); |
+ i::Handle<i::BreakPoint> break_point(i::BreakPoint::cast(*break_point_obj), |
+ isolate); |
+ return ToApiHandle<debug::BreakPoint>( |
+ handle_scope.CloseAndEscape(break_point)); |
+} |
+ |
+v8::Local<v8::Value> debug::BreakPoint::Data() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
+ i::HandleScope handle_scope(isolate); |
+ i::Handle<i::BreakPoint> break_point = Utils::OpenHandle(this); |
+ i::Handle<i::Object> data_obj(break_point->data(), isolate); |
+ return Utils::ToLocal(handle_scope.CloseAndEscape(data_obj)); |
+} |
+ |
v8::Isolate* debug::Script::GetIsolate() const { |
return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); |
} |
@@ -9239,11 +9272,30 @@ bool debug::Script::GetPossibleBreakpoints( |
return true; |
} |
+debug::Location debug::Script::SetBreakPoint( |
+ const debug::Location& position, |
+ Local<debug::BreakPoint> break_point) const { |
+ i::Handle<i::Script> script = Utils::OpenHandle(this); |
+ i::Isolate* isolate = script->GetIsolate(); |
+ int offset = GetSourcePosition(position); |
+ i::Handle<i::BreakPoint> break_point_obj = Utils::OpenHandle(*break_point); |
+ int result_offset = offset; |
+ if (!isolate->debug()->SetBreakPointForScript( |
+ script, break_point_obj, &result_offset, i::BREAK_POSITION_ALIGNED)) { |
+ return debug::Location(); |
+ } |
+ i::Script::PositionInfo info; |
+ i::Script::GetPositionInfo(script, result_offset, &info, |
+ i::Script::WITH_OFFSET); |
+ return debug::Location(info.line, info.column); |
+} |
+ |
int debug::Script::GetSourcePosition(const debug::Location& location) const { |
i::Handle<i::Script> script = Utils::OpenHandle(this); |
if (script->type() == i::Script::TYPE_WASM) { |
- // TODO(clemensh): Return the proper thing for wasm. |
- return 0; |
+ return i::WasmCompiledModule::cast(script->wasm_compiled_module()) |
+ ->GetFunctionOffset(location.GetLineNumber()) + |
+ location.GetColumnNumber(); |
} |
int line = std::max(location.GetLineNumber() - script->line_offset(), 0); |
@@ -9317,6 +9369,14 @@ debug::WasmDisassembly debug::WasmScript::DisassembleFunction( |
return compiled_module->DisassembleFunction(function_index); |
} |
+void debug::ClearBreakPoint(v8::Isolate* v8_isolate, |
+ Local<BreakPoint> break_point) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ ENTER_V8(isolate); |
+ i::Handle<i::Object> break_point_obj = Utils::OpenHandle(*break_point); |
+ isolate->debug()->ClearBreakPoint(break_point_obj); |
+} |
+ |
debug::Location::Location(int line_number, int column_number) |
: line_number_(line_number), column_number_(column_number) { |
CHECK(line_number >= 0); |
@@ -9338,7 +9398,8 @@ int debug::Location::GetColumnNumber() const { |
} |
bool debug::Location::IsEmpty() const { |
- return line_number_ == -1 && column_number_ == -1; |
+ return line_number_ == v8::Function::kLineOffsetNotFound && |
+ column_number_ == v8::Function::kLineOffsetNotFound; |
} |
void debug::GetLoadedScripts(v8::Isolate* v8_isolate, |