blob: 579bfbbcd107358b2b1b9f9e2bef3eeb998e9d9f [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
Chris Lattner30fdc8d2010-06-08 16:52:24 +000010// C Includes
11// C++ Includes
12// Other libraries and framework includes
13// Project includes
Eugene Zelenko26cac3a2016-02-20 00:58:29 +000014#include "CommandObjectLog.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000015#include "lldb/Core/Debugger.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000016#include "lldb/Core/Debugger.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000017#include "lldb/Core/Log.h"
18#include "lldb/Core/Module.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019#include "lldb/Core/StreamFile.h"
20#include "lldb/Core/Timer.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000021#include "lldb/Host/FileSpec.h"
Vince Harron5275aaa2015-01-15 20:08:35 +000022#include "lldb/Host/StringConvert.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000023#include "lldb/Interpreter/Args.h"
Sean Callanan4be39902010-06-23 21:28:25 +000024#include "lldb/Interpreter/CommandInterpreter.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000025#include "lldb/Interpreter/CommandReturnObject.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000026#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027#include "lldb/Symbol/LineTable.h"
28#include "lldb/Symbol/ObjectFile.h"
29#include "lldb/Symbol/SymbolFile.h"
30#include "lldb/Symbol/SymbolVendor.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031#include "lldb/Target/Process.h"
32#include "lldb/Target/Target.h"
Zachary Turnerbf9a7732017-02-02 21:39:50 +000033#include "lldb/Utility/RegularExpression.h"
34#include "lldb/Utility/Stream.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000035
36using namespace lldb;
37using namespace lldb_private;
38
Zachary Turner1f0f5b52016-09-22 20:22:55 +000039static OptionDefinition g_log_options[] = {
40 // clang-format off
41 { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeFilename, "Set the destination file to log to." },
42 { LLDB_OPT_SET_1, false, "threadsafe", 't', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable thread safe logging to avoid interweaved log lines." },
43 { LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable verbose logging." },
44 { LLDB_OPT_SET_1, false, "debug", 'g', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Enable debug logging." },
45 { LLDB_OPT_SET_1, false, "sequence", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with an increasing integer sequence id." },
46 { LLDB_OPT_SET_1, false, "timestamp", 'T', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with a timestamp." },
47 { LLDB_OPT_SET_1, false, "pid-tid", 'p', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the process and thread ID that generates the log line." },
48 { LLDB_OPT_SET_1, false, "thread-name",'n', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend all log lines with the thread name for the thread that generates the log line." },
49 { LLDB_OPT_SET_1, false, "stack", 'S', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append a stack backtrace to each log line." },
50 { LLDB_OPT_SET_1, false, "append", 'a', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Append to the log file instead of overwriting." },
Pavel Labath107d9bb2017-01-18 11:00:26 +000051 { LLDB_OPT_SET_1, false, "file-function",'F',OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Prepend the names of files and function that generate the logs." },
Zachary Turner1f0f5b52016-09-22 20:22:55 +000052 // clang-format on
53};
54
Kate Stoneb9c1b512016-09-06 20:57:50 +000055class CommandObjectLogEnable : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000056public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000057 //------------------------------------------------------------------
58 // Constructors and Destructors
59 //------------------------------------------------------------------
60 CommandObjectLogEnable(CommandInterpreter &interpreter)
61 : CommandObjectParsed(interpreter, "log enable",
Eugene Zelenko26cac3a2016-02-20 00:58:29 +000062 "Enable logging for a single log channel.",
63 nullptr),
Kate Stoneb9c1b512016-09-06 20:57:50 +000064 m_options() {
65 CommandArgumentEntry arg1;
66 CommandArgumentEntry arg2;
67 CommandArgumentData channel_arg;
68 CommandArgumentData category_arg;
Caroline Ticeceb6b132010-10-26 03:11:13 +000069
Kate Stoneb9c1b512016-09-06 20:57:50 +000070 // Define the first (and only) variant of this arg.
71 channel_arg.arg_type = eArgTypeLogChannel;
72 channel_arg.arg_repetition = eArgRepeatPlain;
Caroline Ticeceb6b132010-10-26 03:11:13 +000073
Kate Stoneb9c1b512016-09-06 20:57:50 +000074 // There is only one variant this argument could be; put it into the
75 // argument entry.
76 arg1.push_back(channel_arg);
77
78 category_arg.arg_type = eArgTypeLogCategory;
79 category_arg.arg_repetition = eArgRepeatPlus;
80
81 arg2.push_back(category_arg);
82
83 // Push the data for the first argument into the m_arguments vector.
84 m_arguments.push_back(arg1);
85 m_arguments.push_back(arg2);
86 }
87
88 ~CommandObjectLogEnable() override = default;
89
90 Options *GetOptions() override { return &m_options; }
91
Kate Stoneb9c1b512016-09-06 20:57:50 +000092 class CommandOptions : public Options {
93 public:
94 CommandOptions() : Options(), log_file(), log_options(0) {}
95
96 ~CommandOptions() override = default;
97
Zachary Turnerfe114832016-11-12 16:56:47 +000098 Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
Kate Stoneb9c1b512016-09-06 20:57:50 +000099 ExecutionContext *execution_context) override {
100 Error error;
101 const int short_option = m_getopt_table[option_idx].val;
102
103 switch (short_option) {
104 case 'f':
105 log_file.SetFile(option_arg, true);
106 break;
107 case 't':
108 log_options |= LLDB_LOG_OPTION_THREADSAFE;
109 break;
110 case 'v':
111 log_options |= LLDB_LOG_OPTION_VERBOSE;
112 break;
113 case 'g':
114 log_options |= LLDB_LOG_OPTION_DEBUG;
115 break;
116 case 's':
117 log_options |= LLDB_LOG_OPTION_PREPEND_SEQUENCE;
118 break;
119 case 'T':
120 log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP;
121 break;
122 case 'p':
123 log_options |= LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD;
124 break;
125 case 'n':
126 log_options |= LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
127 break;
128 case 'S':
129 log_options |= LLDB_LOG_OPTION_BACKTRACE;
130 break;
131 case 'a':
132 log_options |= LLDB_LOG_OPTION_APPEND;
133 break;
Pavel Labath107d9bb2017-01-18 11:00:26 +0000134 case 'F':
135 log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION;
Kate Stoneb9c1b512016-09-06 20:57:50 +0000136 default:
137 error.SetErrorStringWithFormat("unrecognized option '%c'",
138 short_option);
139 break;
140 }
141
142 return error;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000143 }
144
Kate Stoneb9c1b512016-09-06 20:57:50 +0000145 void OptionParsingStarting(ExecutionContext *execution_context) override {
146 log_file.Clear();
147 log_options = 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000148 }
149
Zachary Turner1f0f5b52016-09-22 20:22:55 +0000150 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
Zachary Turner70602432016-09-22 21:06:13 +0000151 return llvm::makeArrayRef(g_log_options);
Zachary Turner1f0f5b52016-09-22 20:22:55 +0000152 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000153
Kate Stoneb9c1b512016-09-06 20:57:50 +0000154 // Instance variables to hold the values for command options.
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000155
Kate Stoneb9c1b512016-09-06 20:57:50 +0000156 FileSpec log_file;
157 uint32_t log_options;
158 };
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000159
160protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000161 bool DoExecute(Args &args, CommandReturnObject &result) override {
162 if (args.GetArgumentCount() < 2) {
163 result.AppendErrorWithFormat(
164 "%s takes a log channel and one or more log types.\n",
165 m_cmd_name.c_str());
Zachary Turner11eb9c62016-10-05 20:03:37 +0000166 return false;
Jim Ingham5a988412012-06-08 21:56:10 +0000167 }
Zachary Turner11eb9c62016-10-05 20:03:37 +0000168
169 // Store into a std::string since we're about to shift the channel off.
Zachary Turner14f6b2c2016-12-09 01:08:29 +0000170 const std::string channel = args[0].ref;
Zachary Turner11eb9c62016-10-05 20:03:37 +0000171 args.Shift(); // Shift off the channel
172 char log_file[PATH_MAX];
173 if (m_options.log_file)
174 m_options.log_file.GetPath(log_file, sizeof(log_file));
175 else
176 log_file[0] = '\0';
177 bool success = m_interpreter.GetDebugger().EnableLog(
178 channel.c_str(), args.GetConstArgumentVector(), log_file,
179 m_options.log_options, result.GetErrorStream());
180 if (success)
181 result.SetStatus(eReturnStatusSuccessFinishNoResult);
182 else
183 result.SetStatus(eReturnStatusFailed);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000184 return result.Succeeded();
185 }
Jim Ingham5a988412012-06-08 21:56:10 +0000186
Kate Stoneb9c1b512016-09-06 20:57:50 +0000187 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000188};
189
Kate Stoneb9c1b512016-09-06 20:57:50 +0000190class CommandObjectLogDisable : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000191public:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000192 //------------------------------------------------------------------
193 // Constructors and Destructors
194 //------------------------------------------------------------------
195 CommandObjectLogDisable(CommandInterpreter &interpreter)
196 : CommandObjectParsed(interpreter, "log disable",
Eugene Zelenko26cac3a2016-02-20 00:58:29 +0000197 "Disable one or more log channel categories.",
Kate Stoneb9c1b512016-09-06 20:57:50 +0000198 nullptr) {
199 CommandArgumentEntry arg1;
200 CommandArgumentEntry arg2;
201 CommandArgumentData channel_arg;
202 CommandArgumentData category_arg;
Caroline Tice7149fab2010-10-29 21:56:41 +0000203
Kate Stoneb9c1b512016-09-06 20:57:50 +0000204 // Define the first (and only) variant of this arg.
205 channel_arg.arg_type = eArgTypeLogChannel;
206 channel_arg.arg_repetition = eArgRepeatPlain;
Caroline Tice7149fab2010-10-29 21:56:41 +0000207
Kate Stoneb9c1b512016-09-06 20:57:50 +0000208 // There is only one variant this argument could be; put it into the
209 // argument entry.
210 arg1.push_back(channel_arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000211
Kate Stoneb9c1b512016-09-06 20:57:50 +0000212 category_arg.arg_type = eArgTypeLogCategory;
213 category_arg.arg_repetition = eArgRepeatPlus;
214
215 arg2.push_back(category_arg);
216
217 // Push the data for the first argument into the m_arguments vector.
218 m_arguments.push_back(arg1);
219 m_arguments.push_back(arg2);
220 }
221
222 ~CommandObjectLogDisable() override = default;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000223
Jim Ingham5a988412012-06-08 21:56:10 +0000224protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000225 bool DoExecute(Args &args, CommandReturnObject &result) override {
Zachary Turner11eb9c62016-10-05 20:03:37 +0000226 if (args.empty()) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000227 result.AppendErrorWithFormat(
228 "%s takes a log channel and one or more log types.\n",
229 m_cmd_name.c_str());
Zachary Turner11eb9c62016-10-05 20:03:37 +0000230 return false;
231 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000232
Zachary Turner11eb9c62016-10-05 20:03:37 +0000233 Log::Callbacks log_callbacks;
234
Zachary Turner14f6b2c2016-12-09 01:08:29 +0000235 const std::string channel = args[0].ref;
Zachary Turner11eb9c62016-10-05 20:03:37 +0000236 args.Shift(); // Shift off the channel
237 if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
238 log_callbacks.disable(args.GetConstArgumentVector(),
239 &result.GetErrorStream());
240 result.SetStatus(eReturnStatusSuccessFinishNoResult);
241 } else if (channel == "all") {
242 Log::DisableAllLogChannels(&result.GetErrorStream());
243 } else {
244 LogChannelSP log_channel_sp(LogChannel::FindPlugin(channel.data()));
245 if (log_channel_sp) {
246 log_channel_sp->Disable(args.GetConstArgumentVector(),
247 &result.GetErrorStream());
Kate Stoneb9c1b512016-09-06 20:57:50 +0000248 result.SetStatus(eReturnStatusSuccessFinishNoResult);
Zachary Turner11eb9c62016-10-05 20:03:37 +0000249 } else
250 result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
251 channel.data());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000252 }
Kate Stoneb9c1b512016-09-06 20:57:50 +0000253 return result.Succeeded();
254 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000255};
256
Kate Stoneb9c1b512016-09-06 20:57:50 +0000257class CommandObjectLogList : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000258public:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000259 //------------------------------------------------------------------
260 // Constructors and Destructors
261 //------------------------------------------------------------------
262 CommandObjectLogList(CommandInterpreter &interpreter)
263 : CommandObjectParsed(interpreter, "log list",
264 "List the log categories for one or more log "
265 "channels. If none specified, lists them all.",
266 nullptr) {
267 CommandArgumentEntry arg;
268 CommandArgumentData channel_arg;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000269
Kate Stoneb9c1b512016-09-06 20:57:50 +0000270 // Define the first (and only) variant of this arg.
271 channel_arg.arg_type = eArgTypeLogChannel;
272 channel_arg.arg_repetition = eArgRepeatStar;
273
274 // There is only one variant this argument could be; put it into the
275 // argument entry.
276 arg.push_back(channel_arg);
277
278 // Push the data for the first argument into the m_arguments vector.
279 m_arguments.push_back(arg);
280 }
281
282 ~CommandObjectLogList() override = default;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000283
Jim Ingham5a988412012-06-08 21:56:10 +0000284protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000285 bool DoExecute(Args &args, CommandReturnObject &result) override {
Zachary Turner11eb9c62016-10-05 20:03:37 +0000286 if (args.empty()) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000287 Log::ListAllLogChannels(&result.GetOutputStream());
288 result.SetStatus(eReturnStatusSuccessFinishResult);
289 } else {
Zachary Turner11eb9c62016-10-05 20:03:37 +0000290 for (auto &entry : args.entries()) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000291 Log::Callbacks log_callbacks;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000292
Zachary Turner11eb9c62016-10-05 20:03:37 +0000293 if (Log::GetLogChannelCallbacks(ConstString(entry.ref),
Kate Stoneb9c1b512016-09-06 20:57:50 +0000294 log_callbacks)) {
295 log_callbacks.list_categories(&result.GetOutputStream());
296 result.SetStatus(eReturnStatusSuccessFinishResult);
Zachary Turner11eb9c62016-10-05 20:03:37 +0000297 } else if (entry.ref == "all") {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000298 Log::ListAllLogChannels(&result.GetOutputStream());
299 result.SetStatus(eReturnStatusSuccessFinishResult);
300 } else {
Zachary Turner11eb9c62016-10-05 20:03:37 +0000301 LogChannelSP log_channel_sp(LogChannel::FindPlugin(entry.c_str()));
Kate Stoneb9c1b512016-09-06 20:57:50 +0000302 if (log_channel_sp) {
303 log_channel_sp->ListCategories(&result.GetOutputStream());
304 result.SetStatus(eReturnStatusSuccessFinishNoResult);
305 } else
306 result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
Zachary Turner11eb9c62016-10-05 20:03:37 +0000307 entry.c_str());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000308 }
Kate Stoneb9c1b512016-09-06 20:57:50 +0000309 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000310 }
Kate Stoneb9c1b512016-09-06 20:57:50 +0000311 return result.Succeeded();
312 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000313};
314
Kate Stoneb9c1b512016-09-06 20:57:50 +0000315class CommandObjectLogTimer : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000316public:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000317 //------------------------------------------------------------------
318 // Constructors and Destructors
319 //------------------------------------------------------------------
320 CommandObjectLogTimer(CommandInterpreter &interpreter)
321 : CommandObjectParsed(interpreter, "log timers",
322 "Enable, disable, dump, and reset LLDB internal "
323 "performance timers.",
324 "log timers < enable <depth> | disable | dump | "
325 "increment <bool> | reset >") {}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000326
Kate Stoneb9c1b512016-09-06 20:57:50 +0000327 ~CommandObjectLogTimer() override = default;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000328
Jim Ingham5a988412012-06-08 21:56:10 +0000329protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000330 bool DoExecute(Args &args, CommandReturnObject &result) override {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000331 result.SetStatus(eReturnStatusFailed);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000332
Zachary Turner11eb9c62016-10-05 20:03:37 +0000333 if (args.GetArgumentCount() == 1) {
Zachary Turner14f6b2c2016-12-09 01:08:29 +0000334 auto sub_command = args[0].ref;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000335
Zachary Turner11eb9c62016-10-05 20:03:37 +0000336 if (sub_command.equals_lower("enable")) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000337 Timer::SetDisplayDepth(UINT32_MAX);
338 result.SetStatus(eReturnStatusSuccessFinishNoResult);
Zachary Turner11eb9c62016-10-05 20:03:37 +0000339 } else if (sub_command.equals_lower("disable")) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000340 Timer::DumpCategoryTimes(&result.GetOutputStream());
341 Timer::SetDisplayDepth(0);
342 result.SetStatus(eReturnStatusSuccessFinishResult);
Zachary Turner11eb9c62016-10-05 20:03:37 +0000343 } else if (sub_command.equals_lower("dump")) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000344 Timer::DumpCategoryTimes(&result.GetOutputStream());
345 result.SetStatus(eReturnStatusSuccessFinishResult);
Zachary Turner11eb9c62016-10-05 20:03:37 +0000346 } else if (sub_command.equals_lower("reset")) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000347 Timer::ResetCategoryTimes();
348 result.SetStatus(eReturnStatusSuccessFinishResult);
349 }
Zachary Turner11eb9c62016-10-05 20:03:37 +0000350 } else if (args.GetArgumentCount() == 2) {
Zachary Turner14f6b2c2016-12-09 01:08:29 +0000351 auto sub_command = args[0].ref;
352 auto param = args[1].ref;
Jim Ingham932725f2010-11-04 23:08:26 +0000353
Zachary Turner11eb9c62016-10-05 20:03:37 +0000354 if (sub_command.equals_lower("enable")) {
355 uint32_t depth;
356 if (param.consumeInteger(0, depth)) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000357 result.AppendError(
358 "Could not convert enable depth to an unsigned integer.");
Zachary Turner11eb9c62016-10-05 20:03:37 +0000359 } else {
360 Timer::SetDisplayDepth(depth);
361 result.SetStatus(eReturnStatusSuccessFinishNoResult);
362 }
363 } else if (sub_command.equals_lower("increment")) {
Kate Stoneb9c1b512016-09-06 20:57:50 +0000364 bool success;
Zachary Turner11eb9c62016-10-05 20:03:37 +0000365 bool increment = Args::StringToBoolean(param, false, &success);
Kate Stoneb9c1b512016-09-06 20:57:50 +0000366 if (success) {
367 Timer::SetQuiet(!increment);
368 result.SetStatus(eReturnStatusSuccessFinishNoResult);
369 } else
370 result.AppendError("Could not convert increment value to boolean.");
371 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000372 }
Kate Stoneb9c1b512016-09-06 20:57:50 +0000373
374 if (!result.Succeeded()) {
375 result.AppendError("Missing subcommand");
376 result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
377 }
378 return result.Succeeded();
379 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000380};
381
Kate Stone7428a182016-07-14 22:03:10 +0000382CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000383 : CommandObjectMultiword(interpreter, "log",
384 "Commands controlling LLDB internal logging.",
385 "log <subcommand> [<command-options>]") {
386 LoadSubCommand("enable",
387 CommandObjectSP(new CommandObjectLogEnable(interpreter)));
388 LoadSubCommand("disable",
389 CommandObjectSP(new CommandObjectLogDisable(interpreter)));
390 LoadSubCommand("list",
391 CommandObjectSP(new CommandObjectLogList(interpreter)));
392 LoadSubCommand("timers",
393 CommandObjectSP(new CommandObjectLogTimer(interpreter)));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000394}
395
Eugene Zelenko26cac3a2016-02-20 00:58:29 +0000396CommandObjectLog::~CommandObjectLog() = default;