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"
11 
12 #include <string>
13 
14 #ifndef LLDB_CORE_DEBUGGER_EVENTS_H
15 #define LLDB_CORE_DEBUGGER_EVENTS_H
16 
17 namespace lldb_private {
18 class Stream;
19 
20 class ProgressEventData : public EventData {
21 public:
22  ProgressEventData(uint64_t progress_id, const std::string &message,
23  uint64_t completed, uint64_t total, bool debugger_specific)
24  : m_message(message), m_id(progress_id), m_completed(completed),
25  m_total(total), m_debugger_specific(debugger_specific) {}
26 
28 
29  ConstString GetFlavor() const override;
30 
31  void Dump(Stream *s) const override;
32 
33  static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
34  uint64_t GetID() const { return m_id; }
35  bool IsFinite() const { return m_total != UINT64_MAX; }
36  uint64_t GetCompleted() const { return m_completed; }
37  uint64_t GetTotal() const { return m_total; }
38  const std::string &GetMessage() const { return m_message; }
39  bool IsDebuggerSpecific() const { return m_debugger_specific; }
40 
41 private:
43  const uint64_t m_id;
44  uint64_t m_completed;
45  const uint64_t m_total;
46  const bool m_debugger_specific;
47  ProgressEventData(const ProgressEventData &) = delete;
48  const ProgressEventData &operator=(const ProgressEventData &) = delete;
49 };
50 
52 public:
53  enum class Type {
54  Warning,
55  Error,
56  };
57  DiagnosticEventData(Type type, std::string message, bool debugger_specific)
58  : m_message(std::move(message)), m_type(type),
59  m_debugger_specific(debugger_specific) {}
60  ~DiagnosticEventData() override = default;
61 
62  const std::string &GetMessage() const { return m_message; }
63  bool IsDebuggerSpecific() const { return m_debugger_specific; }
64  Type GetType() const { return m_type; }
65 
66  llvm::StringRef GetPrefix() const;
67 
68  void Dump(Stream *s) const override;
69 
71  ConstString GetFlavor() const override;
72 
73  static const DiagnosticEventData *
74  GetEventDataFromEvent(const Event *event_ptr);
75 
76 protected:
79  const bool m_debugger_specific;
80 
81  DiagnosticEventData(const DiagnosticEventData &) = delete;
82  const DiagnosticEventData &operator=(const DiagnosticEventData &) = delete;
83 };
84 
85 } // namespace lldb_private
86 
87 #endif // LLDB_CORE_DEBUGGER_EVENTS_H
lldb_private::DiagnosticEventData::Type::Warning
@ Warning
lldb_private::Event
Definition: Event.h:182
lldb_private::DiagnosticEventData::IsDebuggerSpecific
bool IsDebuggerSpecific() const
Definition: DebuggerEvents.h:63
lldb_private::ProgressEventData::operator=
const ProgressEventData & operator=(const ProgressEventData &)=delete
lldb_private::DiagnosticEventData::GetType
Type GetType() const
Definition: DebuggerEvents.h:64
lldb_private::EventData
Definition: Event.h:36
lldb_private::DiagnosticEventData::operator=
const DiagnosticEventData & operator=(const DiagnosticEventData &)=delete
lldb_private::DiagnosticEventData::Dump
void Dump(Stream *s) const override
Definition: DebuggerEvents.cpp:59
lldb_private::ProgressEventData::GetFlavor
ConstString GetFlavor() const override
Definition: DebuggerEvents.cpp:28
lldb_private::ProgressEventData::Dump
void Dump(Stream *s) const override
Definition: DebuggerEvents.cpp:32
lldb_private::DiagnosticEventData::GetEventDataFromEvent
static const DiagnosticEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: DebuggerEvents.cpp:79
lldb_private::Stream
Definition: Stream.h:28
lldb_private::ProgressEventData::ProgressEventData
ProgressEventData(uint64_t progress_id, const std::string &message, uint64_t completed, uint64_t total, bool debugger_specific)
Definition: DebuggerEvents.h:22
lldb_private::DiagnosticEventData::m_type
Type m_type
Definition: DebuggerEvents.h:78
lldb_private::DiagnosticEventData::m_message
std::string m_message
Definition: DebuggerEvents.h:77
lldb_private::DiagnosticEventData::GetPrefix
llvm::StringRef GetPrefix() const
Definition: DebuggerEvents.cpp:49
lldb_private::DiagnosticEventData::Type
Type
Definition: DebuggerEvents.h:53
lldb_private::DiagnosticEventData::~DiagnosticEventData
~DiagnosticEventData() override=default
lldb_private::ProgressEventData::GetID
uint64_t GetID() const
Definition: DebuggerEvents.h:34
lldb_private::ProgressEventData
Definition: DebuggerEvents.h:20
lldb_private::ProgressEventData::GetEventDataFromEvent
static const ProgressEventData * GetEventDataFromEvent(const Event *event_ptr)
Definition: DebuggerEvents.cpp:45
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ProgressEventData::GetFlavorString
static ConstString GetFlavorString()
Definition: DebuggerEvents.cpp:23
lldb_private::DiagnosticEventData::GetFlavor
ConstString GetFlavor() const override
Definition: DebuggerEvents.cpp:74
lldb_private::DiagnosticEventData::Type::Error
@ Error
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ProgressEventData::IsDebuggerSpecific
bool IsDebuggerSpecific() const
Definition: DebuggerEvents.h:39
lldb_private::ProgressEventData::m_total
const uint64_t m_total
Definition: DebuggerEvents.h:45
Event.h
lldb_private::DiagnosticEventData
Definition: DebuggerEvents.h:51
lldb_private::ProgressEventData::m_id
const uint64_t m_id
Definition: DebuggerEvents.h:43
lldb_private::ProgressEventData::m_debugger_specific
const bool m_debugger_specific
Definition: DebuggerEvents.h:46
lldb_private::ProgressEventData::IsFinite
bool IsFinite() const
Definition: DebuggerEvents.h:35
message
message(FATAL_ERROR "invalid libipt include path provided") endif() include_directories($
Definition: Plugins/Trace/intel-pt/CMakeLists.txt:6
lldb_private::DiagnosticEventData::DiagnosticEventData
DiagnosticEventData(Type type, std::string message, bool debugger_specific)
Definition: DebuggerEvents.h:57
lldb_private::ProgressEventData::GetCompleted
uint64_t GetCompleted() const
Definition: DebuggerEvents.h:36
lldb_private::ProgressEventData::GetMessage
const std::string & GetMessage() const
Definition: DebuggerEvents.h:38
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
ConstString.h
lldb_private::ProgressEventData::GetTotal
uint64_t GetTotal() const
Definition: DebuggerEvents.h:37
lldb_private::DiagnosticEventData::GetMessage
const std::string & GetMessage() const
Definition: DebuggerEvents.h:62
lldb_private::ProgressEventData::m_completed
uint64_t m_completed
Definition: DebuggerEvents.h:44
lldb_private::ProgressEventData::m_message
std::string m_message
Definition: DebuggerEvents.h:42
lldb_private::DiagnosticEventData::GetFlavorString
static ConstString GetFlavorString()
Definition: DebuggerEvents.cpp:69
UINT64_MAX
#define UINT64_MAX
Definition: lldb-defines.h:23
lldb_private::DiagnosticEventData::m_debugger_specific
const bool m_debugger_specific
Definition: DebuggerEvents.h:79