• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- SBListener.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 #ifndef LLDB_API_SBLISTENER_H
10 #define LLDB_API_SBLISTENER_H
11 
12 #include "lldb/API/SBDefines.h"
13 
14 namespace lldb {
15 
16 class LLDB_API SBListener {
17 public:
18   SBListener();
19 
20   SBListener(const char *name);
21 
22   SBListener(const SBListener &rhs);
23 
24   ~SBListener();
25 
26   const lldb::SBListener &operator=(const lldb::SBListener &rhs);
27 
28   void AddEvent(const lldb::SBEvent &event);
29 
30   void Clear();
31 
32   explicit operator bool() const;
33 
34   bool IsValid() const;
35 
36   uint32_t StartListeningForEventClass(SBDebugger &debugger,
37                                        const char *broadcaster_class,
38                                        uint32_t event_mask);
39 
40   bool StopListeningForEventClass(SBDebugger &debugger,
41                                   const char *broadcaster_class,
42                                   uint32_t event_mask);
43 
44   uint32_t StartListeningForEvents(const lldb::SBBroadcaster &broadcaster,
45                                    uint32_t event_mask);
46 
47   bool StopListeningForEvents(const lldb::SBBroadcaster &broadcaster,
48                               uint32_t event_mask);
49 
50   // Returns true if an event was received, false if we timed out.
51   bool WaitForEvent(uint32_t num_seconds, lldb::SBEvent &event);
52 
53   bool WaitForEventForBroadcaster(uint32_t num_seconds,
54                                   const lldb::SBBroadcaster &broadcaster,
55                                   lldb::SBEvent &sb_event);
56 
57   bool WaitForEventForBroadcasterWithType(
58       uint32_t num_seconds, const lldb::SBBroadcaster &broadcaster,
59       uint32_t event_type_mask, lldb::SBEvent &sb_event);
60 
61   bool PeekAtNextEvent(lldb::SBEvent &sb_event);
62 
63   bool PeekAtNextEventForBroadcaster(const lldb::SBBroadcaster &broadcaster,
64                                      lldb::SBEvent &sb_event);
65 
66   bool
67   PeekAtNextEventForBroadcasterWithType(const lldb::SBBroadcaster &broadcaster,
68                                         uint32_t event_type_mask,
69                                         lldb::SBEvent &sb_event);
70 
71   bool GetNextEvent(lldb::SBEvent &sb_event);
72 
73   bool GetNextEventForBroadcaster(const lldb::SBBroadcaster &broadcaster,
74                                   lldb::SBEvent &sb_event);
75 
76   bool
77   GetNextEventForBroadcasterWithType(const lldb::SBBroadcaster &broadcaster,
78                                      uint32_t event_type_mask,
79                                      lldb::SBEvent &sb_event);
80 
81   bool HandleBroadcastEvent(const lldb::SBEvent &event);
82 
83 protected:
84   friend class SBAttachInfo;
85   friend class SBBroadcaster;
86   friend class SBCommandInterpreter;
87   friend class SBDebugger;
88   friend class SBLaunchInfo;
89   friend class SBTarget;
90 
91   SBListener(const lldb::ListenerSP &listener_sp);
92 
93   lldb::ListenerSP GetSP();
94 
95 private:
96   lldb_private::Listener *operator->() const;
97 
98   lldb_private::Listener *get() const;
99 
100   void reset(lldb::ListenerSP listener_sp);
101 
102   lldb::ListenerSP m_opaque_sp;
103   lldb_private::Listener *m_unused_ptr;
104 };
105 
106 } // namespace lldb
107 
108 #endif // LLDB_API_SBLISTENER_H
109