Greg Clayton | 2f5cf85 | 2018-08-16 17:59:38 +0000 | [diff] [blame] | 1 | //===-- BreakpointBase.cpp --------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Greg Clayton | 2f5cf85 | 2018-08-16 17:59:38 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "BreakpointBase.h" |
| 10 | #include "llvm/ADT/StringExtras.h" |
| 11 | |
| 12 | using namespace lldb_vscode; |
| 13 | |
| 14 | BreakpointBase::BreakpointBase(const llvm::json::Object &obj) |
| 15 | : condition(GetString(obj, "condition")), |
| 16 | hitCondition(GetString(obj, "hitCondition")), |
| 17 | logMessage(GetString(obj, "logMessage")) {} |
| 18 | |
| 19 | void BreakpointBase::SetCondition() { bp.SetCondition(condition.c_str()); } |
| 20 | |
| 21 | void BreakpointBase::SetHitCondition() { |
| 22 | uint64_t hitCount = 0; |
| 23 | if (llvm::to_integer(hitCondition, hitCount)) |
| 24 | bp.SetIgnoreCount(hitCount - 1); |
| 25 | } |
| 26 | |
| 27 | void 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 | } |