Commit b981bf0b authored by Kim-Anh Tran's avatar Kim-Anh Tran Committed by Commit Bot

[debug] Set a cap on how many breakpoints v8 returns

This prevents v8 to send too many breakpoints and
thus exceed the maximum length for a message in
mojo.

Bug: chromium:1105172
Change-Id: I2af21f117d24c52d2f0df6294f15f091b84b1a75
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2300542Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68890}
parent 2ba80497
......@@ -62,6 +62,9 @@ static const char kDebuggerNotPaused[] =
static const size_t kBreakpointHintMaxLength = 128;
static const intptr_t kBreakpointHintMaxSearchOffset = 80 * 10;
// Limit the number of breakpoints returned, as we otherwise may exceed
// the maximum length of a message in mojo (see https://crbug.com/1105172).
static const size_t kMaxNumBreakpoints = 1000;
// TODO(1099680): getScriptSource and getWasmBytecode return Wasm wire bytes
// as protocol::Binary, which is encoded as JSON string in the communication
......@@ -736,7 +739,12 @@ Response V8DebuggerAgentImpl::getPossibleBreakpoints(
*locations =
std::make_unique<protocol::Array<protocol::Debugger::BreakLocation>>();
for (size_t i = 0; i < v8Locations.size(); ++i) {
// TODO(1106269): Return an error instead of capping the number of
// breakpoints.
const size_t numBreakpointsToSend =
std::min(v8Locations.size(), kMaxNumBreakpoints);
for (size_t i = 0; i < numBreakpointsToSend; ++i) {
std::unique_ptr<protocol::Debugger::BreakLocation> breakLocation =
protocol::Debugger::BreakLocation::create()
.setScriptId(scriptId)
......
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