in lib/Debugger.ProtocolHandler/DebuggerImpl.cpp [104:180]
Response DebuggerImpl::setBreakpointByUrl(
int in_lineNumber,
Maybe<String> in_url,
Maybe<String> in_urlRegex,
Maybe<int> in_columnNumber,
Maybe<String> in_condition,
String *out_breakpointId,
std::unique_ptr<Array<Location>>* out_locations)
{
String url;
DebuggerBreakpoint::QueryType type;
if (in_url.isJust())
{
url = in_url.fromJust();
type = DebuggerBreakpoint::QueryType::Url;
}
else if (in_urlRegex.isJust())
{
url = in_urlRegex.fromJust();
type = DebuggerBreakpoint::QueryType::UrlRegex;
}
else
{
return Response::Error(c_ErrorUrlRequired);
}
int columnNumber = in_columnNumber.fromMaybe(0);
if (columnNumber < 0)
{
return Response::Error(c_ErrorInvalidColumnNumber);
}
String condition = in_condition.fromMaybe("");
DebuggerBreakpoint breakpoint(
m_debugger,
url,
type,
in_lineNumber,
columnNumber,
condition);
String breakpointId = breakpoint.GenerateKey();
auto result = m_breakpointMap.find(breakpointId);
if (result != m_breakpointMap.end())
{
return Response::Error(c_ErrorBreakpointExists);
}
auto locations = Array<Location>::create();
try
{
for (const auto& script : m_scriptMap)
{
if (breakpoint.TryLoadScript(script.second))
{
if (TryResolveBreakpoint(breakpoint))
{
locations->addItem(breakpoint.GetActualLocation());
}
}
}
}
catch (const JsErrorException& e)
{
return Response::Error(e.what());
}
m_breakpointMap.emplace(breakpointId, breakpoint);
*out_breakpointId = breakpointId;
*out_locations = std::move(locations);
return Response::OK();
}