diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2022-06-23 08:06:17 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2022-06-23 09:12:01 -0700 |
commit | 09dea546692f4e9f32bf16f1a9d5d0de52a64691 (patch) | |
tree | 79140cde59821f85766befc35340715c99e590b3 /lldb/source/Commands/CommandObjectLog.cpp | |
parent | 734ad031f16653f1b650d2ea8b7d83e8910925b3 (diff) | |
download | llvm-09dea546692f4e9f32bf16f1a9d5d0de52a64691.zip llvm-09dea546692f4e9f32bf16f1a9d5d0de52a64691.tar.gz llvm-09dea546692f4e9f32bf16f1a9d5d0de52a64691.tar.bz2 |
[lldb] Support a buffered logging mode
This patch adds a buffered logging mode to lldb. A buffer size can be
passed to `log enable` with the -b flag. If no buffer size is specified,
logging is unbuffered.
Differential revision: https://reviews.llvm.org/D127986
Diffstat (limited to 'lldb/source/Commands/CommandObjectLog.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectLog.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index c8df308..190b262 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -11,6 +11,7 @@ #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionArgParser.h" +#include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/FileSpec.h" @@ -21,7 +22,7 @@ using namespace lldb; using namespace lldb_private; -#define LLDB_OPTIONS_log +#define LLDB_OPTIONS_log_enable #include "CommandOptions.inc" /// Common completion logic for log enable/disable. @@ -89,6 +90,10 @@ public: log_file.SetFile(option_arg, FileSpec::Style::native); FileSystem::Instance().Resolve(log_file); break; + case 'b': + error = + buffer_size.SetValueFromString(option_arg, eVarSetOperationAssign); + break; case 't': log_options |= LLDB_LOG_OPTION_THREADSAFE; break; @@ -125,16 +130,16 @@ public: void OptionParsingStarting(ExecutionContext *execution_context) override { log_file.Clear(); + buffer_size.Clear(); log_options = 0; } llvm::ArrayRef<OptionDefinition> GetDefinitions() override { - return llvm::makeArrayRef(g_log_options); + return llvm::makeArrayRef(g_log_enable_options); } - // Instance variables to hold the values for command options. - FileSpec log_file; + OptionValueUInt64 buffer_size; uint32_t log_options = 0; }; @@ -164,9 +169,9 @@ protected: std::string error; llvm::raw_string_ostream error_stream(error); - bool success = - GetDebugger().EnableLog(channel, args.GetArgumentArrayRef(), log_file, - m_options.log_options, error_stream); + bool success = GetDebugger().EnableLog( + channel, args.GetArgumentArrayRef(), log_file, m_options.log_options, + m_options.buffer_size.GetCurrentValue(), error_stream); result.GetErrorStream() << error_stream.str(); if (success) |