Coverage Report

Created: 2023-10-14 09:29

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/tools/lldb-vscode/BreakpointBase.h
Line
Count
Source (jump to first uncovered line)
1
//===-- BreakpointBase.h ----------------------------------------*- 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
#ifndef LLDB_TOOLS_LLDB_VSCODE_BREAKPOINTBASE_H
10
#define LLDB_TOOLS_LLDB_VSCODE_BREAKPOINTBASE_H
11
12
#include "JSONUtils.h"
13
#include "lldb/API/SBBreakpoint.h"
14
#include "llvm/Support/JSON.h"
15
#include <string>
16
#include <vector>
17
18
namespace lldb_vscode {
19
20
struct BreakpointBase {
21
  // logMessage part can be either a raw text or an expression.
22
  struct LogMessagePart {
23
    LogMessagePart(llvm::StringRef text, bool is_expr)
24
0
        : text(text), is_expr(is_expr) {}
25
    std::string text;
26
    bool is_expr;
27
  };
28
  // An optional expression for conditional breakpoints.
29
  std::string condition;
30
  // An optional expression that controls how many hits of the breakpoint are
31
  // ignored. The backend is expected to interpret the expression as needed
32
  std::string hitCondition;
33
  // If this attribute exists and is non-empty, the backend must not 'break'
34
  // (stop) but log the message instead. Expressions within {} are
35
  // interpolated.
36
  std::string logMessage;
37
  std::vector<LogMessagePart> logMessageParts;
38
  // The LLDB breakpoint associated wit this source breakpoint
39
  lldb::SBBreakpoint bp;
40
41
2
  BreakpointBase() = default;
42
  BreakpointBase(const llvm::json::Object &obj);
43
44
  void SetCondition();
45
  void SetHitCondition();
46
  void SetLogMessage();
47
  void UpdateBreakpoint(const BreakpointBase &request_bp);
48
49
  // Format \param text and return formatted text in \param formatted.
50
  // \return any formatting failures.
51
  lldb::SBError FormatLogText(llvm::StringRef text, std::string &formatted);
52
  lldb::SBError AppendLogMessagePart(llvm::StringRef part, bool is_expr);
53
  void NotifyLogMessageError(llvm::StringRef error);
54
55
  static const char *GetBreakpointLabel();
56
  static bool BreakpointHitCallback(void *baton, lldb::SBProcess &process,
57
                                    lldb::SBThread &thread,
58
                                    lldb::SBBreakpointLocation &location);
59
};
60
61
} // namespace lldb_vscode
62
63
#endif