49 lines · cpp
1//===-- ExceptionBreakpoint.cpp ---------------------------------*- 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#include "ExceptionBreakpoint.h"10#include "BreakpointBase.h"11#include "DAP.h"12#include "Protocol/ProtocolTypes.h"13#include "lldb/API/SBMutex.h"14#include "lldb/API/SBTarget.h"15#include <mutex>16 17using namespace llvm;18using namespace lldb_dap::protocol;19 20namespace lldb_dap {21 22protocol::Breakpoint ExceptionBreakpoint::SetBreakpoint(StringRef condition) {23 lldb::SBMutex lock = m_dap.GetAPIMutex();24 std::lock_guard<lldb::SBMutex> guard(lock);25 26 if (!m_bp.IsValid()) {27 m_bp = m_dap.target.BreakpointCreateForException(28 m_language, m_kind == eExceptionKindCatch,29 m_kind == eExceptionKindThrow);30 m_bp.AddName(BreakpointBase::kDAPBreakpointLabel);31 }32 33 m_bp.SetCondition(condition.data());34 35 protocol::Breakpoint breakpoint;36 breakpoint.id = m_bp.GetID();37 breakpoint.verified = m_bp.IsValid();38 return breakpoint;39}40 41void ExceptionBreakpoint::ClearBreakpoint() {42 if (!m_bp.IsValid())43 return;44 m_dap.target.BreakpointDelete(m_bp.GetID());45 m_bp = lldb::SBBreakpoint();46}47 48} // namespace lldb_dap49