| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010-2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010-2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "core/inspector/InspectorPageAgent.h" | 42 #include "core/inspector/InspectorPageAgent.h" |
| 43 #include "core/inspector/InspectorState.h" | 43 #include "core/inspector/InspectorState.h" |
| 44 #include "core/inspector/InstrumentingAgents.h" | 44 #include "core/inspector/InstrumentingAgents.h" |
| 45 #include "core/inspector/ScriptArguments.h" | 45 #include "core/inspector/ScriptArguments.h" |
| 46 #include "core/inspector/ScriptCallStack.h" | 46 #include "core/inspector/ScriptCallStack.h" |
| 47 #include "core/platform/text/RegularExpression.h" | 47 #include "core/platform/text/RegularExpression.h" |
| 48 #include "platform/JSONValues.h" | 48 #include "platform/JSONValues.h" |
| 49 #include "wtf/text/WTFString.h" | 49 #include "wtf/text/WTFString.h" |
| 50 | 50 |
| 51 using WebCore::TypeBuilder::Array; | 51 using WebCore::TypeBuilder::Array; |
| 52 using WebCore::TypeBuilder::Debugger::BreakpointId; |
| 53 using WebCore::TypeBuilder::Debugger::CallFrame; |
| 52 using WebCore::TypeBuilder::Debugger::FunctionDetails; | 54 using WebCore::TypeBuilder::Debugger::FunctionDetails; |
| 55 using WebCore::TypeBuilder::Debugger::Location; |
| 53 using WebCore::TypeBuilder::Debugger::ScriptId; | 56 using WebCore::TypeBuilder::Debugger::ScriptId; |
| 54 using WebCore::TypeBuilder::Runtime::RemoteObject; | 57 using WebCore::TypeBuilder::Runtime::RemoteObject; |
| 55 | 58 |
| 56 namespace WebCore { | 59 namespace WebCore { |
| 57 | 60 |
| 58 namespace DebuggerAgentState { | 61 namespace DebuggerAgentState { |
| 59 static const char debuggerEnabled[] = "debuggerEnabled"; | 62 static const char debuggerEnabled[] = "debuggerEnabled"; |
| 60 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; | 63 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; |
| 61 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; | 64 static const char pauseOnExceptionsState[] = "pauseOnExceptionsState"; |
| 62 | 65 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 291 |
| 289 static bool matches(const String& url, const String& pattern, bool isRegex) | 292 static bool matches(const String& url, const String& pattern, bool isRegex) |
| 290 { | 293 { |
| 291 if (isRegex) { | 294 if (isRegex) { |
| 292 RegularExpression regex(pattern, TextCaseSensitive); | 295 RegularExpression regex(pattern, TextCaseSensitive); |
| 293 return regex.match(url) != -1; | 296 return regex.match(url) != -1; |
| 294 } | 297 } |
| 295 return url == pattern; | 298 return url == pattern; |
| 296 } | 299 } |
| 297 | 300 |
| 298 void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li
neNumber, const String* const optionalURL, const String* const optionalURLRegex,
const int* const optionalColumnNumber, const String* const optionalCondition, c
onst bool* isAntiBreakpoint, TypeBuilder::Debugger::BreakpointId* outBreakpointI
d, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& locations) | 301 void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString* errorString, int li
neNumber, const String* const optionalURL, const String* const optionalURLRegex,
const int* const optionalColumnNumber, const String* const optionalCondition, c
onst bool* isAntiBreakpoint, BreakpointId* outBreakpointId, RefPtr<Array<Locatio
n> >& locations) |
| 299 { | 302 { |
| 300 locations = Array<TypeBuilder::Debugger::Location>::create(); | 303 locations = Array<Location>::create(); |
| 301 if (!optionalURL == !optionalURLRegex) { | 304 if (!optionalURL == !optionalURLRegex) { |
| 302 *errorString = "Either url or urlRegex must be specified."; | 305 *errorString = "Either url or urlRegex must be specified."; |
| 303 return; | 306 return; |
| 304 } | 307 } |
| 305 | 308 |
| 306 bool isAntiBreakpointValue = isAntiBreakpoint && *isAntiBreakpoint; | 309 bool isAntiBreakpointValue = isAntiBreakpoint && *isAntiBreakpoint; |
| 307 | 310 |
| 308 String url = optionalURL ? *optionalURL : *optionalURLRegex; | 311 String url = optionalURL ? *optionalURL : *optionalURLRegex; |
| 309 int columnNumber; | 312 int columnNumber; |
| 310 if (optionalColumnNumber) { | 313 if (optionalColumnNumber) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 327 } | 330 } |
| 328 | 331 |
| 329 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex, isAntiBreakpointValue)); | 332 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur
l, lineNumber, columnNumber, condition, isRegex, isAntiBreakpointValue)); |
| 330 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCoo
kie); | 333 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCoo
kie); |
| 331 | 334 |
| 332 if (!isAntiBreakpointValue) { | 335 if (!isAntiBreakpointValue) { |
| 333 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); | 336 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); |
| 334 for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end();
++it) { | 337 for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end();
++it) { |
| 335 if (!matches(it->value.url, url, isRegex)) | 338 if (!matches(it->value.url, url, isRegex)) |
| 336 continue; | 339 continue; |
| 337 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint
(breakpointId, it->key, breakpoint, UserBreakpointSource); | 340 RefPtr<Location> location = resolveBreakpoint(breakpointId, it->key,
breakpoint, UserBreakpointSource); |
| 338 if (location) | 341 if (location) |
| 339 locations->addItem(location); | 342 locations->addItem(location); |
| 340 } | 343 } |
| 341 } | 344 } |
| 342 *outBreakpointId = breakpointId; | 345 *outBreakpointId = breakpointId; |
| 343 } | 346 } |
| 344 | 347 |
| 345 static bool parseLocation(ErrorString* errorString, PassRefPtr<JSONObject> locat
ion, String* scriptId, int* lineNumber, int* columnNumber) | 348 static bool parseLocation(ErrorString* errorString, PassRefPtr<JSONObject> locat
ion, String* scriptId, int* lineNumber, int* columnNumber) |
| 346 { | 349 { |
| 347 if (!location->getString("scriptId", scriptId) || !location->getNumber("line
Number", lineNumber)) { | 350 if (!location->getString("scriptId", scriptId) || !location->getNumber("line
Number", lineNumber)) { |
| 348 // FIXME: replace with input validation. | 351 // FIXME: replace with input validation. |
| 349 *errorString = "scriptId and lineNumber are required."; | 352 *errorString = "scriptId and lineNumber are required."; |
| 350 return false; | 353 return false; |
| 351 } | 354 } |
| 352 *columnNumber = 0; | 355 *columnNumber = 0; |
| 353 location->getNumber("columnNumber", columnNumber); | 356 location->getNumber("columnNumber", columnNumber); |
| 354 return true; | 357 return true; |
| 355 } | 358 } |
| 356 | 359 |
| 357 void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPt
r<JSONObject>& location, const String* const optionalCondition, TypeBuilder::Deb
ugger::BreakpointId* outBreakpointId, RefPtr<TypeBuilder::Debugger::Location>& a
ctualLocation) | 360 void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const RefPt
r<JSONObject>& location, const String* const optionalCondition, BreakpointId* ou
tBreakpointId, RefPtr<Location>& actualLocation) |
| 358 { | 361 { |
| 359 String scriptId; | 362 String scriptId; |
| 360 int lineNumber; | 363 int lineNumber; |
| 361 int columnNumber; | 364 int columnNumber; |
| 362 | 365 |
| 363 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 366 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
| 364 return; | 367 return; |
| 365 | 368 |
| 366 String condition = optionalCondition ? *optionalCondition : emptyString(); | 369 String condition = optionalCondition ? *optionalCondition : emptyString(); |
| 367 | 370 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 int columnNumber; | 423 int columnNumber; |
| 421 | 424 |
| 422 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) | 425 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum
ber)) |
| 423 return; | 426 return; |
| 424 | 427 |
| 425 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); | 428 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); |
| 426 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, interstateLocation); | 429 m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(scriptI
d, breakpoint, &lineNumber, &columnNumber, interstateLocation); |
| 427 resume(errorString); | 430 resume(errorString); |
| 428 } | 431 } |
| 429 | 432 |
| 430 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location> >& positions) | 433 void InspectorDebuggerAgent::getStepInPositions(ErrorString* errorString, const
String& callFrameId, RefPtr<Array<Location> >& positions) |
| 431 { | 434 { |
| 432 if (!isPaused() || m_currentCallStack.isNull()) { | 435 if (!isPaused() || m_currentCallStack.isNull()) { |
| 433 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 436 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 434 return; | 437 return; |
| 435 } | 438 } |
| 436 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 439 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
| 437 if (injectedScript.hasNoValue()) { | 440 if (injectedScript.hasNoValue()) { |
| 438 *errorString = "Inspected frame has gone"; | 441 *errorString = "Inspected frame has gone"; |
| 439 return; | 442 return; |
| 440 } | 443 } |
| 441 | 444 |
| 442 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); | 445 injectedScript.getStepInPositions(errorString, m_currentCallStack, callFrame
Id, positions); |
| 443 } | 446 } |
| 444 | 447 |
| 445 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<TypeBuilder::Debugger::CallFrame> >& callFrames) | 448 void InspectorDebuggerAgent::getBacktrace(ErrorString* errorString, RefPtr<Array
<CallFrame> >& callFrames) |
| 446 { | 449 { |
| 447 if (!assertPaused(errorString)) | 450 if (!assertPaused(errorString)) |
| 448 return; | 451 return; |
| 449 scriptDebugServer().updateCallStack(&m_currentCallStack); | 452 scriptDebugServer().updateCallStack(&m_currentCallStack); |
| 450 callFrames = currentCallFrames(); | 453 callFrames = currentCallFrames(); |
| 451 } | 454 } |
| 452 | 455 |
| 453 String InspectorDebuggerAgent::scriptURL(JavaScriptCallFrame* frame) | 456 String InspectorDebuggerAgent::scriptURL(JavaScriptCallFrame* frame) |
| 454 { | 457 { |
| 455 String scriptIdString = String::number(frame->sourceID()); | 458 String scriptIdString = String::number(frame->sourceID()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (m_skipStepInCount > 0) { | 535 if (m_skipStepInCount > 0) { |
| 533 --m_skipStepInCount; | 536 --m_skipStepInCount; |
| 534 return ScriptDebugListener::StepInto; | 537 return ScriptDebugListener::StepInto; |
| 535 } | 538 } |
| 536 return ScriptDebugListener::StepOut; | 539 return ScriptDebugListener::StepOut; |
| 537 } | 540 } |
| 538 } | 541 } |
| 539 return ScriptDebugListener::NoSkip; | 542 return ScriptDebugListener::NoSkip; |
| 540 } | 543 } |
| 541 | 544 |
| 542 PassRefPtr<TypeBuilder::Debugger::Location> InspectorDebuggerAgent::resolveBreak
point(const String& breakpointId, const String& scriptId, const ScriptBreakpoint
& breakpoint, BreakpointSource source) | 545 PassRefPtr<Location> InspectorDebuggerAgent::resolveBreakpoint(const String& bre
akpointId, const String& scriptId, const ScriptBreakpoint& breakpoint, Breakpoin
tSource source) |
| 543 { | 546 { |
| 544 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); | 547 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); |
| 545 if (scriptIterator == m_scripts.end()) | 548 if (scriptIterator == m_scripts.end()) |
| 546 return 0; | 549 return 0; |
| 547 Script& script = scriptIterator->value; | 550 Script& script = scriptIterator->value; |
| 548 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.
lineNumber) | 551 if (breakpoint.lineNumber < script.startLine || script.endLine < breakpoint.
lineNumber) |
| 549 return 0; | 552 return 0; |
| 550 | 553 |
| 551 int actualLineNumber; | 554 int actualLineNumber; |
| 552 int actualColumnNumber; | 555 int actualColumnNumber; |
| 553 String debugServerBreakpointId = scriptDebugServer().setBreakpoint(scriptId,
breakpoint, &actualLineNumber, &actualColumnNumber, false); | 556 String debugServerBreakpointId = scriptDebugServer().setBreakpoint(scriptId,
breakpoint, &actualLineNumber, &actualColumnNumber, false); |
| 554 if (debugServerBreakpointId.isEmpty()) | 557 if (debugServerBreakpointId.isEmpty()) |
| 555 return 0; | 558 return 0; |
| 556 | 559 |
| 557 m_serverBreakpoints.set(debugServerBreakpointId, std::make_pair(breakpointId
, source)); | 560 m_serverBreakpoints.set(debugServerBreakpointId, std::make_pair(breakpointId
, source)); |
| 558 | 561 |
| 559 BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIds
Iterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); | 562 BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIds
Iterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); |
| 560 if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpoin
tIds.end()) | 563 if (debugServerBreakpointIdsIterator == m_breakpointIdToDebugServerBreakpoin
tIds.end()) |
| 561 debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpoint
Ids.set(breakpointId, Vector<String>()).iterator; | 564 debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpoint
Ids.set(breakpointId, Vector<String>()).iterator; |
| 562 debugServerBreakpointIdsIterator->value.append(debugServerBreakpointId); | 565 debugServerBreakpointIdsIterator->value.append(debugServerBreakpointId); |
| 563 | 566 |
| 564 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo
cation::create() | 567 RefPtr<Location> location = Location::create() |
| 565 .setScriptId(scriptId) | 568 .setScriptId(scriptId) |
| 566 .setLineNumber(actualLineNumber); | 569 .setLineNumber(actualLineNumber); |
| 567 location->setColumnNumber(actualColumnNumber); | 570 location->setColumnNumber(actualColumnNumber); |
| 568 return location; | 571 return location; |
| 569 } | 572 } |
| 570 | 573 |
| 571 static PassRefPtr<JSONObject> scriptToInspectorObject(ScriptObject scriptObject) | 574 static PassRefPtr<JSONObject> scriptToInspectorObject(ScriptObject scriptObject) |
| 572 { | 575 { |
| 573 if (scriptObject.hasNoValue()) | 576 if (scriptObject.hasNoValue()) |
| 574 return 0; | 577 return 0; |
| 575 RefPtr<JSONValue> value = scriptObject.toJSONValue(scriptObject.scriptState(
)); | 578 RefPtr<JSONValue> value = scriptObject.toJSONValue(scriptObject.scriptState(
)); |
| 576 if (!value) | 579 if (!value) |
| 577 return 0; | 580 return 0; |
| 578 return value->asObject(); | 581 return value->asObject(); |
| 579 } | 582 } |
| 580 | 583 |
| 581 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<WebCore::TypeBuilder::Page::SearchMatch>
>& results) | 584 void InspectorDebuggerAgent::searchInContent(ErrorString* error, const String& s
criptId, const String& query, const bool* const optionalCaseSensitive, const boo
l* const optionalIsRegex, RefPtr<Array<WebCore::TypeBuilder::Page::SearchMatch>
>& results) |
| 582 { | 585 { |
| 583 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; | 586 bool isRegex = optionalIsRegex ? *optionalIsRegex : false; |
| 584 bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; | 587 bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; |
| 585 | 588 |
| 586 ScriptsMap::iterator it = m_scripts.find(scriptId); | 589 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 587 if (it != m_scripts.end()) | 590 if (it != m_scripts.end()) |
| 588 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, caseSensitive, isRegex); | 591 results = ContentSearchUtils::searchInTextByLines(it->value.source, quer
y, caseSensitive, isRegex); |
| 589 else | 592 else |
| 590 *error = "No script for id: " + scriptId; | 593 *error = "No script for id: " + scriptId; |
| 591 } | 594 } |
| 592 | 595 |
| 593 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil
der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S
tring& newContent, const bool* const preview, RefPtr<Array<TypeBuilder::Debugger
::CallFrame> >& newCallFrames, RefPtr<JSONObject>& result) | 596 void InspectorDebuggerAgent::setScriptSource(ErrorString* error, RefPtr<TypeBuil
der::Debugger::SetScriptSourceError>& errorData, const String& scriptId, const S
tring& newContent, const bool* const preview, RefPtr<Array<CallFrame> >& newCall
Frames, RefPtr<JSONObject>& result) |
| 594 { | 597 { |
| 595 bool previewOnly = preview && *preview; | 598 bool previewOnly = preview && *preview; |
| 596 ScriptObject resultObject; | 599 ScriptObject resultObject; |
| 597 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) | 600 if (!scriptDebugServer().setScriptSource(scriptId, newContent, previewOnly,
error, errorData, &m_currentCallStack, &resultObject)) |
| 598 return; | 601 return; |
| 599 newCallFrames = currentCallFrames(); | 602 newCallFrames = currentCallFrames(); |
| 600 RefPtr<JSONObject> object = scriptToInspectorObject(resultObject); | 603 RefPtr<JSONObject> object = scriptToInspectorObject(resultObject); |
| 601 if (object) | 604 if (object) |
| 602 result = object; | 605 result = object; |
| 603 } | 606 } |
| 604 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<TypeBuilder::Debugger::CallFrame> >& newCallFrames,
RefPtr<JSONObject>& result) | 607 void InspectorDebuggerAgent::restartFrame(ErrorString* errorString, const String
& callFrameId, RefPtr<Array<CallFrame> >& newCallFrames, RefPtr<JSONObject>& res
ult) |
| 605 { | 608 { |
| 606 if (!isPaused() || m_currentCallStack.isNull()) { | 609 if (!isPaused() || m_currentCallStack.isNull()) { |
| 607 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 610 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 608 return; | 611 return; |
| 609 } | 612 } |
| 610 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 613 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
| 611 if (injectedScript.hasNoValue()) { | 614 if (injectedScript.hasNoValue()) { |
| 612 *errorString = "Inspected frame has gone"; | 615 *errorString = "Inspected frame has gone"; |
| 613 return; | 616 return; |
| 614 } | 617 } |
| 615 | 618 |
| 616 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); | 619 injectedScript.restartFrame(errorString, m_currentCallStack, callFrameId, &r
esult); |
| 617 scriptDebugServer().updateCallStack(&m_currentCallStack); | 620 scriptDebugServer().updateCallStack(&m_currentCallStack); |
| 618 newCallFrames = currentCallFrames(); | 621 newCallFrames = currentCallFrames(); |
| 619 } | 622 } |
| 620 | 623 |
| 621 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) | 624 void InspectorDebuggerAgent::getScriptSource(ErrorString* error, const String& s
criptId, String* scriptSource) |
| 622 { | 625 { |
| 623 ScriptsMap::iterator it = m_scripts.find(scriptId); | 626 ScriptsMap::iterator it = m_scripts.find(scriptId); |
| 624 if (it != m_scripts.end()) | 627 if (it != m_scripts.end()) |
| 625 *scriptSource = it->value.source; | 628 *scriptSource = it->value.source; |
| 626 else | 629 else |
| 627 *error = "No script for id: " + scriptId; | 630 *error = "No script for id: " + scriptId; |
| 628 } | 631 } |
| 629 | 632 |
| 630 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>& details) | 633 void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
String& functionId, RefPtr<FunctionDetails>& details) |
| 631 { | 634 { |
| 632 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(functionId); | 635 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(functionId); |
| 633 if (injectedScript.hasNoValue()) { | 636 if (injectedScript.hasNoValue()) { |
| 634 *errorString = "Function object id is obsolete"; | 637 *errorString = "Function object id is obsolete"; |
| 635 return; | 638 return; |
| 636 } | 639 } |
| 637 injectedScript.getFunctionDetails(errorString, functionId, &details); | 640 injectedScript.getFunctionDetails(errorString, functionId, &details); |
| 638 } | 641 } |
| 639 | 642 |
| 640 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb
ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data) | 643 void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Deb
ugger::Reason::Enum breakReason, PassRefPtr<JSONObject> data) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 750 |
| 748 void InspectorDebuggerAgent::setPauseOnExceptionsImpl(ErrorString* errorString,
int pauseState) | 751 void InspectorDebuggerAgent::setPauseOnExceptionsImpl(ErrorString* errorString,
int pauseState) |
| 749 { | 752 { |
| 750 scriptDebugServer().setPauseOnExceptionsState(static_cast<ScriptDebugServer:
:PauseOnExceptionsState>(pauseState)); | 753 scriptDebugServer().setPauseOnExceptionsState(static_cast<ScriptDebugServer:
:PauseOnExceptionsState>(pauseState)); |
| 751 if (scriptDebugServer().pauseOnExceptionsState() != pauseState) | 754 if (scriptDebugServer().pauseOnExceptionsState() != pauseState) |
| 752 *errorString = "Internal error. Could not change pause on exceptions sta
te"; | 755 *errorString = "Internal error. Could not change pause on exceptions sta
te"; |
| 753 else | 756 else |
| 754 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, pauseState)
; | 757 m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, pauseState)
; |
| 755 } | 758 } |
| 756 | 759 |
| 757 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const
String& callFrameId, const String& expression, const String* const objectGroup,
const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptio
nsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview,
RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>
* wasThrown) | 760 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const
String& callFrameId, const String& expression, const String* const objectGroup,
const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptio
nsAndMuteConsole, const bool* const returnByValue, const bool* generatePreview,
RefPtr<RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) |
| 758 { | 761 { |
| 759 if (!isPaused() || m_currentCallStack.isNull()) { | 762 if (!isPaused() || m_currentCallStack.isNull()) { |
| 760 *errorString = "Attempt to access callframe when debugger is not on paus
e"; | 763 *errorString = "Attempt to access callframe when debugger is not on paus
e"; |
| 761 return; | 764 return; |
| 762 } | 765 } |
| 763 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); | 766 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb
jectId(callFrameId); |
| 764 if (injectedScript.hasNoValue()) { | 767 if (injectedScript.hasNoValue()) { |
| 765 *errorString = "Inspected frame has gone"; | 768 *errorString = "Inspected frame has gone"; |
| 766 return; | 769 return; |
| 767 } | 770 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 794 String exceptionMessage; | 797 String exceptionMessage; |
| 795 scriptDebugServer().compileScript(injectedScript.scriptState(), expression,
sourceURL, &scriptIdValue, &exceptionMessage); | 798 scriptDebugServer().compileScript(injectedScript.scriptState(), expression,
sourceURL, &scriptIdValue, &exceptionMessage); |
| 796 if (!scriptIdValue && !exceptionMessage) { | 799 if (!scriptIdValue && !exceptionMessage) { |
| 797 *errorString = "Script compilation failed"; | 800 *errorString = "Script compilation failed"; |
| 798 return; | 801 return; |
| 799 } | 802 } |
| 800 *syntaxErrorMessage = exceptionMessage; | 803 *syntaxErrorMessage = exceptionMessage; |
| 801 *scriptId = scriptIdValue; | 804 *scriptId = scriptIdValue; |
| 802 } | 805 } |
| 803 | 806 |
| 804 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId&
scriptId, const int* executionContextId, const String* const objectGroup, const
bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<TypeBuilder::Runtime::
RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) | 807 void InspectorDebuggerAgent::runScript(ErrorString* errorString, const ScriptId&
scriptId, const int* executionContextId, const String* const objectGroup, const
bool* const doNotPauseOnExceptionsAndMuteConsole, RefPtr<RemoteObject>& result,
TypeBuilder::OptOutput<bool>* wasThrown) |
| 805 { | 808 { |
| 806 InjectedScript injectedScript = injectedScriptForEval(errorString, execution
ContextId); | 809 InjectedScript injectedScript = injectedScriptForEval(errorString, execution
ContextId); |
| 807 if (injectedScript.hasNoValue()) { | 810 if (injectedScript.hasNoValue()) { |
| 808 *errorString = "Inspected frame has gone"; | 811 *errorString = "Inspected frame has gone"; |
| 809 return; | 812 return; |
| 810 } | 813 } |
| 811 | 814 |
| 812 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); | 815 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
criptDebugServer().pauseOnExceptionsState(); |
| 813 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { | 816 if (doNotPauseOnExceptionsAndMuteConsole && *doNotPauseOnExceptionsAndMuteCo
nsole) { |
| 814 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) | 817 if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExce
ptions) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 | 888 |
| 886 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
Text) | 889 void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
Text) |
| 887 { | 890 { |
| 888 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP
auseOnExceptions) { | 891 if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontP
auseOnExceptions) { |
| 889 RefPtr<JSONObject> directive = JSONObject::create(); | 892 RefPtr<JSONObject> directive = JSONObject::create(); |
| 890 directive->setString("directiveText", directiveText); | 893 directive->setString("directiveText", directiveText); |
| 891 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv
e.release()); | 894 breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directiv
e.release()); |
| 892 } | 895 } |
| 893 } | 896 } |
| 894 | 897 |
| 895 PassRefPtr<Array<TypeBuilder::Debugger::CallFrame> > InspectorDebuggerAgent::cur
rentCallFrames() | 898 PassRefPtr<Array<CallFrame> > InspectorDebuggerAgent::currentCallFrames() |
| 896 { | 899 { |
| 897 if (!m_pausedScriptState) | 900 if (!m_pausedScriptState) |
| 898 return Array<TypeBuilder::Debugger::CallFrame>::create(); | 901 return Array<CallFrame>::create(); |
| 899 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState); | 902 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m
_pausedScriptState); |
| 900 if (injectedScript.hasNoValue()) { | 903 if (injectedScript.hasNoValue()) { |
| 901 ASSERT_NOT_REACHED(); | 904 ASSERT_NOT_REACHED(); |
| 902 return Array<TypeBuilder::Debugger::CallFrame>::create(); | 905 return Array<CallFrame>::create(); |
| 903 } | 906 } |
| 904 return injectedScript.wrapCallFrames(m_currentCallStack); | 907 return injectedScript.wrapCallFrames(m_currentCallStack); |
| 905 } | 908 } |
| 906 | 909 |
| 907 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) | 910 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) |
| 908 { | 911 { |
| 909 bool deprecated; | 912 bool deprecated; |
| 910 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co
ntentSearchUtils::JavaScriptMagicComment, &deprecated); | 913 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co
ntentSearchUtils::JavaScriptMagicComment, &deprecated); |
| 911 if (!sourceMapURL.isEmpty()) { | 914 if (!sourceMapURL.isEmpty()) { |
| 912 // FIXME: add deprecated console message here. | 915 // FIXME: add deprecated console message here. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 bool isRegex; | 959 bool isRegex; |
| 957 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); | 960 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); |
| 958 String url; | 961 String url; |
| 959 breakpointObject->getString(DebuggerAgentState::url, &url); | 962 breakpointObject->getString(DebuggerAgentState::url, &url); |
| 960 if (!matches(scriptURL, url, isRegex)) | 963 if (!matches(scriptURL, url, isRegex)) |
| 961 continue; | 964 continue; |
| 962 ScriptBreakpoint breakpoint; | 965 ScriptBreakpoint breakpoint; |
| 963 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); | 966 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint.
lineNumber); |
| 964 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); | 967 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin
t.columnNumber); |
| 965 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); | 968 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c
ondition); |
| 966 RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it-
>key, scriptId, breakpoint, UserBreakpointSource); | 969 RefPtr<Location> location = resolveBreakpoint(it->key, scriptId, breakpo
int, UserBreakpointSource); |
| 967 if (location) | 970 if (location) |
| 968 m_frontend->breakpointResolved(it->key, location); | 971 m_frontend->breakpointResolved(it->key, location); |
| 969 } | 972 } |
| 970 } | 973 } |
| 971 | 974 |
| 972 void InspectorDebuggerAgent::failedToParseSource(const String& url, const String
& data, int firstLine, int errorLine, const String& errorMessage) | 975 void InspectorDebuggerAgent::failedToParseSource(const String& url, const String
& data, int firstLine, int errorLine, const String& errorMessage) |
| 973 { | 976 { |
| 974 m_frontend->scriptFailedToParse(url, data, firstLine, errorLine, errorMessag
e); | 977 m_frontend->scriptFailedToParse(url, data, firstLine, errorLine, errorMessag
e); |
| 975 } | 978 } |
| 976 | 979 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 void InspectorDebuggerAgent::reset() | 1084 void InspectorDebuggerAgent::reset() |
| 1082 { | 1085 { |
| 1083 m_scripts.clear(); | 1086 m_scripts.clear(); |
| 1084 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1087 m_breakpointIdToDebugServerBreakpointIds.clear(); |
| 1085 if (m_frontend) | 1088 if (m_frontend) |
| 1086 m_frontend->globalObjectCleared(); | 1089 m_frontend->globalObjectCleared(); |
| 1087 } | 1090 } |
| 1088 | 1091 |
| 1089 } // namespace WebCore | 1092 } // namespace WebCore |
| 1090 | 1093 |
| OLD | NEW |