xref: /llvm-project/lldb/tools/lldb-dap/ExceptionBreakpoint.cpp (revision b99d4112585302cbd01f9b851a04adc6e4fb5218)
101263c6cSJonas Devlieghere //===-- ExceptionBreakpoint.cpp ---------------------------------*- C++ -*-===//
201263c6cSJonas Devlieghere //
301263c6cSJonas Devlieghere // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
401263c6cSJonas Devlieghere // See https://llvm.org/LICENSE.txt for license information.
501263c6cSJonas Devlieghere // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
601263c6cSJonas Devlieghere //
701263c6cSJonas Devlieghere //===----------------------------------------------------------------------===//
801263c6cSJonas Devlieghere 
901263c6cSJonas Devlieghere #include "ExceptionBreakpoint.h"
1001263c6cSJonas Devlieghere #include "BreakpointBase.h"
1101263c6cSJonas Devlieghere #include "DAP.h"
12*b99d4112SJohn Harrison #include "lldb/API/SBTarget.h"
1301263c6cSJonas Devlieghere 
1401263c6cSJonas Devlieghere namespace lldb_dap {
1501263c6cSJonas Devlieghere 
1601263c6cSJonas Devlieghere void ExceptionBreakpoint::SetBreakpoint() {
1701263c6cSJonas Devlieghere   if (bp.IsValid())
1801263c6cSJonas Devlieghere     return;
1901263c6cSJonas Devlieghere   bool catch_value = filter.find("_catch") != std::string::npos;
2001263c6cSJonas Devlieghere   bool throw_value = filter.find("_throw") != std::string::npos;
21*b99d4112SJohn Harrison   bp = dap.target.BreakpointCreateForException(language, catch_value,
2201263c6cSJonas Devlieghere                                                throw_value);
2301263c6cSJonas Devlieghere   // See comments in BreakpointBase::GetBreakpointLabel() for details of why
2401263c6cSJonas Devlieghere   // we add a label to our breakpoints.
2501263c6cSJonas Devlieghere   bp.AddName(BreakpointBase::GetBreakpointLabel());
2601263c6cSJonas Devlieghere }
2701263c6cSJonas Devlieghere 
2801263c6cSJonas Devlieghere void ExceptionBreakpoint::ClearBreakpoint() {
2901263c6cSJonas Devlieghere   if (!bp.IsValid())
3001263c6cSJonas Devlieghere     return;
31*b99d4112SJohn Harrison   dap.target.BreakpointDelete(bp.GetID());
3201263c6cSJonas Devlieghere   bp = lldb::SBBreakpoint();
3301263c6cSJonas Devlieghere }
3401263c6cSJonas Devlieghere 
3501263c6cSJonas Devlieghere } // namespace lldb_dap
36