LLDB  mainline
StructuredDataDarwinLog.h
Go to the documentation of this file.
1 //===-- StructuredDataDarwinLog.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_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
10 #define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
11 
13 
14 #include <mutex>
15 
16 // Forward declarations
17 namespace sddarwinlog_private {
18 class EnableCommand;
19 }
20 
21 namespace lldb_private {
22 
25 
26 public:
27  // Public static API
28 
29  static void Initialize();
30 
31  static void Terminate();
32 
34 
35  /// Return whether the DarwinLog functionality is enabled.
36  ///
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
40  /// processes.
41  ///
42  /// \return
43  /// True if DarwinLog support is/will be enabled for existing or
44  /// newly launched/attached processes.
45  static bool IsEnabled();
46 
47  // PluginInterface API
48 
49  ConstString GetPluginName() override;
50 
51  // StructuredDataPlugin API
52 
53  bool SupportsStructuredDataType(ConstString type_name) override;
54 
56  Process &process, ConstString type_name,
57  const StructuredData::ObjectSP &object_sp) override;
58 
60  lldb_private::Stream &stream) override;
61 
62  bool GetEnabled(ConstString type_name) const override;
63 
64  void ModulesDidLoad(Process &process, ModuleList &module_list) override;
65 
66  ~StructuredDataDarwinLog() override;
67 
68 private:
69  // Private constructors
70 
71  StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
72 
73  // Private static methods
74 
75  static lldb::StructuredDataPluginSP CreateInstance(Process &process);
76 
77  static void DebuggerInitialize(Debugger &debugger);
78 
79  static bool InitCompletionHookCallback(void *baton,
80  StoppointCallbackContext *context,
81  lldb::user_id_t break_id,
82  lldb::user_id_t break_loc_id);
83 
84  static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,
85  Target *target);
86 
87  // Internal helper methods used by friend classes
88  void SetEnabled(bool enabled);
89 
90  void AddInitCompletionHook(Process &process);
91 
92  // Private methods
93 
94  void DumpTimestamp(Stream &stream, uint64_t timestamp);
95 
96  size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
97 
99  Stream &stream);
100 
101  /// Call the enable command again, using whatever settings were initially
102  /// made.
103 
104  void EnableNow();
105 
106  // Private data
113 };
114 }
115 
116 #endif // LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
lldb_private::StructuredDataDarwinLog::CreateInstance
static lldb::StructuredDataPluginSP CreateInstance(Process &process)
Definition: StructuredDataDarwinLog.cpp:1348
lldb_private::StructuredDataDarwinLog::HandleDisplayOfEvent
size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event, Stream &stream)
Definition: StructuredDataDarwinLog.cpp:1755
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
lldb_private::StructuredDataDarwinLog::m_added_breakpoint
bool m_added_breakpoint
Definition: StructuredDataDarwinLog.h:111
lldb_private::StructuredDataDarwinLog::m_added_breakpoint_mutex
std::mutex m_added_breakpoint_mutex
Definition: StructuredDataDarwinLog.h:110
lldb_private::StructuredDataDarwinLog::FilterLaunchInfo
static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info, Target *target)
Definition: StructuredDataDarwinLog.cpp:1392
lldb_private::StructuredDataDarwinLog::HandleArrivalOfStructuredData
void HandleArrivalOfStructuredData(Process &process, ConstString type_name, const StructuredData::ObjectSP &object_sp) override
Handle the arrival of asynchronous structured data from the process.
Definition: StructuredDataDarwinLog.cpp:1081
lldb_private::Process
Definition: Process.h:342
lldb_private::StructuredDataDarwinLog::SupportsStructuredDataType
bool SupportsStructuredDataType(ConstString type_name) override
Return whether this plugin supports the given StructuredData feature.
Definition: StructuredDataDarwinLog.cpp:1076
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StructuredDataDarwinLog::Terminate
static void Terminate()
Definition: StructuredDataDarwinLog.cpp:1053
lldb_private::Target
Definition: Target.h:454
lldb_private::StructuredDataDarwinLog::m_is_enabled
bool m_is_enabled
Definition: StructuredDataDarwinLog.h:109
sddarwinlog_private::EnableCommand
Definition: StructuredDataDarwinLog.cpp:741
lldb_private::StructuredDataDarwinLog::AddInitCompletionHook
void AddInitCompletionHook(Process &process)
Definition: StructuredDataDarwinLog.cpp:1591
lldb_private::StructuredDataPlugin
Plugin that supports process-related structured data sent asynchronously from the debug monitor (e....
Definition: StructuredDataPlugin.h:40
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::ModuleList
Definition: ModuleList.h:72
lldb_private::StructuredDataDarwinLog::EnableNow
void EnableNow()
Call the enable command again, using whatever settings were initially made.
Definition: StructuredDataDarwinLog.cpp:1790
lldb_private::StructuredDataDarwinLog::~StructuredDataDarwinLog
~StructuredDataDarwinLog() override
Definition: StructuredDataDarwinLog.cpp:1324
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::StructuredDataDarwinLog::GetEnabled
bool GetEnabled(ConstString type_name) const override
Returns whether the plugin's features are enabled.
Definition: StructuredDataDarwinLog.cpp:1220
StructuredDataPlugin.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::StructuredDataDarwinLog::IsEnabled
static bool IsEnabled()
Return whether the DarwinLog functionality is enabled.
lldb_private::StructuredDataDarwinLog::Initialize
static void Initialize()
Definition: StructuredDataDarwinLog.cpp:1046
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::StructuredDataDarwinLog::InitCompletionHookCallback
static bool InitCompletionHookCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Definition: StructuredDataDarwinLog.cpp:1480
lldb_private::StructuredDataDarwinLog::DumpTimestamp
void DumpTimestamp(Stream &stream, uint64_t timestamp)
Definition: StructuredDataDarwinLog.cpp:1654
lldb_private::StructuredDataDarwinLog::m_first_timestamp_seen
uint64_t m_first_timestamp_seen
Definition: StructuredDataDarwinLog.h:108
lldb_private::StructuredDataDarwinLog::StructuredDataDarwinLog
StructuredDataDarwinLog(const lldb::ProcessWP &process_wp)
Definition: StructuredDataDarwinLog.cpp:1339
lldb_private::StructuredDataDarwinLog::m_breakpoint_id
lldb::user_id_t m_breakpoint_id
Definition: StructuredDataDarwinLog.h:112
lldb_private::StructuredDataDarwinLog::DebuggerInitialize
static void DebuggerInitialize(Debugger &debugger)
Definition: StructuredDataDarwinLog.cpp:1359
lldb_private::StructuredDataDarwinLog::m_recorded_first_timestamp
bool m_recorded_first_timestamp
Definition: StructuredDataDarwinLog.h:107
lldb_private::Status
Definition: Status.h:44
sddarwinlog_private
Definition: StructuredDataDarwinLog.cpp:46
lldb_private::StructuredDataDarwinLog
Definition: StructuredDataDarwinLog.h:23
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StructuredDataDarwinLog::SetEnabled
void SetEnabled(bool enabled)
Definition: StructuredDataDarwinLog.cpp:1227
lldb_private::StructuredDataDarwinLog::GetDescription
Status GetDescription(const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) override
Get a human-readable description of the contents of the data.
Definition: StructuredDataDarwinLog.cpp:1143
lldb_private::StructuredDataDarwinLog::DumpHeader
size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event)
Definition: StructuredDataDarwinLog.cpp:1672
lldb_private::StructuredDataDarwinLog::ModulesDidLoad
void ModulesDidLoad(Process &process, ModuleList &module_list) override
Allow the plugin to do work related to modules that loaded in the the corresponding process.
Definition: StructuredDataDarwinLog.cpp:1231
lldb_private::StructuredDataDarwinLog::GetPluginName
ConstString GetPluginName() override
Definition: StructuredDataDarwinLog.cpp:1067
lldb_private::StructuredDataDarwinLog::GetStaticPluginName
static ConstString GetStaticPluginName()
Definition: StructuredDataDarwinLog.cpp:1057