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/Utility/Event.h"
12
13#include <string>
14
15#ifndef LLDB_CORE_DEBUGGER_EVENTS_H
16#define LLDB_CORE_DEBUGGER_EVENTS_H
17
18namespace lldb_private {
19class Stream;
20
22public:
23 ProgressEventData(uint64_t progress_id, std::string title, std::string update,
24 uint64_t completed, uint64_t total, bool debugger_specific)
25 : m_title(std::move(title)), m_details(std::move(update)),
26 m_id(progress_id), m_completed(completed), m_total(total),
27 m_debugger_specific(debugger_specific) {}
28
29 static llvm::StringRef GetFlavorString();
30
31 llvm::StringRef GetFlavor() const override;
32
33 void Dump(Stream *s) const override;
34
35 static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
36
38 GetAsStructuredData(const Event *event_ptr);
39
40 uint64_t GetID() const { return m_id; }
41 bool IsFinite() const { return m_total != UINT64_MAX; }
42 uint64_t GetCompleted() const { return m_completed; }
43 uint64_t GetTotal() const { return m_total; }
44 std::string GetMessage() const {
45 std::string message = m_title;
46 if (!m_details.empty()) {
47 message.append(": ");
48 message.append(m_details);
49 }
50 return message;
51 }
52 const std::string &GetTitle() const { return m_title; }
53 const std::string &GetDetails() const { return m_details; }
54 bool IsDebuggerSpecific() const { return m_debugger_specific; }
55
56private:
57 /// The title of this progress event. The value is expected to remain stable
58 /// for a given progress ID.
59 std::string m_title;
60
61 /// Details associated with this progress event update. The value is expected
62 /// to change between progress events.
63 std::string m_details;
64
65 /// Unique ID used to associate progress events.
66 const uint64_t m_id;
67
68 uint64_t m_completed;
69 const uint64_t m_total;
73};
74
76public:
77 enum class Type {
78 Info,
79 Warning,
80 Error,
81 };
82 DiagnosticEventData(Type type, std::string message, bool debugger_specific)
83 : m_message(std::move(message)), m_type(type),
84 m_debugger_specific(debugger_specific) {}
85 ~DiagnosticEventData() override = default;
86
87 const std::string &GetMessage() const { return m_message; }
88 bool IsDebuggerSpecific() const { return m_debugger_specific; }
89 Type GetType() const { return m_type; }
90
91 llvm::StringRef GetPrefix() const;
92
93 void Dump(Stream *s) const override;
94
95 static llvm::StringRef GetFlavorString();
96 llvm::StringRef GetFlavor() const override;
97
98 static const DiagnosticEventData *
99 GetEventDataFromEvent(const Event *event_ptr);
100
102 GetAsStructuredData(const Event *event_ptr);
103
104protected:
105 std::string m_message;
108
111};
112
114public:
116 : m_debugger_wp(debugger_wp), m_module_spec(std::move(module_spec)) {}
117
118 static llvm::StringRef GetFlavorString();
119 llvm::StringRef GetFlavor() const override;
120
121 static const SymbolChangeEventData *
122 GetEventDataFromEvent(const Event *event_ptr);
123
124 void DoOnRemoval(Event *event_ptr) override;
125
126private:
129
133};
134
135} // namespace lldb_private
136
137#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
llvm::StringRef GetFlavor() const override
ProgressEventData(uint64_t progress_id, std::string title, std::string update, uint64_t completed, uint64_t total, bool debugger_specific)
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
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
#define UINT64_MAX
Definition: lldb-defines.h:23
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:322