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

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

Issue 2465553003: [inspector] added Debugger.getPossibleBreakpoints method (Closed)
Patch Set: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: src/inspector/v8-debugger-agent-impl.cc
diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc
index f318619b35bf2b37a0696f9af59bef791840af77..d20e9c96e329166404ca2dd23ad6d3d0cb5235ce 100644
--- a/src/inspector/v8-debugger-agent-impl.cc
+++ b/src/inspector/v8-debugger-agent-impl.cc
@@ -380,6 +380,58 @@ void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) {
m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId);
}
+void V8DebuggerAgentImpl::getPossibleBreakpoints(
+ ErrorString* errorString,
+ std::unique_ptr<protocol::Debugger::Location> start,
+ const Maybe<protocol::Debugger::Location>& end,
+ std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) {
+ String16 scriptId = start->getScriptId();
+
+ if (start->getLineNumber() < 0 || start->getColumnNumber(0) < 0) {
+ *errorString = "start.lineNumber and start.columnNumber should be >= 0";
+ return;
+ }
+
+ v8::DebugInterface::Script::Location v8Start(start->getLineNumber(),
+ start->getColumnNumber(0));
+ v8::DebugInterface::Script::Location v8End;
+ if (end.isJust()) {
+ if (end.fromJust()->getScriptId() != scriptId) {
+ *errorString = "Locations should contain the same scriptId";
+ return;
+ }
+ int line = end.fromJust()->getLineNumber();
+ int column = end.fromJust()->getColumnNumber(0);
+ if (line < 0 || column < 0) {
+ *errorString = "end.lineNumber and end.columnNumber should be >= 0";
+ return;
+ }
+ v8End = v8::DebugInterface::Script::Location(line, column);
+ }
+ auto it = m_scripts.find(scriptId);
+ if (it == m_scripts.end()) {
+ *errorString = "Script not found";
+ return;
+ }
+
+ std::vector<v8::DebugInterface::Script::Location> v8Locations;
+ if (!it->second->getPossibleBreakpoints(v8Start, v8End, &v8Locations)) {
+ *errorString = "Internal error";
+ return;
+ }
+
+ using protocol::Debugger::Location;
dgozman 2016/11/03 21:13:13 Please remove.
kozy 2016/11/03 22:17:13 Done.
+ *locations = protocol::Array<Location>::create();
+ for (size_t i = 0; i < v8Locations.size(); ++i) {
+ (*locations)
+ ->addItem(Location::create()
+ .setScriptId(scriptId)
+ .setLineNumber(v8Locations[i].GetLineNumber())
+ .setColumnNumber(v8Locations[i].GetColumnNumber())
+ .build());
+ }
+}
+
void V8DebuggerAgentImpl::continueToLocation(
ErrorString* errorString,
std::unique_ptr<protocol::Debugger::Location> location) {
@@ -547,7 +599,7 @@ void V8DebuggerAgentImpl::setScriptSource(
return;
ScriptsMap::iterator it = m_scripts.find(scriptId);
- if (it != m_scripts.end()) it->second->setSource(m_isolate, newSource);
+ if (it != m_scripts.end()) it->second->setSource(newSource);
std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString);
if (!callFrames) return;

Powered by Google App Engine
This is Rietveld 408576698