Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:44

0001 //===-- DebuggerEvents.h ----------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #include "lldb/Core/ModuleSpec.h"
0010 #include "lldb/Core/Progress.h"
0011 #include "lldb/Utility/Event.h"
0012 #include "lldb/Utility/StructuredData.h"
0013 
0014 #include <string>
0015 
0016 #ifndef LLDB_CORE_DEBUGGER_EVENTS_H
0017 #define LLDB_CORE_DEBUGGER_EVENTS_H
0018 
0019 namespace lldb_private {
0020 class Stream;
0021 
0022 class ProgressEventData : public EventData {
0023 public:
0024   ProgressEventData(uint64_t progress_id, std::string title,
0025                     std::string details, uint64_t completed, uint64_t total,
0026                     bool debugger_specific)
0027       : m_title(std::move(title)), m_details(std::move(details)),
0028         m_id(progress_id), m_completed(completed), m_total(total),
0029         m_debugger_specific(debugger_specific) {}
0030 
0031   static llvm::StringRef GetFlavorString();
0032 
0033   llvm::StringRef GetFlavor() const override;
0034 
0035   void Dump(Stream *s) const override;
0036 
0037   static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
0038 
0039   static StructuredData::DictionarySP
0040   GetAsStructuredData(const Event *event_ptr);
0041 
0042   uint64_t GetID() const { return m_id; }
0043   bool IsFinite() const { return m_total != Progress::kNonDeterministicTotal; }
0044   uint64_t GetCompleted() const { return m_completed; }
0045   uint64_t GetTotal() const { return m_total; }
0046   std::string GetMessage() const {
0047     std::string message = m_title;
0048     if (!m_details.empty()) {
0049       message.append(": ");
0050       message.append(m_details);
0051     }
0052     return message;
0053   }
0054   const std::string &GetTitle() const { return m_title; }
0055   const std::string &GetDetails() const { return m_details; }
0056   bool IsDebuggerSpecific() const { return m_debugger_specific; }
0057 
0058 private:
0059   /// The title of this progress event. The value is expected to remain stable
0060   /// for a given progress ID.
0061   std::string m_title;
0062 
0063   /// Details associated with this progress event update. The value is expected
0064   /// to change between progress events.
0065   std::string m_details;
0066 
0067   /// Unique ID used to associate progress events.
0068   const uint64_t m_id;
0069 
0070   uint64_t m_completed;
0071   const uint64_t m_total;
0072   const bool m_debugger_specific;
0073   ProgressEventData(const ProgressEventData &) = delete;
0074   const ProgressEventData &operator=(const ProgressEventData &) = delete;
0075 };
0076 
0077 class DiagnosticEventData : public EventData {
0078 public:
0079   DiagnosticEventData(lldb::Severity severity, std::string message,
0080                       bool debugger_specific)
0081       : m_message(std::move(message)), m_severity(severity),
0082         m_debugger_specific(debugger_specific) {}
0083   ~DiagnosticEventData() override = default;
0084 
0085   const std::string &GetMessage() const { return m_message; }
0086   bool IsDebuggerSpecific() const { return m_debugger_specific; }
0087   lldb::Severity GetSeverity() const { return m_severity; }
0088 
0089   llvm::StringRef GetPrefix() const;
0090 
0091   void Dump(Stream *s) const override;
0092 
0093   static llvm::StringRef GetFlavorString();
0094   llvm::StringRef GetFlavor() const override;
0095 
0096   static const DiagnosticEventData *
0097   GetEventDataFromEvent(const Event *event_ptr);
0098 
0099   static StructuredData::DictionarySP
0100   GetAsStructuredData(const Event *event_ptr);
0101 
0102 protected:
0103   std::string m_message;
0104   lldb::Severity m_severity;
0105   const bool m_debugger_specific;
0106 
0107   DiagnosticEventData(const DiagnosticEventData &) = delete;
0108   const DiagnosticEventData &operator=(const DiagnosticEventData &) = delete;
0109 };
0110 
0111 class SymbolChangeEventData : public EventData {
0112 public:
0113   SymbolChangeEventData(lldb::DebuggerWP debugger_wp, ModuleSpec module_spec)
0114       : m_debugger_wp(debugger_wp), m_module_spec(std::move(module_spec)) {}
0115 
0116   static llvm::StringRef GetFlavorString();
0117   llvm::StringRef GetFlavor() const override;
0118 
0119   static const SymbolChangeEventData *
0120   GetEventDataFromEvent(const Event *event_ptr);
0121 
0122   void DoOnRemoval(Event *event_ptr) override;
0123 
0124 private:
0125   lldb::DebuggerWP m_debugger_wp;
0126   ModuleSpec m_module_spec;
0127 
0128   SymbolChangeEventData(const SymbolChangeEventData &) = delete;
0129   const SymbolChangeEventData &
0130   operator=(const SymbolChangeEventData &) = delete;
0131 };
0132 
0133 } // namespace lldb_private
0134 
0135 #endif // LLDB_CORE_DEBUGGER_EVENTS_H