LLDB  mainline
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lldb_private::StructuredDataDarwinLog Class Reference

#include <StructuredDataDarwinLog.h>

Inheritance diagram for lldb_private::StructuredDataDarwinLog:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::StructuredDataDarwinLog:
Collaboration graph
[legend]

Public Member Functions

ConstString GetPluginName () override
 
bool SupportsStructuredDataType (ConstString type_name) override
 Return whether this plugin supports the given StructuredData feature. More...
 
void HandleArrivalOfStructuredData (Process &process, ConstString type_name, const StructuredData::ObjectSP &object_sp) override
 Handle the arrival of asynchronous structured data from the process. More...
 
Status GetDescription (const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) override
 Get a human-readable description of the contents of the data. More...
 
bool GetEnabled (ConstString type_name) const override
 Returns whether the plugin's features are enabled. More...
 
void ModulesDidLoad (Process &process, ModuleList &module_list) override
 Allow the plugin to do work related to modules that loaded in the the corresponding process. More...
 
 ~StructuredDataDarwinLog () override
 
- Public Member Functions inherited from lldb_private::StructuredDataPlugin
 ~StructuredDataPlugin () override
 
lldb::ProcessSP GetProcess () const
 
- Public Member Functions inherited from lldb_private::PluginInterface
 PluginInterface ()=default
 
virtual ~PluginInterface ()=default
 
 PluginInterface (const PluginInterface &)=delete
 
PluginInterfaceoperator= (const PluginInterface &)=delete
 

Static Public Member Functions

static void Initialize ()
 
static void Terminate ()
 
static ConstString GetStaticPluginName ()
 
static bool IsEnabled ()
 Return whether the DarwinLog functionality is enabled. More...
 

Private Member Functions

 StructuredDataDarwinLog (const lldb::ProcessWP &process_wp)
 
void SetEnabled (bool enabled)
 
void AddInitCompletionHook (Process &process)
 
void DumpTimestamp (Stream &stream, uint64_t timestamp)
 
size_t DumpHeader (Stream &stream, const StructuredData::Dictionary &event)
 
size_t HandleDisplayOfEvent (const StructuredData::Dictionary &event, Stream &stream)
 
void EnableNow ()
 Call the enable command again, using whatever settings were initially made. More...
 

Static Private Member Functions

static lldb::StructuredDataPluginSP CreateInstance (Process &process)
 
static void DebuggerInitialize (Debugger &debugger)
 
