[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / tools / lldb-dap / SourceBreakpoint.h
blob064bd29d9fc7966e4219d576815ee8260882a58a
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 "DAPForward.h"
14 #include "lldb/API/SBError.h"
15 #include "llvm/ADT/StringRef.h"
16 #include <cstdint>
17 #include <string>
18 #include <vector>
20 namespace lldb_dap {
22 struct SourceBreakpoint : public Breakpoint {
23 // logMessage part can be either a raw text or an expression.
24 struct LogMessagePart {
25 LogMessagePart(llvm::StringRef text, bool is_expr)
26 : text(text), is_expr(is_expr) {}
27 std::string text;
28 bool is_expr;
30 // If this attribute exists and is non-empty, the backend must not 'break'
31 // (stop) but log the message instead. Expressions within {} are
32 // interpolated.
33 std::string logMessage;
34 std::vector<LogMessagePart> logMessageParts;
36 uint32_t line; ///< The source line of the breakpoint or logpoint
37 uint32_t column; ///< An optional source column of the breakpoint
39 SourceBreakpoint(DAP &d, const llvm::json::Object &obj);
41 // Set this breakpoint in LLDB as a new breakpoint
42 void SetBreakpoint(const llvm::StringRef source_path);
43 void UpdateBreakpoint(const SourceBreakpoint &request_bp);
45 void SetLogMessage();
46 // Format \param text and return formatted text in \param formatted.
47 // \return any formatting failures.
48 lldb::SBError FormatLogText(llvm::StringRef text, std::string &formatted);
49 lldb::SBError AppendLogMessagePart(llvm::StringRef part, bool is_expr);
50 void NotifyLogMessageError(llvm::StringRef error);
52 static bool BreakpointHitCallback(void *baton, lldb::SBProcess &process,
53 lldb::SBThread &thread,
54 lldb::SBBreakpointLocation &location);
57 inline bool operator<(const SourceBreakpoint &lhs,
58 const SourceBreakpoint &rhs) {
59 if (lhs.line == rhs.line)
60 return lhs.column < rhs.column;
61 return lhs.line < rhs.line;
64 } // namespace lldb_dap
66 #endif