Bump version to 19.1.0 (final)
[llvm-project.git] / lldb / tools / lldb-dap / SourceBreakpoint.h
blobaa3fbe6d0f96d2ef6c30db97e387f739c6d9adca
1 //===-- SourceBreakpoint.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 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_TOOLS_LLDB_DAP_SOURCEBREAKPOINT_H
10 #define LLDB_TOOLS_LLDB_DAP_SOURCEBREAKPOINT_H
12 #include "Breakpoint.h"
13 #include "llvm/ADT/StringRef.h"
15 namespace lldb_dap {
17 struct SourceBreakpoint : public Breakpoint {
18 // logMessage part can be either a raw text or an expression.
19 struct LogMessagePart {
20 LogMessagePart(llvm::StringRef text, bool is_expr)
21 : text(text), is_expr(is_expr) {}
22 std::string text;
23 bool is_expr;
25 // If this attribute exists and is non-empty, the backend must not 'break'
26 // (stop) but log the message instead. Expressions within {} are
27 // interpolated.
28 std::string logMessage;
29 std::vector<LogMessagePart> logMessageParts;
31 uint32_t line; ///< The source line of the breakpoint or logpoint
32 uint32_t column; ///< An optional source column of the breakpoint
34 SourceBreakpoint() : Breakpoint(), line(0), column(0) {}
35 SourceBreakpoint(const llvm::json::Object &obj);
37 // Set this breakpoint in LLDB as a new breakpoint
38 void SetBreakpoint(const llvm::StringRef source_path);
39 void UpdateBreakpoint(const SourceBreakpoint &request_bp);
41 void SetLogMessage();
42 // Format \param text and return formatted text in \param formatted.
43 // \return any formatting failures.
44 lldb::SBError FormatLogText(llvm::StringRef text, std::string &formatted);
45 lldb::SBError AppendLogMessagePart(llvm::StringRef part, bool is_expr);
46 void NotifyLogMessageError(llvm::StringRef error);
48 static bool BreakpointHitCallback(void *baton, lldb::SBProcess &process,
49 lldb::SBThread &thread,
50 lldb::SBBreakpointLocation &location);
53 inline bool operator<(const SourceBreakpoint &lhs,
54 const SourceBreakpoint &rhs) {
55 if (lhs.line == rhs.line)
56 return lhs.column < rhs.column;
57 return lhs.line < rhs.line;
60 } // namespace lldb_dap
62 #endif