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 DiagnosticEventData(lldb::Severity severity, std::string message,
80 bool debugger_specific)
81 : m_message(std::move(message)), m_severity(severity),
82 m_debugger_specific(debugger_specific) {}
83 ~DiagnosticEventData() override = default;
84
85 const std::string &GetMessage() const { return m_message; }
86 bool IsDebuggerSpecific() const { return m_debugger_specific; }
88
89 llvm::StringRef GetPrefix() const;
90
91 void Dump(Stream *s) const override;
92
93 static llvm::StringRef GetFlavorString();
94 llvm::StringRef GetFlavor() const override;
95
96 static const DiagnosticEventData *
97 GetEventDataFromEvent(const Event *event_ptr);
98
100 GetAsStructuredData(const Event *event_ptr);
101
102protected:
103 std::string m_message;
106
109};
110
112public:
114 : m_debugger_wp(debugger_wp), m_module_spec(std::move(module_spec)) {}
115
116 static llvm::StringRef GetFlavorString();
117 llvm::StringRef GetFlavor() const override;
118
119 static const SymbolChangeEventData *
120 GetEventDataFromEvent(const Event *event_ptr);
121
122 void DoOnRemoval(Event *event_ptr) override;
123
124private:
127
131};
132
133} // namespace lldb_private
134
135#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
lldb::Severity GetSeverity() const
DiagnosticEventData(lldb::Severity severity, 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.
Severity
Used for expressing severity in logs and diagnostics.
std::weak_ptr< lldb_private::Debugger > DebuggerWP
Definition: lldb-forward.h:338