blob: af775250cb9f569a90a27317cef9e9e565bdb4b1 [file] [log] [blame]
Greg Clayton2f5cf852018-08-16 17:59:38 +00001//===-- BreakpointBase.cpp --------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Greg Clayton2f5cf852018-08-16 17:59:38 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "BreakpointBase.h"
10#include "llvm/ADT/StringExtras.h"
11
12using namespace lldb_vscode;
13
14BreakpointBase::BreakpointBase(const llvm::json::Object &obj)
15 : condition(GetString(obj, "condition")),
16 hitCondition(GetString(obj, "hitCondition")),
17 logMessage(GetString(obj, "logMessage")) {}
18
19void BreakpointBase::SetCondition() { bp.SetCondition(condition.c_str()); }
20
21void BreakpointBase::SetHitCondition() {
22 uint64_t hitCount = 0;
23 if (llvm::to_integer(hitCondition, hitCount))
24 bp.SetIgnoreCount(hitCount - 1);
25}
26
27void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) {
28 if (condition != request_bp.condition) {
29 condition = request_bp.condition;
30 SetCondition();
31 }
32 if (hitCondition != request_bp.hitCondition) {
33 hitCondition = request_bp.hitCondition;
34 SetHitCondition();
35 }
36}