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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "ExceptionBreakpoint.h"
10#include "BreakpointBase.h"
11#include "DAP.h"
12#include "lldb/API/SBMutex.h"
13#include "lldb/API/SBTarget.h"
14#include <mutex>
15
16namespace lldb_dap {
17
18void ExceptionBreakpoint::SetBreakpoint() {
19 lldb::SBMutex lock = m_dap.GetAPIMutex();
20 std::lock_guard<lldb::SBMutex> guard(lock);
21
22 if (m_bp.IsValid())
23 return;
24 bool catch_value = m_filter.find(s: "_catch") != std::string::npos;
25 bool throw_value = m_filter.find(s: "_throw") != std::string::npos;
26 m_bp = m_dap.target.BreakpointCreateForException(language: m_language, catch_bp: catch_value,
27 throw_bp: throw_value);
28 m_bp.AddName(new_name: BreakpointBase::kDAPBreakpointLabel);
29}
30
31void ExceptionBreakpoint::ClearBreakpoint() {
32 if (!m_bp.IsValid())
33 return;
34 m_dap.target.BreakpointDelete(break_id: m_bp.GetID());
35 m_bp = lldb::SBBreakpoint();
36}
37
38} // namespace lldb_dap
39

source code of lldb/tools/lldb-dap/ExceptionBreakpoint.cpp