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) {
101 if (!
error.Success())
102 error.SetErrorStringWithFormat(
103 "unrecognized value for log handler '%s'",
104 option_arg.str().c_str());
135 llvm_unreachable(
"Unimplemented option");
149 return llvm::ArrayRef(g_log_enable_options);
168 "%s takes a log channel and one or more log types.\n",
176 "the circular buffer handler requires a non-zero buffer size.\n");
183 result.
AppendError(
"a buffer size can only be specified for the circular "
184 "and stream buffer handler.\n");
190 "a file name can only be specified for the stream handler.\n");
195 const std::string channel = std::string(args[0].ref());
204 llvm::raw_string_ostream error_stream(
error);
225 "Disable one or more log channel categories.",
238 arg1.push_back(channel_arg);
243 arg2.push_back(category_arg);
262 "%s takes a log channel and one or more log types.\n",
267 const std::string channel = std::string(args[0].ref());
269 if (channel ==
"all") {
274 llvm::raw_string_ostream error_stream(
error);
288 "List the log categories for one or more log "
289 "channels. If none specified, lists them all.",
306 llvm::raw_string_ostream output_stream(output);
312 for (
const auto &entry : args.
entries())
325 "dump circular buffer logs", nullptr) {
344 switch (short_option) {
350 llvm_unreachable(
"Unimplemented option");
361 return llvm::ArrayRef(g_log_dump_options);
377 "%s takes a log channel and one or more log types.\n",
382 std::unique_ptr<llvm::raw_ostream> stream_up;
392 llvm::toString(file.takeError()).c_str());
395 stream_up = std::make_unique<llvm::raw_fd_ostream>(
396 (*file)->GetDescriptor(),
true);
398 stream_up = std::make_unique<llvm::raw_fd_ostream>(
399 GetDebugger().GetOutputFile().GetDescriptor(),
false);
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
std::vector< CommandArgumentData > CommandArgumentEntry
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
std::vector< CommandArgumentEntry > m_arguments
void 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.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Clear()
Clears the object state.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
int Open(const char *path, int flags, int mode=0600)
Wraps ::open in a platform-independent way.
static FileSystem & Instance()
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.
uint64_t GetCurrentValue() const
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
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)