]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
Update bmake to version 20180919
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / StructuredData / DarwinLog / StructuredDataDarwinLog.h
1 //===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef StructuredDataDarwinLog_h
11 #define StructuredDataDarwinLog_h
12
13 #include "lldb/Target/StructuredDataPlugin.h"
14
15 #include <mutex>
16
17 // Forward declarations
18 namespace sddarwinlog_private {
19 class EnableCommand;
20 }
21
22 namespace lldb_private {
23
24 class StructuredDataDarwinLog : public StructuredDataPlugin {
25   friend sddarwinlog_private::EnableCommand;
26
27 public:
28   // -------------------------------------------------------------------------
29   // Public static API
30   // -------------------------------------------------------------------------
31
32   static void Initialize();
33
34   static void Terminate();
35
36   static const ConstString &GetStaticPluginName();
37
38   // -------------------------------------------------------------------------
39   /// Return whether the DarwinLog functionality is enabled.
40   ///
41   /// The DarwinLog functionality is enabled if the user expicitly enabled
42   /// it with the enable command, or if the user has the setting set
43   /// that controls if we always enable it for newly created/attached
44   /// processes.
45   ///
46   /// @return
47   ///      True if DarwinLog support is/will be enabled for existing or
48   ///      newly launched/attached processes.
49   // -------------------------------------------------------------------------
50   static bool IsEnabled();
51
52   // -------------------------------------------------------------------------
53   // PluginInterface API
54   // -------------------------------------------------------------------------
55
56   ConstString GetPluginName() override;
57
58   uint32_t GetPluginVersion() override;
59
60   // -------------------------------------------------------------------------
61   // StructuredDataPlugin API
62   // -------------------------------------------------------------------------
63
64   bool SupportsStructuredDataType(const ConstString &type_name) override;
65
66   void HandleArrivalOfStructuredData(
67       Process &process, const ConstString &type_name,
68       const StructuredData::ObjectSP &object_sp) override;
69
70   Status GetDescription(const StructuredData::ObjectSP &object_sp,
71                         lldb_private::Stream &stream) override;
72
73   bool GetEnabled(const ConstString &type_name) const override;
74
75   void ModulesDidLoad(Process &process, ModuleList &module_list) override;
76
77   ~StructuredDataDarwinLog();
78
79 private:
80   // -------------------------------------------------------------------------
81   // Private constructors
82   // -------------------------------------------------------------------------
83
84   StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
85
86   // -------------------------------------------------------------------------
87   // Private static methods
88   // -------------------------------------------------------------------------
89
90   static lldb::StructuredDataPluginSP CreateInstance(Process &process);
91
92   static void DebuggerInitialize(Debugger &debugger);
93
94   static bool InitCompletionHookCallback(void *baton,
95                                          StoppointCallbackContext *context,
96                                          lldb::user_id_t break_id,
97                                          lldb::user_id_t break_loc_id);
98
99   static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,
100                                  Target *target);
101
102   // -------------------------------------------------------------------------
103   // Internal helper methods used by friend classes
104   // -------------------------------------------------------------------------
105   void SetEnabled(bool enabled);
106
107   void AddInitCompletionHook(Process &process);
108
109   // -------------------------------------------------------------------------
110   // Private methods
111   // -------------------------------------------------------------------------
112
113   void DumpTimestamp(Stream &stream, uint64_t timestamp);
114
115   size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
116
117   size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,
118                               Stream &stream);
119
120   // -------------------------------------------------------------------------
121   /// Call the enable command again, using whatever settings were initially
122   /// made.
123   // -------------------------------------------------------------------------
124
125   void EnableNow();
126
127   // -------------------------------------------------------------------------
128   // Private data
129   // -------------------------------------------------------------------------
130   bool m_recorded_first_timestamp;
131   uint64_t m_first_timestamp_seen;
132   bool m_is_enabled;
133   std::mutex m_added_breakpoint_mutex;
134   bool m_added_breakpoint;
135   lldb::user_id_t m_breakpoint_id;
136 };
137 }
138
139 #endif /* StructuredDataPluginDarwinLog_hpp */