Skip to content

lldb-dap: DataBreakpointInfoRequest handler violates specification #156473

@Anthony-Eid

Description

@Anthony-Eid

Summary

The DataBreakpiontInforRequest handler seems to violate the DAP spec by requiring frame ID be sent in the request body. This causes two problems

  1. There's no way to specify a global scope for expressions
  2. The handler always responds with an error when request uses a variable reference to distinguish the scope being used

FrameId Specification

/**
   * When `name` is an expression, evaluate it in the scope of this stack frame.
   * If not specified, the expression is evaluated in the global scope. When
   * `variablesReference` is specified, this property has no effect.
   */
  frameId?: number;

Bug lldb-dap/Protocol/ProtocolRequest.cpp:461

The bug is caused below because frameId is not mapped as an optional. Please note that this isn't the only violation for this request handler, variablesReference, bytes, asAddresss and mode should all be optional as well (everything except the name field should be an optional).

bool fromJSON(const json::Value &Params, DataBreakpointInfoArguments &DBIA,
              json::Path P) {
  json::ObjectMapper O(Params, P);
  return O && O.map("variablesReference", DBIA.variablesReference) &&
         O.map("name", DBIA.name) && O.map("frameId", DBIA.frameId) &&
         O.map("bytes", DBIA.bytes) && O.map("asAddress", DBIA.asAddress) &&
         O.map("mode", DBIA.mode);
}

Dap logs showing error (With Zed)

{
  "type": "request",
  "seq": 21,
  "command": "dataBreakpointInfo",
  "arguments": {
    "variablesReference": 10,
    "name": "c",
    "asAddress": false
  }
}
// Receive
{
  "body": {
    "error": {
      "format": "invalid arguments for request 'dataBreakpointInfo': missing value at arguments.frameId\n/* error: missing value */\n{\n  \"asAddress\": false,\n  \"name\": \"c\",\n  \"variablesReference\": 10\n}",
      "id": 3,
      "showUser": true
    }
  },
  "command": "dataBreakpointInfo",
  "request_seq": 21,
  "seq": 0,
  "success": false,
  "type": "response"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions