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 StructuredDataDarwinLog_h
10 #define 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 ConstString GetStaticPluginName();
35 /// Return whether the DarwinLog functionality is enabled.
37 /// The DarwinLog functionality is enabled if the user expicitly 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 ConstString GetPluginName() override;
51 uint32_t GetPluginVersion() override;
53 // StructuredDataPlugin API
55 bool SupportsStructuredDataType(ConstString type_name) override;
57 void HandleArrivalOfStructuredData(
58 Process &process, ConstString type_name,
59 const StructuredData::ObjectSP &object_sp) override;
61 Status GetDescription(const StructuredData::ObjectSP &object_sp,
62 lldb_private::Stream &stream) override;
64 bool GetEnabled(ConstString type_name) const override;
66 void ModulesDidLoad(Process &process, ModuleList &module_list) override;
68 ~StructuredDataDarwinLog() override;
71 // Private constructors
73 StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
75 // Private static methods
77 static lldb::StructuredDataPluginSP CreateInstance(Process &process);
79 static void DebuggerInitialize(Debugger &debugger);
81 static bool InitCompletionHookCallback(void *baton,
82 StoppointCallbackContext *context,
83 lldb::user_id_t break_id,
84 lldb::user_id_t break_loc_id);
86 static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,
89 // Internal helper methods used by friend classes
90 void SetEnabled(bool enabled);
92 void AddInitCompletionHook(Process &process);
96 void DumpTimestamp(Stream &stream, uint64_t timestamp);
98 size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
100 size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,
103 /// Call the enable command again, using whatever settings were initially
109 bool m_recorded_first_timestamp;
110 uint64_t m_first_timestamp_seen;
112 std::mutex m_added_breakpoint_mutex;
113 bool m_added_breakpoint;
114 lldb::user_id_t m_breakpoint_id;
118 #endif /* StructuredDataPluginDarwinLog_hpp */