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

Side by Side Diff: src/api.cc

Issue 2710953004: [inspector] added restrictToFunction flag for getPossibleBreakpoints (Closed)
Patch Set: addressed comments Created 3 years, 9 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 | « no previous file | src/debug/debug.h » ('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 9210 matching lines...) Expand 10 before | Expand all | Expand 10 after
9221 } 9221 }
9222 9222
9223 namespace { 9223 namespace {
9224 int GetSmiValue(i::Handle<i::FixedArray> array, int index) { 9224 int GetSmiValue(i::Handle<i::FixedArray> array, int index) {
9225 return i::Smi::cast(array->get(index))->value(); 9225 return i::Smi::cast(array->get(index))->value();
9226 } 9226 }
9227 } // namespace 9227 } // namespace
9228 9228
9229 bool debug::Script::GetPossibleBreakpoints( 9229 bool debug::Script::GetPossibleBreakpoints(
9230 const debug::Location& start, const debug::Location& end, 9230 const debug::Location& start, const debug::Location& end,
9231 std::vector<debug::Location>* locations) const { 9231 bool restrict_to_function, std::vector<debug::Location>* locations) const {
9232 CHECK(!start.IsEmpty()); 9232 CHECK(!start.IsEmpty());
9233 i::Handle<i::Script> script = Utils::OpenHandle(this); 9233 i::Handle<i::Script> script = Utils::OpenHandle(this);
9234 if (script->type() == i::Script::TYPE_WASM) { 9234 if (script->type() == i::Script::TYPE_WASM) {
9235 i::Handle<i::WasmCompiledModule> compiled_module( 9235 i::Handle<i::WasmCompiledModule> compiled_module(
9236 i::WasmCompiledModule::cast(script->wasm_compiled_module())); 9236 i::WasmCompiledModule::cast(script->wasm_compiled_module()));
9237 return compiled_module->GetPossibleBreakpoints(start, end, locations); 9237 return compiled_module->GetPossibleBreakpoints(start, end, locations);
9238 } 9238 }
9239 9239
9240 i::Script::InitLineEnds(script); 9240 i::Script::InitLineEnds(script);
9241 CHECK(script->line_ends()->IsFixedArray()); 9241 CHECK(script->line_ends()->IsFixedArray());
9242 i::Isolate* isolate = script->GetIsolate(); 9242 i::Isolate* isolate = script->GetIsolate();
9243 i::Handle<i::FixedArray> line_ends = 9243 i::Handle<i::FixedArray> line_ends =
9244 i::Handle<i::FixedArray>::cast(i::handle(script->line_ends(), isolate)); 9244 i::Handle<i::FixedArray>::cast(i::handle(script->line_ends(), isolate));
9245 CHECK(line_ends->length()); 9245 CHECK(line_ends->length());
9246 9246
9247 int start_offset = GetSourcePosition(start); 9247 int start_offset = GetSourcePosition(start);
9248 int end_offset; 9248 int end_offset;
9249 if (end.IsEmpty()) { 9249 if (end.IsEmpty()) {
9250 end_offset = GetSmiValue(line_ends, line_ends->length() - 1) + 1; 9250 end_offset = GetSmiValue(line_ends, line_ends->length() - 1) + 1;
9251 } else { 9251 } else {
9252 end_offset = GetSourcePosition(end); 9252 end_offset = GetSourcePosition(end);
9253 } 9253 }
9254 if (start_offset >= end_offset) return true; 9254 if (start_offset >= end_offset) return true;
9255 9255
9256 std::set<int> offsets; 9256 std::set<int> offsets;
9257 if (!isolate->debug()->GetPossibleBreakpoints(script, start_offset, 9257 if (!isolate->debug()->GetPossibleBreakpoints(
9258 end_offset, &offsets)) { 9258 script, start_offset, end_offset, restrict_to_function, &offsets)) {
9259 return false; 9259 return false;
9260 } 9260 }
9261 9261
9262 int current_line_end_index = 0; 9262 int current_line_end_index = 0;
9263 for (const auto& it : offsets) { 9263 for (const auto& it : offsets) {
9264 int offset = it; 9264 int offset = it;
9265 while (offset > GetSmiValue(line_ends, current_line_end_index)) { 9265 while (offset > GetSmiValue(line_ends, current_line_end_index)) {
9266 ++current_line_end_index; 9266 ++current_line_end_index;
9267 CHECK(current_line_end_index < line_ends->length()); 9267 CHECK(current_line_end_index < line_ends->length());
9268 } 9268 }
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
10259 Address callback_address = 10259 Address callback_address =
10260 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10260 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10261 VMState<EXTERNAL> state(isolate); 10261 VMState<EXTERNAL> state(isolate);
10262 ExternalCallbackScope call_scope(isolate, callback_address); 10262 ExternalCallbackScope call_scope(isolate, callback_address);
10263 callback(info); 10263 callback(info);
10264 } 10264 }
10265 10265
10266 10266
10267 } // namespace internal 10267 } // namespace internal
10268 } // namespace v8 10268 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698