1 //===-- DebuggerEvents.cpp ------------------------------------------------===//
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/DebuggerEvents.h"
10 
11 using namespace lldb_private;
12 
13 ConstString ProgressEventData::GetFlavorString() {
14   static ConstString g_flavor("ProgressEventData");
15   return g_flavor;
16 }
17 
18 ConstString ProgressEventData::GetFlavor() const {
19   return ProgressEventData::GetFlavorString();
20 }
21 
22 void ProgressEventData::Dump(Stream *s) const {
23   s->Printf(" id = %" PRIu64 ", message = \"%s\"", m_id, m_message.c_str());
24   if (m_completed == 0 || m_completed == m_total)
25     s->Printf(", type = %s", m_completed == 0 ? "start" : "end");
26   else
27     s->PutCString(", type = update");
28   // If m_total is UINT64_MAX, there is no progress to report, just "start"
29   // and "end". If it isn't we will show the completed and total amounts.
30   if (m_total != UINT64_MAX)
31     s->Printf(", progress = %" PRIu64 " of %" PRIu64, m_completed, m_total);
32 }
33 
34 const ProgressEventData *
35 ProgressEventData::GetEventDataFromEvent(const Event *event_ptr) {
36   if (event_ptr)
37     if (const EventData *event_data = event_ptr->GetData())
38       if (event_data->GetFlavor() == ProgressEventData::GetFlavorString())
39         return static_cast<const ProgressEventData *>(event_ptr->GetData());
40   return nullptr;
41 }
42