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]

Public Member Functions

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

Static Public Member Functions

static void Initialize ()
 
static void Terminate ()
 
static llvm::StringRef GetStaticPluginName ()
 
static bool IsEnabled ()
 Return whether the DarwinLog functionality is enabled.
 

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.
 

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.
 

Detailed Description

Definition at line 23 of file StructuredDataDarwinLog.h.

Constructor & Destructor Documentation

◆ ~StructuredDataDarwinLog()

StructuredDataDarwinLog::~StructuredDataDarwinLog ( )
override

◆ StructuredDataDarwinLog()

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

Definition at line 1316 of file StructuredDataDarwinLog.cpp.

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 1125 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(), HandleDisplayOfEvent(), m_first_timestamp_seen, m_recorded_first_timestamp, and SetErrorWithJSON().

◆ GetEnabled()

bool StructuredDataDarwinLog::GetEnabled ( llvm::StringRef  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 1202 of file StructuredDataDarwinLog.cpp.

References GetStaticPluginName(), and m_is_enabled.

◆ GetPluginName()

llvm::StringRef lldb_private::StructuredDataDarwinLog::GetPluginName ( )
inlineoverridevirtual

Implements lldb_private::PluginInterface.

Definition at line 49 of file StructuredDataDarwinLog.h.

References GetStaticPluginName().

◆ GetStaticPluginName()

static llvm::StringRef lldb_private::StructuredDataDarwinLog::GetStaticPluginName ( )
inlinestatic

◆ HandleArrivalOfStructuredData()

void StructuredDataDarwinLog::HandleArrivalOfStructuredData ( Process process,
llvm::StringRef  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 1065 of file StructuredDataDarwinLog.cpp.

References lldb_private::Process::BroadcastStructuredData(), sddarwinlog_private::GetDarwinLogTypeName(), lldb_private::StreamString::GetData(), lldb_private::Target::GetDebugger(), sddarwinlog_private::GetGlobalEnableOptions(), lldb_private::GetLog(), lldb_private::Process::GetTarget(), LLDB_LOG, LLDB_LOGF, lldb_private::Process, 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 1212 of file StructuredDataDarwinLog.cpp.

References AddInitCompletionHook(), EnableNow(), GetGlobalProperties(), lldb_private::GetLog(), lldb_private::ModuleList::GetModuleAtIndex(), lldb_private::ModuleList::GetSize(), lldb_private::Process::GetUniqueID(), LLDB_LOGF, m_added_breakpoint, m_added_breakpoint_mutex, lldb_private::Process, and sddarwinlog_private::s_is_explicitly_enabled.

◆ SetEnabled()

void StructuredDataDarwinLog::SetEnabled ( bool  enabled)
private

Definition at line 1208 of file StructuredDataDarwinLog.cpp.

References m_is_enabled.

Referenced by sddarwinlog_private::EnableCommand::DoExecute().

◆ SupportsStructuredDataType()

bool StructuredDataDarwinLog::SupportsStructuredDataType ( llvm::StringRef  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 1060 of file StructuredDataDarwinLog.cpp.

References sddarwinlog_private::GetDarwinLogTypeName().

◆ Terminate()

void StructuredDataDarwinLog::Terminate ( )
static

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(), and ModulesDidLoad().

◆ 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(), and ModulesDidLoad().

◆ 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(), and ~StructuredDataDarwinLog().

◆ 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(), and GetDescription().

◆ m_is_enabled

bool lldb_private::StructuredDataDarwinLog::m_is_enabled
private

Definition at line 109 of file StructuredDataDarwinLog.h.

Referenced by EnableNow(), GetEnabled(), and SetEnabled().

◆ m_recorded_first_timestamp

bool lldb_private::StructuredDataDarwinLog::m_recorded_first_timestamp
private

Definition at line 107 of file StructuredDataDarwinLog.h.

Referenced by GetDescription().


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