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()) {
200 error.SetErrorStringWithFormatv(
"unknown filter operation \"{0}\"",
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()) {
284 error.SetErrorString(
"regex filter type requires a regex "
291 if (llvm::Error err = regex.GetError()) {
292 error.SetErrorString(llvm::toString(std::move(err)));
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()) {
335 error.SetErrorString(
"exact match filter type requires an "
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) {
556 error.SetErrorStringWithFormat(
"unsupported option '%c'", short_option);
569 config_sp->AddBooleanItem(
"enabled", enabled);
576 auto source_flags_sp =
578 config_sp->AddItem(
"source-flags", source_flags_sp);
585 source_flags_sp->AddBooleanItem(
"live-stream",
m_live_stream);
588 config_sp->AddBooleanItem(
"filter-fall-through-accepts",
593 auto json_filter_rules_sp =
595 config_sp->AddItem(
"filter-rules", json_filter_rules_sp);
599 json_filter_rules_sp->AddItem(rule_sp->Serialize());
637 if (rule_text.empty()) {
638 error.SetErrorString(
"invalid rule_text");
663 auto action_end_pos = rule_text.find(
' ');
664 if (action_end_pos == std::string::npos) {
665 error.SetErrorStringWithFormat(
"could not parse filter rule "
666 "action from \"%s\"",
667 rule_text.str().c_str());
670 auto action = rule_text.substr(0, action_end_pos);
672 if (action ==
"accept")
674 else if (action ==
"reject")
677 error.SetErrorString(
"filter action must be \"accept\" or \"deny\"");
682 auto attribute_end_pos = rule_text.find(
" ", action_end_pos + 1);
683 if (attribute_end_pos == std::string::npos) {
684 error.SetErrorStringWithFormat(
"could not parse filter rule "
685 "attribute from \"%s\"",
686 rule_text.str().c_str());
689 auto attribute = rule_text.substr(action_end_pos + 1,
690 attribute_end_pos - (action_end_pos + 1));
692 if (attribute_index < 0) {
693 error.SetErrorStringWithFormat(
"filter rule attribute unknown: "
695 attribute.str().c_str());
700 auto operation_end_pos = rule_text.find(
" ", attribute_end_pos + 1);
701 auto operation = rule_text.substr(
702 attribute_end_pos + 1, operation_end_pos - (attribute_end_pos + 1));
706 accept, attribute_index, operation,
707 std::string(rule_text.substr(operation_end_pos + 1)),
error);
709 if (rule_sp &&
error.Success())
717 if (attribute_name == Item.value())
742 const char *help,
const char *syntax)
748 const char *source_name) {
758 stream.
Printf(
"darwin-log source settings specify to exclude "
759 "%s messages, but setting "
760 "'plugin.structured-data.darwin-log."
761 "strict-sources' is disabled. This process will "
762 "automatically have %s messages included. Enable"
763 " the property and relaunch the target binary to have"
764 " these messages excluded.",
765 source_name, source_name);
798 if (!process_sp->IsAlive()) {
806 if (!plugin_sp || (plugin_sp->GetPluginName() !=
808 result.
AppendError(
"failed to get StructuredDataPlugin for "
831 if (!
error.Success()) {
858 "Show whether Darwin log supported is available"
860 "plugin structured-data darwin-log status") {}
871 stream.PutCString(
"Availability: unknown (requires process)\n");
872 stream.PutCString(
"Enabled: not applicable "
873 "(requires process)\n");
877 stream.Printf(
"Availability: %s\n",
878 plugin_sp ?
"available" :
"unavailable");
880 plugin_sp ? plugin_sp->GetEnabled(
883 stream.Printf(
"Enabled: %s\n", enabled ?
"true" :
"false");
897 stream.PutCString(
"DarwinLog filter rules:\n");
901 if (options_sp->GetFilterRules().empty()) {
903 stream.PutCString(
"none\n");
907 for (
auto rule_sp : options_sp->GetFilterRules()) {
913 stream.Printf(
"%02d: ", rule_number);
914 rule_sp->Dump(stream);
915 stream.PutChar(
'\n');
922 stream.Printf(
"no-match behavior: %s\n",
923 options_sp->GetFallthroughAccepts() ?
"accept" :
"reject");
934 "Commands for configuring Darwin os_log "
938 auto enable_help =
"Enable Darwin log collection, or re-enable "
939 "with modified configuration.";
940 auto enable_syntax =
"plugin structured-data darwin-log enable";
944 "enable", enable_help, enable_syntax));
948 auto disable_help =
"Disable Darwin log collection.";
949 auto disable_syntax =
"plugin structured-data darwin-log disable";
953 "disable", disable_help, disable_syntax));
973 options_sp->NotifyOptionParsingStarting(&exe_ctx);
978 auto options_property_sp =
980 "plugin.structured-data.darwin-log."
981 "auto-enable-options",
983 if (!
error.Success())
985 if (!options_property_sp) {
986 error.SetErrorString(
"failed to find option setting for "
987 "plugin.structured-data.darwin-log.");
991 const char *enable_options =
992 options_property_sp->GetAsString()->GetCurrentValue();
993 Args args(enable_options);
998 if (first_arg && (strcmp(first_arg,
"--") == 0))
1002 bool require_validation =
false;
1003 llvm::Expected<Args> args_or =
1004 options_sp->Parse(args, &exe_ctx,
PlatformSP(), require_validation);
1007 log, args_or.takeError(),
1008 "Parsing plugin.structured-data.darwin-log.auto-enable-options value "
1013 if (!options_sp->VerifyOptions(result))
1023 command_stream <<
"plugin structured-data darwin-log enable";
1025 if (!enable_options.empty()) {
1026 command_stream <<
' ';
1027 command_stream << enable_options;
1040#pragma mark Public static API
1056#pragma mark StructuredDataPlugin API
1061 llvm::StringRef type_name) {
1066 Process &process, llvm::StringRef type_name,
1072 object_sp->Dump(json_stream);
1075 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called with json: %s",
1076 __FUNCTION__, json_stream.
GetData());
1082 "StructuredDataDarwinLog::%s() StructuredData object "
1091 "StructuredData type expected to be {0} but was {1}, ignoring",
1101 if (options_sp && options_sp->GetBroadcastEvents()) {
1102 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() broadcasting event",
1114 error.SetErrorString(
"Internal error: message not set.");
1119 object.Dump(object_stream);
1120 object_stream.
Flush();
1122 error.SetErrorStringWithFormat(
"%s: %s", message, object_stream.
GetData());
1130 error.SetErrorString(
"No structured data.");
1144 llvm::StringRef type_name;
1155 object_sp->Dump(stream);
1164 "'events' field, expected to be an array",
1177 auto event =
object->GetAsDictionary();
1187 uint64_t timestamp = 0;
1188 if (event->GetValueForKeyAsInteger(
"timestamp", timestamp)) {
1215 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s called (process uid %u)",
1224 "StructuredDataDarwinLog::%s not applicable, we're not "
1225 "enabled (process uid %u)",
1235 "StructuredDataDarwinLog::%s process uid %u's "
1236 "post-libtrace-init breakpoint is already set",
1245 const char *logging_module_cstr =
1247 if (!logging_module_cstr || (logging_module_cstr[0] == 0)) {
1250 "StructuredDataDarwinLog::%s no logging module name "
1251 "specified, we don't know where to set a breakpoint "
1259 bool found_logging_support_module =
false;
1260 for (
size_t i = 0; i < module_list.
GetSize(); ++i) {
1265 auto &file_spec = module_sp->GetFileSpec();
1266 found_logging_support_module =
1267 (file_spec.GetFilename() == logging_module_cstr);
1268 if (found_logging_support_module)
1272 if (!found_logging_support_module) {
1274 "StructuredDataDarwinLog::%s logging module %s "
1275 "has not yet been loaded, can't set a breakpoint "
1276 "yet (process uid %u)",
1277 __FUNCTION__, logging_module_cstr, process.
GetUniqueID());
1285 "StructuredDataDarwinLog::%s post-init hook breakpoint "
1286 "set for logging module %s (process uid %u)",
1287 __FUNCTION__, logging_module_cstr, process.
GetUniqueID());
1312#pragma mark Private instance methods
1318 m_first_timestamp_seen(0), m_is_enabled(false),
1319 m_added_breakpoint_mutex(), m_added_breakpoint(),
1328 llvm::Triple::VendorType::Apple) {
1329 auto process_wp =
ProcessWP(process.shared_from_this());
1342 llvm::StringRef parent_command_text =
"plugin structured-data";
1343 auto parent_command =
1345 if (!parent_command) {
1351 auto command_name =
"darwin-log";
1353 bool result = parent_command->LoadSubCommand(command_name, command_sp);
1360 const bool is_global_setting =
true;
1363 "Properties for the darwin-log plug-in.", is_global_setting);
1391 if (triple.getVendor() != llvm::Triple::Apple) {
1409 error.SetErrorString(
"requires a target to auto-enable DarwinLog.");
1415 if (!options_sp && debugger_sp) {
1417 if (!options_sp || !
error.Success())
1425 if (!options_sp->GetEchoToStdErr()) {
1437 launch_info.
GetEnvironment()[
"IDE_DISABLED_OS_ACTIVITY_DT_MODE"] =
"1";
1442 const char *env_var_value;
1443 if (options_sp->GetIncludeDebugLevel())
1444 env_var_value =
"debug";
1445 else if (options_sp->GetIncludeInfoLevel())
1446 env_var_value =
"info";
1448 env_var_value =
"default";
1450 launch_info.
GetEnvironment()[
"OS_ACTIVITY_MODE"] = env_var_value;
1464 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called", __FUNCTION__);
1469 "StructuredDataDarwinLog::%s() warning: no context, "
1479 "StructuredDataDarwinLog::%s() warning: invalid "
1480 "process in context, ignoring",
1484 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() call is for process uid %d",
1485 __FUNCTION__, process_sp->GetUniqueID());
1489 LLDB_LOG(log,
"warning: no plugin for feature {0} in process uid {1}",
1495 bool called_enable_method =
false;
1496 const auto process_uid = process_sp->GetUniqueID();
1498 std::weak_ptr<StructuredDataPlugin> plugin_wp(plugin_sp);
1500 [plugin_wp, &called_enable_method, log, process_uid]() {
1502 "StructuredDataDarwinLog::post-init callback: "
1503 "called (process uid %u)",
1506 auto strong_plugin_sp = plugin_wp.lock();
1507 if (!strong_plugin_sp) {
1509 "StructuredDataDarwinLog::post-init callback: "
1510 "plugin no longer exists, ignoring (process "
1517 if (!called_enable_method) {
1519 "StructuredDataDarwinLog::post-init callback: "
1520 "calling EnableNow() (process uid %u)",
1524 called_enable_method =
true;
1529 "StructuredDataDarwinLog::post-init callback: "
1530 "skipping EnableNow(), already called by "
1531 "callback [we hit this more than once] "
1541 "StructuredDataDarwinLog::%s() warning: failed to "
1542 "retrieve the current thread from the execution "
1543 "context, nowhere to run the thread plan (process uid "
1545 __FUNCTION__, process_sp->GetUniqueID());
1550 auto thread_plan_sp =
1552 const bool abort_other_plans =
false;
1553 thread_sp->QueueThreadPlan(thread_plan_sp, abort_other_plans);
1555 "StructuredDataDarwinLog::%s() queuing thread plan on "
1556 "trace library init method entry (process uid %u)",
1557 __FUNCTION__, process_sp->GetUniqueID());
1565 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called (process uid %u)",
1573 "StructuredDataDarwinLog::%s() ignoring request, "
1574 "breakpoint already set (process uid %u)",
1589 auto module_file_spec =
1591 module_spec_list.
Append(module_file_spec);
1596 const char *func_name =
"_libtrace_init";
1600 const bool internal =
true;
1601 const bool hardware =
false;
1604 &module_spec_list, source_spec_list, func_name, eFunctionNameTypeFull,
1606 if (!breakpoint_sp) {
1609 "StructuredDataDarwinLog::%s() failed to set "
1610 "breakpoint in module %s, function %s (process uid %u)",
1620 "StructuredDataDarwinLog::%s() breakpoint set in module %s,"
1621 "function %s (process uid %u)",
1627 uint64_t timestamp) {
1639 stream.
Printf(
"%02" PRIu64
":%02" PRIu64
":%02" PRIu64
".%09" PRIu64, hours,
1640 minutes, seconds, nanos_remaining);
1655 process_sp->GetTarget().GetDebugger().shared_from_this();
1668 if (!options_sp->GetDisplayAnyHeaderFields())
1673 int header_count = 0;
1674 if (options_sp->GetDisplayTimestampRelative()) {
1675 uint64_t timestamp = 0;
1682 if (options_sp->GetDisplayActivityChain()) {
1683 llvm::StringRef activity_chain;
1685 !activity_chain.empty()) {
1686 if (header_count > 0)
1697 if (options_sp->GetDisplaySubsystem()) {
1698 llvm::StringRef subsystem;
1700 !subsystem.empty()) {
1701 if (header_count > 0)
1709 if (options_sp->GetDisplayCategory()) {
1710 llvm::StringRef category;
1712 !category.empty()) {
1713 if (header_count > 0)
1730 llvm::StringRef event_type;
1740 size_t total_bytes = 0;
1743 llvm::StringRef message;
1748 const auto len = message.size();
1752 stream.
Write(message.data(), len);
1757 total_bytes +=
sizeof(char);
1764 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() called", __FUNCTION__);
1771 "StructuredDataDarwinLog::%s() warning: failed to get "
1772 "valid process, skipping",
1776 LLDB_LOGF(log,
"StructuredDataDarwinLog::%s() call is for process uid %u",
1777 __FUNCTION__, process_sp->GetUniqueID());
1784 process_sp->GetTarget().GetDebugger().shared_from_this();
1787 "StructuredDataDarwinLog::%s() warning: failed to get "
1788 "debugger shared pointer, skipping (process uid %u)",
1789 __FUNCTION__, process_sp->GetUniqueID());
1797 auto &interpreter = debugger_sp->GetCommandInterpreter();
1802 "StructuredDataDarwinLog::%s() ran enable command "
1803 "successfully for (process uid %u)",
1804 __FUNCTION__, process_sp->GetUniqueID());
1807 "StructuredDataDarwinLog::%s() error: running "
1808 "enable command failed (process uid %u)",
1809 __FUNCTION__, process_sp->GetUniqueID());
1812 debugger_sp->GetID());
1818 auto config_sp = options_sp->BuildConfigurationData(
true);
1821 "StructuredDataDarwinLog::%s() warning: failed to "
1822 "build configuration data for enable options, skipping "
1824 __FUNCTION__, process_sp->GetUniqueID());
1834 if (!
error.Success()) {
1836 "StructuredDataDarwinLog::%s() "
1837 "ConfigureStructuredData() call failed "
1838 "(process uid %u): %s",
1839 __FUNCTION__, process_sp->GetUniqueID(),
error.AsCString());
1841 debugger_sp->GetID());
1846 "StructuredDataDarwinLog::%s() success via direct "
1847 "configuration (process uid %u)",
1848 __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
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)