blob: aa09f53c792b3dbb0d87d1180f46168fd43cd58a [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Daniel Malea93a64302012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Chris Lattner30fdc8d2010-06-08 16:52:24 +000012#include "CommandObjectLog.h"
13
14// C Includes
15// C++ Includes
16// Other libraries and framework includes
17// Project includes
18#include "lldb/lldb-private-log.h"
19
Jim Ingham40af72e2010-06-15 19:49:27 +000020#include "lldb/Interpreter/Args.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021#include "lldb/Core/Debugger.h"
Greg Clayton53239f02011-02-08 05:05:52 +000022#include "lldb/Host/FileSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023#include "lldb/Core/Log.h"
24#include "lldb/Core/Module.h"
Jim Ingham40af72e2010-06-15 19:49:27 +000025#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Core/RegularExpression.h"
27#include "lldb/Core/Stream.h"
28#include "lldb/Core/StreamFile.h"
29#include "lldb/Core/Timer.h"
30
Greg Clayton66111032010-06-23 01:19:29 +000031#include "lldb/Core/Debugger.h"
Vince Harron5275aaa2015-01-15 20:08:35 +000032#include "lldb/Host/StringConvert.h"
Sean Callanan4be39902010-06-23 21:28:25 +000033#include "lldb/Interpreter/CommandInterpreter.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034#include "lldb/Interpreter/CommandReturnObject.h"
35
36#include "lldb/Symbol/LineTable.h"
37#include "lldb/Symbol/ObjectFile.h"
38#include "lldb/Symbol/SymbolFile.h"
39#include "lldb/Symbol/SymbolVendor.h"
40
41#include "lldb/Target/Process.h"
42#include "lldb/Target/Target.h"
43
44using namespace lldb;
45using namespace lldb_private;
46
47
Jim Ingham5a988412012-06-08 21:56:10 +000048class CommandObjectLogEnable : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +000049{
50public:
51 //------------------------------------------------------------------
52 // Constructors and Destructors
53 //------------------------------------------------------------------
Greg Claytona7015092010-09-18 01:14:36 +000054 CommandObjectLogEnable(CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +000055 CommandObjectParsed (interpreter,
56 "log enable",
57 "Enable logging for a single log channel.",
58 NULL),
Greg Claytoneb0103f2011-04-07 22:46:35 +000059 m_options (interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000060 {
Caroline Ticeceb6b132010-10-26 03:11:13 +000061
62 CommandArgumentEntry arg1;
63 CommandArgumentEntry arg2;
Caroline Tice405fe672010-10-04 22:28:36 +000064 CommandArgumentData channel_arg;
Caroline Ticeceb6b132010-10-26 03:11:13 +000065 CommandArgumentData category_arg;
Caroline Tice405fe672010-10-04 22:28:36 +000066
67 // Define the first (and only) variant of this arg.
68 channel_arg.arg_type = eArgTypeLogChannel;
69 channel_arg.arg_repetition = eArgRepeatPlain;
70
71 // There is only one variant this argument could be; put it into the argument entry.
Caroline Ticeceb6b132010-10-26 03:11:13 +000072 arg1.push_back (channel_arg);
Caroline Tice405fe672010-10-04 22:28:36 +000073
Caroline Ticeceb6b132010-10-26 03:11:13 +000074 category_arg.arg_type = eArgTypeLogCategory;
75 category_arg.arg_repetition = eArgRepeatPlus;
76
77 arg2.push_back (category_arg);
78
Caroline Tice405fe672010-10-04 22:28:36 +000079 // Push the data for the first argument into the m_arguments vector.
Caroline Ticeceb6b132010-10-26 03:11:13 +000080 m_arguments.push_back (arg1);
81 m_arguments.push_back (arg2);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082 }
83
84 virtual
85 ~CommandObjectLogEnable()
86 {
87 }
88
89 Options *
90 GetOptions ()
91 {
92 return &m_options;
93 }
94
Greg Claytonab65b342011-04-13 22:47:15 +000095// int
96// HandleArgumentCompletion (Args &input,
97// int &cursor_index,
98// int &cursor_char_position,
99// OptionElementVector &opt_element_vector,
100// int match_start_point,
101// int max_return_elements,
102// bool &word_complete,
103// StringList &matches)
104// {
105// std::string completion_str (input.GetArgumentAtIndex(cursor_index));
106// completion_str.erase (cursor_char_position);
107//
108// if (cursor_index == 1)
109// {
110// //
111// Log::AutoCompleteChannelName (completion_str.c_str(), matches);
112// }
113// return matches.GetSize();
114// }
115//
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000116
117 class CommandOptions : public Options
118 {
119 public:
120
Greg Claytoneb0103f2011-04-07 22:46:35 +0000121 CommandOptions (CommandInterpreter &interpreter) :
122 Options (interpreter),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123 log_file (),
124 log_options (0)
125 {
126 }
127
128
129 virtual
130 ~CommandOptions ()
131 {
132 }
133
134 virtual Error
Greg Claytonf6b8b582011-04-13 00:18:08 +0000135 SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000136 {
137 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000138 const int short_option = m_getopt_table[option_idx].val;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000139
140 switch (short_option)
141 {
Greg Clayton889037d2012-12-07 18:37:09 +0000142 case 'f': log_file.SetFile(option_arg, true); break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000143 case 't': log_options |= LLDB_LOG_OPTION_THREADSAFE; break;
144 case 'v': log_options |= LLDB_LOG_OPTION_VERBOSE; break;
145 case 'g': log_options |= LLDB_LOG_OPTION_DEBUG; break;
146 case 's': log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE; break;
147 case 'T': log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP; break;
148 case 'p': log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;break;
149 case 'n': log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME; break;
Greg Clayton3a18e312012-10-08 22:41:53 +0000150 case 'S': log_options |= LLDB_LOG_OPTION_BACKTRACE; break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000151 default:
Greg Clayton86edbf42011-10-26 00:56:27 +0000152 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000153 break;
154 }
155
156 return error;
157 }
158
159 void
Greg Claytonf6b8b582011-04-13 00:18:08 +0000160 OptionParsingStarting ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000161 {
Greg Clayton889037d2012-12-07 18:37:09 +0000162 log_file.Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000163 log_options = 0;
164 }
165
Greg Claytone0d378b2011-03-24 21:19:54 +0000166 const OptionDefinition*
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000167 GetDefinitions ()
168 {
169 return g_option_table;
170 }
171
172 // Options table: Required for subclasses of Options.
173
Greg Claytone0d378b2011-03-24 21:19:54 +0000174 static OptionDefinition g_option_table[];
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000175
176 // Instance variables to hold the values for command options.
177
Greg Clayton889037d2012-12-07 18:37:09 +0000178 FileSpec log_file;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000179 uint32_t log_options;
180 };
181
182protected:
Jim Ingham5a988412012-06-08 21:56:10 +0000183 virtual bool
184 DoExecute (Args& args,
185 CommandReturnObject &result)
186 {
187 if (args.GetArgumentCount() < 2)
188 {
189 result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
190 }
191 else
192 {
193 std::string channel(args.GetArgumentAtIndex(0));
194 args.Shift (); // Shift off the channel
Greg Clayton889037d2012-12-07 18:37:09 +0000195 char log_file[PATH_MAX];
196 if (m_options.log_file)
197 m_options.log_file.GetPath(log_file, sizeof(log_file));
198 else
199 log_file[0] = '\0';
Jim Ingham5a988412012-06-08 21:56:10 +0000200 bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(),
201 args.GetConstArgumentVector(),
Greg Clayton889037d2012-12-07 18:37:09 +0000202 log_file,
Jim Ingham5a988412012-06-08 21:56:10 +0000203 m_options.log_options,
204 result.GetErrorStream());
205 if (success)
206 result.SetStatus (eReturnStatusSuccessFinishNoResult);
207 else
208 result.SetStatus (eReturnStatusFailed);
209 }
210 return result.Succeeded();
211 }
212
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000213 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000214};
215
Greg Claytone0d378b2011-03-24 21:19:54 +0000216OptionDefinition
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000217CommandObjectLogEnable::CommandOptions::g_option_table[] =
218{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000219{ LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFilename, "Set the destination file to log to."},
220{ LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
221{ LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable verbose logging." },
222{ LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable debug logging." },
223{ LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
224{ LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
225{ LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
226{ LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
227{ LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
228{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000229};
230
Jim Ingham5a988412012-06-08 21:56:10 +0000231class CommandObjectLogDisable : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000232{
233public:
234 //------------------------------------------------------------------
235 // Constructors and Destructors
236 //------------------------------------------------------------------
Greg Claytona7015092010-09-18 01:14:36 +0000237 CommandObjectLogDisable(CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000238 CommandObjectParsed (interpreter,
239 "log disable",
240 "Disable one or more log channel categories.",
241 NULL)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000242 {
Caroline Tice7149fab2010-10-29 21:56:41 +0000243 CommandArgumentEntry arg1;
244 CommandArgumentEntry arg2;
Caroline Tice405fe672010-10-04 22:28:36 +0000245 CommandArgumentData channel_arg;
Caroline Tice7149fab2010-10-29 21:56:41 +0000246 CommandArgumentData category_arg;
Caroline Tice405fe672010-10-04 22:28:36 +0000247
248 // Define the first (and only) variant of this arg.
249 channel_arg.arg_type = eArgTypeLogChannel;
Caroline Tice7149fab2010-10-29 21:56:41 +0000250 channel_arg.arg_repetition = eArgRepeatPlain;
Caroline Tice405fe672010-10-04 22:28:36 +0000251
252 // There is only one variant this argument could be; put it into the argument entry.
Caroline Tice7149fab2010-10-29 21:56:41 +0000253 arg1.push_back (channel_arg);
Caroline Tice405fe672010-10-04 22:28:36 +0000254
Caroline Tice7149fab2010-10-29 21:56:41 +0000255 category_arg.arg_type = eArgTypeLogCategory;
256 category_arg.arg_repetition = eArgRepeatPlus;
257
258 arg2.push_back (category_arg);
259
Caroline Tice405fe672010-10-04 22:28:36 +0000260 // Push the data for the first argument into the m_arguments vector.
Caroline Tice7149fab2010-10-29 21:56:41 +0000261 m_arguments.push_back (arg1);
262 m_arguments.push_back (arg2);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000263 }
264
265 virtual
266 ~CommandObjectLogDisable()
267 {
268 }
269
Jim Ingham5a988412012-06-08 21:56:10 +0000270protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000271 virtual bool
Jim Ingham5a988412012-06-08 21:56:10 +0000272 DoExecute (Args& args,
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000273 CommandReturnObject &result)
274 {
275 const size_t argc = args.GetArgumentCount();
276 if (argc == 0)
277 {
Jim Inghamdff04402012-05-12 00:38:30 +0000278 result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000279 }
280 else
281 {
Caroline Tice20ad3c42010-10-29 21:48:37 +0000282 Log::Callbacks log_callbacks;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000283
Caroline Tice20ad3c42010-10-29 21:48:37 +0000284 std::string channel(args.GetArgumentAtIndex(0));
285 args.Shift (); // Shift off the channel
Greg Clayton57abc5d2013-05-10 21:47:16 +0000286 if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
Caroline Tice20ad3c42010-10-29 21:48:37 +0000287 {
Jim Ingham228063c2012-02-21 02:23:08 +0000288 log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream());
Caroline Tice20ad3c42010-10-29 21:48:37 +0000289 result.SetStatus(eReturnStatusSuccessFinishNoResult);
290 }
291 else if (channel == "all")
292 {
293 Log::DisableAllLogChannels(&result.GetErrorStream());
294 }
295 else
296 {
Greg Claytonab65b342011-04-13 22:47:15 +0000297 LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
Caroline Tice20ad3c42010-10-29 21:48:37 +0000298 if (log_channel_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000299 {
Jim Ingham228063c2012-02-21 02:23:08 +0000300 log_channel_sp->Disable(args.GetConstArgumentVector(), &result.GetErrorStream());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000301 result.SetStatus(eReturnStatusSuccessFinishNoResult);
302 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000303 else
Caroline Tice20ad3c42010-10-29 21:48:37 +0000304 result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000305 }
306 }
307 return result.Succeeded();
308 }
309};
310
Jim Ingham5a988412012-06-08 21:56:10 +0000311class CommandObjectLogList : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000312{
313public:
314 //------------------------------------------------------------------
315 // Constructors and Destructors
316 //------------------------------------------------------------------
Greg Claytona7015092010-09-18 01:14:36 +0000317 CommandObjectLogList(CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000318 CommandObjectParsed (interpreter,
319 "log list",
320 "List the log categories for one or more log channels. If none specified, lists them all.",
321 NULL)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000322 {
Caroline Tice405fe672010-10-04 22:28:36 +0000323 CommandArgumentEntry arg;
324 CommandArgumentData channel_arg;
325
326 // Define the first (and only) variant of this arg.
327 channel_arg.arg_type = eArgTypeLogChannel;
328 channel_arg.arg_repetition = eArgRepeatStar;
329
330 // There is only one variant this argument could be; put it into the argument entry.
331 arg.push_back (channel_arg);
332
333 // Push the data for the first argument into the m_arguments vector.
334 m_arguments.push_back (arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000335 }
336
337 virtual
338 ~CommandObjectLogList()
339 {
340 }
341
Jim Ingham5a988412012-06-08 21:56:10 +0000342protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000343 virtual bool
Jim Ingham5a988412012-06-08 21:56:10 +0000344 DoExecute (Args& args,
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000345 CommandReturnObject &result)
346 {
347 const size_t argc = args.GetArgumentCount();
348 if (argc == 0)
349 {
350 Log::ListAllLogChannels (&result.GetOutputStream());
351 result.SetStatus(eReturnStatusSuccessFinishResult);
352 }
353 else
354 {
355 for (size_t i=0; i<argc; ++i)
356 {
357 Log::Callbacks log_callbacks;
358
359 std::string channel(args.GetArgumentAtIndex(i));
Greg Clayton57abc5d2013-05-10 21:47:16 +0000360 if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000361 {
362 log_callbacks.list_categories (&result.GetOutputStream());
363 result.SetStatus(eReturnStatusSuccessFinishResult);
364 }
365 else if (channel == "all")
366 {
367 Log::ListAllLogChannels (&result.GetOutputStream());
368 result.SetStatus(eReturnStatusSuccessFinishResult);
369 }
370 else
371 {
Greg Claytonab65b342011-04-13 22:47:15 +0000372 LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000373 if (log_channel_sp)
374 {
375 log_channel_sp->ListCategories(&result.GetOutputStream());
376 result.SetStatus(eReturnStatusSuccessFinishNoResult);
377 }
378 else
379 result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
380 }
381 }
382 }
383 return result.Succeeded();
384 }
385};
386
Jim Ingham5a988412012-06-08 21:56:10 +0000387class CommandObjectLogTimer : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000388{
389public:
390 //------------------------------------------------------------------
391 // Constructors and Destructors
392 //------------------------------------------------------------------
Greg Claytona7015092010-09-18 01:14:36 +0000393 CommandObjectLogTimer(CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000394 CommandObjectParsed (interpreter,
395 "log timers",
396 "Enable, disable, dump, and reset LLDB internal performance timers.",
397 "log timers < enable <depth> | disable | dump | increment <bool> | reset >")
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000398 {
399 }
400
401 virtual
402 ~CommandObjectLogTimer()
403 {
404 }
405
Jim Ingham5a988412012-06-08 21:56:10 +0000406protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000407 virtual bool
Jim Ingham5a988412012-06-08 21:56:10 +0000408 DoExecute (Args& args,
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000409 CommandReturnObject &result)
410 {
411 const size_t argc = args.GetArgumentCount();
412 result.SetStatus(eReturnStatusFailed);
413
414 if (argc == 1)
415 {
416 const char *sub_command = args.GetArgumentAtIndex(0);
417
418 if (strcasecmp(sub_command, "enable") == 0)
419 {
420 Timer::SetDisplayDepth (UINT32_MAX);
421 result.SetStatus(eReturnStatusSuccessFinishNoResult);
422 }
423 else if (strcasecmp(sub_command, "disable") == 0)
424 {
425 Timer::DumpCategoryTimes (&result.GetOutputStream());
426 Timer::SetDisplayDepth (0);
427 result.SetStatus(eReturnStatusSuccessFinishResult);
428 }
429 else if (strcasecmp(sub_command, "dump") == 0)
430 {
431 Timer::DumpCategoryTimes (&result.GetOutputStream());
432 result.SetStatus(eReturnStatusSuccessFinishResult);
433 }
434 else if (strcasecmp(sub_command, "reset") == 0)
435 {
436 Timer::ResetCategoryTimes ();
437 result.SetStatus(eReturnStatusSuccessFinishResult);
438 }
439
440 }
Jim Ingham932725f2010-11-04 23:08:26 +0000441 else if (argc == 2)
442 {
443 const char *sub_command = args.GetArgumentAtIndex(0);
444
445 if (strcasecmp(sub_command, "enable") == 0)
446 {
447 bool success;
Vince Harron5275aaa2015-01-15 20:08:35 +0000448 uint32_t depth = StringConvert::ToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success);
Jim Ingham932725f2010-11-04 23:08:26 +0000449 if (success)
450 {
451 Timer::SetDisplayDepth (depth);
452 result.SetStatus(eReturnStatusSuccessFinishNoResult);
453 }
454 else
455 result.AppendError("Could not convert enable depth to an unsigned integer.");
456 }
Jim Inghamf7f4f502010-11-04 23:19:21 +0000457 if (strcasecmp(sub_command, "increment") == 0)
458 {
459 bool success;
460 bool increment = Args::StringToBoolean(args.GetArgumentAtIndex(1), false, &success);
461 if (success)
462 {
463 Timer::SetQuiet (!increment);
464 result.SetStatus(eReturnStatusSuccessFinishNoResult);
465 }
466 else
467 result.AppendError("Could not convert increment value to boolean.");
468 }
Jim Ingham932725f2010-11-04 23:08:26 +0000469 }
470
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000471 if (!result.Succeeded())
472 {
473 result.AppendError("Missing subcommand");
474 result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
475 }
476 return result.Succeeded();
477 }
478};
479
480//----------------------------------------------------------------------
481// CommandObjectLog constructor
482//----------------------------------------------------------------------
Greg Clayton66111032010-06-23 01:19:29 +0000483CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) :
Greg Claytona7015092010-09-18 01:14:36 +0000484 CommandObjectMultiword (interpreter,
485 "log",
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000486 "A set of commands for operating on logs.",
487 "log <command> [<command-options>]")
488{
Greg Claytona7015092010-09-18 01:14:36 +0000489 LoadSubCommand ("enable", CommandObjectSP (new CommandObjectLogEnable (interpreter)));
490 LoadSubCommand ("disable", CommandObjectSP (new CommandObjectLogDisable (interpreter)));
491 LoadSubCommand ("list", CommandObjectSP (new CommandObjectLogList (interpreter)));
492 LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter)));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000493}
494
495//----------------------------------------------------------------------
496// Destructor
497//----------------------------------------------------------------------
498CommandObjectLog::~CommandObjectLog()
499{
500}
501
502
503
504