LLDB mainline
|
#include <StructuredDataDarwinLog.h>
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 | |
PluginInterface & | operator= (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. | |
Definition at line 23 of file StructuredDataDarwinLog.h.
|
override |
Definition at line 1301 of file StructuredDataDarwinLog.cpp.
References lldb_private::StructuredDataPlugin::GetProcess(), LLDB_INVALID_BREAK_ID, and m_breakpoint_id.
|
private |
Definition at line 1316 of file StructuredDataDarwinLog.cpp.
|
private |
Definition at line 1563 of file StructuredDataDarwinLog.cpp.
References lldb_private::FileSpecList::Append(), lldb_private::Target::CreateBreakpoint(), lldb::eLanguageTypeC, lldb_private::eLazyBoolCalculate, GetGlobalProperties(), lldb_private::GetLog(), lldb_private::Process::GetTarget(), lldb_private::Process::GetUniqueID(), InitCompletionHookCallback(), LLDB_LOGF, m_added_breakpoint, m_added_breakpoint_mutex, m_breakpoint_id, and lldb_private::Process.
Referenced by sddarwinlog_private::EnableCommand::DoExecute(), and ModulesDidLoad().
|
staticprivate |
Definition at line 1325 of file StructuredDataDarwinLog.cpp.
References lldb_private::Target::GetArchitecture(), lldb_private::Process::GetTarget(), and lldb_private::ArchSpec::GetTriple().
Referenced by Initialize(), and Terminate().
|
staticprivate |
Definition at line 1336 of file StructuredDataDarwinLog.cpp.
References lldb_private::PluginManager::CreateSettingForStructuredDataPlugin(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::CommandInterpreter::GetCommandObjectForCommand(), GetGlobalProperties(), lldb_private::PluginManager::GetSettingForPlatformPlugin(), sddarwinlog_private::StructuredDataDarwinLogProperties::GetSettingName(), and lldb_private::StructuredDataPlugin::InitializeBasePluginForDebugger().
Referenced by Initialize().
|
private |
Definition at line 1644 of file StructuredDataDarwinLog.cpp.
References DumpTimestamp(), sddarwinlog_private::GetGlobalEnableOptions(), lldb_private::StructuredDataPlugin::GetProcess(), lldb_private::StreamString::GetSize(), lldb_private::StreamString::GetString(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsInteger(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsString(), lldb_private::Stream::PutChar(), and lldb_private::Stream::PutCString().
Referenced by HandleDisplayOfEvent().
|
private |
Definition at line 1626 of file StructuredDataDarwinLog.cpp.
References m_first_timestamp_seen, sddarwinlog_private::NANOS_PER_HOUR, sddarwinlog_private::NANOS_PER_MINUTE, sddarwinlog_private::NANOS_PER_SECOND, and lldb_private::Stream::Printf().
Referenced by DumpHeader().
|
private |
Call the enable command again, using whatever settings were initially made.
Definition at line 1762 of file StructuredDataDarwinLog.cpp.
References error(), sddarwinlog_private::GetDarwinLogTypeName(), sddarwinlog_private::GetGlobalEnableOptions(), lldb_private::GetLog(), lldb_private::StructuredDataPlugin::GetProcess(), LLDB_LOGF, m_is_enabled, lldb_private::Process, lldb_private::Debugger::ReportError(), and sddarwinlog_private::RunEnableCommand().
Referenced by InitCompletionHookCallback(), and ModulesDidLoad().
|
staticprivate |
Definition at line 1367 of file StructuredDataDarwinLog.cpp.
References lldb_private::Flags::AnySet(), error(), lldb_private::ProcessInfo::GetArchitecture(), lldb_private::Target::GetArchitecture(), lldb_private::Target::GetDebugger(), lldb_private::ProcessInfo::GetEnvironment(), lldb_private::ProcessLaunchInfo::GetFlags(), sddarwinlog_private::GetGlobalEnableOptions(), GetGlobalProperties(), lldb_private::ArchSpec::GetTriple(), sddarwinlog_private::ParseAutoEnableOptions(), sddarwinlog_private::s_is_explicitly_enabled, and sddarwinlog_private::SetGlobalEnableOptions().
Referenced by Initialize().
|
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.
[in] | object_sp | A shared pointer to the structured data to format. |
[in] | stream | The stream where the structured data should be pretty printed. |
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().
|
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.
[in] | type_name | The 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.
|
inlineoverridevirtual |
Implements lldb_private::PluginInterface.
Definition at line 49 of file StructuredDataDarwinLog.h.
References GetStaticPluginName().
|
inlinestatic |
Definition at line 33 of file StructuredDataDarwinLog.h.
Referenced by sddarwinlog_private::EnableCommand::DoExecute(), sddarwinlog_private::StatusCommand::DoExecute(), GetEnabled(), GetPluginName(), and Initialize().
|
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.
[in] | process | The process instance that just received the structured data. This will always be the same process for a given instance of a plugin. |
[in] | type_name | The 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_sp | A 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().
|
private |
Definition at line 1727 of file StructuredDataDarwinLog.cpp.
References DumpHeader(), sddarwinlog_private::GetLogEventType(), lldb_private::StructuredData::Dictionary::GetValueForKeyAsString(), lldb_private::Stream::PutChar(), and lldb_private::Stream::Write().
Referenced by GetDescription().
|
staticprivate |
Definition at line 1455 of file StructuredDataDarwinLog.cpp.
References EnableNow(), lldb_private::StoppointCallbackContext::exe_ctx_ref, sddarwinlog_private::GetDarwinLogTypeName(), lldb_private::GetLog(), lldb_private::ExecutionContextRef::GetProcessSP(), lldb_private::ExecutionContextRef::GetThreadSP(), LLDB_LOG, LLDB_LOGF, and lldb_private::Process.
Referenced by AddInitCompletionHook().
|
static |
Definition at line 1044 of file StructuredDataDarwinLog.cpp.
References CreateInstance(), DebuggerInitialize(), FilterLaunchInfo(), GetStaticPluginName(), sddarwinlog_private::RegisterFilterOperations(), and lldb_private::PluginManager::RegisterPlugin().
|
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.
|
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.
[in] | process | The 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_list | The 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.
|
private |
Definition at line 1208 of file StructuredDataDarwinLog.cpp.
References m_is_enabled.
Referenced by sddarwinlog_private::EnableCommand::DoExecute().
|
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.
[in] | type_name | The name of the feature tag supported by a process. e.g. "darwin-log". |
Implements lldb_private::StructuredDataPlugin.
Definition at line 1060 of file StructuredDataDarwinLog.cpp.
References sddarwinlog_private::GetDarwinLogTypeName().
|
static |
Definition at line 1051 of file StructuredDataDarwinLog.cpp.
References CreateInstance(), and lldb_private::PluginManager::UnregisterPlugin().
|
private |
Definition at line 111 of file StructuredDataDarwinLog.h.
Referenced by AddInitCompletionHook(), and ModulesDidLoad().
|
private |
Definition at line 110 of file StructuredDataDarwinLog.h.
Referenced by AddInitCompletionHook(), and ModulesDidLoad().
|
private |
Definition at line 112 of file StructuredDataDarwinLog.h.
Referenced by AddInitCompletionHook(), and ~StructuredDataDarwinLog().
|
private |
Definition at line 108 of file StructuredDataDarwinLog.h.
Referenced by DumpTimestamp(), and GetDescription().
|
private |
Definition at line 109 of file StructuredDataDarwinLog.h.
Referenced by EnableNow(), GetEnabled(), and SetEnabled().
|
private |
Definition at line 107 of file StructuredDataDarwinLog.h.
Referenced by GetDescription().