35#include "llvm/ADT/StringMap.h"
37#define DARWIN_LOG_TYPE_VALUE "DarwinLog"
45#pragma mark Anonymous Namespace
69 std::map<DebuggerWP, EnableOptionsSP, std::owner_less<DebuggerWP>>;
77 static std::mutex s_options_map_lock;
78 return s_options_map_lock;
88 auto find_it = options_map.find(debugger_wp);
89 if (find_it != options_map.end())
90 return find_it->second;
100 auto find_it = options_map.find(debugger_wp);
101 if (find_it != options_map.end())
102 find_it->second = options_sp;
104 options_map.insert(std::make_pair(debugger_wp, options_sp));
108#pragma mark Settings Handling
112#define LLDB_PROPERTIES_darwinlog
113#include "StructuredDataDarwinLogProperties.inc"
116#define LLDB_PROPERTIES_darwinlog
117#include "StructuredDataDarwinLogPropertiesEnum.inc"
123 static constexpr llvm::StringLiteral g_setting_name(
"darwin-log");
124 return g_setting_name;
135 const uint32_t idx = ePropertyEnableOnStartup;
136 return GetPropertyAtIndexAs<bool>(
137 idx, g_darwinlog_properties[idx].default_uint_value != 0);
141 const uint32_t idx = ePropertyAutoEnableOptions;
142 return GetPropertyAtIndexAs<llvm::StringRef>(
143 idx, g_darwinlog_properties[idx].default_cstr_value);
168 static constexpr llvm::StringLiteral s_key_name(
"DarwinLog");
173 static constexpr llvm::StringLiteral s_event_type(
"log");
185 std::function<
FilterRuleSP(
bool accept,
size_t attribute_index,
194 llvm::StringRef operation,
198 auto find_it = map.find(operation);
199 if (find_it == map.end()) {
201 "unknown filter operation \"{0}\"", operation);
205 return find_it->second(match_accepts, attribute, op_arg,
error);
234 FilterRule(
bool accept,
size_t attribute_index, llvm::StringRef operation)
280 const std::string &op_arg,
283 if (op_arg.empty()) {
291 if (llvm::Error err = regex.GetError()) {
302 static constexpr llvm::StringLiteral s_operation(
"regex");
307 const std::string ®ex_text)
332 const std::string &op_arg,
334 if (op_arg.empty()) {
336 "argument containing the text that must "
337 "match the specified message attribute.");
347 static constexpr llvm::StringLiteral s_operation(
"match");
352 const std::string &match_text)
379 "Specifies log messages from other related processes should be "
383 "Specifies debug-level log messages should be included. Specifying"
384 " --debug implies --info."},
387 "Specifies info-level log messages should be included."},
394 "Appends a filter rule to the log message filter chain. Multiple "
395 "rules may be added by specifying this option multiple times, "
396 "once per filter rule. Filter rules are processed in the order "
397 "they are specified, with the --no-match-accepts setting used "
398 "for any message that doesn't match one of the rules.\n"
400 " Filter spec format:\n"
402 " --filter \"{action} {attribute} {op}\"\n"
409 " activity | // message's most-derived activity\n"
410 " activity-chain | // message's {parent}:{child} activity\n"
411 " category | // message's category\n"
412 " message | // message's expanded contents\n"
413 " subsystem | // message's subsystem\n"
416 " match {exact-match-text} |\n"
417 " regex {search-regex}\n"
419 "The regex flavor used is the C++ std::regex ECMAScript format. "
420 "Prefer character classes like [[:digit:]] to \\d and the like, as "
421 "getting the backslashes escaped through properly is error-prone."},
424 "Specify whether logging events are live-streamed or buffered. "
425 "True indicates live streaming, false indicates buffered. The "
426 "default is true (live streaming). Live streaming will deliver "
427 "log messages with less delay, but buffered capture mode has less "
428 "of an observer effect."},
431 "Specify whether a log message that doesn't match any filter rule "
432 "is accepted or rejected, where true indicates accept. The "
436 "Specify whether os_log()/NSLog() messages are echoed to the "
437 "target program's stderr. When DarwinLog is enabled, we shut off "
438 "the mirroring of os_log()/NSLog() to the program's stderr. "
439 "Setting this flag to true will restore the stderr mirroring."
440 "The default is false."},
443 "Specify if the plugin should broadcast events. Broadcasting "
444 "log events is a requirement for displaying the log entries in "
445 "LLDB command-line. It is also required if LLDB clients want to "
446 "process log events. The default is true."},
450 "Include timestamp in the message header when printing a log "
451 "message. The timestamp is relative to the first displayed "
455 "Include the subsystem in the message header when displaying "
459 "Include the category in the message header when displaying "
463 "Include the activity parent-child chain in the message header "
464 "when displaying a log message. The activity hierarchy is "
465 "displayed as {grandparent-activity}:"
466 "{parent-activity}:{activity}[:...]."},
469 "Shortcut to specify that all header fields should be displayed."}};
498 switch (short_option) {
570 config_sp->AddBooleanItem(
"enabled", enabled);
577 auto source_flags_sp =
579 config_sp->AddItem(
"source-flags", source_flags_sp);
586 source_flags_sp->AddBooleanItem(
"live-stream",
m_live_stream);
589 config_sp->AddBooleanItem(
"filter-fall-through-accepts",
594 auto json_filter_rules_sp =
596 config_sp->AddItem(
"filter-rules", json_filter_rules_sp);
600 json_filter_rules_sp->AddItem(rule_sp->Serialize());
638 if (rule_text.empty()) {
664 auto action_end_pos = rule_text.find(
' ');
665 if (action_end_pos == std::string::npos) {
667 "action from \"%s\"",
668 rule_text.str().c_str());
671 auto action = rule_text.substr(0, action_end_pos);
673 if (action ==
"accept")
675 else if (action ==
"reject")
679 "filter action must be \"accept\" or \"deny\"");
684 auto attribute_end_pos = rule_text.find(
" ", action_end_pos + 1);
685 if (attribute_end_pos == std::string::npos) {
687 "attribute from \"%s\"",
688 rule_text.str().c_str());
691 auto attribute = rule_text.substr(action_end_pos + 1,
692 attribute_end_pos - (action_end_pos + 1));
694 if (attribute_index < 0) {
698 attribute.str().c_str());
703 auto operation_end_pos = rule_text.find(
" ", attribute_end_pos + 1);
704 auto operation = rule_text.substr(
705 attribute_end_pos + 1, operation_end_pos - (attribute_end_pos + 1));
709 accept, attribute_index, operation,
710 std::string(rule_text.substr(operation_end_pos + 1)),
error);
712 if (rule_sp &&
error.Success())
720 if (attribute_name == Item.value())
745 const char *help,
const char *syntax)
751 const char *source_name) {
761 stream.
Printf(
"darwin-log source settings specify to exclude "
762 "%s messages, but setting "
763 "'plugin.structured-data.darwin-log."
764 "strict-sources' is disabled. This process will "
765 "automatically have %s messages included. Enable"
766 " the property and relaunch the target binary to have"
767 " these messages excluded.",
768 source_name, source_name);
801 if (!process_sp->IsAlive()) {
809 if (!plugin_sp || (plugin_sp->GetPluginName() !=
811 result.
AppendError(
"failed to get StructuredDataPlugin for "
834 if (!
error.Success()) {
861 "Show whether Darwin log supported is available"
863 "plugin structured-data darwin-log status") {}
874 stream.PutCString(
"Availability: unknown (requires process)\n");
875 stream.PutCString(
"Enabled: not applicable "
876 "(requires process)\n");
880 stream.Printf(
"Availability: %s\n",
881 plugin_sp ?
"available" :
"unavailable");
883 plugin_sp ? plugin_sp->GetEnabled(
886 stream.Printf(
"Enabled: %s\n", enabled ?
"true" :
"false");
900 stream.PutCString(
"DarwinLog filter rules:\n");
904 if (options_sp->GetFilterRules().empty()) {
906 stream.PutCString(
"none\n");
910 for (
auto rule_sp : options_sp->GetFilterRules()) {
916 stream.Printf(
"%02d: ", rule_number);
917 rule_sp->Dump(stream);
918 stream.PutChar(
'\n');
925 stream.Printf(
"no-match behavior: %s\n",
926 options_sp->GetFallthroughAccepts() ?
"accept" :
"reject");
937 "Commands for configuring Darwin os_log "
941 auto enable_help =
"Enable Darwin log collection, or re-enable "
942 "with modified configuration.";
943 auto enable_syntax =
"plugin structured-data darwin-log enable";
947 "enable", enable_help, enable_syntax));
951 auto disable_help =
"Disable Darwin log collection.";
952 auto disable_syntax =
"plugin structured-data darwin-log disable";
956 "disable", disable_help, disable_syntax));
976 options_sp->NotifyOptionParsingStarting(&exe_ctx);
981 auto options_property_sp =
983 "plugin.structured-data.darwin-log."
984 "auto-enable-options",
986 if (!
error.Success())
988 if (!options_property_sp) {
990 "plugin.structured-data.darwin-log.");
994 const char *enable_options =
995 options_property_sp->GetAsString()->GetCurrentValue();
996 Args args(enable_options);
1001 if (first_arg && (strcmp(first_arg,
"--") == 0))
1005 bool require_validation =
false;
1006 llvm::Expected<Args> args_or =
1007 options_sp->Parse(args, &exe_ctx,
PlatformSP(), require_validation);
1010 log, args_or.takeError(),
1011 "Parsing plugin.structured-data.darwin-log.auto-enable-options value "
1016 if (!options_sp->VerifyOptions(result))
1026 command_stream <<
"plugin structured-data darwin-log enable";
1028 if (!enable_options.empty()) {
1029 command_stream <<
' ';
1030 command_stream << enable_options;
1043#pragma mark Public static API
1059#pragma mark StructuredDataPlugin API
1064 llvm::StringRef type_name) {
1069 Process &process, llvm::StringRef type_name,
1075 object_sp->Dump(json_stream);
1078 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called with json: %s",
1079 __FUNCTION__, json_stream.
GetData());
1085 "StructuredDataDarwinLog::%s() StructuredData object "
1094 "StructuredData type expected to be {0} but was {1}, ignoring",
1104 if (options_sp && options_sp->GetBroadcastEvents()) {
1105 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() broadcasting event",
1122 object.Dump(object_stream);
1123 object_stream.
Flush();
1148 llvm::StringRef type_name;
1159 object_sp->Dump(stream);
1168 "'events' field, expected to be an array",
1181 auto event =
object->GetAsDictionary();
1191 uint64_t timestamp = 0;
1192 if (event->GetValueForKeyAsInteger(
"timestamp", timestamp)) {
1219 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s called (process uid %u)",
1228 "StructuredDataDarwinLog::%s not applicable, we're not "
1229 "enabled (process uid %u)",
1239 "StructuredDataDarwinLog::%s process uid %u's "
1240 "post-libtrace-init breakpoint is already set",
1249 const char *logging_module_cstr =
1251 if (!logging_module_cstr || (logging_module_cstr[0] == 0)) {
1254 "StructuredDataDarwinLog::%s no logging module name "
1255 "specified, we don't know where to set a breakpoint "
1263 bool found_logging_support_module =
false;
1264 for (
size_t i = 0; i < module_list.
GetSize(); ++i) {
1269 auto &file_spec = module_sp->GetFileSpec();
1270 found_logging_support_module =
1271 (file_spec.GetFilename() == logging_module_cstr);
1272 if (found_logging_support_module)
1276 if (!found_logging_support_module) {
1278 "StructuredDataDarwinLog::%s logging module %s "
1279 "has not yet been loaded, can't set a breakpoint "
1280 "yet (process uid %u)",
1281 __FUNCTION__, logging_module_cstr, process.
GetUniqueID());
1289 "StructuredDataDarwinLog::%s post-init hook breakpoint "
1290 "set for logging module %s (process uid %u)",
1291 __FUNCTION__, logging_module_cstr, process.
GetUniqueID());
1316#pragma mark Private instance methods
1322 m_first_timestamp_seen(0), m_is_enabled(false),
1323 m_added_breakpoint_mutex(), m_added_breakpoint(),
1332 llvm::Triple::VendorType::Apple) {
1333 auto process_wp =
ProcessWP(process.shared_from_this());
1346 llvm::StringRef parent_command_text =
"plugin structured-data";
1347 auto parent_command =
1349 if (!parent_command) {
1355 auto command_name =
"darwin-log";
1357 bool result = parent_command->LoadSubCommand(command_name, command_sp);
1364 const bool is_global_setting =
true;
1367 "Properties for the darwin-log plug-in.", is_global_setting);
1395 if (triple.getVendor() != llvm::Triple::Apple) {
1420 if (!options_sp && debugger_sp) {
1422 if (!options_sp || !
error.Success())
1430 if (!options_sp->GetEchoToStdErr()) {
1442 launch_info.
GetEnvironment()[
"IDE_DISABLED_OS_ACTIVITY_DT_MODE"] =
"1";
1447 const char *env_var_value;
1448 if (options_sp->GetIncludeDebugLevel())
1449 env_var_value =
"debug";
1450 else if (options_sp->GetIncludeInfoLevel())
1451 env_var_value =
"info";
1453 env_var_value =
"default";
1455 launch_info.
GetEnvironment()[
"OS_ACTIVITY_MODE"] = env_var_value;
1469 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called", __FUNCTION__);
1474 "StructuredDataDarwinLog::%s() warning: no context, "
1484 "StructuredDataDarwinLog::%s() warning: invalid "
1485 "process in context, ignoring",
1489 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() call is for process uid %d",
1490 __FUNCTION__, process_sp->GetUniqueID());
1494 LLDB_LOG(log,
"warning: no plugin for feature {0} in process uid {1}",
1500 bool called_enable_method =
false;
1501 const auto process_uid = process_sp->GetUniqueID();
1503 std::weak_ptr<StructuredDataPlugin> plugin_wp(plugin_sp);
1505 [plugin_wp, &called_enable_method, log, process_uid]() {
1507 "StructuredDataDarwinLog::post-init callback: "
1508 "called (process uid %u)",
1511 auto strong_plugin_sp = plugin_wp.lock();
1512 if (!strong_plugin_sp) {
1514 "StructuredDataDarwinLog::post-init callback: "
1515 "plugin no longer exists, ignoring (process "
1522 if (!called_enable_method) {
1524 "StructuredDataDarwinLog::post-init callback: "
1525 "calling EnableNow() (process uid %u)",
1529 called_enable_method =
true;
1534 "StructuredDataDarwinLog::post-init callback: "
1535 "skipping EnableNow(), already called by "
1536 "callback [we hit this more than once] "
1546 "StructuredDataDarwinLog::%s() warning: failed to "
1547 "retrieve the current thread from the execution "
1548 "context, nowhere to run the thread plan (process uid "
1550 __FUNCTION__, process_sp->GetUniqueID());
1555 auto thread_plan_sp =
1557 const bool abort_other_plans =
false;
1558 thread_sp->QueueThreadPlan(thread_plan_sp, abort_other_plans);
1560 "StructuredDataDarwinLog::%s() queuing thread plan on "
1561 "trace library init method entry (process uid %u)",
1562 __FUNCTION__, process_sp->GetUniqueID());
1570 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called (process uid %u)",
1578 "StructuredDataDarwinLog::%s() ignoring request, "
1579 "breakpoint already set (process uid %u)",
1594 auto module_file_spec =
1596 module_spec_list.
Append(module_file_spec);
1601 const char *func_name =
"_libtrace_init";
1605 const bool internal =
true;
1606 const bool hardware =
false;
1609 &module_spec_list, source_spec_list, func_name, eFunctionNameTypeFull,
1611 if (!breakpoint_sp) {
1614 "StructuredDataDarwinLog::%s() failed to set "
1615 "breakpoint in module %s, function %s (process uid %u)",
1625 "StructuredDataDarwinLog::%s() breakpoint set in module %s,"
1626 "function %s (process uid %u)",
1632 uint64_t timestamp) {
1644 stream.
Printf(
"%02" PRIu64
":%02" PRIu64
":%02" PRIu64
".%09" PRIu64, hours,
1645 minutes, seconds, nanos_remaining);
1660 process_sp->GetTarget().GetDebugger().shared_from_this();
1673 if (!options_sp->GetDisplayAnyHeaderFields())
1678 int header_count = 0;
1679 if (options_sp->GetDisplayTimestampRelative()) {
1680 uint64_t timestamp = 0;
1687 if (options_sp->GetDisplayActivityChain()) {
1688 llvm::StringRef activity_chain;
1690 !activity_chain.empty()) {
1691 if (header_count > 0)
1702 if (options_sp->GetDisplaySubsystem()) {
1703 llvm::StringRef subsystem;
1705 !subsystem.empty()) {
1706 if (header_count > 0)
1714 if (options_sp->GetDisplayCategory()) {
1715 llvm::StringRef category;
1717 !category.empty()) {
1718 if (header_count > 0)
1735 llvm::StringRef event_type;
1745 size_t total_bytes = 0;
1748 llvm::StringRef message;
1753 const auto len = message.size();
1757 stream.
Write(message.data(), len);
1762 total_bytes +=
sizeof(char);
1769 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called", __FUNCTION__);
1776 "StructuredDataDarwinLog::%s() warning: failed to get "
1777 "valid process, skipping",
1781 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() call is for process uid %u",
1782 __FUNCTION__, process_sp->GetUniqueID());
1789 process_sp->GetTarget().GetDebugger().shared_from_this();
1792 "StructuredDataDarwinLog::%s() warning: failed to get "
1793 "debugger shared pointer, skipping (process uid %u)",
1794 __FUNCTION__, process_sp->GetUniqueID());
1802 auto &interpreter = debugger_sp->GetCommandInterpreter();
1807 "StructuredDataDarwinLog::%s() ran enable command "
1808 "successfully for (process uid %u)",
1809 __FUNCTION__, process_sp->GetUniqueID());
1812 "StructuredDataDarwinLog::%s() error: running "
1813 "enable command failed (process uid %u)",
1814 __FUNCTION__, process_sp->GetUniqueID());
1817 debugger_sp->GetID());
1823 auto config_sp = options_sp->BuildConfigurationData(
true);
1826 "StructuredDataDarwinLog::%s() warning: failed to "
1827 "build configuration data for enable options, skipping "
1829 __FUNCTION__, process_sp->GetUniqueID());
1839 if (!
error.Success()) {
1841 "StructuredDataDarwinLog::%s() "
1842 "ConfigureStructuredData() call failed "
1843 "(process uid %u): %s",
1844 __FUNCTION__, process_sp->GetUniqueID(),
error.AsCString());
1846 debugger_sp->GetID());
1851 "StructuredDataDarwinLog::%s() success via direct "
1852 "configuration (process uid %u)",
1853 __FUNCTION__, process_sp->GetUniqueID());
static llvm::raw_ostream & error(Stream &strm)
static DynamicLoaderDarwinKernelProperties & GetGlobalProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
static void SetErrorWithJSON(Status &error, const char *message, StructuredData::Object &object)
llvm::Triple & GetTriple()
Architecture triple accessor.
A command line argument class.
void Shift()
Shifts the first argument C string value of the array off the argument array.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
bool HandleCommand(const char *command_line, LazyBool add_to_history, const ExecutionContext &override_context, CommandReturnObject &result)
CommandObject * GetCommandObjectForCommand(llvm::StringRef &command_line)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandInterpreter & GetCommandInterpreter()
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void void AppendWarning(llvm::StringRef in_string)
Stream & GetOutputStream()
A class to manage flag bits.
CommandInterpreter & GetCommandInterpreter()
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
lldb::ThreadSP GetThreadSP() const
Get accessor that creates a strong reference from the weak thread reference contained in this object.
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
bool AnySet(ValueType mask) const
Test one or more flags.
A collection class for Module objects.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
size_t GetSize() const
Gets the size of the module list.
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForStructuredDataPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool UnregisterPlugin(ABICreateInstance create_callback)
Environment & GetEnvironment()
ArchSpec & GetArchitecture()
A plug-in interface definition class for debugging a process.
void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp)
Broadcasts the given structured data object from the given plugin.
uint32_t GetUniqueID() const
Target & GetTarget()
Get the target object pointer for this module.
lldb::OptionValuePropertiesSP m_collection_sp
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, Status &error) const
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
const char * GetData() const
void Flush() override
Flush the stream.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
virtual void Flush()=0
Flush the stream.
Status GetDescription(const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) override
Get a human-readable description of the contents of the data.
static void DebuggerInitialize(Debugger &debugger)
lldb::user_id_t m_breakpoint_id
void DumpTimestamp(Stream &stream, uint64_t timestamp)
static bool InitCompletionHookCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
void AddInitCompletionHook(Process &process)
StructuredDataDarwinLog(const lldb::ProcessWP &process_wp)
std::mutex m_added_breakpoint_mutex
size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event, Stream &stream)
void HandleArrivalOfStructuredData(Process &process, llvm::StringRef type_name, const StructuredData::ObjectSP &object_sp) override
Handle the arrival of asynchronous structured data from the process.
static lldb::StructuredDataPluginSP CreateInstance(Process &process)
bool m_recorded_first_timestamp
static llvm::StringRef GetStaticPluginName()
static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info, Target *target)
void EnableNow()
Call the enable command again, using whatever settings were initially made.
size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event)
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
void SetEnabled(bool enabled)
bool GetEnabled(llvm::StringRef type_name) const override
Returns whether the plugin's features are enabled.
bool SupportsStructuredDataType(llvm::StringRef type_name) override
Return whether this plugin supports the given StructuredData feature.
uint64_t m_first_timestamp_seen
Plugin that supports process-related structured data sent asynchronously from the debug monitor (e....
lldb::ProcessSP GetProcess() const
static void InitializeBasePluginForDebugger(Debugger &debugger)
Derived classes must call this before attempting to hook up commands to the 'plugin structured-data' ...
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
void AddBooleanItem(llvm::StringRef key, bool value)
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
void AddStringItem(llvm::StringRef key, llvm::StringRef value)
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
Dictionary * GetAsDictionary()
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< Array > ArraySP
const lldb::ProcessSP & GetProcessSP() const
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
const ArchSpec & GetArchitecture() const
This thread plan calls a function object when the current function exits.
std::function< void()> Callback
Definition for the callback made when the currently executing thread finishes executing its function.
Provides the darwin-log base command.
BaseCommand(CommandInterpreter &interpreter)
EnableCommand(CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax)
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
void AppendStrictSourcesWarning(CommandReturnObject &result, const char *source_name)
EnableOptionsSP m_options_sp
bool GetDisplayActivityChain() const
Status ParseFilterRule(llvm::StringRef rule_text)
bool GetDisplayTimestampRelative() const
bool GetEchoToStdErr() const
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
bool GetIncludeInfoLevel() const
bool GetDisplaySubsystem() const
bool m_include_info_level
int MatchAttributeIndex(llvm::StringRef attribute_name) const
bool GetBroadcastEvents() const
bool m_include_any_process
bool m_filter_fall_through_accepts
const FilterRules & GetFilterRules() const
bool m_include_debug_level
bool m_display_timestamp_relative
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
FilterRules m_filter_rules
StructuredData::DictionarySP BuildConfigurationData(bool enabled)
bool m_display_activity_chain
bool GetFallthroughAccepts() const
void OptionParsingStarting(ExecutionContext *execution_context) override
bool GetDisplayAnyHeaderFields() const
bool GetIncludeDebugLevel() const
bool GetDisplayCategory() const
const std::string m_match_text
static llvm::StringRef StaticGetOperation()
static void RegisterOperation()
static FilterRuleSP CreateOperation(bool accept, size_t attribute_index, const std::string &op_arg, Status &error)
void DoSerialization(StructuredData::Dictionary &dict) const override
void Dump(Stream &stream) const override
ExactMatchFilterRule(bool accept, size_t attribute_index, const std::string &match_text)
virtual ~FilterRule()=default
static void RegisterOperation(llvm::StringRef operation, const OperationCreationFunc &creation_func)
bool GetMatchAccepts() const
static CreationFuncMap & GetCreationFuncMap()
llvm::StringMap< OperationCreationFunc > CreationFuncMap
llvm::StringRef GetOperationType() const
FilterRule(bool accept, size_t attribute_index, llvm::StringRef operation)
virtual void Dump(Stream &stream) const =0
const char * GetFilterAttribute() const
virtual void DoSerialization(StructuredData::Dictionary &dict) const =0
static FilterRuleSP CreateRule(bool match_accepts, size_t attribute, llvm::StringRef operation, const std::string &op_arg, Status &error)
StructuredData::ObjectSP Serialize() const
const llvm::StringRef m_operation
const size_t m_attribute_index
std::function< FilterRuleSP(bool accept, size_t attribute_index, const std::string &op_arg, Status &error)> OperationCreationFunc
static llvm::StringRef StaticGetOperation()
static void RegisterOperation()
const std::string m_regex_text
static FilterRuleSP CreateOperation(bool accept, size_t attribute_index, const std::string &op_arg, Status &error)
void DoSerialization(StructuredData::Dictionary &dict) const override
RegexFilterRule(bool accept, size_t attribute_index, const std::string ®ex_text)
void Dump(Stream &stream) const override
Provides the status command.
StatusCommand(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
static llvm::StringRef GetSettingName()
const char * GetLoggingModuleName() const
StructuredDataDarwinLogProperties()
bool GetEnableOnStartup() const
llvm::StringRef GetAutoEnableOptions() const
~StructuredDataDarwinLogProperties() override=default
#define LLDB_INVALID_BREAK_ID
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::Platform > PlatformSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::StructuredDataPlugin > StructuredDataPluginSP
std::weak_ptr< lldb_private::Debugger > DebuggerWP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
std::weak_ptr< lldb_private::Process > ProcessWP
const uint64_t NANOS_PER_MILLI
EnableOptionsSP GetGlobalEnableOptions(const DebuggerSP &debugger_sp)
std::map< DebuggerWP, EnableOptionsSP, std::owner_less< DebuggerWP > > OptionsMap
const uint64_t NANOS_PER_SECOND
static OptionsMap & GetGlobalOptionsMap()
const char *const s_filter_attributes[]
bool RunEnableCommand(CommandInterpreter &interpreter)
static llvm::StringRef GetLogEventType()
void SetGlobalEnableOptions(const DebuggerSP &debugger_sp, const EnableOptionsSP &options_sp)
static bool s_is_explicitly_enabled
Global, sticky enable switch.
const uint64_t NANOS_PER_HOUR
static bool DEFAULT_FILTER_FALLTHROUGH_ACCEPTS
static std::mutex & GetGlobalOptionsMapLock()
const uint64_t NANOS_PER_MINUTE
std::shared_ptr< FilterRule > FilterRuleSP
const uint64_t NANOS_PER_MICRO
static llvm::StringRef GetDarwinLogTypeName()
std::vector< FilterRuleSP > FilterRules
std::shared_ptr< EnableOptions > EnableOptionsSP
static constexpr OptionDefinition g_enable_option_table[]
Provides the main on-off switch for enabling darwin logging.
static StructuredDataDarwinLogProperties & GetGlobalProperties()
static void RegisterFilterOperations()
EnableOptionsSP ParseAutoEnableOptions(Status &error, Debugger &debugger)
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)