Skip to content

Commit 60a9aff

Browse files
committed
adding breakpoints protocol types
1 parent ccdd55c commit 60a9aff

File tree

2 files changed

+186
-0
lines changed

2 files changed

+186
-0
lines changed

lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,184 @@ enum SteppingGranularity : unsigned {
322322
bool fromJSON(const llvm::json::Value &, SteppingGranularity &,
323323
llvm::json::Path);
324324

325+
/// Information about a breakpoint created in `setBreakpoints`, `setFunctionBreakpoints`, `setInstructionBreakpoints`, or `setDataBreakpoints` requests.
326+
struct Breakpoint {
327+
/// A machine-readable explanation of why a breakpoint may not be verified.
328+
enum class Reason : unsigned {
329+
/// Indicates a breakpoint might be verified in the future, but
330+
/// the adapter cannot verify it in the current state.
331+
eBreakpointReasonPending,
332+
/// Indicates a breakpoint was not able to be verified, and the
333+
/// adapter does not believe it can be verified without intervention.
334+
eBreakpointReasonFailed,
335+
};
336+
337+
/// The identifier for the breakpoint. It is needed if breakpoint events are
338+
/// used to update or remove breakpoints.
339+
std::optional<int> id;
340+
341+
/// If true, the breakpoint could be set (but not necessarily at the desired
342+
/// location).
343+
bool verified;
344+
345+
/// A message about the state of the breakpoint.
346+
/// This is shown to the user and can be used to explain why a breakpoint could
347+
/// not be verified.
348+
std::optional<std::string> message;
349+
350+
/// The source where the breakpoint is located.
351+
std::optional<Source> source;
352+
353+
/// The start line of the actual range covered by the breakpoint.
354+
std::optional<uint32_t> line;
355+
356+
/// Start position of the source range covered by the breakpoint. It is
357+
/// measured in UTF-16 code units and the client capability `columnsStartAt1`
358+
/// determines whether it is 0- or 1-based.
359+
std::optional<uint32_t> column;
360+
361+
/// The end line of the actual range covered by the breakpoint.
362+
std::optional<uint32_t> endLine;
363+
364+
/// End position of the source range covered by the breakpoint. It is measured
365+
/// in UTF-16 code units and the client capability `columnsStartAt1` determines
366+
/// whether it is 0- or 1-based.
367+
/// If no end line is given, then the end column is assumed to be in the start
368+
/// line.
369+
std::optional<uint32_t> endColumn;
370+
371+
/// A memory reference to where the breakpoint is set.
372+
std::optional<std::string> instructionReference;
373+
374+
/// The offset from the instruction reference.
375+
/// This can be negative.
376+
std::optional<int64_t> offset;
377+
378+
/// A machine-readable explanation of why a breakpoint may not be verified. If
379+
/// a breakpoint is verified or a specific reason is not known, the adapter
380+
/// should omit this property.
381+
std::optional<Reason> reason;
382+
};
383+
llvm::json::Value toJSON(const Breakpoint &);
384+
385+
/// Properties of a breakpoint or logpoint passed to the `setBreakpoints` request
386+
struct SourceBreakpoint {
387+
/// The source line of the breakpoint or logpoint.
388+
uint32_t line;
389+
390+
/// Start position within source line of the breakpoint or logpoint. It is
391+
/// measured in UTF-16 code units and the client capability `columnsStartAt1`
392+
/// determines whether it is 0- or 1-based.
393+
std::optional<uint32_t> column;
394+
395+
/// The expression for conditional breakpoints.
396+
/// It is only honored by a debug adapter if the corresponding capability
397+
/// `supportsConditionalBreakpoints` is true.
398+
std::optional<std::string> condition;
399+
400+
/// The expression that controls how many hits of the breakpoint are ignored.
401+
/// The debug adapter is expected to interpret the expression as needed.
402+
/// The attribute is only honored by a debug adapter if the corresponding
403+
/// capability `supportsHitConditionalBreakpoints` is true.
404+
/// If both this property and `condition` are specified, `hitCondition` should
405+
/// be evaluated only if the `condition` is met, and the debug adapter should
406+
/// stop only if both conditions are met.
407+
std::optional<std::string> hitCondition;
408+
409+
/// If this attribute exists and is non-empty, the debug adapter must not
410+
/// 'break' (stop)
411+
/// but log the message instead. Expressions within `{}` are interpolated.
412+
/// The attribute is only honored by a debug adapter if the corresponding
413+
/// capability `supportsLogPoints` is true.
414+
/// If either `hitCondition` or `condition` is specified, then the message
415+
/// should only be logged if those conditions are met.
416+
std::optional<std::string> logMessage;
417+
418+
/// The mode of this breakpoint. If defined, this must be one of the
419+
/// `breakpointModes` the debug adapter advertised in its `Capabilities`.
420+
std::optional<std::string> mode;
421+
};
422+
bool fromJSON(const llvm::json::Value &, SourceBreakpoint &,
423+
llvm::json::Path);
424+
425+
/// Properties of a breakpoint passed to the `setFunctionBreakpoints` request.
426+
struct FunctionBreakpoint {
427+
/// The name of the function.
428+
std::string name;
429+
430+
/// An expression for conditional breakpoints.
431+
/// It is only honored by a debug adapter if the corresponding capability
432+
/// `supportsConditionalBreakpoints` is true.
433+
std::optional<std::string> condition;
434+
435+
/// An expression that controls how many hits of the breakpoint are ignored.
436+
/// The debug adapter is expected to interpret the expression as needed.
437+
/// The attribute is only honored by a debug adapter if the corresponding
438+
/// capability `supportsHitConditionalBreakpoints` is true.
439+
std::optional<std::string> hitCondition;
440+
};
441+
bool fromJSON(const llvm::json::Value &, FunctionBreakpoint &,
442+
llvm::json::Path);
443+
444+
/// This enumeration defines all possible access types for data breakpoints. Values: ‘read’, ‘write’, ‘readWrite’
445+
enum DataBreakpointAccessType : unsigned {
446+
eDataBreakpointAccessTypeRead,
447+
eDataBreakpointAccessTypeWrite,
448+
eDataBreakpointAccessTypeReadWrite
449+
};
450+
bool fromJSON(const llvm::json::Value &, DataBreakpointAccessType &,
451+
llvm::json::Path);
452+
453+
/// Properties of a data breakpoint passed to the `setDataBreakpoints` request.
454+
struct DataBreakpointInfo {
455+
/// An id representing the data. This id is returned from the
456+
/// `dataBreakpointInfo` request.
457+
std::string dataId;
458+
459+
/// The access type of the data.
460+
std::optional<DataBreakpointAccessType> accessType;
461+
462+
/// An expression for conditional breakpoints.
463+
std::optional<std::string> condition;
464+
465+
/// An expression that controls how many hits of the breakpoint are ignored.
466+
/// The debug adapter is expected to interpret the expression as needed.
467+
std::optional<std::string> hitCondition;
468+
};
469+
bool fromJSON(const llvm::json::Value &, DataBreakpointInfo &,
470+
llvm::json::Path);
471+
472+
/// Properties of a breakpoint passed to the `setInstructionBreakpoints` request
473+
struct InstructionBreakpoint {
474+
/// The instruction reference of the breakpoint.
475+
/// This should be a memory or instruction pointer reference from an
476+
/// `EvaluateResponse`, `Variable`, `StackFrame`, `GotoTarget`, or
477+
/// `Breakpoint`.
478+
std::string instructionReference;
479+
480+
/// The offset from the instruction reference in bytes.
481+
/// This can be negative.
482+
std::optional<int64_t> offset;
483+
484+
/// An expression for conditional breakpoints.
485+
/// It is only honored by a debug adapter if the corresponding capability
486+
/// `supportsConditionalBreakpoints` is true.
487+
std::optional<std::string> condition;
488+
489+
/// An expression that controls how many hits of the breakpoint are ignored.
490+
/// The debug adapter is expected to interpret the expression as needed.
491+
/// The attribute is only honored by a debug adapter if the corresponding
492+
/// capability `supportsHitConditionalBreakpoints` is true.
493+
std::optional<std::string> hitCondition;
494+
495+
/// The mode of this breakpoint. If defined, this must be one of the
496+
/// `breakpointModes` the debug adapter advertised in its `Capabilities`.
497+
std::optional<std::string> mode;
498+
};
499+
bool fromJSON(const llvm::json::Value &, InstructionBreakpoint &,
500+
llvm::json::Path);
501+
502+
325503
} // namespace lldb_dap::protocol
326504

327505
#endif

llvm/include/llvm/Support/JSON.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,14 @@ inline bool fromJSON(const Value &E, bool &Out, Path P) {
776776
P.report("expected boolean");
777777
return false;
778778
}
779+
inline bool fromJSON(const Value &E, unsigned int &Out, Path P) {
780+
if (auto S = E.getAsInteger()) {
781+
Out = *S;
782+
return true;
783+
}
784+
P.report("expected integer");
785+
return false;
786+
}
779787
inline bool fromJSON(const Value &E, uint64_t &Out, Path P) {
780788
if (auto S = E.getAsUINT64()) {
781789
Out = *S;

0 commit comments

Comments
 (0)