Stephen Hines | c6ca60f | 2023-05-09 02:19:22 -0700 | [diff] [blame^] | 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 | |
| 9 | #include "lldb/Core/ModuleSpec.h" |
| 10 | #include "lldb/Utility/ConstString.h" |
| 11 | #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 | |
| 18 | namespace lldb_private { |
| 19 | class Stream; |
| 20 | |
| 21 | class ProgressEventData : public EventData { |
| 22 | public: |
| 23 | ProgressEventData(uint64_t progress_id, const std::string &message, |
| 24 | uint64_t completed, uint64_t total, bool debugger_specific) |
| 25 | : m_message(message), m_id(progress_id), m_completed(completed), |
| 26 | m_total(total), m_debugger_specific(debugger_specific) {} |
| 27 | |
| 28 | static ConstString GetFlavorString(); |
| 29 | |
| 30 | ConstString GetFlavor() const override; |
| 31 | |
| 32 | void Dump(Stream *s) const override; |
| 33 | |
| 34 | static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr); |
| 35 | uint64_t GetID() const { return m_id; } |
| 36 | bool IsFinite() const { return m_total != UINT64_MAX; } |
| 37 | uint64_t GetCompleted() const { return m_completed; } |
| 38 | uint64_t GetTotal() const { return m_total; } |
| 39 | const std::string &GetMessage() const { return m_message; } |
| 40 | bool IsDebuggerSpecific() const { return m_debugger_specific; } |
| 41 | |
| 42 | private: |
| 43 | std::string m_message; |
| 44 | const uint64_t m_id; |
| 45 | uint64_t m_completed; |
| 46 | const uint64_t m_total; |
| 47 | const bool m_debugger_specific; |
| 48 | ProgressEventData(const ProgressEventData &) = delete; |
| 49 | const ProgressEventData &operator=(const ProgressEventData &) = delete; |
| 50 | }; |
| 51 | |
| 52 | class DiagnosticEventData : public EventData { |
| 53 | public: |
| 54 | enum class Type { |
| 55 | Info, |
| 56 | Warning, |
| 57 | Error, |
| 58 | }; |
| 59 | DiagnosticEventData(Type type, std::string message, bool debugger_specific) |
| 60 | : m_message(std::move(message)), m_type(type), |
| 61 | m_debugger_specific(debugger_specific) {} |
| 62 | ~DiagnosticEventData() override = default; |
| 63 | |
| 64 | const std::string &GetMessage() const { return m_message; } |
| 65 | bool IsDebuggerSpecific() const { return m_debugger_specific; } |
| 66 | Type GetType() const { return m_type; } |
| 67 | |
| 68 | llvm::StringRef GetPrefix() const; |
| 69 | |
| 70 | void Dump(Stream *s) const override; |
| 71 | |
| 72 | static ConstString GetFlavorString(); |
| 73 | ConstString GetFlavor() const override; |
| 74 | |
| 75 | static const DiagnosticEventData * |
| 76 | GetEventDataFromEvent(const Event *event_ptr); |
| 77 | |
| 78 | protected: |
| 79 | std::string m_message; |
| 80 | Type m_type; |
| 81 | const bool m_debugger_specific; |
| 82 | |
| 83 | DiagnosticEventData(const DiagnosticEventData &) = delete; |
| 84 | const DiagnosticEventData &operator=(const DiagnosticEventData &) = delete; |
| 85 | }; |
| 86 | |
| 87 | class SymbolChangeEventData : public EventData { |
| 88 | public: |
| 89 | SymbolChangeEventData(lldb::DebuggerWP debugger_wp, ModuleSpec module_spec) |
| 90 | : m_debugger_wp(debugger_wp), m_module_spec(std::move(module_spec)) {} |
| 91 | |
| 92 | static ConstString GetFlavorString(); |
| 93 | ConstString GetFlavor() const override; |
| 94 | |
| 95 | static const SymbolChangeEventData * |
| 96 | GetEventDataFromEvent(const Event *event_ptr); |
| 97 | |
| 98 | void DoOnRemoval(Event *event_ptr) override; |
| 99 | |
| 100 | private: |
| 101 | lldb::DebuggerWP m_debugger_wp; |
| 102 | ModuleSpec m_module_spec; |
| 103 | |
| 104 | SymbolChangeEventData(const SymbolChangeEventData &) = delete; |
| 105 | const SymbolChangeEventData & |
| 106 | operator=(const SymbolChangeEventData &) = delete; |
| 107 | }; |
| 108 | |
| 109 | } // namespace lldb_private |
| 110 | |
| 111 | #endif // LLDB_CORE_DEBUGGER_EVENTS_H |