62 lines · c
1//===-- BreakpointBase.h ----------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H10#define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H11 12#include "DAPForward.h"13#include "Protocol/ProtocolTypes.h"14#include <optional>15#include <string>16 17namespace lldb_dap {18 19class BreakpointBase {20public:21 explicit BreakpointBase(DAP &d) : m_dap(d) {}22 BreakpointBase(DAP &d, const std::optional<std::string> &condition,23 const std::optional<std::string> &hit_condition);24 virtual ~BreakpointBase() = default;25 26 virtual void SetCondition() = 0;27 virtual void SetHitCondition() = 0;28 virtual protocol::Breakpoint ToProtocolBreakpoint() = 0;29 30 void UpdateBreakpoint(const BreakpointBase &request_bp);31 32 /// Breakpoints in LLDB can have names added to them which are kind of like33 /// labels or categories. All breakpoints that are set through DAP get sent34 /// through the various DAP set*Breakpoint packets, and these breakpoints will35 /// be labeled with this name so if breakpoint update events come in for36 /// breakpoints that the client doesn't know about, like if a breakpoint is37 /// set manually using the debugger console, we won't report any updates on38 /// them and confused the client. This label gets added by all of the39 /// breakpoint classes after they set breakpoints to mark a breakpoint as a40 /// DAP breakpoint. We can later check a lldb::SBBreakpoint object that comes41 /// in via LLDB breakpoint changed events and check the breakpoint by calling42 /// "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a43 /// breakpoint in one of the DAP breakpoints that we should report changes44 /// for.45 static constexpr const char *kDAPBreakpointLabel = "dap";46 47protected:48 /// Associated DAP session.49 DAP &m_dap;50 51 /// An optional expression for conditional breakpoints.52 std::string m_condition;53 54 /// An optional expression that controls how many hits of the breakpoint are55 /// ignored. The backend is expected to interpret the expression as needed56 std::string m_hit_condition;57};58 59} // namespace lldb_dap60 61#endif62