LLDB mainline
DebuggerEvents.h
Go to the documentation of this file.
1//===-- DebuggerEvents.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
10#include "lldb/Core/Progress.h"
11#include "lldb/Utility/Event.h"
13
14#include <string>
15
16#ifndef LLDB_CORE_DEBUGGER_EVENTS_H
17#define LLDB_CORE_DEBUGGER_EVENTS_H
18
19namespace lldb_private {
20class Stream;
21
23public:
24 ProgressEventData(uint64_t progress_id, std::string title,
25 std::string details, uint64_t completed, uint64_t total,
26 bool debugger_specific)
27 : m_title(std::move(title)), m_details(std::move(details)),
28 m_id(progress_id), m_completed(completed), m_total(total),
29 m_debugger_specific(debugger_specific) {}
30
31 static llvm::StringRef GetFlavorString();
32
33 llvm::StringRef GetFlavor() const override;
34
35 void Dump(Stream *s) const override;
36
37 static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
38
40 GetAsStructuredData(const Event *event_ptr);
41
42 uint64_t GetID() const { return m_id; }
44 uint64_t GetCompleted() const { return m_completed; }
45 uint64_t GetTotal() const { return m_total; }
46 std::string GetMessage() const {
47 std::string message = m_title;
48 if (!m_details.empty()) {
49 message.append(": ");
50 message.append(m_details);
51 }
52 return message;
53 }
54 const std::string &GetTitle() const { return m_title; }
55 const std::string &GetDetails() const { return m_details; }
56 bool IsDebuggerSpecific() const { return m_debugger_specific; }
57
58private:
59 /// The title of this progress event. The value is expected to remain stable
60 /// for a given progress ID.
61 std::string m_title;
62
63 /// Details associated with this progress event update. The value is expected
64 /// to change between progress events.
65 std::string m_details;
66
67 /// Unique ID used to associate progress events.
68 const uint64_t m_id;
69
70 uint64_t m_completed;
71 const uint64_t m_total;
75};
76
78public:
79 enum class Type {
80 Info,
81 Warning,
82 Error,
83 };
84 DiagnosticEventData(Type type, std::string message, bool debugger_specific)
85 : m_message(std::move(message)), m_type(type),
86 m_debugger_specific(debugger_specific) {}
87 ~DiagnosticEventData() override = default;
88
89 const std::string &GetMessage() const { return m_message; }
90 bool IsDebuggerSpecific() const { return m_debugger_specific; }
91 Type GetType() const { return m_type; }
92
93 llvm::StringRef GetPrefix() const;
94
95 void Dump(Stream *s) const override;
96
97 static llvm::StringRef GetFlavorString();
98 llvm::StringRef GetFlavor() const override;
99
100 static const DiagnosticEventData *
101 GetEventDataFromEvent(const Event *event_ptr);
102
104 GetAsStructuredData(const Event *event_ptr);
105
106protected:
107 std::string m_message;
110
113};
114
116public:
118 : m_debugger_wp(debugger_wp), m_module_spec(std::move(module_spec)) {}
119
120 static llvm::StringRef GetFlavorString();
121 llvm::StringRef GetFlavor() const override;
122
123 static const SymbolChangeEventData *
124 GetEventDataFromEvent(const Event *event_ptr);
125
126 void DoOnRemoval(Event *event_ptr) override;
127
128private:
131
135};
136
137} // namespace lldb_private
138
139#endif // LLDB_CORE_DEBUGGER_EVENTS_H
void Dump(Stream *s) const override
DiagnosticEventData(const DiagnosticEventData &)=delete
const DiagnosticEventData & operator=(const DiagnosticEventData &)=delete
static llvm::StringRef GetFlavorString()
const std::string & GetMessage() const
llvm::StringRef GetPrefix() const
~DiagnosticEventData() override=default
DiagnosticEventData(Type type, std::string message, bool debugger_specific)
static StructuredData::DictionarySP GetAsStructuredData(const Event *event_ptr)
static const DiagnosticEventData * GetEventDataFromEvent(const Event *event_ptr)
llvm::StringRef GetFlavor() const override
void Dump(Stream *s) const override
ProgressEventData(uint64_t progress_id, std::string title, std::string details, uint64_t completed, uint64_t total, bool debugger_specific)
llvm::StringRef GetFlavor() const override
static const ProgressEventData * GetEventDataFromEvent(const Event *event_ptr)
const ProgressEventData & operator=(const ProgressEventData &)=delete
static StructuredData::DictionarySP GetAsStructuredData(const Event *event_ptr)
std::string m_details
Details associated with this progress event update.
static llvm::StringRef GetFlavorString()
const uint64_t m_id
Unique ID used to associate progress events.
const std::string & GetTitle() const
ProgressEventData(const ProgressEventData &)=delete
std::string m_title
The title of this progress event.
std::string GetMessage() const
const std::string & GetDetails() const
static constexpr uint64_t kNonDeterministicTotal
Used to indicate a non-deterministic progress report.
Definition: Progress.h:107
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
std::shared_ptr< Dictionary > DictionarySP
static const SymbolChangeEventData * GetEventDataFromEvent(const Event *event_ptr)
const SymbolChangeEventData & operator=(const SymbolChangeEventData &)=delete
llvm::StringRef GetFlavor() const override
SymbolChangeEventData(const SymbolChangeEventData &)=delete
static llvm::StringRef GetFlavorString()
SymbolChangeEventData(lldb::DebuggerWP debugger_wp, ModuleSpec module_spec)
void DoOnRemoval(Event *event_ptr) override
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::weak_ptr< lldb_private::Debugger > DebuggerWP
Definition: lldb-forward.h:332