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

Side by Side Diff: src/inspector/v8-debugger-agent-impl.cc

Issue 2482513002: [inspector] use debuggerContext as current in getPossibleBreakpoints (Closed)
Patch Set: Created 4 years, 1 month 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 | test/inspector/debugger/get-possible-breakpoints.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/inspector/v8-debugger-agent-impl.h" 5 #include "src/inspector/v8-debugger-agent-impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/debug/debug-interface.h" 9 #include "src/debug/debug-interface.h"
10 #include "src/inspector/injected-script.h" 10 #include "src/inspector/injected-script.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); 349 m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId);
350 } 350 }
351 351
352 Response V8DebuggerAgentImpl::getPossibleBreakpoints( 352 Response V8DebuggerAgentImpl::getPossibleBreakpoints(
353 std::unique_ptr<protocol::Debugger::Location> start, 353 std::unique_ptr<protocol::Debugger::Location> start,
354 Maybe<protocol::Debugger::Location> end, 354 Maybe<protocol::Debugger::Location> end,
355 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { 355 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) {
356 String16 scriptId = start->getScriptId(); 356 String16 scriptId = start->getScriptId();
357 357
358 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) 358 if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) {
359 return Response::Error( 359 return Response::Error(
360 "start.lineNumber and start.columnNumber should be >= 0"); 360 "start.lineNumber and start.columnNumber should be >= 0");
361 }
361 362
362 v8::DebugInterface::Location v8Start(start->getLineNumber(), 363 v8::DebugInterface::Location v8Start(start->getLineNumber(),
363 start->getColumnNumber(0)); 364 start->getColumnNumber(0));
364 v8::DebugInterface::Location v8End; 365 v8::DebugInterface::Location v8End;
365 if (end.isJust()) { 366 if (end.isJust()) {
366 if (end.fromJust()->getScriptId() != scriptId) 367 if (end.fromJust()->getScriptId() != scriptId)
367 return Response::Error("Locations should contain the same scriptId"); 368 return Response::Error("Locations should contain the same scriptId");
368 int line = end.fromJust()->getLineNumber(); 369 int line = end.fromJust()->getLineNumber();
369 int column = end.fromJust()->getColumnNumber(0); 370 int column = end.fromJust()->getColumnNumber(0);
370 if (line < 0 || column < 0) 371 if (line < 0 || column < 0)
371 return Response::Error( 372 return Response::Error(
372 "end.lineNumber and end.columnNumber should be >= 0"); 373 "end.lineNumber and end.columnNumber should be >= 0");
373 v8End = v8::DebugInterface::Location(line, column); 374 v8End = v8::DebugInterface::Location(line, column);
374 } 375 }
375 auto it = m_scripts.find(scriptId); 376 auto it = m_scripts.find(scriptId);
376 if (it == m_scripts.end()) return Response::Error("Script not found"); 377 if (it == m_scripts.end()) return Response::Error("Script not found");
377 378
379 v8::HandleScope handleScope(m_isolate);
380 v8::Context::Scope scope(v8::DebugInterface::GetDebugContext(m_isolate));
381
378 std::vector<v8::DebugInterface::Location> v8Locations; 382 std::vector<v8::DebugInterface::Location> v8Locations;
379 if (!it->second->getPossibleBreakpoints(v8Start, v8End, &v8Locations)) 383 if (!it->second->getPossibleBreakpoints(v8Start, v8End, &v8Locations))
380 return Response::InternalError(); 384 return Response::InternalError();
381 385
382 *locations = protocol::Array<protocol::Debugger::Location>::create(); 386 *locations = protocol::Array<protocol::Debugger::Location>::create();
383 for (size_t i = 0; i < v8Locations.size(); ++i) { 387 for (size_t i = 0; i < v8Locations.size(); ++i) {
384 (*locations) 388 (*locations)
385 ->addItem(protocol::Debugger::Location::create() 389 ->addItem(protocol::Debugger::Location::create()
386 .setScriptId(scriptId) 390 .setScriptId(scriptId)
387 .setLineNumber(v8Locations[i].GetLineNumber()) 391 .setLineNumber(v8Locations[i].GetLineNumber())
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 1222
1219 void V8DebuggerAgentImpl::reset() { 1223 void V8DebuggerAgentImpl::reset() {
1220 if (!enabled()) return; 1224 if (!enabled()) return;
1221 m_scheduledDebuggerStep = NoStep; 1225 m_scheduledDebuggerStep = NoStep;
1222 m_scripts.clear(); 1226 m_scripts.clear();
1223 m_blackboxedPositions.clear(); 1227 m_blackboxedPositions.clear();
1224 m_breakpointIdToDebuggerBreakpointIds.clear(); 1228 m_breakpointIdToDebuggerBreakpointIds.clear();
1225 } 1229 }
1226 1230
1227 } // namespace v8_inspector 1231 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | test/inspector/debugger/get-possible-breakpoints.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698