14
14
#include < memory>
15
15
#include < vector>
16
16
17
+ #include " lldb/Core/DebuggerEvents.h"
17
18
#include " lldb/Core/FormatEntity.h"
18
19
#include " lldb/Core/IOHandler.h"
19
20
#include " lldb/Core/SourceManager.h"
@@ -76,6 +77,8 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
76
77
// / Broadcaster event bits definitions.
77
78
enum {
78
79
eBroadcastBitProgress = (1 << 0 ),
80
+ eBroadcastBitWarning = (1 << 1 ),
81
+ eBroadcastBitError = (1 << 2 ),
79
82
};
80
83
81
84
static ConstString GetStaticBroadcasterClass ();
@@ -84,39 +87,6 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
84
87
Broadcaster &GetBroadcaster () { return m_broadcaster; }
85
88
const Broadcaster &GetBroadcaster () const { return m_broadcaster; }
86
89
87
- class ProgressEventData : public EventData {
88
-
89
- public:
90
- ProgressEventData (uint64_t progress_id, const std::string &message,
91
- uint64_t completed, uint64_t total,
92
- bool debugger_specific)
93
- : m_message(message), m_id(progress_id), m_completed(completed),
94
- m_total (total), m_debugger_specific(debugger_specific) {}
95
-
96
- static ConstString GetFlavorString ();
97
-
98
- ConstString GetFlavor () const override ;
99
-
100
- void Dump (Stream *s) const override ;
101
-
102
- static const ProgressEventData *
103
- GetEventDataFromEvent (const Event *event_ptr);
104
- uint64_t GetID () const { return m_id; }
105
- uint64_t GetCompleted () const { return m_completed; }
106
- uint64_t GetTotal () const { return m_total; }
107
- const std::string &GetMessage () const { return m_message; }
108
- bool IsDebuggerSpecific () const { return m_debugger_specific; }
109
-
110
- private:
111
- std::string m_message;
112
- const uint64_t m_id;
113
- uint64_t m_completed;
114
- const uint64_t m_total;
115
- const bool m_debugger_specific;
116
- ProgressEventData (const ProgressEventData &) = delete;
117
- const ProgressEventData &operator =(const ProgressEventData &) = delete ;
118
- };
119
-
120
90
~Debugger () override ;
121
91
122
92
static lldb::DebuggerSP
@@ -415,6 +385,50 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
415
385
return m_broadcaster_manager_sp;
416
386
}
417
387
388
+ // / Report warning events.
389
+ // /
390
+ // / Progress events will be delivered to any debuggers that have listeners
391
+ // / for the eBroadcastBitError.
392
+ // /
393
+ // / \param[in] message
394
+ // / The warning message to be reported.
395
+ // /
396
+ // / \param [in] debugger_id
397
+ // / If this optional parameter has a value, it indicates the unique
398
+ // / debugger identifier that this progress should be delivered to. If this
399
+ // / optional parameter does not have a value, the progress will be
400
+ // / delivered to all debuggers.
401
+ // /
402
+ // / \param [in] once
403
+ // / If a pointer is passed to a std::once_flag, then it will be used to
404
+ // / ensure the given warning is only broadcast once.
405
+ static void
406
+ ReportWarning (std::string messsage,
407
+ llvm::Optional<lldb::user_id_t > debugger_id = llvm::None,
408
+ std::once_flag *once = nullptr );
409
+
410
+ // / Report error events.
411
+ // /
412
+ // / Progress events will be delivered to any debuggers that have listeners
413
+ // / for the eBroadcastBitError.
414
+ // /
415
+ // / \param[in] message
416
+ // / The error message to be reported.
417
+ // /
418
+ // / \param [in] debugger_id
419
+ // / If this optional parameter has a value, it indicates the unique
420
+ // / debugger identifier that this progress should be delivered to. If this
421
+ // / optional parameter does not have a value, the progress will be
422
+ // / delivered to all debuggers.
423
+ // /
424
+ // / \param [in] once
425
+ // / If a pointer is passed to a std::once_flag, then it will be used to
426
+ // / ensure the given error is only broadcast once.
427
+ static void
428
+ ReportError (std::string messsage,
429
+ llvm::Optional<lldb::user_id_t > debugger_id = llvm::None,
430
+ std::once_flag *once = nullptr );
431
+
418
432
protected:
419
433
friend class CommandInterpreter ;
420
434
friend class SwiftREPL ;
@@ -454,7 +468,12 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
454
468
uint64_t completed, uint64_t total,
455
469
llvm::Optional<lldb::user_id_t > debugger_id);
456
470
457
- void PrintProgress (const Debugger::ProgressEventData &data);
471
+ static void ReportDiagnosticImpl (DiagnosticEventData::Type type,
472
+ std::string message,
473
+ llvm::Optional<lldb::user_id_t > debugger_id,
474
+ std::once_flag *once);
475
+
476
+ void PrintProgress (const ProgressEventData &data);
458
477
459
478
bool StartEventHandlerThread ();
460
479
@@ -487,6 +506,8 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
487
506
488
507
void HandleProgressEvent (const lldb::EventSP &event_sp);
489
508
509
+ void HandleDiagnosticEvent (const lldb::EventSP &event_sp);
510
+
490
511
// Ensures two threads don't attempt to flush process output in parallel.
491
512
std::mutex m_output_flush_mutex;
492
513
void FlushProcessOutput (Process &process, bool flush_stdout,
0 commit comments