12f5cf851SGreg Clayton //===-- FunctionBreakpoint.cpp ----------------------------------*- C++ -*-===//
22f5cf851SGreg Clayton //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
62f5cf851SGreg Clayton //
72f5cf851SGreg Clayton //===----------------------------------------------------------------------===//
82f5cf851SGreg Clayton 
92f5cf851SGreg Clayton #include "FunctionBreakpoint.h"
102f5cf851SGreg Clayton #include "VSCode.h"
112f5cf851SGreg Clayton 
122f5cf851SGreg Clayton namespace lldb_vscode {
132f5cf851SGreg Clayton 
FunctionBreakpoint(const llvm::json::Object & obj)142f5cf851SGreg Clayton FunctionBreakpoint::FunctionBreakpoint(const llvm::json::Object &obj)
15adcd0268SBenjamin Kramer     : BreakpointBase(obj), functionName(std::string(GetString(obj, "name"))) {}
162f5cf851SGreg Clayton 
SetBreakpoint()172f5cf851SGreg Clayton void FunctionBreakpoint::SetBreakpoint() {
182f5cf851SGreg Clayton   if (functionName.empty())
192f5cf851SGreg Clayton     return;
202f5cf851SGreg Clayton   bp = g_vsc.target.BreakpointCreateByName(functionName.c_str());
219cb227f5SGreg Clayton   // See comments in BreakpointBase::GetBreakpointLabel() for details of why
229cb227f5SGreg Clayton   // we add a label to our breakpoints.
239cb227f5SGreg Clayton   bp.AddName(GetBreakpointLabel());
242f5cf851SGreg Clayton   if (!condition.empty())
252f5cf851SGreg Clayton     SetCondition();
262f5cf851SGreg Clayton   if (!hitCondition.empty())
272f5cf851SGreg Clayton     SetHitCondition();
28*8c6e138aSJeffrey Tan   if (!logMessage.empty())
29*8c6e138aSJeffrey Tan     SetLogMessage();
302f5cf851SGreg Clayton }
312f5cf851SGreg Clayton 
3299614d41SWalter Erquinigo } // namespace lldb_vscode
33