27#define LLDB_OPTIONS_log_enable
28#include "CommandOptions.inc"
30#define LLDB_OPTIONS_log_dump
31#include "CommandOptions.inc"
39 }
else if (arg_index >= 1) {
42 channel, [&request](llvm::StringRef name, llvm::StringRef desc) {
53 "Enable logging for a single log channel.",
66 arg1.push_back(channel_arg);
71 arg2.push_back(category_arg);
93 switch (short_option) {
95 log_file.SetFile(option_arg, FileSpec::Style::native);
101 if (!
error.Success())
103 "unrecognized value for log handler '{0}'", option_arg);
133 llvm_unreachable(
"Unimplemented option");
147 return llvm::ArrayRef(g_log_enable_options);
166 "%s takes a log channel and one or more log types",
172 m_options.buffer_size.GetCurrentValue() == 0) {
174 "the circular buffer handler requires a non-zero buffer size.\n");
180 m_options.buffer_size.GetCurrentValue() != 0) {
181 result.
AppendError(
"a buffer size can only be specified for the circular "
182 "and stream buffer handler.\n");
188 "a file name can only be specified for the stream handler.\n");
193 const std::string channel = std::string(args[0].ref());
197 m_options.log_file.GetPath(log_file,
sizeof(log_file));
202 llvm::raw_string_ostream error_stream(
error);
223 "Disable one or more log channel categories.",
236 arg1.push_back(channel_arg);
241 arg2.push_back(category_arg);
260 "%s takes a log channel and one or more log types",
265 const std::string channel = std::string(args[0].ref());
267 if (channel ==
"all") {
272 llvm::raw_string_ostream error_stream(
error);
287 "List the log categories for one or more log "
288 "channels. If none specified, lists them all.",
305 llvm::raw_string_ostream output_stream(output);
311 for (
const auto &entry : args.
entries())
324 "dump circular buffer logs", nullptr) {
343 switch (short_option) {
345 log_file.SetFile(option_arg, FileSpec::Style::native);
349 llvm_unreachable(
"Unimplemented option");
360 return llvm::ArrayRef(g_log_dump_options);
376 "%s takes a log channel and one or more log types",
381 std::unique_ptr<llvm::raw_ostream> stream_up;
387 m_options.log_file, flags, lldb::eFilePermissionsFileDefault,
false);
391 llvm::toString(file.takeError()).c_str());
394 stream_up = std::make_unique<llvm::raw_fd_ostream>(
395 (*file)->GetDescriptor(),
true);
397 stream_up = std::make_unique<llvm::raw_fd_ostream>(
402 const std::string channel = std::string(args[0].ref());
404 llvm::raw_string_ostream error_stream(
error);
421 "enable LLDB internal performance timers",
422 "log timers enable <depth>") {
437 if (args[0].ref().consumeInteger(0, depth)) {
439 "Could not convert enable depth to an unsigned integer.");
458 "disable LLDB internal performance timers",
481 "dump LLDB internal performance timers", nullptr) {}
502 "reset LLDB internal performance timers", nullptr) {
524 "increment LLDB internal performance timers",
525 "log timers increment <bool>") {
551 result.
AppendError(
"could not convert increment value to boolean");
565 "Enable, disable, dump, and reset LLDB internal "
566 "performance timers.",
567 "log timers < enable <depth> | disable | dump | "
568 "increment <bool> | reset >") {
587 "Commands controlling LLDB internal logging.",
588 "log <subcommand> [<command-options>]") {
static void CompleteEnableDisable(CompletionRequest &request)
Common completion logic for log enable/disable.
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION
#define LLDB_LOG_OPTION_APPEND
#define LLDB_LOG_OPTION_BACKTRACE
#define LLDB_LOG_OPTION_PREPEND_TIMESTAMP
#define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD
#define LLDB_LOG_OPTION_PREPEND_SEQUENCE
#define LLDB_LOG_OPTION_VERBOSE
#define LLDB_LOG_OPTION_PREPEND_THREAD_NAME
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectLogDisable(CommandInterpreter &interpreter)
~CommandObjectLogDisable() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandOptions() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
CommandObjectLogDump(CommandInterpreter &interpreter)
Options * GetOptions() override
~CommandObjectLogDump() override=default
void DoExecute(Args &args, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionValueUInt64 buffer_size
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
~CommandOptions() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
Options * GetOptions() override
CommandObjectLogEnable(CommandInterpreter &interpreter)
~CommandObjectLogEnable() override=default
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectLogList(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectLogList() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectLogTimerDisable(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectLogTimerDisable() override=default
~CommandObjectLogTimerDump() override=default
CommandObjectLogTimerDump(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectLogTimerEnable() override=default
CommandObjectLogTimerEnable(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectLogTimerIncrement(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectLogTimerIncrement() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectLogTimerReset(CommandInterpreter &interpreter)
~CommandObjectLogTimerReset() override=default
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectLogTimer(CommandInterpreter &interpreter)
~CommandObjectLogTimer() override=default
A command line argument class.
llvm::ArrayRef< const char * > GetArgumentArrayRef() const
Gets the argument as an ArrayRef.
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.
llvm::ArrayRef< ArgEntry > entries() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
~CommandObjectLog() override
CommandObjectLog(CommandInterpreter &interpreter)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
std::vector< CommandArgumentData > CommandArgumentEntry
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
std::vector< CommandArgumentEntry > m_arguments
void AppendError(llvm::StringRef in_string)
Stream & GetErrorStream()
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
const Args & GetParsedLine() const
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
size_t GetCursorIndex() const
bool EnableLog(llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::StringRef log_file, uint32_t log_options, size_t buffer_size, LogHandlerKind log_handler_kind, llvm::raw_ostream &error_stream)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
int Open(const char *path, int flags, int mode=0600)
Wraps open in a platform-independent way.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static bool DisableLogChannel(llvm::StringRef channel, llvm::ArrayRef< const char * > categories, llvm::raw_ostream &error_stream)
static void ListAllLogChannels(llvm::raw_ostream &stream)
static bool DumpLogChannel(llvm::StringRef channel, llvm::raw_ostream &output_stream, llvm::raw_ostream &error_stream)
static bool ListChannelCategories(llvm::StringRef channel, llvm::raw_ostream &stream)
static void DisableAllLogChannels()
static void ForEachChannelCategory(llvm::StringRef channel, llvm::function_ref< void(llvm::StringRef, llvm::StringRef)> lambda)
Calls the given lambda for every category in the given channel.
static std::vector< llvm::StringRef > ListChannels()
Returns the list of log channels.
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static void ResetCategoryTimes()
static void SetQuiet(bool value)
static void SetDisplayDepth(uint32_t depth)
static void DumpCategoryTimes(Stream &s)
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)