1 //===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
10 #define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
12 #include "lldb/Target/StructuredDataPlugin.h"
16 // Forward declarations
17 namespace sddarwinlog_private
{
21 namespace lldb_private
{
23 class StructuredDataDarwinLog
: public StructuredDataPlugin
{
24 friend sddarwinlog_private::EnableCommand
;
29 static void Initialize();
31 static void Terminate();
33 static llvm::StringRef
GetStaticPluginName() { return "darwin-log"; }
35 /// Return whether the DarwinLog functionality is enabled.
37 /// The DarwinLog functionality is enabled if the user explicitly enabled
38 /// it with the enable command, or if the user has the setting set
39 /// that controls if we always enable it for newly created/attached
43 /// True if DarwinLog support is/will be enabled for existing or
44 /// newly launched/attached processes.
45 static bool IsEnabled();
47 // PluginInterface API
49 llvm::StringRef
GetPluginName() override
{ return GetStaticPluginName(); }
51 // StructuredDataPlugin API
53 bool SupportsStructuredDataType(llvm::StringRef type_name
) override
;
55 void HandleArrivalOfStructuredData(
56 Process
&process
, llvm::StringRef type_name
,
57 const StructuredData::ObjectSP
&object_sp
) override
;
59 Status
GetDescription(const StructuredData::ObjectSP
&object_sp
,
60 lldb_private::Stream
&stream
) override
;
62 bool GetEnabled(llvm::StringRef type_name
) const override
;
64 void ModulesDidLoad(Process
&process
, ModuleList
&module_list
) override
;
66 ~StructuredDataDarwinLog() override
;
69 // Private constructors
71 StructuredDataDarwinLog(const lldb::ProcessWP
&process_wp
);
73 // Private static methods
75 static lldb::StructuredDataPluginSP
CreateInstance(Process
&process
);
77 static void DebuggerInitialize(Debugger
&debugger
);
79 static bool InitCompletionHookCallback(void *baton
,
80 StoppointCallbackContext
*context
,
81 lldb::user_id_t break_id
,
82 lldb::user_id_t break_loc_id
);
84 static Status
FilterLaunchInfo(ProcessLaunchInfo
&launch_info
,
87 // Internal helper methods used by friend classes
88 void SetEnabled(bool enabled
);
90 void AddInitCompletionHook(Process
&process
);
94 void DumpTimestamp(Stream
&stream
, uint64_t timestamp
);
96 size_t DumpHeader(Stream
&stream
, const StructuredData::Dictionary
&event
);
98 size_t HandleDisplayOfEvent(const StructuredData::Dictionary
&event
,
101 /// Call the enable command again, using whatever settings were initially
107 bool m_recorded_first_timestamp
;
108 uint64_t m_first_timestamp_seen
;
110 std::mutex m_added_breakpoint_mutex
;
111 bool m_added_breakpoint
;
112 lldb::user_id_t m_breakpoint_id
;
116 #endif // LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H