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>
Reviewed by Benjamin Poulain.
......@@ -1293,8 +1293,7 @@
],
"returns": [
{ "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." },
{ "name": "actualLineNumber", "type": "integer", "description": "Line number in the script." },
{ "name": "actualColumnNumber", "type": "integer", "description": "Column number in the script." }
{ "name": "location", "$ref" : "Location", "description": "Location this breakpoint resolved into." }
],
"description": "Sets JavaScript breakpoint at a given location."
},
......@@ -1412,9 +1411,7 @@
"name": "breakpointResolved",
"parameters": [
{ "name": "breakpointId", "type": "string", "description": "Breakpoint unique identifier." },
{ "name": "sourceId", "type": "string", "description": "Identifier of the script breakpoint is set in." },
{ "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." }
{ "name": "location", "$ref": "Location", "description": "Actual breakpoint location." }
],
"description": "Fired when breakpoint is resolved to an actual script and location."
},
......
......@@ -141,6 +141,17 @@ void InspectorDebuggerAgent::inspectedURLChanged(const String&)
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)
{
int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
......@@ -151,32 +162,21 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url,
RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints);
if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end())
return;
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);
breakpointsCookie->setObject(breakpointId, breakpointObject);
breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, enabled));
m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie);
ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled);
for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) {
if (it->second.url != url)
continue;
int actualLineNumber = 0, actualColumnNumber = 0;
if (!resolveBreakpoint(breakpointId, it->first, breakpoint, &actualLineNumber, &actualColumnNumber))
continue;
RefPtr<InspectorObject> location = InspectorObject::create();
location->setString("sourceID", it->first);
location->setNumber("lineNumber", actualLineNumber);
location->setNumber("columnNumber", actualColumnNumber);
locations->get()->pushObject(location);
RefPtr<InspectorObject> location = resolveBreakpoint(breakpointId, it->first, breakpoint);
if (location)
(*locations)->pushObject(location);
}
*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;
String condition = optionalCondition ? *optionalCondition : "";
......@@ -186,9 +186,11 @@ void InspectorDebuggerAgent::setBreakpoint(ErrorString*, const String& sourceId,
if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end())
return;
ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled);
if (!resolveBreakpoint(breakpointId, sourceId, breakpoint, actualLineNumber, actualColumnNumber))
return;
*location = resolveBreakpoint(breakpointId, sourceId, breakpoint);
if (*location)
*outBreakpointId = breakpointId;
else
*errorString = "Could not resolve breakpoint";
}
void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakpointId)
......@@ -216,14 +218,14 @@ void InspectorDebuggerAgent::continueToLocation(ErrorString* error, const String
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);
if (scriptIterator == m_scripts.end())
return false;
return 0;
Script& script = scriptIterator->second;
if (breakpoint.lineNumber < script.lineOffset)
return false;
return 0;
if (!script.linesCount) {
script.linesCount = 1;
for (size_t i = 0; i < script.data.length(); ++i) {
......@@ -232,18 +234,24 @@ bool InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const
}
}
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())
return false;
return 0;
BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId);
if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpointIds.end())
debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.set(breakpointId, Vector<String>()).first;
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)
......@@ -364,9 +372,9 @@ void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String
breakpointObject->getNumber("columnNumber", &breakpoint.columnNumber);
breakpointObject->getString("condition", &breakpoint.condition);
breakpointObject->getBoolean("enabled", &breakpoint.enabled);
int actualLineNumber = 0, actualColumnNumber = 0;
if (resolveBreakpoint(it->first, sourceID, breakpoint, &actualLineNumber, &actualColumnNumber))
m_frontend->breakpointResolved(it->first, sourceID, actualLineNumber, actualColumnNumber);
RefPtr<InspectorObject> location = resolveBreakpoint(it->first, sourceID, breakpoint);
if (location)
m_frontend->breakpointResolved(it->first, location);
}
}
......
......@@ -39,6 +39,7 @@
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
......@@ -80,7 +81,7 @@ public:
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 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 continueToLocation(ErrorString*, const String& sourceId, int lineNumber, int columnNumber);
......@@ -123,7 +124,7 @@ private:
virtual void didPause(ScriptState*);
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();
class Script {
......
......@@ -40,10 +40,3 @@ WebInspector.Breakpoint = function(id, url, sourceID, lineNumber, columnNumber,
this.enabled = enabled;
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 = {
setBreakpointBySourceId: function(sourceID, lineNumber, columnNumber, condition, enabled, callback)
{
function didSetBreakpoint(error, breakpointId, actualLineNumber, actualColumnNumber)
function didSetBreakpoint(error, breakpointId, location)
{
var breakpoint;
if (!error && breakpointId) {
breakpoint = new WebInspector.Breakpoint(breakpointId, "", sourceID, lineNumber, columnNumber, condition, enabled);
breakpoint.addLocation(sourceID, actualLineNumber, actualColumnNumber);
breakpoint.locations.push(location);
this._breakpoints[breakpointId] = breakpoint;
}
if (callback)
......@@ -122,10 +122,10 @@ WebInspector.DebuggerModel.prototype = {
delete this._breakpoints[breakpointId];
},
_breakpointResolved: function(breakpointId, sourceID, lineNumber, columnNumber)
_breakpointResolved: function(breakpointId, location)
{
var breakpoint = this._breakpoints[breakpointId];
breakpoint.addLocation(sourceID, lineNumber, columnNumber);
breakpoint.locations.push(location);
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