1ac7ddfbfSEd Maste //===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste
104bb0738eSEd Maste #include "CommandObjectLog.h"
11ac7ddfbfSEd Maste #include "lldb/Core/Debugger.h"
12ac7ddfbfSEd Maste #include "lldb/Core/Module.h"
13ac7ddfbfSEd Maste #include "lldb/Core/StreamFile.h"
14f678e45dSDimitry Andric #include "lldb/Host/OptionParser.h"
15ac7ddfbfSEd Maste #include "lldb/Interpreter/CommandInterpreter.h"
16ac7ddfbfSEd Maste #include "lldb/Interpreter/CommandReturnObject.h"
174ba319b5SDimitry Andric #include "lldb/Interpreter/OptionArgParser.h"
18435933ddSDimitry Andric #include "lldb/Interpreter/Options.h"
19ac7ddfbfSEd Maste #include "lldb/Symbol/LineTable.h"
20ac7ddfbfSEd Maste #include "lldb/Symbol/ObjectFile.h"
21ac7ddfbfSEd Maste #include "lldb/Symbol/SymbolFile.h"
22ac7ddfbfSEd Maste #include "lldb/Symbol/SymbolVendor.h"
23ac7ddfbfSEd Maste #include "lldb/Target/Process.h"
24ac7ddfbfSEd Maste #include "lldb/Target/Target.h"
254ba319b5SDimitry Andric #include "lldb/Utility/Args.h"
26f678e45dSDimitry Andric #include "lldb/Utility/FileSpec.h"
27f678e45dSDimitry Andric #include "lldb/Utility/Log.h"
28f678e45dSDimitry Andric #include "lldb/Utility/RegularExpression.h"
29f678e45dSDimitry Andric #include "lldb/Utility/Stream.h"
30a580b014SDimitry Andric #include "lldb/Utility/Timer.h"
31ac7ddfbfSEd Maste
32ac7ddfbfSEd Maste using namespace lldb;
33ac7ddfbfSEd Maste using namespace lldb_private;
34ac7ddfbfSEd Maste
35*b5893f02SDimitry Andric static constexpr OptionDefinition g_log_options[] = {
36435933ddSDimitry Andric // clang-format off
37*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFilename, "Set the destination file to log to." },
38*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
39*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Enable verbose logging." },
40*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
41*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
42*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
43*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
44*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
45*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
46*b5893f02SDimitry Andric { LLDB_OPT_SET_1, false, "file-function",'F',OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Prepend the names of files and function that generate the logs." },
47435933ddSDimitry Andric // clang-format on
48435933ddSDimitry Andric };
49435933ddSDimitry Andric
50435933ddSDimitry Andric class CommandObjectLogEnable : public CommandObjectParsed {
51ac7ddfbfSEd Maste public:
52ac7ddfbfSEd Maste //------------------------------------------------------------------
53ac7ddfbfSEd Maste // Constructors and Destructors
54ac7ddfbfSEd Maste //------------------------------------------------------------------
CommandObjectLogEnable(CommandInterpreter & interpreter)55435933ddSDimitry Andric CommandObjectLogEnable(CommandInterpreter &interpreter)
56435933ddSDimitry Andric : CommandObjectParsed(interpreter, "log enable",
57ac7ddfbfSEd Maste "Enable logging for a single log channel.",
584bb0738eSEd Maste nullptr),
59435933ddSDimitry Andric m_options() {
60ac7ddfbfSEd Maste CommandArgumentEntry arg1;
61ac7ddfbfSEd Maste CommandArgumentEntry arg2;
62ac7ddfbfSEd Maste CommandArgumentData channel_arg;
63ac7ddfbfSEd Maste CommandArgumentData category_arg;
64ac7ddfbfSEd Maste
65ac7ddfbfSEd Maste // Define the first (and only) variant of this arg.
66ac7ddfbfSEd Maste channel_arg.arg_type = eArgTypeLogChannel;
67ac7ddfbfSEd Maste channel_arg.arg_repetition = eArgRepeatPlain;
68ac7ddfbfSEd Maste
69435933ddSDimitry Andric // There is only one variant this argument could be; put it into the
70435933ddSDimitry Andric // argument entry.
71ac7ddfbfSEd Maste arg1.push_back(channel_arg);
72ac7ddfbfSEd Maste
73ac7ddfbfSEd Maste category_arg.arg_type = eArgTypeLogCategory;
74ac7ddfbfSEd Maste category_arg.arg_repetition = eArgRepeatPlus;
75ac7ddfbfSEd Maste
76ac7ddfbfSEd Maste arg2.push_back(category_arg);
77ac7ddfbfSEd Maste
78ac7ddfbfSEd Maste // Push the data for the first argument into the m_arguments vector.
79ac7ddfbfSEd Maste m_arguments.push_back(arg1);
80ac7ddfbfSEd Maste m_arguments.push_back(arg2);
81ac7ddfbfSEd Maste }
82ac7ddfbfSEd Maste
834bb0738eSEd Maste ~CommandObjectLogEnable() override = default;
84ac7ddfbfSEd Maste
GetOptions()85435933ddSDimitry Andric Options *GetOptions() override { return &m_options; }
86ac7ddfbfSEd Maste
87435933ddSDimitry Andric class CommandOptions : public Options {
88ac7ddfbfSEd Maste public:
CommandOptions()89435933ddSDimitry Andric CommandOptions() : Options(), log_file(), log_options(0) {}
90ac7ddfbfSEd Maste
914bb0738eSEd Maste ~CommandOptions() override = default;
92ac7ddfbfSEd Maste
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)935517e702SDimitry Andric Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
94435933ddSDimitry Andric ExecutionContext *execution_context) override {
955517e702SDimitry Andric Status error;
96ac7ddfbfSEd Maste const int short_option = m_getopt_table[option_idx].val;
97ac7ddfbfSEd Maste
98435933ddSDimitry Andric switch (short_option) {
99435933ddSDimitry Andric case 'f':
100*b5893f02SDimitry Andric log_file.SetFile(option_arg, FileSpec::Style::native);
101*b5893f02SDimitry Andric FileSystem::Instance().Resolve(log_file);
102435933ddSDimitry Andric break;
103435933ddSDimitry Andric case 't':
104435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_THREADSAFE;
105435933ddSDimitry Andric break;
106435933ddSDimitry Andric case 'v':
107435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_VERBOSE;
108435933ddSDimitry Andric break;
109435933ddSDimitry Andric case 's':
110435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE;
111435933ddSDimitry Andric break;
112435933ddSDimitry Andric case 'T':
113435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP;
114435933ddSDimitry Andric break;
115435933ddSDimitry Andric case 'p':
116435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;
117435933ddSDimitry Andric break;
118435933ddSDimitry Andric case 'n':
119435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
120435933ddSDimitry Andric break;
121435933ddSDimitry Andric case 'S':
122435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_BACKTRACE;
123435933ddSDimitry Andric break;
124435933ddSDimitry Andric case 'a':
125435933ddSDimitry Andric log_options |= LLDB_LOG_OPTION_APPEND;
126435933ddSDimitry Andric break;
127f678e45dSDimitry Andric case 'F':
128f678e45dSDimitry Andric log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION;
129f678e45dSDimitry Andric break;
130ac7ddfbfSEd Maste default:
131435933ddSDimitry Andric error.SetErrorStringWithFormat("unrecognized option '%c'",
132435933ddSDimitry Andric short_option);
133ac7ddfbfSEd Maste break;
134ac7ddfbfSEd Maste }
135ac7ddfbfSEd Maste
136ac7ddfbfSEd Maste return error;
137ac7ddfbfSEd Maste }
138ac7ddfbfSEd Maste
OptionParsingStarting(ExecutionContext * execution_context)139435933ddSDimitry Andric void OptionParsingStarting(ExecutionContext *execution_context) override {
140ac7ddfbfSEd Maste log_file.Clear();
141ac7ddfbfSEd Maste log_options = 0;
142ac7ddfbfSEd Maste }
143ac7ddfbfSEd Maste
GetDefinitions()144435933ddSDimitry Andric llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
145435933ddSDimitry Andric return llvm::makeArrayRef(g_log_options);
146ac7ddfbfSEd Maste }
147ac7ddfbfSEd Maste
148ac7ddfbfSEd Maste // Instance variables to hold the values for command options.
149ac7ddfbfSEd Maste
150ac7ddfbfSEd Maste FileSpec log_file;
151ac7ddfbfSEd Maste uint32_t log_options;
152ac7ddfbfSEd Maste };
153ac7ddfbfSEd Maste
154ac7ddfbfSEd Maste protected:
DoExecute(Args & args,CommandReturnObject & result)155435933ddSDimitry Andric bool DoExecute(Args &args, CommandReturnObject &result) override {
156435933ddSDimitry Andric if (args.GetArgumentCount() < 2) {
157435933ddSDimitry Andric result.AppendErrorWithFormat(
158435933ddSDimitry Andric "%s takes a log channel and one or more log types.\n",
159435933ddSDimitry Andric m_cmd_name.c_str());
160435933ddSDimitry Andric return false;
161ac7ddfbfSEd Maste }
162435933ddSDimitry Andric
163435933ddSDimitry Andric // Store into a std::string since we're about to shift the channel off.
164435933ddSDimitry Andric const std::string channel = args[0].ref;
165ac7ddfbfSEd Maste args.Shift(); // Shift off the channel
166ac7ddfbfSEd Maste char log_file[PATH_MAX];
167ac7ddfbfSEd Maste if (m_options.log_file)
168ac7ddfbfSEd Maste m_options.log_file.GetPath(log_file, sizeof(log_file));
169ac7ddfbfSEd Maste else
170ac7ddfbfSEd Maste log_file[0] = '\0';
171f678e45dSDimitry Andric
172f678e45dSDimitry Andric std::string error;
173f678e45dSDimitry Andric llvm::raw_string_ostream error_stream(error);
174435933ddSDimitry Andric bool success = m_interpreter.GetDebugger().EnableLog(
175f678e45dSDimitry Andric channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
176f678e45dSDimitry Andric error_stream);
177f678e45dSDimitry Andric result.GetErrorStream() << error_stream.str();
178f678e45dSDimitry Andric
179ac7ddfbfSEd Maste if (success)
180ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
181ac7ddfbfSEd Maste else
182ac7ddfbfSEd Maste result.SetStatus(eReturnStatusFailed);
183ac7ddfbfSEd Maste return result.Succeeded();
184ac7ddfbfSEd Maste }
185ac7ddfbfSEd Maste
186ac7ddfbfSEd Maste CommandOptions m_options;
187ac7ddfbfSEd Maste };
188ac7ddfbfSEd Maste
189435933ddSDimitry Andric class CommandObjectLogDisable : public CommandObjectParsed {
190ac7ddfbfSEd Maste public:
191ac7ddfbfSEd Maste //------------------------------------------------------------------
192ac7ddfbfSEd Maste // Constructors and Destructors
193ac7ddfbfSEd Maste //------------------------------------------------------------------
CommandObjectLogDisable(CommandInterpreter & interpreter)194435933ddSDimitry Andric CommandObjectLogDisable(CommandInterpreter &interpreter)
195435933ddSDimitry Andric : CommandObjectParsed(interpreter, "log disable",
196ac7ddfbfSEd Maste "Disable one or more log channel categories.",
197435933ddSDimitry Andric nullptr) {
198ac7ddfbfSEd Maste CommandArgumentEntry arg1;
199ac7ddfbfSEd Maste CommandArgumentEntry arg2;
200ac7ddfbfSEd Maste CommandArgumentData channel_arg;
201ac7ddfbfSEd Maste CommandArgumentData category_arg;
202ac7ddfbfSEd Maste
203ac7ddfbfSEd Maste // Define the first (and only) variant of this arg.
204ac7ddfbfSEd Maste channel_arg.arg_type = eArgTypeLogChannel;
205ac7ddfbfSEd Maste channel_arg.arg_repetition = eArgRepeatPlain;
206ac7ddfbfSEd Maste
207435933ddSDimitry Andric // There is only one variant this argument could be; put it into the
208435933ddSDimitry Andric // argument entry.
209ac7ddfbfSEd Maste arg1.push_back(channel_arg);
210ac7ddfbfSEd Maste
211ac7ddfbfSEd Maste category_arg.arg_type = eArgTypeLogCategory;
212ac7ddfbfSEd Maste category_arg.arg_repetition = eArgRepeatPlus;
213ac7ddfbfSEd Maste
214ac7ddfbfSEd Maste arg2.push_back(category_arg);
215ac7ddfbfSEd Maste
216ac7ddfbfSEd Maste // Push the data for the first argument into the m_arguments vector.
217ac7ddfbfSEd Maste m_arguments.push_back(arg1);
218ac7ddfbfSEd Maste m_arguments.push_back(arg2);
219ac7ddfbfSEd Maste }
220ac7ddfbfSEd Maste
2214bb0738eSEd Maste ~CommandObjectLogDisable() override = default;
222ac7ddfbfSEd Maste
223ac7ddfbfSEd Maste protected:
DoExecute(Args & args,CommandReturnObject & result)224435933ddSDimitry Andric bool DoExecute(Args &args, CommandReturnObject &result) override {
225435933ddSDimitry Andric if (args.empty()) {
226435933ddSDimitry Andric result.AppendErrorWithFormat(
227435933ddSDimitry Andric "%s takes a log channel and one or more log types.\n",
228435933ddSDimitry Andric m_cmd_name.c_str());
229435933ddSDimitry Andric return false;
230ac7ddfbfSEd Maste }
231435933ddSDimitry Andric
232435933ddSDimitry Andric const std::string channel = args[0].ref;
233ac7ddfbfSEd Maste args.Shift(); // Shift off the channel
234f678e45dSDimitry Andric if (channel == "all") {
235f678e45dSDimitry Andric Log::DisableAllLogChannels();
236ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
237435933ddSDimitry Andric } else {
238f678e45dSDimitry Andric std::string error;
239f678e45dSDimitry Andric llvm::raw_string_ostream error_stream(error);
240f678e45dSDimitry Andric if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(),
241f678e45dSDimitry Andric error_stream))
242ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
243f678e45dSDimitry Andric result.GetErrorStream() << error_stream.str();
244ac7ddfbfSEd Maste }
245ac7ddfbfSEd Maste return result.Succeeded();
246ac7ddfbfSEd Maste }
247ac7ddfbfSEd Maste };
248ac7ddfbfSEd Maste
249435933ddSDimitry Andric class CommandObjectLogList : public CommandObjectParsed {
250ac7ddfbfSEd Maste public:
251ac7ddfbfSEd Maste //------------------------------------------------------------------
252ac7ddfbfSEd Maste // Constructors and Destructors
253ac7ddfbfSEd Maste //------------------------------------------------------------------
CommandObjectLogList(CommandInterpreter & interpreter)254435933ddSDimitry Andric CommandObjectLogList(CommandInterpreter &interpreter)
255435933ddSDimitry Andric : CommandObjectParsed(interpreter, "log list",
256435933ddSDimitry Andric "List the log categories for one or more log "
257435933ddSDimitry Andric "channels. If none specified, lists them all.",
258435933ddSDimitry Andric nullptr) {
259ac7ddfbfSEd Maste CommandArgumentEntry arg;
260ac7ddfbfSEd Maste CommandArgumentData channel_arg;
261ac7ddfbfSEd Maste
262ac7ddfbfSEd Maste // Define the first (and only) variant of this arg.
263ac7ddfbfSEd Maste channel_arg.arg_type = eArgTypeLogChannel;
264ac7ddfbfSEd Maste channel_arg.arg_repetition = eArgRepeatStar;
265ac7ddfbfSEd Maste
266435933ddSDimitry Andric // There is only one variant this argument could be; put it into the
267435933ddSDimitry Andric // argument entry.
268ac7ddfbfSEd Maste arg.push_back(channel_arg);
269ac7ddfbfSEd Maste
270ac7ddfbfSEd Maste // Push the data for the first argument into the m_arguments vector.
271ac7ddfbfSEd Maste m_arguments.push_back(arg);
272ac7ddfbfSEd Maste }
273ac7ddfbfSEd Maste
2744bb0738eSEd Maste ~CommandObjectLogList() override = default;
275ac7ddfbfSEd Maste
276ac7ddfbfSEd Maste protected:
DoExecute(Args & args,CommandReturnObject & result)277435933ddSDimitry Andric bool DoExecute(Args &args, CommandReturnObject &result) override {
278f678e45dSDimitry Andric std::string output;
279f678e45dSDimitry Andric llvm::raw_string_ostream output_stream(output);
280435933ddSDimitry Andric if (args.empty()) {
281f678e45dSDimitry Andric Log::ListAllLogChannels(output_stream);
282ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult);
283435933ddSDimitry Andric } else {
284f678e45dSDimitry Andric bool success = true;
285f678e45dSDimitry Andric for (const auto &entry : args.entries())
286f678e45dSDimitry Andric success =
287f678e45dSDimitry Andric success && Log::ListChannelCategories(entry.ref, output_stream);
288f678e45dSDimitry Andric if (success)
289ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult);
290ac7ddfbfSEd Maste }
291f678e45dSDimitry Andric result.GetOutputStream() << output_stream.str();
292ac7ddfbfSEd Maste return result.Succeeded();
293ac7ddfbfSEd Maste }
294ac7ddfbfSEd Maste };
295ac7ddfbfSEd Maste
296435933ddSDimitry Andric class CommandObjectLogTimer : public CommandObjectParsed {
297ac7ddfbfSEd Maste public:
298ac7ddfbfSEd Maste //------------------------------------------------------------------
299ac7ddfbfSEd Maste // Constructors and Destructors
300ac7ddfbfSEd Maste //------------------------------------------------------------------
CommandObjectLogTimer(CommandInterpreter & interpreter)301435933ddSDimitry Andric CommandObjectLogTimer(CommandInterpreter &interpreter)
302435933ddSDimitry Andric : CommandObjectParsed(interpreter, "log timers",
303435933ddSDimitry Andric "Enable, disable, dump, and reset LLDB internal "
304435933ddSDimitry Andric "performance timers.",
305435933ddSDimitry Andric "log timers < enable <depth> | disable | dump | "
306435933ddSDimitry Andric "increment <bool> | reset >") {}
307ac7ddfbfSEd Maste
3084bb0738eSEd Maste ~CommandObjectLogTimer() override = default;
309ac7ddfbfSEd Maste
310ac7ddfbfSEd Maste protected:
DoExecute(Args & args,CommandReturnObject & result)311435933ddSDimitry Andric bool DoExecute(Args &args, CommandReturnObject &result) override {
312ac7ddfbfSEd Maste result.SetStatus(eReturnStatusFailed);
313ac7ddfbfSEd Maste
314435933ddSDimitry Andric if (args.GetArgumentCount() == 1) {
315435933ddSDimitry Andric auto sub_command = args[0].ref;
316ac7ddfbfSEd Maste
317435933ddSDimitry Andric if (sub_command.equals_lower("enable")) {
318ac7ddfbfSEd Maste Timer::SetDisplayDepth(UINT32_MAX);
319ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
320435933ddSDimitry Andric } else if (sub_command.equals_lower("disable")) {
321ac7ddfbfSEd Maste Timer::DumpCategoryTimes(&result.GetOutputStream());
322ac7ddfbfSEd Maste Timer::SetDisplayDepth(0);
323ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult);
324435933ddSDimitry Andric } else if (sub_command.equals_lower("dump")) {
325ac7ddfbfSEd Maste Timer::DumpCategoryTimes(&result.GetOutputStream());
326ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult);
327435933ddSDimitry Andric } else if (sub_command.equals_lower("reset")) {
328ac7ddfbfSEd Maste Timer::ResetCategoryTimes();
329ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishResult);
330ac7ddfbfSEd Maste }
331435933ddSDimitry Andric } else if (args.GetArgumentCount() == 2) {
332435933ddSDimitry Andric auto sub_command = args[0].ref;
333435933ddSDimitry Andric auto param = args[1].ref;
334ac7ddfbfSEd Maste
335435933ddSDimitry Andric if (sub_command.equals_lower("enable")) {
336435933ddSDimitry Andric uint32_t depth;
337435933ddSDimitry Andric if (param.consumeInteger(0, depth)) {
338435933ddSDimitry Andric result.AppendError(
339435933ddSDimitry Andric "Could not convert enable depth to an unsigned integer.");
340435933ddSDimitry Andric } else {
341ac7ddfbfSEd Maste Timer::SetDisplayDepth(depth);
342ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
343ac7ddfbfSEd Maste }
344435933ddSDimitry Andric } else if (sub_command.equals_lower("increment")) {
345ac7ddfbfSEd Maste bool success;
3464ba319b5SDimitry Andric bool increment = OptionArgParser::ToBoolean(param, false, &success);
347435933ddSDimitry Andric if (success) {
348ac7ddfbfSEd Maste Timer::SetQuiet(!increment);
349ac7ddfbfSEd Maste result.SetStatus(eReturnStatusSuccessFinishNoResult);
350435933ddSDimitry Andric } else
351ac7ddfbfSEd Maste result.AppendError("Could not convert increment value to boolean.");
352ac7ddfbfSEd Maste }
353ac7ddfbfSEd Maste }
354ac7ddfbfSEd Maste
355435933ddSDimitry Andric if (!result.Succeeded()) {
356ac7ddfbfSEd Maste result.AppendError("Missing subcommand");
357ac7ddfbfSEd Maste result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
358ac7ddfbfSEd Maste }
359ac7ddfbfSEd Maste return result.Succeeded();
360ac7ddfbfSEd Maste }
361ac7ddfbfSEd Maste };
362ac7ddfbfSEd Maste
CommandObjectLog(CommandInterpreter & interpreter)3634bb0738eSEd Maste CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter)
364435933ddSDimitry Andric : CommandObjectMultiword(interpreter, "log",
365435933ddSDimitry Andric "Commands controlling LLDB internal logging.",
366435933ddSDimitry Andric "log <subcommand> [<command-options>]") {
367435933ddSDimitry Andric LoadSubCommand("enable",
368435933ddSDimitry Andric CommandObjectSP(new CommandObjectLogEnable(interpreter)));
369435933ddSDimitry Andric LoadSubCommand("disable",
370435933ddSDimitry Andric CommandObjectSP(new CommandObjectLogDisable(interpreter)));
371435933ddSDimitry Andric LoadSubCommand("list",
372435933ddSDimitry Andric CommandObjectSP(new CommandObjectLogList(interpreter)));
373435933ddSDimitry Andric LoadSubCommand("timers",
374435933ddSDimitry Andric CommandObjectSP(new CommandObjectLogTimer(interpreter)));
375ac7ddfbfSEd Maste }
376ac7ddfbfSEd Maste
3774bb0738eSEd Maste CommandObjectLog::~CommandObjectLog() = default;
378