blob: 4f0af6aeaaa435b3098c1156ef1ced9ea43679a3 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- CommandObjectBreakpoint.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
10#include "CommandObjectBreakpoint.h"
11#include "CommandObjectBreakpointCommand.h"
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/Breakpoint/Breakpoint.h"
18#include "lldb/Breakpoint/BreakpointIDList.h"
19#include "lldb/Breakpoint/BreakpointLocation.h"
Jim Ingham84cdc152010-06-15 19:49:27 +000020#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Core/RegularExpression.h"
22#include "lldb/Core/StreamString.h"
23#include "lldb/Interpreter/CommandInterpreter.h"
24#include "lldb/Interpreter/CommandReturnObject.h"
25#include "lldb/Target/Target.h"
26#include "lldb/Interpreter/CommandCompletions.h"
27#include "lldb/Target/StackFrame.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000028#include "lldb/Target/Thread.h"
29#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000030
Johnny Chena62ad7c2010-10-28 17:27:46 +000031#include <vector>
32
Chris Lattner24943d22010-06-08 16:52:24 +000033using namespace lldb;
34using namespace lldb_private;
35
36static void
Jim Ingham2e8cb8a2011-02-19 02:53:09 +000037AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level)
Chris Lattner24943d22010-06-08 16:52:24 +000038{
39 s->IndentMore();
40 bp->GetDescription (s, level, true);
41 s->IndentLess();
42 s->EOL();
43}
44
45//-------------------------------------------------------------------------
46// CommandObjectBreakpointSet::CommandOptions
47//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +000048#pragma mark Set::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +000049
Greg Claytonf15996e2011-04-07 22:46:35 +000050CommandObjectBreakpointSet::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
51 Options (interpreter),
Johnny Chene4f3cd72012-05-25 21:10:46 +000052 m_condition (),
Jim Inghamd6d47972011-09-23 00:54:11 +000053 m_filenames (),
Chris Lattner24943d22010-06-08 16:52:24 +000054 m_line_num (0),
55 m_column (0),
Greg Clayton2dfe4c62010-11-02 03:02:38 +000056 m_check_inlines (true),
Jim Ingham4722b102012-03-06 00:37:27 +000057 m_func_names (),
58 m_func_name_type_mask (eFunctionNameTypeNone),
Chris Lattner24943d22010-06-08 16:52:24 +000059 m_func_regexp (),
Jim Ingham03c8ee52011-09-21 01:17:13 +000060 m_source_text_regexp(),
Chris Lattner24943d22010-06-08 16:52:24 +000061 m_modules (),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000062 m_load_addr(),
Greg Clayton54e7afa2010-07-09 20:39:50 +000063 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000064 m_thread_id(LLDB_INVALID_THREAD_ID),
Greg Clayton54e7afa2010-07-09 20:39:50 +000065 m_thread_index (UINT32_MAX),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000066 m_thread_name(),
Jim Ingham4722b102012-03-06 00:37:27 +000067 m_queue_name(),
68 m_catch_bp (false),
69 m_throw_bp (false),
Jim Ingham2cf5ccb2012-05-22 00:12:20 +000070 m_language (eLanguageTypeUnknown),
71 m_skip_prologue (eLazyBoolCalculate)
Chris Lattner24943d22010-06-08 16:52:24 +000072{
Chris Lattner24943d22010-06-08 16:52:24 +000073}
74
75CommandObjectBreakpointSet::CommandOptions::~CommandOptions ()
76{
77}
78
Johnny Chen8d03c6f2012-05-08 00:43:20 +000079// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
80// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
Johnny Chen6f4a1152012-05-07 23:23:41 +000081#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
82#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
Jim Ingham2cf5ccb2012-05-22 00:12:20 +000083#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
Jim Inghamd6d47972011-09-23 00:54:11 +000084
Greg Claytonb3448432011-03-24 21:19:54 +000085OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +000086CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
87{
Jim Ingham4722b102012-03-06 00:37:27 +000088 { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
Jim Inghamee033f22012-05-03 20:30:08 +000089 "Set the breakpoint only in this shared library. "
90 "Can repeat this option multiple times to specify multiple shared libraries."},
Jim Ingham34e9a982010-06-15 18:47:14 +000091
Caroline Tice4d6675c2010-10-01 19:59:14 +000092 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
93 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000094
Johnny Chene4f3cd72012-05-25 21:10:46 +000095 { LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression,
96 "The breakpoint stops only if this condition expression evaluates to true."},
97
Bill Wendlingff7df6d2012-04-03 04:13:41 +000098 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000099 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000100
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000101 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000102 "The breakpoint stops only for the thread whose TID matches this argument."},
103
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000104 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000105 "The breakpoint stops only for the thread whose thread name matches this argument."},
106
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000107 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000108 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
109
Jim Inghamd6d47972011-09-23 00:54:11 +0000110 { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
111 "Specifies the source file in which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000112
Caroline Tice4d6675c2010-10-01 19:59:14 +0000113 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Jim Inghamd6d47972011-09-23 00:54:11 +0000114 "Specifies the line number on which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000115
Chris Lattner24943d22010-06-08 16:52:24 +0000116 // Comment out this option for the moment, as we don't actually use it, but will in the future.
117 // This way users won't see it, but the infrastructure is left in place.
Johnny Chene4f3cd72012-05-25 21:10:46 +0000118 // { 0, false, "column", 'C', required_argument, NULL, "<column>",
Chris Lattner24943d22010-06-08 16:52:24 +0000119 // "Set the breakpoint by source location at this particular column."},
120
Caroline Tice4d6675c2010-10-01 19:59:14 +0000121 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000122 "Set the breakpoint by address, at the specified address."},
123
Caroline Tice4d6675c2010-10-01 19:59:14 +0000124 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000125 "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple snames" },
Chris Lattner24943d22010-06-08 16:52:24 +0000126
Caroline Tice4d6675c2010-10-01 19:59:14 +0000127 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamee033f22012-05-03 20:30:08 +0000128 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
129 "for Objective C this means a full function prototype with class and selector. "
130 "Can be repeated multiple times to make one breakpoint for multiple names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000131
Caroline Tice4d6675c2010-10-01 19:59:14 +0000132 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamee033f22012-05-03 20:30:08 +0000133 "Set the breakpoint by ObjC selector name. Can be repeated multiple times to make one breakpoint for multiple Selectors." },
Greg Clayton12bec712010-06-28 21:30:43 +0000134
Caroline Tice4d6675c2010-10-01 19:59:14 +0000135 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamee033f22012-05-03 20:30:08 +0000136 "Set the breakpoint by C++ method names. Can be repeated multiple times to make one breakpoint for multiple methods." },
Greg Clayton12bec712010-06-28 21:30:43 +0000137
Caroline Tice4d6675c2010-10-01 19:59:14 +0000138 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000139 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
140
Greg Clayton48fbdf72010-10-12 04:29:14 +0000141 { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000142 "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). "
143 "Can be repeated multiple times to make one breakpoint for multiple symbols." },
Greg Clayton48fbdf72010-10-12 04:29:14 +0000144
Jim Ingham03c8ee52011-09-21 01:17:13 +0000145 { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression,
146 "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." },
147
Jim Ingham4722b102012-03-06 00:37:27 +0000148 { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage,
149 "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
150
151 { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean,
152 "Set the breakpoint on exception throW." },
153
154 { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
155 "Set the breakpoint on exception catcH." },
Jim Ingham03c8ee52011-09-21 01:17:13 +0000156
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000157 { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', required_argument, NULL, 0, eArgTypeBoolean,
158 "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." },
159
Caroline Tice4d6675c2010-10-01 19:59:14 +0000160 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000161};
162
Greg Claytonb3448432011-03-24 21:19:54 +0000163const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000164CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
165{
166 return g_option_table;
167}
168
169Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000170CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000171{
172 Error error;
173 char short_option = (char) m_getopt_table[option_idx].val;
174
175 switch (short_option)
176 {
177 case 'a':
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000178 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
Chris Lattner24943d22010-06-08 16:52:24 +0000179 if (m_load_addr == LLDB_INVALID_ADDRESS)
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000180 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
Chris Lattner24943d22010-06-08 16:52:24 +0000181
182 if (m_load_addr == LLDB_INVALID_ADDRESS)
Greg Clayton9c236732011-10-26 00:56:27 +0000183 error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000184 break;
185
Johnny Chene4f3cd72012-05-25 21:10:46 +0000186 case 'C':
Chris Lattner24943d22010-06-08 16:52:24 +0000187 m_column = Args::StringToUInt32 (option_arg, 0);
188 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000189
Johnny Chene4f3cd72012-05-25 21:10:46 +0000190 case 'c':
191 m_condition.assign(option_arg);
192 break;
193
Chris Lattner24943d22010-06-08 16:52:24 +0000194 case 'f':
Jim Inghamd6d47972011-09-23 00:54:11 +0000195 m_filenames.AppendIfUnique (FileSpec(option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000196 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000197
Chris Lattner24943d22010-06-08 16:52:24 +0000198 case 'l':
199 m_line_num = Args::StringToUInt32 (option_arg, 0);
200 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000201
Greg Clayton48fbdf72010-10-12 04:29:14 +0000202 case 'b':
Jim Ingham4722b102012-03-06 00:37:27 +0000203 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000204 m_func_name_type_mask |= eFunctionNameTypeBase;
205 break;
206
Greg Clayton48fbdf72010-10-12 04:29:14 +0000207 case 'n':
Jim Ingham4722b102012-03-06 00:37:27 +0000208 m_func_names.push_back (option_arg);
Greg Clayton48fbdf72010-10-12 04:29:14 +0000209 m_func_name_type_mask |= eFunctionNameTypeAuto;
210 break;
211
Greg Clayton12bec712010-06-28 21:30:43 +0000212 case 'F':
Jim Ingham4722b102012-03-06 00:37:27 +0000213 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000214 m_func_name_type_mask |= eFunctionNameTypeFull;
215 break;
216
217 case 'S':
Jim Ingham4722b102012-03-06 00:37:27 +0000218 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000219 m_func_name_type_mask |= eFunctionNameTypeSelector;
220 break;
221
Jim Inghamd9e2b762010-08-26 23:56:11 +0000222 case 'M':
Jim Ingham4722b102012-03-06 00:37:27 +0000223 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000224 m_func_name_type_mask |= eFunctionNameTypeMethod;
225 break;
226
Jim Ingham03c8ee52011-09-21 01:17:13 +0000227 case 'p':
228 m_source_text_regexp.assign (option_arg);
229 break;
230
Chris Lattner24943d22010-06-08 16:52:24 +0000231 case 'r':
Greg Clayton889fbd02011-03-26 19:14:58 +0000232 m_func_regexp.assign (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000233 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000234
Chris Lattner24943d22010-06-08 16:52:24 +0000235 case 's':
236 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000237 m_modules.AppendIfUnique (FileSpec (option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000238 break;
239 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000240 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000241 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000242 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000243 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000244 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000245 }
Jim Ingham10622a22010-06-18 00:58:52 +0000246 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000247 case 't' :
248 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000249 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000250 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +0000251 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000252 }
253 break;
254 case 'T':
Greg Clayton889fbd02011-03-26 19:14:58 +0000255 m_thread_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000256 break;
257 case 'q':
Greg Clayton889fbd02011-03-26 19:14:58 +0000258 m_queue_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000259 break;
260 case 'x':
261 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000262 m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000263 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000264 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000265
266 }
267 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000268 case 'E':
269 {
270 LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
271
272 switch (language)
273 {
274 case eLanguageTypeC89:
275 case eLanguageTypeC:
276 case eLanguageTypeC99:
277 m_language = eLanguageTypeC;
278 break;
279 case eLanguageTypeC_plus_plus:
280 m_language = eLanguageTypeC_plus_plus;
281 break;
282 case eLanguageTypeObjC:
283 m_language = eLanguageTypeObjC;
284 break;
285 case eLanguageTypeObjC_plus_plus:
286 error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
287 break;
288 case eLanguageTypeUnknown:
289 error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
290 break;
291 default:
292 error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
293 }
294 }
295 break;
296 case 'w':
297 {
298 bool success;
299 m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
300 if (!success)
301 error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
302 }
303 break;
304 case 'h':
305 {
306 bool success;
307 m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
308 if (!success)
309 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
310 }
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000311 case 'K':
312 {
313 bool success;
314 bool value;
315 value = Args::StringToBoolean (option_arg, true, &success);
316 if (value)
317 m_skip_prologue = eLazyBoolYes;
318 else
319 m_skip_prologue = eLazyBoolNo;
320
321 if (!success)
322 error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
323 }
Jim Ingham4722b102012-03-06 00:37:27 +0000324 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000325 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000326 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000327 break;
328 }
329
330 return error;
331}
332
333void
Greg Clayton143fcc32011-04-13 00:18:08 +0000334CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000335{
Johnny Chene4f3cd72012-05-25 21:10:46 +0000336 m_condition.clear();
Jim Inghamd6d47972011-09-23 00:54:11 +0000337 m_filenames.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000338 m_line_num = 0;
339 m_column = 0;
Jim Ingham4722b102012-03-06 00:37:27 +0000340 m_func_names.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000341 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000342 m_func_regexp.clear();
343 m_load_addr = LLDB_INVALID_ADDRESS;
Jim Inghamd6d47972011-09-23 00:54:11 +0000344 m_modules.Clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000345 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000346 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000347 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000348 m_thread_name.clear();
349 m_queue_name.clear();
Jim Ingham4722b102012-03-06 00:37:27 +0000350 m_language = eLanguageTypeUnknown;
351 m_catch_bp = false;
352 m_throw_bp = true;
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000353 m_skip_prologue = eLazyBoolCalculate;
Chris Lattner24943d22010-06-08 16:52:24 +0000354}
355
356//-------------------------------------------------------------------------
357// CommandObjectBreakpointSet
358//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000359#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000360
Greg Clayton238c0a12010-09-18 01:14:36 +0000361CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
362 CommandObject (interpreter,
363 "breakpoint set",
364 "Sets a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000365 "breakpoint set <cmd-options>"),
366 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000367{
368}
369
370CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
371{
372}
373
374Options *
375CommandObjectBreakpointSet::GetOptions ()
376{
377 return &m_options;
378}
379
380bool
Jim Inghamd6d47972011-09-23 00:54:11 +0000381CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000382{
Jim Inghamd6d47972011-09-23 00:54:11 +0000383 uint32_t default_line;
384 // First use the Source Manager's default file.
385 // Then use the current stack frame's file.
386 if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
Jim Ingham03c8ee52011-09-21 01:17:13 +0000387 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000388 StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
389 if (cur_frame == NULL)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000390 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000391 result.AppendError ("No selected frame to use to find the default file.");
392 result.SetStatus (eReturnStatusFailed);
393 return false;
394 }
395 else if (!cur_frame->HasDebugInformation())
396 {
397 result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
398 result.SetStatus (eReturnStatusFailed);
399 return false;
400 }
401 else
402 {
403 const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
404 if (sc.line_entry.file)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000405 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000406 file = sc.line_entry.file;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000407 }
408 else
409 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000410 result.AppendError ("Can't find the file for the selected frame to use as the default file.");
411 result.SetStatus (eReturnStatusFailed);
412 return false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000413 }
414 }
415 }
Jim Ingham03c8ee52011-09-21 01:17:13 +0000416 return true;
417}
418
419bool
Chris Lattner24943d22010-06-08 16:52:24 +0000420CommandObjectBreakpointSet::Execute
421(
422 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000423 CommandReturnObject &result
424)
425{
Greg Clayton238c0a12010-09-18 01:14:36 +0000426 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000427 if (target == NULL)
428 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000429 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000430 result.SetStatus (eReturnStatusFailed);
431 return false;
432 }
433
434 // The following are the various types of breakpoints that could be set:
435 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
436 // 2). -a [-s -g] (setting breakpoint by address)
437 // 3). -n [-s -g] (setting breakpoint by function name)
438 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000439 // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
Jim Ingham4722b102012-03-06 00:37:27 +0000440 // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.)
Chris Lattner24943d22010-06-08 16:52:24 +0000441
442 BreakpointSetType break_type = eSetTypeInvalid;
443
444 if (m_options.m_line_num != 0)
445 break_type = eSetTypeFileAndLine;
446 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
447 break_type = eSetTypeAddress;
Jim Ingham4722b102012-03-06 00:37:27 +0000448 else if (!m_options.m_func_names.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000449 break_type = eSetTypeFunctionName;
450 else if (!m_options.m_func_regexp.empty())
451 break_type = eSetTypeFunctionRegexp;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000452 else if (!m_options.m_source_text_regexp.empty())
453 break_type = eSetTypeSourceRegexp;
Jim Ingham4722b102012-03-06 00:37:27 +0000454 else if (m_options.m_language != eLanguageTypeUnknown)
455 break_type = eSetTypeException;
Chris Lattner24943d22010-06-08 16:52:24 +0000456
Chris Lattner24943d22010-06-08 16:52:24 +0000457 Breakpoint *bp = NULL;
Greg Clayton537a7a82010-10-20 20:54:39 +0000458 FileSpec module_spec;
Chris Lattner24943d22010-06-08 16:52:24 +0000459 bool use_module = false;
Jim Inghamd6d47972011-09-23 00:54:11 +0000460 int num_modules = m_options.m_modules.GetSize();
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000461
462 const bool internal = false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000463
Chris Lattner24943d22010-06-08 16:52:24 +0000464 if ((num_modules > 0) && (break_type != eSetTypeAddress))
465 use_module = true;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000466
Chris Lattner24943d22010-06-08 16:52:24 +0000467 switch (break_type)
468 {
469 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000470 {
Greg Clayton887aa282010-10-11 01:05:37 +0000471 FileSpec file;
Jim Inghamd6d47972011-09-23 00:54:11 +0000472 uint32_t num_files = m_options.m_filenames.GetSize();
473 if (num_files == 0)
474 {
475 if (!GetDefaultFile (target, file, result))
476 {
477 result.AppendError("No file supplied and no default file available.");
478 result.SetStatus (eReturnStatusFailed);
479 return false;
480 }
481 }
482 else if (num_files > 1)
483 {
484 result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
485 result.SetStatus (eReturnStatusFailed);
486 return false;
487 }
488 else
489 file = m_options.m_filenames.GetFileSpecAtIndex(0);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000490
Jim Inghamd6d47972011-09-23 00:54:11 +0000491 bp = target->CreateBreakpoint (&(m_options.m_modules),
Jim Ingham03c8ee52011-09-21 01:17:13 +0000492 file,
493 m_options.m_line_num,
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000494 m_options.m_check_inlines,
495 m_options.m_skip_prologue,
496 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000497 }
Greg Clayton887aa282010-10-11 01:05:37 +0000498 break;
499
Chris Lattner24943d22010-06-08 16:52:24 +0000500 case eSetTypeAddress: // Breakpoint by address
501 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
502 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000503
Chris Lattner24943d22010-06-08 16:52:24 +0000504 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000505 {
Greg Clayton12bec712010-06-28 21:30:43 +0000506 uint32_t name_type_mask = m_options.m_func_name_type_mask;
507
508 if (name_type_mask == 0)
Greg Clayton48fbdf72010-10-12 04:29:14 +0000509 name_type_mask = eFunctionNameTypeAuto;
Jim Ingham4722b102012-03-06 00:37:27 +0000510
Jim Inghamd6d47972011-09-23 00:54:11 +0000511 bp = target->CreateBreakpoint (&(m_options.m_modules),
512 &(m_options.m_filenames),
Jim Ingham4722b102012-03-06 00:37:27 +0000513 m_options.m_func_names,
514 name_type_mask,
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000515 m_options.m_skip_prologue,
516 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000517 }
Chris Lattner24943d22010-06-08 16:52:24 +0000518 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000519
Chris Lattner24943d22010-06-08 16:52:24 +0000520 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
521 {
522 RegularExpression regexp(m_options.m_func_regexp.c_str());
Jim Ingham03c8ee52011-09-21 01:17:13 +0000523 if (!regexp.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000524 {
Jim Ingham03c8ee52011-09-21 01:17:13 +0000525 char err_str[1024];
526 regexp.GetErrorAsCString(err_str, sizeof(err_str));
527 result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
528 err_str);
529 result.SetStatus (eReturnStatusFailed);
530 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000531 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000532
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000533 bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
534 &(m_options.m_filenames),
535 regexp,
536 m_options.m_skip_prologue,
537 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000538 }
539 break;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000540 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
541 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000542 int num_files = m_options.m_filenames.GetSize();
543
544 if (num_files == 0)
545 {
546 FileSpec file;
547 if (!GetDefaultFile (target, file, result))
548 {
549 result.AppendError ("No files provided and could not find default file.");
550 result.SetStatus (eReturnStatusFailed);
551 return false;
552 }
553 else
554 {
555 m_options.m_filenames.Append (file);
556 }
557 }
558
Jim Ingham03c8ee52011-09-21 01:17:13 +0000559 RegularExpression regexp(m_options.m_source_text_regexp.c_str());
560 if (!regexp.IsValid())
561 {
562 char err_str[1024];
563 regexp.GetErrorAsCString(err_str, sizeof(err_str));
564 result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
565 err_str);
566 result.SetStatus (eReturnStatusFailed);
567 return false;
568 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000569 bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000570 }
571 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000572 case eSetTypeException:
573 {
574 bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
575 }
576 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000577 default:
578 break;
579 }
580
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000581 // Now set the various options that were passed in:
582 if (bp)
583 {
584 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
585 bp->SetThreadID (m_options.m_thread_id);
586
Greg Clayton54e7afa2010-07-09 20:39:50 +0000587 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000588 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
589
590 if (!m_options.m_thread_name.empty())
591 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
592
593 if (!m_options.m_queue_name.empty())
594 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
595
Greg Clayton54e7afa2010-07-09 20:39:50 +0000596 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000597 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
Johnny Chene4f3cd72012-05-25 21:10:46 +0000598
599 if (!m_options.m_condition.empty())
600 bp->GetOptions()->SetCondition(m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000601 }
602
Jim Ingham03c8ee52011-09-21 01:17:13 +0000603 if (bp)
Chris Lattner24943d22010-06-08 16:52:24 +0000604 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000605 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000606 output_stream.Printf ("Breakpoint created: ");
607 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
608 output_stream.EOL();
Jim Ingham4722b102012-03-06 00:37:27 +0000609 // Don't print out this warning for exception breakpoints. They can get set before the target
610 // is set, but we won't know how to actually set the breakpoint till we run.
611 if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
Caroline Ticecf2f3052010-10-28 16:28:56 +0000612 output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n");
Chris Lattner24943d22010-06-08 16:52:24 +0000613 result.SetStatus (eReturnStatusSuccessFinishResult);
614 }
615 else if (!bp)
616 {
617 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
618 result.SetStatus (eReturnStatusFailed);
619 }
620
621 return result.Succeeded();
622}
623
Chris Lattner24943d22010-06-08 16:52:24 +0000624//-------------------------------------------------------------------------
625// CommandObjectMultiwordBreakpoint
626//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000627#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000628
Greg Clayton63094e02010-06-23 01:19:29 +0000629CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000630 CommandObjectMultiword (interpreter,
631 "breakpoint",
Jim Ingham7224aab2011-05-26 20:39:01 +0000632 "A set of commands for operating on breakpoints. Also see _regexp-break.",
Greg Clayton238c0a12010-09-18 01:14:36 +0000633 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000634{
635 bool status;
636
Greg Clayton238c0a12010-09-18 01:14:36 +0000637 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000638 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
639 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
Johnny Chena62ad7c2010-10-28 17:27:46 +0000640 CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
641 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000642 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000643 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000644 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000645
Johnny Chena62ad7c2010-10-28 17:27:46 +0000646 list_command_object->SetCommandName ("breakpoint list");
Chris Lattner24943d22010-06-08 16:52:24 +0000647 enable_command_object->SetCommandName("breakpoint enable");
648 disable_command_object->SetCommandName("breakpoint disable");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000649 clear_command_object->SetCommandName("breakpoint clear");
650 delete_command_object->SetCommandName("breakpoint delete");
Jim Ingham10622a22010-06-18 00:58:52 +0000651 set_command_object->SetCommandName("breakpoint set");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000652 command_command_object->SetCommandName ("breakpoint command");
653 modify_command_object->SetCommandName ("breakpoint modify");
Chris Lattner24943d22010-06-08 16:52:24 +0000654
Greg Clayton238c0a12010-09-18 01:14:36 +0000655 status = LoadSubCommand ("list", list_command_object);
656 status = LoadSubCommand ("enable", enable_command_object);
657 status = LoadSubCommand ("disable", disable_command_object);
Johnny Chena62ad7c2010-10-28 17:27:46 +0000658 status = LoadSubCommand ("clear", clear_command_object);
Greg Clayton238c0a12010-09-18 01:14:36 +0000659 status = LoadSubCommand ("delete", delete_command_object);
660 status = LoadSubCommand ("set", set_command_object);
661 status = LoadSubCommand ("command", command_command_object);
662 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000663}
664
665CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
666{
667}
668
669void
670CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
671 BreakpointIDList *valid_ids)
672{
673 // args can be strings representing 1). integers (for breakpoint ids)
674 // 2). the full breakpoint & location canonical representation
675 // 3). the word "to" or a hyphen, representing a range (in which case there
676 // had *better* be an entry both before & after of one of the first two types.
Jim Inghamd1686902010-10-14 23:45:03 +0000677 // If args is empty, we will use the last created breakpoint (if there is one.)
Chris Lattner24943d22010-06-08 16:52:24 +0000678
679 Args temp_args;
680
Jim Inghamd1686902010-10-14 23:45:03 +0000681 if (args.GetArgumentCount() == 0)
682 {
Greg Clayton987c7eb2011-09-17 08:33:22 +0000683 if (target->GetLastCreatedBreakpoint())
Jim Inghamd1686902010-10-14 23:45:03 +0000684 {
685 valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
686 result.SetStatus (eReturnStatusSuccessFinishNoResult);
687 }
688 else
689 {
690 result.AppendError("No breakpoint specified and no last created breakpoint.");
691 result.SetStatus (eReturnStatusFailed);
692 }
693 return;
694 }
695
Chris Lattner24943d22010-06-08 16:52:24 +0000696 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
697 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
698 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
699
700 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
701
702 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
703
Greg Clayton54e7afa2010-07-09 20:39:50 +0000704 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000705
706 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
707 // and put into valid_ids.
708
709 if (result.Succeeded())
710 {
711 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
712 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
713
Greg Clayton54e7afa2010-07-09 20:39:50 +0000714 const size_t count = valid_ids->GetSize();
715 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000716 {
717 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
718 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
719 if (breakpoint != NULL)
720 {
721 int num_locations = breakpoint->GetNumLocations();
722 if (cur_bp_id.GetLocationID() > num_locations)
723 {
724 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000725 BreakpointID::GetCanonicalReference (&id_str,
726 cur_bp_id.GetBreakpointID(),
727 cur_bp_id.GetLocationID());
728 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000729 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
730 id_str.GetData());
731 result.SetStatus (eReturnStatusFailed);
732 }
733 }
734 else
735 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000736 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000737 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
738 result.SetStatus (eReturnStatusFailed);
739 }
740 }
741 }
742}
743
744//-------------------------------------------------------------------------
745// CommandObjectBreakpointList::Options
746//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000747#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000748
Greg Claytonf15996e2011-04-07 22:46:35 +0000749CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
750 Options (interpreter),
Caroline Tice41950cc2011-02-04 22:59:41 +0000751 m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions
Chris Lattner24943d22010-06-08 16:52:24 +0000752{
Chris Lattner24943d22010-06-08 16:52:24 +0000753}
754
755CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
756{
757}
758
Greg Claytonb3448432011-03-24 21:19:54 +0000759OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000760CommandObjectBreakpointList::CommandOptions::g_option_table[] =
761{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000762 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000763 "Show debugger internal breakpoints" },
764
Caroline Tice4d6675c2010-10-01 19:59:14 +0000765 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000766 "Give a brief description of the breakpoint (no location info)."},
767
768 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
769 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000770 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000771 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000772
Caroline Tice4d6675c2010-10-01 19:59:14 +0000773 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000774 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000775
Caroline Tice4d6675c2010-10-01 19:59:14 +0000776 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000777};
778
Greg Claytonb3448432011-03-24 21:19:54 +0000779const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000780CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
781{
782 return g_option_table;
783}
784
785Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000786CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000787{
788 Error error;
789 char short_option = (char) m_getopt_table[option_idx].val;
790
791 switch (short_option)
792 {
793 case 'b':
794 m_level = lldb::eDescriptionLevelBrief;
795 break;
796 case 'f':
797 m_level = lldb::eDescriptionLevelFull;
798 break;
799 case 'v':
800 m_level = lldb::eDescriptionLevelVerbose;
801 break;
802 case 'i':
803 m_internal = true;
804 break;
805 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000806 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000807 break;
808 }
809
810 return error;
811}
812
813void
Greg Clayton143fcc32011-04-13 00:18:08 +0000814CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000815{
Jim Inghamdc259052011-05-17 01:21:41 +0000816 m_level = lldb::eDescriptionLevelFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000817 m_internal = false;
818}
819
820//-------------------------------------------------------------------------
821// CommandObjectBreakpointList
822//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000823#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000824
Greg Clayton238c0a12010-09-18 01:14:36 +0000825CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
826 CommandObject (interpreter,
827 "breakpoint list",
828 "List some or all breakpoints at configurable levels of detail.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000829 NULL),
830 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000831{
Caroline Ticefb355112010-10-01 17:46:38 +0000832 CommandArgumentEntry arg;
833 CommandArgumentData bp_id_arg;
834
835 // Define the first (and only) variant of this arg.
836 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000837 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000838
839 // There is only one variant this argument could be; put it into the argument entry.
840 arg.push_back (bp_id_arg);
841
842 // Push the data for the first argument into the m_arguments vector.
843 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000844}
845
846CommandObjectBreakpointList::~CommandObjectBreakpointList ()
847{
848}
849
850Options *
851CommandObjectBreakpointList::GetOptions ()
852{
853 return &m_options;
854}
855
856bool
857CommandObjectBreakpointList::Execute
858(
859 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000860 CommandReturnObject &result
861)
862{
Greg Clayton238c0a12010-09-18 01:14:36 +0000863 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000864 if (target == NULL)
865 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000866 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000867 result.SetStatus (eReturnStatusSuccessFinishNoResult);
868 return true;
869 }
870
871 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000872 Mutex::Locker locker;
873 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
874
Chris Lattner24943d22010-06-08 16:52:24 +0000875 size_t num_breakpoints = breakpoints.GetSize();
876
877 if (num_breakpoints == 0)
878 {
879 result.AppendMessage ("No breakpoints currently set.");
880 result.SetStatus (eReturnStatusSuccessFinishNoResult);
881 return true;
882 }
883
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000884 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000885
886 if (args.GetArgumentCount() == 0)
887 {
888 // No breakpoint selected; show info about all currently set breakpoints.
889 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000890 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000891 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000892 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000893 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000894 }
895 result.SetStatus (eReturnStatusSuccessFinishNoResult);
896 }
897 else
898 {
899 // Particular breakpoints selected; show info about that breakpoint.
900 BreakpointIDList valid_bp_ids;
901 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
902
903 if (result.Succeeded())
904 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000905 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000906 {
907 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
908 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000909 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000910 }
911 result.SetStatus (eReturnStatusSuccessFinishNoResult);
912 }
913 else
914 {
915 result.AppendError ("Invalid breakpoint id.");
916 result.SetStatus (eReturnStatusFailed);
917 }
918 }
919
920 return result.Succeeded();
921}
922
923//-------------------------------------------------------------------------
924// CommandObjectBreakpointEnable
925//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000926#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000927
Greg Clayton238c0a12010-09-18 01:14:36 +0000928CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
929 CommandObject (interpreter,
930 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000931 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
932 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000933{
Caroline Ticefb355112010-10-01 17:46:38 +0000934 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000935 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000936 // Add the entry for the first argument for this command to the object's arguments vector.
937 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000938}
939
940
941CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
942{
943}
944
945
946bool
Greg Clayton63094e02010-06-23 01:19:29 +0000947CommandObjectBreakpointEnable::Execute
948(
Greg Clayton63094e02010-06-23 01:19:29 +0000949 Args& args,
950 CommandReturnObject &result
951)
Chris Lattner24943d22010-06-08 16:52:24 +0000952{
Greg Clayton238c0a12010-09-18 01:14:36 +0000953 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000954 if (target == NULL)
955 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000956 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000957 result.SetStatus (eReturnStatusFailed);
958 return false;
959 }
960
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000961 Mutex::Locker locker;
962 target->GetBreakpointList().GetListMutex(locker);
963
Chris Lattner24943d22010-06-08 16:52:24 +0000964 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000965
Chris Lattner24943d22010-06-08 16:52:24 +0000966 size_t num_breakpoints = breakpoints.GetSize();
967
968 if (num_breakpoints == 0)
969 {
970 result.AppendError ("No breakpoints exist to be enabled.");
971 result.SetStatus (eReturnStatusFailed);
972 return false;
973 }
974
975 if (args.GetArgumentCount() == 0)
976 {
977 // No breakpoint selected; enable all currently set breakpoints.
978 target->EnableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000979 result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +0000980 result.SetStatus (eReturnStatusSuccessFinishNoResult);
981 }
982 else
983 {
984 // Particular breakpoint selected; enable that breakpoint.
985 BreakpointIDList valid_bp_ids;
986 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
987
988 if (result.Succeeded())
989 {
990 int enable_count = 0;
991 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000992 const size_t count = valid_bp_ids.GetSize();
993 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000994 {
995 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
996
997 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
998 {
999 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1000 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1001 {
1002 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1003 if (location)
1004 {
1005 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +00001006 ++loc_count;
1007 }
1008 }
1009 else
1010 {
Jim Ingham10622a22010-06-18 00:58:52 +00001011 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +00001012 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001013 }
1014 }
1015 }
1016 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
1017 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1018 }
1019 }
1020
1021 return result.Succeeded();
1022}
1023
1024//-------------------------------------------------------------------------
1025// CommandObjectBreakpointDisable
1026//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001027#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +00001028
Greg Clayton238c0a12010-09-18 01:14:36 +00001029CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
1030 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +00001031 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001032 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001033 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001034{
Caroline Ticefb355112010-10-01 17:46:38 +00001035 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001036 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001037 // Add the entry for the first argument for this command to the object's arguments vector.
1038 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001039}
1040
1041CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
1042{
1043}
1044
1045bool
Greg Clayton63094e02010-06-23 01:19:29 +00001046CommandObjectBreakpointDisable::Execute
1047(
Greg Clayton63094e02010-06-23 01:19:29 +00001048 Args& args,
1049 CommandReturnObject &result
1050)
Chris Lattner24943d22010-06-08 16:52:24 +00001051{
Greg Clayton238c0a12010-09-18 01:14:36 +00001052 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001053 if (target == NULL)
1054 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001055 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001056 result.SetStatus (eReturnStatusFailed);
1057 return false;
1058 }
1059
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001060 Mutex::Locker locker;
1061 target->GetBreakpointList().GetListMutex(locker);
1062
Chris Lattner24943d22010-06-08 16:52:24 +00001063 const BreakpointList &breakpoints = target->GetBreakpointList();
1064 size_t num_breakpoints = breakpoints.GetSize();
1065
1066 if (num_breakpoints == 0)
1067 {
1068 result.AppendError ("No breakpoints exist to be disabled.");
1069 result.SetStatus (eReturnStatusFailed);
1070 return false;
1071 }
1072
1073 if (args.GetArgumentCount() == 0)
1074 {
1075 // No breakpoint selected; disable all currently set breakpoints.
1076 target->DisableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001077 result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +00001078 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1079 }
1080 else
1081 {
1082 // Particular breakpoint selected; disable that breakpoint.
1083 BreakpointIDList valid_bp_ids;
1084
1085 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1086
1087 if (result.Succeeded())
1088 {
1089 int disable_count = 0;
1090 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001091 const size_t count = valid_bp_ids.GetSize();
1092 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001093 {
1094 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1095
1096 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1097 {
1098 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1099 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1100 {
1101 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1102 if (location)
1103 {
1104 location->SetEnabled (false);
1105 ++loc_count;
1106 }
1107 }
1108 else
1109 {
Jim Ingham10622a22010-06-18 00:58:52 +00001110 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001111 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001112 }
1113 }
1114 }
1115 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1116 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1117 }
1118 }
1119
1120 return result.Succeeded();
1121}
1122
1123//-------------------------------------------------------------------------
Johnny Chena62ad7c2010-10-28 17:27:46 +00001124// CommandObjectBreakpointClear::CommandOptions
1125//-------------------------------------------------------------------------
1126#pragma mark Clear::CommandOptions
1127
Greg Claytonf15996e2011-04-07 22:46:35 +00001128CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1129 Options (interpreter),
Johnny Chena62ad7c2010-10-28 17:27:46 +00001130 m_filename (),
1131 m_line_num (0)
1132{
1133}
1134
1135CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
1136{
1137}
1138
Greg Claytonb3448432011-03-24 21:19:54 +00001139OptionDefinition
Johnny Chena62ad7c2010-10-28 17:27:46 +00001140CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
1141{
1142 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
1143 "Specify the breakpoint by source location in this particular file."},
1144
1145 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
1146 "Specify the breakpoint by source location at this particular line."},
1147
1148 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1149};
1150
Greg Claytonb3448432011-03-24 21:19:54 +00001151const OptionDefinition*
Johnny Chena62ad7c2010-10-28 17:27:46 +00001152CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
1153{
1154 return g_option_table;
1155}
1156
1157Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001158CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001159{
1160 Error error;
1161 char short_option = (char) m_getopt_table[option_idx].val;
1162
1163 switch (short_option)
1164 {
1165 case 'f':
Greg Clayton889fbd02011-03-26 19:14:58 +00001166 m_filename.assign (option_arg);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001167 break;
1168
1169 case 'l':
1170 m_line_num = Args::StringToUInt32 (option_arg, 0);
1171 break;
1172
1173 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001174 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001175 break;
1176 }
1177
1178 return error;
1179}
1180
1181void
Greg Clayton143fcc32011-04-13 00:18:08 +00001182CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
Johnny Chena62ad7c2010-10-28 17:27:46 +00001183{
Johnny Chena62ad7c2010-10-28 17:27:46 +00001184 m_filename.clear();
1185 m_line_num = 0;
1186}
1187
1188//-------------------------------------------------------------------------
1189// CommandObjectBreakpointClear
1190//-------------------------------------------------------------------------
1191#pragma mark Clear
1192
1193CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
1194 CommandObject (interpreter,
1195 "breakpoint clear",
1196 "Clears a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001197 "breakpoint clear <cmd-options>"),
1198 m_options (interpreter)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001199{
1200}
1201
1202CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
1203{
1204}
1205
1206Options *
1207CommandObjectBreakpointClear::GetOptions ()
1208{
1209 return &m_options;
1210}
1211
1212bool
1213CommandObjectBreakpointClear::Execute
1214(
1215 Args& command,
1216 CommandReturnObject &result
1217)
1218{
1219 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
1220 if (target == NULL)
1221 {
1222 result.AppendError ("Invalid target. No existing target or breakpoints.");
1223 result.SetStatus (eReturnStatusFailed);
1224 return false;
1225 }
1226
1227 // The following are the various types of breakpoints that could be cleared:
1228 // 1). -f -l (clearing breakpoint by source location)
1229
1230 BreakpointClearType break_type = eClearTypeInvalid;
1231
1232 if (m_options.m_line_num != 0)
1233 break_type = eClearTypeFileAndLine;
1234
1235 Mutex::Locker locker;
1236 target->GetBreakpointList().GetListMutex(locker);
1237
1238 BreakpointList &breakpoints = target->GetBreakpointList();
1239 size_t num_breakpoints = breakpoints.GetSize();
1240
1241 // Early return if there's no breakpoint at all.
1242 if (num_breakpoints == 0)
1243 {
1244 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1245 result.SetStatus (eReturnStatusFailed);
1246 return result.Succeeded();
1247 }
1248
1249 // Find matching breakpoints and delete them.
1250
1251 // First create a copy of all the IDs.
1252 std::vector<break_id_t> BreakIDs;
1253 for (size_t i = 0; i < num_breakpoints; ++i)
1254 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
1255
1256 int num_cleared = 0;
1257 StreamString ss;
1258 switch (break_type)
1259 {
1260 case eClearTypeFileAndLine: // Breakpoint by source position
1261 {
1262 const ConstString filename(m_options.m_filename.c_str());
1263 BreakpointLocationCollection loc_coll;
1264
1265 for (size_t i = 0; i < num_breakpoints; ++i)
1266 {
1267 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
1268
1269 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
1270 {
1271 // If the collection size is 0, it's a full match and we can just remove the breakpoint.
1272 if (loc_coll.GetSize() == 0)
1273 {
1274 bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
1275 ss.EOL();
1276 target->RemoveBreakpointByID (bp->GetID());
1277 ++num_cleared;
1278 }
1279 }
1280 }
1281 }
1282 break;
1283
1284 default:
1285 break;
1286 }
1287
1288 if (num_cleared > 0)
1289 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +00001290 Stream &output_stream = result.GetOutputStream();
Johnny Chena62ad7c2010-10-28 17:27:46 +00001291 output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
1292 output_stream << ss.GetData();
1293 output_stream.EOL();
1294 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1295 }
1296 else
1297 {
1298 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1299 result.SetStatus (eReturnStatusFailed);
1300 }
1301
1302 return result.Succeeded();
1303}
1304
1305//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001306// CommandObjectBreakpointDelete
1307//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001308#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001309
Greg Clayton238c0a12010-09-18 01:14:36 +00001310CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1311 CommandObject (interpreter,
1312 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001313 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001314 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001315{
Caroline Ticefb355112010-10-01 17:46:38 +00001316 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001317 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001318 // Add the entry for the first argument for this command to the object's arguments vector.
1319 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001320}
1321
1322
1323CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1324{
1325}
1326
1327bool
Greg Clayton63094e02010-06-23 01:19:29 +00001328CommandObjectBreakpointDelete::Execute
1329(
Greg Clayton63094e02010-06-23 01:19:29 +00001330 Args& args,
1331 CommandReturnObject &result
1332)
Chris Lattner24943d22010-06-08 16:52:24 +00001333{
Greg Clayton238c0a12010-09-18 01:14:36 +00001334 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001335 if (target == NULL)
1336 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001337 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001338 result.SetStatus (eReturnStatusFailed);
1339 return false;
1340 }
1341
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001342 Mutex::Locker locker;
1343 target->GetBreakpointList().GetListMutex(locker);
1344
Chris Lattner24943d22010-06-08 16:52:24 +00001345 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001346
Chris Lattner24943d22010-06-08 16:52:24 +00001347 size_t num_breakpoints = breakpoints.GetSize();
1348
1349 if (num_breakpoints == 0)
1350 {
1351 result.AppendError ("No breakpoints exist to be deleted.");
1352 result.SetStatus (eReturnStatusFailed);
1353 return false;
1354 }
1355
1356 if (args.GetArgumentCount() == 0)
1357 {
Jim Inghamd1686902010-10-14 23:45:03 +00001358 if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
Chris Lattner24943d22010-06-08 16:52:24 +00001359 {
Jim Inghamd1686902010-10-14 23:45:03 +00001360 result.AppendMessage("Operation cancelled...");
Chris Lattner24943d22010-06-08 16:52:24 +00001361 }
Jim Inghamd1686902010-10-14 23:45:03 +00001362 else
1363 {
1364 target->RemoveAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001365 result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
Jim Inghamd1686902010-10-14 23:45:03 +00001366 }
Chris Lattner24943d22010-06-08 16:52:24 +00001367 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1368 }
1369 else
1370 {
1371 // Particular breakpoint selected; disable that breakpoint.
1372 BreakpointIDList valid_bp_ids;
1373 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1374
1375 if (result.Succeeded())
1376 {
1377 int delete_count = 0;
1378 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001379 const size_t count = valid_bp_ids.GetSize();
1380 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001381 {
1382 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1383
1384 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1385 {
1386 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1387 {
1388 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1389 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1390 // It makes no sense to try to delete individual locations, so we disable them instead.
1391 if (location)
1392 {
1393 location->SetEnabled (false);
1394 ++disable_count;
1395 }
1396 }
1397 else
1398 {
1399 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1400 ++delete_count;
1401 }
1402 }
1403 }
1404 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1405 delete_count, disable_count);
1406 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1407 }
1408 }
1409 return result.Succeeded();
1410}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001411
1412//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001413// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001414//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001415#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001416
Greg Claytonf15996e2011-04-07 22:46:35 +00001417CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1418 Options (interpreter),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001419 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001420 m_thread_id(LLDB_INVALID_THREAD_ID),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001421 m_thread_id_passed(false),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001422 m_thread_index (UINT32_MAX),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001423 m_thread_index_passed(false),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001424 m_thread_name(),
1425 m_queue_name(),
Jim Inghamd1686902010-10-14 23:45:03 +00001426 m_condition (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001427 m_enable_passed (false),
1428 m_enable_value (false),
1429 m_name_passed (false),
Jim Inghamd1686902010-10-14 23:45:03 +00001430 m_queue_passed (false),
1431 m_condition_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001432{
1433}
1434
Jim Ingham10622a22010-06-18 00:58:52 +00001435CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001436{
1437}
1438
Greg Claytonb3448432011-03-24 21:19:54 +00001439OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001440CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001441{
Bill Wendlingff7df6d2012-04-03 04:13:41 +00001442{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1443{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
1444{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
1445{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
1446{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
1447{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
1448{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."},
1449{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."},
Jim Inghamd1686902010-10-14 23:45:03 +00001450{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001451};
1452
Greg Claytonb3448432011-03-24 21:19:54 +00001453const OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001454CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001455{
1456 return g_option_table;
1457}
1458
1459Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001460CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001461{
1462 Error error;
1463 char short_option = (char) m_getopt_table[option_idx].val;
1464
1465 switch (short_option)
1466 {
Jim Inghamd1686902010-10-14 23:45:03 +00001467 case 'c':
1468 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001469 m_condition.assign (option_arg);
Jim Inghamd1686902010-10-14 23:45:03 +00001470 else
1471 m_condition.clear();
1472 m_condition_passed = true;
1473 break;
Jim Ingham10622a22010-06-18 00:58:52 +00001474 case 'd':
1475 m_enable_passed = true;
1476 m_enable_value = false;
1477 break;
1478 case 'e':
1479 m_enable_passed = true;
1480 m_enable_value = true;
1481 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001482 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001483 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001484 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +00001485 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001486 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001487 }
Jim Ingham10622a22010-06-18 00:58:52 +00001488 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001489 case 't' :
1490 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001491 if (option_arg[0] == '\0')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001492 {
1493 m_thread_id = LLDB_INVALID_THREAD_ID;
1494 m_thread_id_passed = true;
1495 }
1496 else
1497 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001498 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001499 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +00001500 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001501 else
1502 m_thread_id_passed = true;
1503 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001504 }
1505 break;
1506 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001507 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001508 m_thread_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001509 else
1510 m_thread_name.clear();
1511 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001512 break;
1513 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001514 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001515 m_queue_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001516 else
1517 m_queue_name.clear();
1518 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001519 break;
1520 case 'x':
1521 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001522 if (option_arg[0] == '\n')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001523 {
1524 m_thread_index = UINT32_MAX;
1525 m_thread_index_passed = true;
1526 }
1527 else
1528 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001529 m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001530 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001531 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001532 else
1533 m_thread_index_passed = true;
1534 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001535 }
1536 break;
1537 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001538 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001539 break;
1540 }
1541
1542 return error;
1543}
1544
1545void
Greg Clayton143fcc32011-04-13 00:18:08 +00001546CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001547{
Greg Clayton54e7afa2010-07-09 20:39:50 +00001548 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001549 m_thread_id = LLDB_INVALID_THREAD_ID;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001550 m_thread_id_passed = false;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001551 m_thread_index = UINT32_MAX;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001552 m_thread_index_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001553 m_thread_name.clear();
1554 m_queue_name.clear();
Jim Inghamd1686902010-10-14 23:45:03 +00001555 m_condition.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001556 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001557 m_queue_passed = false;
1558 m_name_passed = false;
Jim Inghamd1686902010-10-14 23:45:03 +00001559 m_condition_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001560}
1561
1562//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001563// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001564//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001565#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001566
Greg Clayton238c0a12010-09-18 01:14:36 +00001567CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1568 CommandObject (interpreter,
1569 "breakpoint modify",
Jim Ingham19ac0bd2010-12-03 22:37:19 +00001570 "Modify the options on a breakpoint or set of breakpoints in the executable. "
Jim Ingham9a7b2912010-12-03 23:04:19 +00001571 "If no breakpoint is specified, acts on the last created breakpoint. "
1572 "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001573 NULL),
1574 m_options (interpreter)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001575{
Caroline Ticefb355112010-10-01 17:46:38 +00001576 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001577 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001578 // Add the entry for the first argument for this command to the object's arguments vector.
1579 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001580}
1581
Jim Ingham10622a22010-06-18 00:58:52 +00001582CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001583{
1584}
1585
1586Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001587CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001588{
1589 return &m_options;
1590}
1591
1592bool
Jim Ingham10622a22010-06-18 00:58:52 +00001593CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001594(
1595 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001596 CommandReturnObject &result
1597)
1598{
Greg Clayton238c0a12010-09-18 01:14:36 +00001599 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001600 if (target == NULL)
1601 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001602 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001603 result.SetStatus (eReturnStatusFailed);
1604 return false;
1605 }
1606
1607 Mutex::Locker locker;
1608 target->GetBreakpointList().GetListMutex(locker);
1609
1610 BreakpointIDList valid_bp_ids;
1611
1612 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1613
1614 if (result.Succeeded())
1615 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001616 const size_t count = valid_bp_ids.GetSize();
1617 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001618 {
1619 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1620
1621 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1622 {
1623 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1624 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1625 {
1626 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1627 if (location)
1628 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001629 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001630 location->SetThreadID (m_options.m_thread_id);
1631
Jim Ingham9a7b2912010-12-03 23:04:19 +00001632 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001633 location->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001634
Jim Inghamd4571222010-06-19 04:35:20 +00001635 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001636 location->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001637
Jim Inghamd4571222010-06-19 04:35:20 +00001638 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001639 location->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001640
Greg Clayton54e7afa2010-07-09 20:39:50 +00001641 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001642 location->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001643
1644 if (m_options.m_enable_passed)
1645 location->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001646
1647 if (m_options.m_condition_passed)
1648 location->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001649 }
1650 }
1651 else
1652 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001653 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001654 bp->SetThreadID (m_options.m_thread_id);
1655
Jim Ingham9a7b2912010-12-03 23:04:19 +00001656 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001657 bp->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001658
Jim Inghamd4571222010-06-19 04:35:20 +00001659 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001660 bp->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001661
Jim Inghamd4571222010-06-19 04:35:20 +00001662 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001663 bp->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001664
Greg Clayton54e7afa2010-07-09 20:39:50 +00001665 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001666 bp->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001667
1668 if (m_options.m_enable_passed)
1669 bp->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001670
1671 if (m_options.m_condition_passed)
1672 bp->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001673 }
1674 }
1675 }
1676 }
1677
1678 return result.Succeeded();
1679}
1680
1681