diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-16 19:47:58 +0000 |
commit | b76161e41bc2c07cd47f9c61f875d1be95e26d10 (patch) | |
tree | d03c19ce10dec6419f97df1d4dac9d47eb88982f /source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp | |
parent | 8b4000f13b303cc154136abc74c55670673e2a96 (diff) |
Notes
Diffstat (limited to 'source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp')
-rw-r--r-- | source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 041d827d526b..f1450c31b36b 100644 --- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -209,7 +209,7 @@ public: using OperationCreationFunc = std::function<FilterRuleSP(bool accept, size_t attribute_index, - const std::string &op_arg, Error &error)>; + const std::string &op_arg, Status &error)>; static void RegisterOperation(const ConstString &operation, const OperationCreationFunc &creation_func) { @@ -218,7 +218,7 @@ public: static FilterRuleSP CreateRule(bool match_accepts, size_t attribute, const ConstString &operation, - const std::string &op_arg, Error &error) { + const std::string &op_arg, Status &error) { // Find the creation func for this type of filter rule. auto map = GetCreationFuncMap(); auto find_it = map.find(operation); @@ -304,7 +304,8 @@ protected: private: static FilterRuleSP CreateOperation(bool accept, size_t attribute_index, - const std::string &op_arg, Error &error) { + const std::string &op_arg, + Status &error) { // We treat the op_arg as a regex. Validate it. if (op_arg.empty()) { error.SetErrorString("regex filter type requires a regex " @@ -358,7 +359,8 @@ protected: private: static FilterRuleSP CreateOperation(bool accept, size_t attribute_index, - const std::string &op_arg, Error &error) { + const std::string &op_arg, + Status &error) { if (op_arg.empty()) { error.SetErrorString("exact match filter type requires an " "argument containing the text that must " @@ -524,9 +526,9 @@ public: m_filter_rules.clear(); } - Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, - ExecutionContext *execution_context) override { - Error error; + Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, + ExecutionContext *execution_context) override { + Status error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { @@ -664,8 +666,8 @@ public: bool GetBroadcastEvents() const { return m_broadcast_events; } private: - Error ParseFilterRule(llvm::StringRef rule_text) { - Error error; + Status ParseFilterRule(llvm::StringRef rule_text) { + Status error; if (rule_text.empty()) { error.SetErrorString("invalid rule_text"); @@ -899,7 +901,7 @@ protected: // Send configuration to the feature by way of the process. // Construct the options we will use. auto config_sp = m_options_sp->BuildConfigurationData(m_enable); - const Error error = + const Status error = process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp); // Report results. @@ -1040,7 +1042,7 @@ public: } }; -EnableOptionsSP ParseAutoEnableOptions(Error &error, Debugger &debugger) { +EnableOptionsSP ParseAutoEnableOptions(Status &error, Debugger &debugger) { // We are abusing the options data model here so that we can parse // options without requiring the Debugger instance. @@ -1212,7 +1214,7 @@ void StructuredDataDarwinLog::HandleArrivalOfStructuredData( // to inspect, including showing backtraces. } -static void SetErrorWithJSON(Error &error, const char *message, +static void SetErrorWithJSON(Status &error, const char *message, StructuredData::Object &object) { if (!message) { error.SetErrorString("Internal error: message not set."); @@ -1226,9 +1228,9 @@ static void SetErrorWithJSON(Error &error, const char *message, error.SetErrorStringWithFormat("%s: %s", message, object_stream.GetData()); } -Error StructuredDataDarwinLog::GetDescription( +Status StructuredDataDarwinLog::GetDescription( const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) { - Error error; + Status error; if (!object_sp) { error.SetErrorString("No structured data."); @@ -1483,9 +1485,9 @@ void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) { } } -Error StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info, - Target *target) { - Error error; +Status StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info, + Target *target) { + Status error; // If we're not debugging this launched process, there's nothing for us // to do here. @@ -1815,7 +1817,7 @@ StructuredDataDarwinLog::DumpHeader(Stream &output_stream, } if (options_sp->GetDisplayActivityChain()) { - std::string activity_chain; + llvm::StringRef activity_chain; if (event.GetValueForKeyAsString("activity-chain", activity_chain) && !activity_chain.empty()) { if (header_count > 0) @@ -1854,7 +1856,7 @@ StructuredDataDarwinLog::DumpHeader(Stream &output_stream, } if (options_sp->GetDisplaySubsystem()) { - std::string subsystem; + llvm::StringRef subsystem; if (event.GetValueForKeyAsString("subsystem", subsystem) && !subsystem.empty()) { if (header_count > 0) @@ -1866,7 +1868,7 @@ StructuredDataDarwinLog::DumpHeader(Stream &output_stream, } if (options_sp->GetDisplayCategory()) { - std::string category; + llvm::StringRef category; if (event.GetValueForKeyAsString("category", category) && !category.empty()) { if (header_count > 0) @@ -1899,16 +1901,16 @@ size_t StructuredDataDarwinLog::HandleDisplayOfEvent( size_t total_bytes = 0; // Grab the message content. - std::string message; + llvm::StringRef message; if (!event.GetValueForKeyAsString("message", message)) return true; // Display the log entry. - const auto len = message.length(); + const auto len = message.size(); total_bytes += DumpHeader(stream, event); - stream.Write(message.c_str(), len); + stream.Write(message.data(), len); total_bytes += len; // Add an end of line. @@ -1991,7 +1993,7 @@ void StructuredDataDarwinLog::EnableNow() { // We can run it directly. // Send configuration to the feature by way of the process. - const Error error = + const Status error = process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp); // Report results. |