1 //===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef StructuredDataDarwinLog_h
11 #define StructuredDataDarwinLog_h
13 #include "lldb/Target/StructuredDataPlugin.h"
17 // Forward declarations
18 namespace sddarwinlog_private {
22 namespace lldb_private {
24 class StructuredDataDarwinLog : public StructuredDataPlugin {
25 friend sddarwinlog_private::EnableCommand;
28 // -------------------------------------------------------------------------
30 // -------------------------------------------------------------------------
32 static void Initialize();
34 static void Terminate();
36 static const ConstString &GetStaticPluginName();
38 // -------------------------------------------------------------------------
39 /// Return whether the DarwinLog functionality is enabled.
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
47 /// True if DarwinLog support is/will be enabled for existing or
48 /// newly launched/attached processes.
49 // -------------------------------------------------------------------------
50 static bool IsEnabled();
52 // -------------------------------------------------------------------------
53 // PluginInterface API
54 // -------------------------------------------------------------------------
56 ConstString GetPluginName() override;
58 uint32_t GetPluginVersion() override;
60 // -------------------------------------------------------------------------
61 // StructuredDataPlugin API
62 // -------------------------------------------------------------------------
64 bool SupportsStructuredDataType(const ConstString &type_name) override;
66 void HandleArrivalOfStructuredData(
67 Process &process, const ConstString &type_name,
68 const StructuredData::ObjectSP &object_sp) override;
70 Status GetDescription(const StructuredData::ObjectSP &object_sp,
71 lldb_private::Stream &stream) override;
73 bool GetEnabled(const ConstString &type_name) const override;
75 void ModulesDidLoad(Process &process, ModuleList &module_list) override;
77 ~StructuredDataDarwinLog();
80 // -------------------------------------------------------------------------
81 // Private constructors
82 // -------------------------------------------------------------------------
84 StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
86 // -------------------------------------------------------------------------
87 // Private static methods
88 // -------------------------------------------------------------------------
90 static lldb::StructuredDataPluginSP CreateInstance(Process &process);
92 static void DebuggerInitialize(Debugger &debugger);
94 static bool InitCompletionHookCallback(void *baton,
95 StoppointCallbackContext *context,
96 lldb::user_id_t break_id,
97 lldb::user_id_t break_loc_id);
99 static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,
102 // -------------------------------------------------------------------------
103 // Internal helper methods used by friend classes
104 // -------------------------------------------------------------------------
105 void SetEnabled(bool enabled);
107 void AddInitCompletionHook(Process &process);
109 // -------------------------------------------------------------------------
111 // -------------------------------------------------------------------------
113 void DumpTimestamp(Stream &stream, uint64_t timestamp);
115 size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
117 size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,
120 // -------------------------------------------------------------------------
121 /// Call the enable command again, using whatever settings were initially
123 // -------------------------------------------------------------------------
127 // -------------------------------------------------------------------------
129 // -------------------------------------------------------------------------
130 bool m_recorded_first_timestamp;
131 uint64_t m_first_timestamp_seen;
133 std::mutex m_added_breakpoint_mutex;
134 bool m_added_breakpoint;
135 lldb::user_id_t m_breakpoint_id;
139 #endif /* StructuredDataPluginDarwinLog_hpp */