static bool InitCompletionHookCallback (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
 
static Status FilterLaunchInfo (ProcessLaunchInfo &launch_info, Target *target)
 

Private Attributes

bool m_recorded_first_timestamp
 
uint64_t m_first_timestamp_seen
 
bool m_is_enabled
 
std::mutex m_added_breakpoint_mutex
 
bool m_added_breakpoint
 
lldb::user_id_t m_breakpoint_id
 

Additional Inherited Members

- Protected Member Functions inherited from lldb_private::StructuredDataPlugin
 StructuredDataPlugin (const lldb::ProcessWP &process_wp)
 
- Static Protected Member Functions inherited from lldb_private::StructuredDataPlugin
static void InitializeBasePluginForDebugger (Debugger &debugger)
 Derived classes must call this before attempting to hook up commands to the 'plugin structured-data' tree. More...
 

Detailed Description

Definition at line 23 of file StructuredDataDarwinLog.h.

Constructor & Destructor Documentation

◆ ~StructuredDataDarwinLog()

StructuredDataDarwinLog::~StructuredDataDarwinLog ( )
override

Definition at line 1324 of file StructuredDataDarwinLog.cpp.

References LLDB_INVALID_BREAK_ID.

◆ StructuredDataDarwinLog()

StructuredDataDarwinLog::StructuredDataDarwinLog ( const lldb::ProcessWP &  process_wp)
private

Definition at line 1339 of file StructuredDataDarwinLog.cpp.

Referenced by CreateInstance().

Member Function Documentation

◆ AddInitCompletionHook()

void StructuredDataDarwinLog::AddInitCompletionHook ( Process process)
private

◆ CreateInstance()

StructuredDataPluginSP StructuredDataDarwinLog::CreateInstance ( Process process)
staticprivate

◆ DebuggerInitialize()

void StructuredDataDarwinLog::DebuggerInitialize ( Debugger debugger)
staticprivate

◆ DumpHeader()

size_t StructuredDataDarwinLog::DumpHeader ( Stream stream,
const StructuredData::Dictionary event 
)
private

◆ DumpTimestamp()

void StructuredDataDarwinLog::DumpTimestamp ( Stream stream,
uint64_t  timestamp 
)
private

◆ EnableNow()

void StructuredDataDarwinLog::EnableNow ( )
private

◆ FilterLaunchInfo()

Status StructuredDataDarwinLog::FilterLaunchInfo ( ProcessLaunchInfo launch_info,
Target target 
)
staticprivate

◆ GetDescription()

Status StructuredDataDarwinLog::GetDescription ( const StructuredData::ObjectSP object_sp,
lldb_private::Stream stream 
)
overridevirtual

Get a human-readable description of the contents of the data.

In command-line LLDB, this method will be called by the Debugger instance for each structured data event generated, and the output will be printed to the LLDB console. If nothing is added to the stream, nothing will be printed; otherwise, a newline will be added to the end when displayed.

Parameters
[in]object_spA shared pointer to the structured data to format.
[in]streamThe stream where the structured data should be pretty printed.
Returns
The error if formatting the object contents failed; otherwise, success.

Implements lldb_private::StructuredDataPlugin.

Definition at line 1143 of file StructuredDataDarwinLog.cpp.

References error(), lldb_private::Stream::Flush(), lldb_private::StructuredData::Array::ForEach(), lldb_private::StructuredData::Object::GetAsDictionary(), sddarwinlog_private::GetDarwinLogTypeName(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsArray(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsString(), and SetErrorWithJSON().

◆ GetEnabled()

bool StructuredDataDarwinLog::GetEnabled ( ConstString  type_name) const
overridevirtual

Returns whether the plugin's features are enabled.

This is a convenience method for plugins that can enable or disable their functionality. It allows retrieval of this state without requiring a cast.

Parameters
[in]type_nameThe name of the feature tag for the asynchronous structured data. This is needed for plugins that support more than one feature.

Reimplemented from lldb_private::StructuredDataPlugin.

Definition at line 1220 of file StructuredDataDarwinLog.cpp.

◆ GetPluginName()

ConstString StructuredDataDarwinLog::GetPluginName ( )
overridevirtual

Implements lldb_private::PluginInterface.

Definition at line 1067 of file StructuredDataDarwinLog.cpp.

◆ GetStaticPluginName()

ConstString StructuredDataDarwinLog::GetStaticPluginName ( )
static

Definition at line 1057 of file StructuredDataDarwinLog.cpp.

◆ HandleArrivalOfStructuredData()

void StructuredDataDarwinLog::HandleArrivalOfStructuredData ( Process process,
ConstString  type_name,
const StructuredData::ObjectSP object_sp 
)
overridevirtual

Handle the arrival of asynchronous structured data from the process.

When asynchronous structured data arrives from the process monitor, it is immediately delivered to the plugin mapped for that feature if one exists. The structured data that arrives from a process monitor must be a dictionary, and it must have a string field named "type" that must contain the StructuredData feature name set as the value. This is the manner in which the data is routed to the proper plugin instance.

Parameters
[in]processThe process instance that just received the structured data. This will always be the same process for a given instance of a plugin.
[in]type_nameThe name of the feature tag for the asynchronous structured data. Note this data will also be present in the object_sp dictionary under the string value with key "type".
[in]object_spA shared pointer to the structured data that arrived. This must be a dictionary. The only key required is the aforementioned key named "type" that must be a string value containing the structured data type name.

Implements lldb_private::StructuredDataPlugin.

Definition at line 1081 of file StructuredDataDarwinLog.cpp.

References lldb_private::ConstString::AsCString(), lldb_private::Process::BroadcastStructuredData(), sddarwinlog_private::GetDarwinLogTypeName(), lldb_private::StreamString::GetData(), lldb_private::Target::GetDebugger(), sddarwinlog_private::GetGlobalEnableOptions(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::Process::GetTarget(), LIBLLDB_LOG_PROCESS, LLDB_LOGF, and lldb_private::Stream::PutCString().

◆ HandleDisplayOfEvent()

size_t StructuredDataDarwinLog::HandleDisplayOfEvent ( const StructuredData::Dictionary event,
Stream stream 
)
private

◆ InitCompletionHookCallback()

bool StructuredDataDarwinLog::InitCompletionHookCallback ( void *  baton,
StoppointCallbackContext context,
lldb::user_id_t  break_id,
lldb::user_id_t  break_loc_id 
)
staticprivate

◆ Initialize()

void StructuredDataDarwinLog::Initialize ( )
static

◆ IsEnabled()

static bool lldb_private::StructuredDataDarwinLog::IsEnabled ( )
static

Return whether the DarwinLog functionality is enabled.

The DarwinLog functionality is enabled if the user explicitly enabled it with the enable command, or if the user has the setting set that controls if we always enable it for newly created/attached processes.

Returns
True if DarwinLog support is/will be enabled for existing or newly launched/attached processes.

◆ ModulesDidLoad()

void StructuredDataDarwinLog::ModulesDidLoad ( Process process,
ModuleList module_list 
)
overridevirtual

Allow the plugin to do work related to modules that loaded in the the corresponding process.

This method defaults to doing nothing. Plugins can override it if they have any behavior they want to enable/modify based on loaded modules.

Parameters
[in]processThe process that just was notified of modules having been loaded. This will always be the same process for a given instance of a plugin.
[in]module_listThe list of modules that the process registered as having just loaded. See Process::ModulesDidLoad(...).

Reimplemented from lldb_private::StructuredDataPlugin.

Definition at line 1231 of file StructuredDataDarwinLog.cpp.

References lldb_private::ConstString::AsCString(), GetGlobalProperties(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::ModuleList::GetModuleAtIndex(), lldb_private::ModuleList::GetSize(), lldb_private::Process::GetUniqueID(), LIBLLDB_LOG_PROCESS, LLDB_LOGF, and sddarwinlog_private::s_is_explicitly_enabled.

◆ SetEnabled()

void StructuredDataDarwinLog::SetEnabled ( bool  enabled)
private

◆ SupportsStructuredDataType()

bool StructuredDataDarwinLog::SupportsStructuredDataType ( ConstString  type_name)
overridevirtual

Return whether this plugin supports the given StructuredData feature.

When Process is informed of a list of process-monitor-supported structured data features, Process will go through the list of plugins, one at a time, and have the first plugin that supports a given feature be the plugin instantiated to handle that feature. There is a 1-1 correspondence between a Process instance and a StructuredDataPlugin mapped to that process. A plugin can support handling multiple features, and if that happens, there is a single plugin instance created covering all of the mapped features for a given process.

Parameters
[in]type_nameThe name of the feature tag supported by a process. e.g. "darwin-log".
Returns
true if the plugin supports the feature; otherwise, false.

Implements lldb_private::StructuredDataPlugin.

Definition at line 1076 of file StructuredDataDarwinLog.cpp.

References sddarwinlog_private::GetDarwinLogTypeName().

◆ Terminate()

void StructuredDataDarwinLog::Terminate ( )
static

Definition at line 1053 of file StructuredDataDarwinLog.cpp.

Member Data Documentation

◆ m_added_breakpoint

bool lldb_private::StructuredDataDarwinLog::m_added_breakpoint
private

Definition at line 111 of file StructuredDataDarwinLog.h.

Referenced by AddInitCompletionHook().

◆ m_added_breakpoint_mutex

std::mutex lldb_private::StructuredDataDarwinLog::m_added_breakpoint_mutex
private

Definition at line 110 of file StructuredDataDarwinLog.h.

Referenced by AddInitCompletionHook().

◆ m_breakpoint_id

lldb::user_id_t lldb_private::StructuredDataDarwinLog::m_breakpoint_id
private

Definition at line 112 of file StructuredDataDarwinLog.h.

Referenced by AddInitCompletionHook().

◆ m_first_timestamp_seen

uint64_t lldb_private::StructuredDataDarwinLog::m_first_timestamp_seen
private

Definition at line 108 of file StructuredDataDarwinLog.h.

Referenced by DumpTimestamp().

◆ m_is_enabled

bool lldb_private::StructuredDataDarwinLog::m_is_enabled
private

Definition at line 109 of file StructuredDataDarwinLog.h.

Referenced by EnableNow().

◆ m_recorded_first_timestamp

bool lldb_private::StructuredDataDarwinLog::m_recorded_first_timestamp
private

Definition at line 107 of file StructuredDataDarwinLog.h.


The documentation for this class was generated from the following files: