Commit 4e55bc66 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2011-04-06 Pavel Feldman <pfeldman@google.com>

        Reviewed by Yury Semikhatsky.

        Web Inspector: migrate debugger domain to the unified breakpoint location notion.
        https://bugs.webkit.org/show_bug.cgi?id=57928

        * inspector/Inspector.json:
        * inspector/InspectorDebuggerAgent.cpp:
        (WebCore::buildObjectForBreakpointCookie):
        (WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
        (WebCore::InspectorDebuggerAgent::setBreakpoint):
        (WebCore::InspectorDebuggerAgent::resolveBreakpoint):
        (WebCore::InspectorDebuggerAgent::didParseSource):
        * inspector/InspectorDebuggerAgent.h:
        * inspector/front-end/Breakpoint.js:
        (WebInspector.Breakpoint):
        * inspector/front-end/DebuggerModel.js:
        (WebInspector.DebuggerModel.prototype.setBreakpointBySourceId):
        (WebInspector.DebuggerModel.prototype._breakpointResolved):

git-svn-id: svn://svn.chromium.org/blink/trunk@83164 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2c90bab4
2011-04-06 Pavel Feldman <pfeldman@google.com>
Reviewed by Yury Semikhatsky.
Web Inspector: migrate debugger domain to the unified breakpoint location notion.
https://bugs.webkit.org/show_bug.cgi?id=57928
* inspector/Inspector.json:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::buildObjectForBreakpointCookie):
(WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
(WebCore::InspectorDebuggerAgent::setBreakpoint):
(WebCore::InspectorDebuggerAgent::resolveBreakpoint):
(WebCore::InspectorDebuggerAgent::didParseSource):
* inspector/InspectorDebuggerAgent.h:
* inspector/front-end/Breakpoint.js:
(WebInspector.Breakpoint):
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel.prototype.setBreakpointBySourceId):
(WebInspector.DebuggerModel.prototype._breakpointResolved):
2011-04-07 Andreas Kling <andreas.kling@nokia.com> 2011-04-07 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Benjamin Poulain. Reviewed by Benjamin Poulain.
...@@ -1278,7 +1278,7 @@ ...@@ -1278,7 +1278,7 @@
], ],
"returns": [ "returns": [
{ "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." }, { "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." },
{ "name": "locations", "type": "array", "items": { "$ref" : "Location"}, "description": "List of the locations this breakpoint resolved into." } { "name": "locations", "type": "array", "items": { "$ref" : "Location"}, "description": "List of the locations this breakpoint resolved into." }
], ],
"description": "Sets JavaScript breakpoint at a given location specified by URL. This breakpoint will survive page reload." "description": "Sets JavaScript breakpoint at a given location specified by URL. This breakpoint will survive page reload."
}, },
...@@ -1293,8 +1293,7 @@ ...@@ -1293,8 +1293,7 @@
], ],
"returns": [ "returns": [
{ "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." }, { "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." },
{ "name": "actualLineNumber", "type": "integer", "description": "Line number in the script." }, { "name": "location", "$ref" : "Location", "description": "Location this breakpoint resolved into." }
{ "name": "actualColumnNumber", "type": "integer", "description": "Column number in the script." }
], ],
"description": "Sets JavaScript breakpoint at a given location." "description": "Sets JavaScript breakpoint at a given location."
}, },
...@@ -1412,9 +1411,7 @@ ...@@ -1412,9 +1411,7 @@
"name": "breakpointResolved", "name": "breakpointResolved",
"parameters": [ "parameters": [
{ "name": "breakpointId", "type": "string", "description": "Breakpoint unique identifier." }, { "name": "breakpointId", "type": "string", "description": "Breakpoint unique identifier." },
{ "name": "sourceId", "type": "string", "description": "Identifier of the script breakpoint is set in." }, { "name": "location", "$ref": "Location", "description": "Actual breakpoint location." }
{ "name": "lineNumber", "type": "integer", "description": "Line number of the statement breakpoint is set on." },
{ "name": "columnNumber", "type": "integer", "description": "Column offset of the statement breakpoint is set on." }
], ],
"description": "Fired when breakpoint is resolved to an actual script and location." "description": "Fired when breakpoint is resolved to an actual script and location."
}, },
......
...@@ -141,6 +141,17 @@ void InspectorDebuggerAgent::inspectedURLChanged(const String&) ...@@ -141,6 +141,17 @@ void InspectorDebuggerAgent::inspectedURLChanged(const String&)
m_breakpointIdToDebugServerBreakpointIds.clear(); m_breakpointIdToDebugServerBreakpointIds.clear();
} }
static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool enabled)
{
RefPtr<InspectorObject> breakpointObject = InspectorObject::create();
breakpointObject->setString("url", url);
breakpointObject->setNumber("lineNumber", lineNumber);
breakpointObject->setNumber("columnNumber", columnNumber);
breakpointObject->setString("condition", condition);
breakpointObject->setBoolean("enabled", enabled);
return breakpointObject;
}
void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* outBreakpointId, RefPtr<InspectorArray>* locations) void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* outBreakpointId, RefPtr<InspectorArray>* locations)
{ {
int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0; int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
...@@ -151,32 +162,21 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url, ...@@ -151,32 +162,21 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url,
RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints); RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints);
if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end())
return; return;
RefPtr<InspectorObject> breakpointObject = InspectorObject::create(); breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, enabled));
breakpointObject->setString("url", url);
breakpointObject->setNumber("lineNumber", lineNumber);
breakpointObject->setNumber("columnNumber", columnNumber);
breakpointObject->setString("condition", condition);
breakpointObject->setBoolean("enabled", enabled);
breakpointsCookie->setObject(breakpointId, breakpointObject);
m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie); m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie);
ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled); ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled);
for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) { for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) {
if (it->second.url != url) if (it->second.url != url)
continue; continue;
int actualLineNumber = 0, actualColumnNumber = 0; RefPtr<InspectorObject> location = resolveBreakpoint(breakpointId, it->first, breakpoint);
if (!resolveBreakpoint(breakpointId, it->first, breakpoint, &actualLineNumber, &actualColumnNumber)) if (location)
continue; (*locations)->pushObject(location);
RefPtr<InspectorObject> location = InspectorObject::create();
location->setString("sourceID", it->first);
location->setNumber("lineNumber", actualLineNumber);
location->setNumber("columnNumber", actualColumnNumber);
locations->get()->pushObject(location);
} }
*outBreakpointId = breakpointId; *outBreakpointId = breakpointId;
} }
void InspectorDebuggerAgent::setBreakpoint(ErrorString*, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* outBreakpointId, int* actualLineNumber, int* actualColumnNumber) void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* outBreakpointId, RefPtr<InspectorObject>* location)
{ {
int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0; int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
String condition = optionalCondition ? *optionalCondition : ""; String condition = optionalCondition ? *optionalCondition : "";
...@@ -186,9 +186,11 @@ void InspectorDebuggerAgent::setBreakpoint(ErrorString*, const String& sourceId, ...@@ -186,9 +186,11 @@ void InspectorDebuggerAgent::setBreakpoint(ErrorString*, const String& sourceId,
if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end()) if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end())
return; return;
ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled); ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled);
if (!resolveBreakpoint(breakpointId, sourceId, breakpoint, actualLineNumber, actualColumnNumber)) *location = resolveBreakpoint(breakpointId, sourceId, breakpoint);
return; if (*location)
*outBreakpointId = breakpointId; *outBreakpointId = breakpointId;
else
*errorString = "Could not resolve breakpoint";
} }
void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakpointId) void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakpointId)
...@@ -216,14 +218,14 @@ void InspectorDebuggerAgent::continueToLocation(ErrorString* error, const String ...@@ -216,14 +218,14 @@ void InspectorDebuggerAgent::continueToLocation(ErrorString* error, const String
resume(error); resume(error);
} }
bool InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint& breakpoint, int* actualLineNumber, int* actualColumnNumber) PassRefPtr<InspectorObject> InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint& breakpoint)
{ {
ScriptsMap::iterator scriptIterator = m_scripts.find(sourceId); ScriptsMap::iterator scriptIterator = m_scripts.find(sourceId);
if (scriptIterator == m_scripts.end()) if (scriptIterator == m_scripts.end())
return false; return 0;
Script& script = scriptIterator->second; Script& script = scriptIterator->second;
if (breakpoint.lineNumber < script.lineOffset) if (breakpoint.lineNumber < script.lineOffset)
return false; return 0;
if (!script.linesCount) { if (!script.linesCount) {
script.linesCount = 1; script.linesCount = 1;
for (size_t i = 0; i < script.data.length(); ++i) { for (size_t i = 0; i < script.data.length(); ++i) {
...@@ -232,18 +234,24 @@ bool InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const ...@@ -232,18 +234,24 @@ bool InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const
} }
} }
if (breakpoint.lineNumber >= script.lineOffset + script.linesCount) if (breakpoint.lineNumber >= script.lineOffset + script.linesCount)
return false; return 0;
String debugServerBreakpointId = scriptDebugServer().setBreakpoint(sourceId, breakpoint, actualLineNumber, actualColumnNumber); int actualLineNumber;
int actualColumnNumber;
String debugServerBreakpointId = scriptDebugServer().setBreakpoint(sourceId, breakpoint, &actualLineNumber, &actualColumnNumber);
if (debugServerBreakpointId.isEmpty()) if (debugServerBreakpointId.isEmpty())
return false; return 0;
BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId);
if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end()) if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end())
debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).first; debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).first;
debugServerBreakpointIdsIterator->second.append(debugServerBreakpointId); debugServerBreakpointIdsIterator->second.append(debugServerBreakpointId);
return true; RefPtr<InspectorObject> location = InspectorObject::create();
location->setString("sourceID", sourceId);
location->setNumber("lineNumber", actualLineNumber);
location->setNumber("columnNumber", actualColumnNumber);
return location;
} }
void InspectorDebuggerAgent::editScriptSource(ErrorString* error, const String& sourceID, const String& newContent, RefPtr<InspectorArray>* newCallFrames) void InspectorDebuggerAgent::editScriptSource(ErrorString* error, const String& sourceID, const String& newContent, RefPtr<InspectorArray>* newCallFrames)
...@@ -364,9 +372,9 @@ void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String ...@@ -364,9 +372,9 @@ void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String
breakpointObject->getNumber("columnNumber", &breakpoint.columnNumber); breakpointObject->getNumber("columnNumber", &breakpoint.columnNumber);
breakpointObject->getString("condition", &breakpoint.condition); breakpointObject->getString("condition", &breakpoint.condition);
breakpointObject->getBoolean("enabled", &breakpoint.enabled); breakpointObject->getBoolean("enabled", &breakpoint.enabled);
int actualLineNumber = 0, actualColumnNumber = 0; RefPtr<InspectorObject> location = resolveBreakpoint(it->first, sourceID, breakpoint);
if (resolveBreakpoint(it->first, sourceID, breakpoint, &actualLineNumber, &actualColumnNumber)) if (location)
m_frontend->breakpointResolved(it->first, sourceID, actualLineNumber, actualColumnNumber); m_frontend->breakpointResolved(it->first, location);
} }
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <wtf/Forward.h> #include <wtf/Forward.h>
#include <wtf/HashMap.h> #include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h> #include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h> #include <wtf/Vector.h>
#include <wtf/text/StringHash.h> #include <wtf/text/StringHash.h>
...@@ -80,7 +81,7 @@ public: ...@@ -80,7 +81,7 @@ public:
void setBreakpointsActive(ErrorString*, bool active); void setBreakpointsActive(ErrorString*, bool active);
void setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* breakpointId, RefPtr<InspectorArray>* locations); void setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* breakpointId, RefPtr<InspectorArray>* locations);
void setBreakpoint(ErrorString*, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* breakpointId, int* actualLineNumber, int* actualColumnNumber); void setBreakpoint(ErrorString*, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalEnabled, String* breakpointId, RefPtr<InspectorObject>* location);
void removeBreakpoint(ErrorString*, const String& breakpointId); void removeBreakpoint(ErrorString*, const String& breakpointId);
void continueToLocation(ErrorString*, const String& sourceId, int lineNumber, int columnNumber); void continueToLocation(ErrorString*, const String& sourceId, int lineNumber, int columnNumber);
...@@ -123,7 +124,7 @@ private: ...@@ -123,7 +124,7 @@ private:
virtual void didPause(ScriptState*); virtual void didPause(ScriptState*);
virtual void didContinue(); virtual void didContinue();
bool resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber); PassRefPtr<InspectorObject> resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint&);
void clear(); void clear();
class Script { class Script {
......
...@@ -40,10 +40,3 @@ WebInspector.Breakpoint = function(id, url, sourceID, lineNumber, columnNumber, ...@@ -40,10 +40,3 @@ WebInspector.Breakpoint = function(id, url, sourceID, lineNumber, columnNumber,
this.enabled = enabled; this.enabled = enabled;
this.locations = []; this.locations = [];
} }
WebInspector.Breakpoint.prototype = {
addLocation: function(sourceID, lineNumber, columnNumber)
{
this.locations.push({ sourceID: sourceID, lineNumber: lineNumber, columnNumber: columnNumber });
}
}
...@@ -102,12 +102,12 @@ WebInspector.DebuggerModel.prototype = { ...@@ -102,12 +102,12 @@ WebInspector.DebuggerModel.prototype = {
setBreakpointBySourceId: function(sourceID, lineNumber, columnNumber, condition, enabled, callback) setBreakpointBySourceId: function(sourceID, lineNumber, columnNumber, condition, enabled, callback)
{ {
function didSetBreakpoint(error, breakpointId, actualLineNumber, actualColumnNumber) function didSetBreakpoint(error, breakpointId, location)
{ {
var breakpoint; var breakpoint;
if (!error && breakpointId) { if (!error && breakpointId) {
breakpoint = new WebInspector.Breakpoint(breakpointId, "", sourceID, lineNumber, columnNumber, condition, enabled); breakpoint = new WebInspector.Breakpoint(breakpointId, "", sourceID, lineNumber, columnNumber, condition, enabled);
breakpoint.addLocation(sourceID, actualLineNumber, actualColumnNumber); breakpoint.locations.push(location);
this._breakpoints[breakpointId] = breakpoint; this._breakpoints[breakpointId] = breakpoint;
} }
if (callback) if (callback)
...@@ -122,10 +122,10 @@ WebInspector.DebuggerModel.prototype = { ...@@ -122,10 +122,10 @@ WebInspector.DebuggerModel.prototype = {
delete this._breakpoints[breakpointId]; delete this._breakpoints[breakpointId];
}, },
_breakpointResolved: function(breakpointId, sourceID, lineNumber, columnNumber) _breakpointResolved: function(breakpointId, location)
{ {
var breakpoint = this._breakpoints[breakpointId]; var breakpoint = this._breakpoints[breakpointId];
breakpoint.addLocation(sourceID, lineNumber, columnNumber); breakpoint.locations.push(location);
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, breakpoint); this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, breakpoint);
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment