blob: 625e472821f00bc88f6a42222873b7149887731c [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),
Jim Inghamd6d47972011-09-23 00:54:11 +000052 m_filenames (),
Chris Lattner24943d22010-06-08 16:52:24 +000053 m_line_num (0),
54 m_column (0),
Greg Clayton2dfe4c62010-11-02 03:02:38 +000055 m_check_inlines (true),
Jim Ingham4722b102012-03-06 00:37:27 +000056 m_func_names (),
57 m_func_name_type_mask (eFunctionNameTypeNone),
Chris Lattner24943d22010-06-08 16:52:24 +000058 m_func_regexp (),
Jim Ingham03c8ee52011-09-21 01:17:13 +000059 m_source_text_regexp(),
Chris Lattner24943d22010-06-08 16:52:24 +000060 m_modules (),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000061 m_load_addr(),
Greg Clayton54e7afa2010-07-09 20:39:50 +000062 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000063 m_thread_id(LLDB_INVALID_THREAD_ID),
Greg Clayton54e7afa2010-07-09 20:39:50 +000064 m_thread_index (UINT32_MAX),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000065 m_thread_name(),
Jim Ingham4722b102012-03-06 00:37:27 +000066 m_queue_name(),
67 m_catch_bp (false),
68 m_throw_bp (false),
69 m_language (eLanguageTypeUnknown)
Chris Lattner24943d22010-06-08 16:52:24 +000070{
Chris Lattner24943d22010-06-08 16:52:24 +000071}
72
73CommandObjectBreakpointSet::CommandOptions::~CommandOptions ()
74{
75}
76
Johnny Chen8d03c6f2012-05-08 00:43:20 +000077// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
78// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
Johnny Chen6f4a1152012-05-07 23:23:41 +000079#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
80#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
Jim Inghamd6d47972011-09-23 00:54:11 +000081
Greg Claytonb3448432011-03-24 21:19:54 +000082OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +000083CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
84{
Jim Ingham4722b102012-03-06 00:37:27 +000085 { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
Jim Inghamee033f22012-05-03 20:30:08 +000086 "Set the breakpoint only in this shared library. "
87 "Can repeat this option multiple times to specify multiple shared libraries."},
Jim Ingham34e9a982010-06-15 18:47:14 +000088
Caroline Tice4d6675c2010-10-01 19:59:14 +000089 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
90 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000091
Bill Wendlingff7df6d2012-04-03 04:13:41 +000092 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000093 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +000094
Bill Wendlingff7df6d2012-04-03 04:13:41 +000095 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000096 "The breakpoint stops only for the thread whose TID matches this argument."},
97
Bill Wendlingff7df6d2012-04-03 04:13:41 +000098 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000099 "The breakpoint stops only for the thread whose thread name matches this argument."},
100
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000101 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000102 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
103
Jim Inghamd6d47972011-09-23 00:54:11 +0000104 { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
105 "Specifies the source file in which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000106
Caroline Tice4d6675c2010-10-01 19:59:14 +0000107 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Jim Inghamd6d47972011-09-23 00:54:11 +0000108 "Specifies the line number on which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000109
Chris Lattner24943d22010-06-08 16:52:24 +0000110 // Comment out this option for the moment, as we don't actually use it, but will in the future.
111 // This way users won't see it, but the infrastructure is left in place.
112 // { 0, false, "column", 'c', required_argument, NULL, "<column>",
113 // "Set the breakpoint by source location at this particular column."},
114
Caroline Tice4d6675c2010-10-01 19:59:14 +0000115 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000116 "Set the breakpoint by address, at the specified address."},
117
Caroline Tice4d6675c2010-10-01 19:59:14 +0000118 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000119 "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 +0000120
Caroline Tice4d6675c2010-10-01 19:59:14 +0000121 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamee033f22012-05-03 20:30:08 +0000122 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
123 "for Objective C this means a full function prototype with class and selector. "
124 "Can be repeated multiple times to make one breakpoint for multiple names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000125
Caroline Tice4d6675c2010-10-01 19:59:14 +0000126 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamee033f22012-05-03 20:30:08 +0000127 "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 +0000128
Caroline Tice4d6675c2010-10-01 19:59:14 +0000129 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamee033f22012-05-03 20:30:08 +0000130 "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 +0000131
Caroline Tice4d6675c2010-10-01 19:59:14 +0000132 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000133 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
134
Greg Clayton48fbdf72010-10-12 04:29:14 +0000135 { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000136 "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). "
137 "Can be repeated multiple times to make one breakpoint for multiple symbols." },
Greg Clayton48fbdf72010-10-12 04:29:14 +0000138
Jim Ingham03c8ee52011-09-21 01:17:13 +0000139 { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression,
140 "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." },
141
Jim Ingham4722b102012-03-06 00:37:27 +0000142 { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage,
143 "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
144
145 { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean,
146 "Set the breakpoint on exception throW." },
147
148 { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
149 "Set the breakpoint on exception catcH." },
Jim Ingham03c8ee52011-09-21 01:17:13 +0000150
Caroline Tice4d6675c2010-10-01 19:59:14 +0000151 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000152};
153
Greg Claytonb3448432011-03-24 21:19:54 +0000154const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000155CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
156{
157 return g_option_table;
158}
159
160Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000161CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000162{
163 Error error;
164 char short_option = (char) m_getopt_table[option_idx].val;
165
166 switch (short_option)
167 {
168 case 'a':
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000169 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
Chris Lattner24943d22010-06-08 16:52:24 +0000170 if (m_load_addr == LLDB_INVALID_ADDRESS)
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000171 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
Chris Lattner24943d22010-06-08 16:52:24 +0000172
173 if (m_load_addr == LLDB_INVALID_ADDRESS)
Greg Clayton9c236732011-10-26 00:56:27 +0000174 error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000175 break;
176
177 case 'c':
178 m_column = Args::StringToUInt32 (option_arg, 0);
179 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000180
Chris Lattner24943d22010-06-08 16:52:24 +0000181 case 'f':
Jim Inghamd6d47972011-09-23 00:54:11 +0000182 m_filenames.AppendIfUnique (FileSpec(option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000183 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000184
Chris Lattner24943d22010-06-08 16:52:24 +0000185 case 'l':
186 m_line_num = Args::StringToUInt32 (option_arg, 0);
187 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000188
Greg Clayton48fbdf72010-10-12 04:29:14 +0000189 case 'b':
Jim Ingham4722b102012-03-06 00:37:27 +0000190 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000191 m_func_name_type_mask |= eFunctionNameTypeBase;
192 break;
193
Greg Clayton48fbdf72010-10-12 04:29:14 +0000194 case 'n':
Jim Ingham4722b102012-03-06 00:37:27 +0000195 m_func_names.push_back (option_arg);
Greg Clayton48fbdf72010-10-12 04:29:14 +0000196 m_func_name_type_mask |= eFunctionNameTypeAuto;
197 break;
198
Greg Clayton12bec712010-06-28 21:30:43 +0000199 case 'F':
Jim Ingham4722b102012-03-06 00:37:27 +0000200 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000201 m_func_name_type_mask |= eFunctionNameTypeFull;
202 break;
203
204 case 'S':
Jim Ingham4722b102012-03-06 00:37:27 +0000205 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000206 m_func_name_type_mask |= eFunctionNameTypeSelector;
207 break;
208
Jim Inghamd9e2b762010-08-26 23:56:11 +0000209 case 'M':
Jim Ingham4722b102012-03-06 00:37:27 +0000210 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000211 m_func_name_type_mask |= eFunctionNameTypeMethod;
212 break;
213
Jim Ingham03c8ee52011-09-21 01:17:13 +0000214 case 'p':
215 m_source_text_regexp.assign (option_arg);
216 break;
217
Chris Lattner24943d22010-06-08 16:52:24 +0000218 case 'r':
Greg Clayton889fbd02011-03-26 19:14:58 +0000219 m_func_regexp.assign (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000220 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000221
Chris Lattner24943d22010-06-08 16:52:24 +0000222 case 's':
223 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000224 m_modules.AppendIfUnique (FileSpec (option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000225 break;
226 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000227 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000228 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000229 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000230 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000231 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000232 }
Jim Ingham10622a22010-06-18 00:58:52 +0000233 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000234 case 't' :
235 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000236 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000237 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +0000238 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000239 }
240 break;
241 case 'T':
Greg Clayton889fbd02011-03-26 19:14:58 +0000242 m_thread_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000243 break;
244 case 'q':
Greg Clayton889fbd02011-03-26 19:14:58 +0000245 m_queue_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000246 break;
247 case 'x':
248 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000249 m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000250 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000251 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000252
253 }
254 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000255 case 'E':
256 {
257 LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
258
259 switch (language)
260 {
261 case eLanguageTypeC89:
262 case eLanguageTypeC:
263 case eLanguageTypeC99:
264 m_language = eLanguageTypeC;
265 break;
266 case eLanguageTypeC_plus_plus:
267 m_language = eLanguageTypeC_plus_plus;
268 break;
269 case eLanguageTypeObjC:
270 m_language = eLanguageTypeObjC;
271 break;
272 case eLanguageTypeObjC_plus_plus:
273 error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
274 break;
275 case eLanguageTypeUnknown:
276 error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
277 break;
278 default:
279 error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
280 }
281 }
282 break;
283 case 'w':
284 {
285 bool success;
286 m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
287 if (!success)
288 error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
289 }
290 break;
291 case 'h':
292 {
293 bool success;
294 m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
295 if (!success)
296 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
297 }
298 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000299 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000300 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000301 break;
302 }
303
304 return error;
305}
306
307void
Greg Clayton143fcc32011-04-13 00:18:08 +0000308CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000309{
Jim Inghamd6d47972011-09-23 00:54:11 +0000310 m_filenames.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000311 m_line_num = 0;
312 m_column = 0;
Jim Ingham4722b102012-03-06 00:37:27 +0000313 m_func_names.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000314 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000315 m_func_regexp.clear();
316 m_load_addr = LLDB_INVALID_ADDRESS;
Jim Inghamd6d47972011-09-23 00:54:11 +0000317 m_modules.Clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000318 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000319 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000320 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000321 m_thread_name.clear();
322 m_queue_name.clear();
Jim Ingham4722b102012-03-06 00:37:27 +0000323 m_language = eLanguageTypeUnknown;
324 m_catch_bp = false;
325 m_throw_bp = true;
Chris Lattner24943d22010-06-08 16:52:24 +0000326}
327
328//-------------------------------------------------------------------------
329// CommandObjectBreakpointSet
330//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000331#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000332
Greg Clayton238c0a12010-09-18 01:14:36 +0000333CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
334 CommandObject (interpreter,
335 "breakpoint set",
336 "Sets a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000337 "breakpoint set <cmd-options>"),
338 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000339{
340}
341
342CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
343{
344}
345
346Options *
347CommandObjectBreakpointSet::GetOptions ()
348{
349 return &m_options;
350}
351
352bool
Jim Inghamd6d47972011-09-23 00:54:11 +0000353CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000354{
Jim Inghamd6d47972011-09-23 00:54:11 +0000355 uint32_t default_line;
356 // First use the Source Manager's default file.
357 // Then use the current stack frame's file.
358 if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
Jim Ingham03c8ee52011-09-21 01:17:13 +0000359 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000360 StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
361 if (cur_frame == NULL)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000362 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000363 result.AppendError ("No selected frame to use to find the default file.");
364 result.SetStatus (eReturnStatusFailed);
365 return false;
366 }
367 else if (!cur_frame->HasDebugInformation())
368 {
369 result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
370 result.SetStatus (eReturnStatusFailed);
371 return false;
372 }
373 else
374 {
375 const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
376 if (sc.line_entry.file)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000377 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000378 file = sc.line_entry.file;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000379 }
380 else
381 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000382 result.AppendError ("Can't find the file for the selected frame to use as the default file.");
383 result.SetStatus (eReturnStatusFailed);
384 return false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000385 }
386 }
387 }
Jim Ingham03c8ee52011-09-21 01:17:13 +0000388 return true;
389}
390
391bool
Chris Lattner24943d22010-06-08 16:52:24 +0000392CommandObjectBreakpointSet::Execute
393(
394 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000395 CommandReturnObject &result
396)
397{
Greg Clayton238c0a12010-09-18 01:14:36 +0000398 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000399 if (target == NULL)
400 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000401 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000402 result.SetStatus (eReturnStatusFailed);
403 return false;
404 }
405
406 // The following are the various types of breakpoints that could be set:
407 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
408 // 2). -a [-s -g] (setting breakpoint by address)
409 // 3). -n [-s -g] (setting breakpoint by function name)
410 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000411 // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
Jim Ingham4722b102012-03-06 00:37:27 +0000412 // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.)
Chris Lattner24943d22010-06-08 16:52:24 +0000413
414 BreakpointSetType break_type = eSetTypeInvalid;
415
416 if (m_options.m_line_num != 0)
417 break_type = eSetTypeFileAndLine;
418 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
419 break_type = eSetTypeAddress;
Jim Ingham4722b102012-03-06 00:37:27 +0000420 else if (!m_options.m_func_names.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000421 break_type = eSetTypeFunctionName;
422 else if (!m_options.m_func_regexp.empty())
423 break_type = eSetTypeFunctionRegexp;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000424 else if (!m_options.m_source_text_regexp.empty())
425 break_type = eSetTypeSourceRegexp;
Jim Ingham4722b102012-03-06 00:37:27 +0000426 else if (m_options.m_language != eLanguageTypeUnknown)
427 break_type = eSetTypeException;
Chris Lattner24943d22010-06-08 16:52:24 +0000428
Chris Lattner24943d22010-06-08 16:52:24 +0000429 Breakpoint *bp = NULL;
Greg Clayton537a7a82010-10-20 20:54:39 +0000430 FileSpec module_spec;
Chris Lattner24943d22010-06-08 16:52:24 +0000431 bool use_module = false;
Jim Inghamd6d47972011-09-23 00:54:11 +0000432 int num_modules = m_options.m_modules.GetSize();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000433
Chris Lattner24943d22010-06-08 16:52:24 +0000434 if ((num_modules > 0) && (break_type != eSetTypeAddress))
435 use_module = true;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000436
Chris Lattner24943d22010-06-08 16:52:24 +0000437 switch (break_type)
438 {
439 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000440 {
Greg Clayton887aa282010-10-11 01:05:37 +0000441 FileSpec file;
Jim Inghamd6d47972011-09-23 00:54:11 +0000442 uint32_t num_files = m_options.m_filenames.GetSize();
443 if (num_files == 0)
444 {
445 if (!GetDefaultFile (target, file, result))
446 {
447 result.AppendError("No file supplied and no default file available.");
448 result.SetStatus (eReturnStatusFailed);
449 return false;
450 }
451 }
452 else if (num_files > 1)
453 {
454 result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
455 result.SetStatus (eReturnStatusFailed);
456 return false;
457 }
458 else
459 file = m_options.m_filenames.GetFileSpecAtIndex(0);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000460
Jim Inghamd6d47972011-09-23 00:54:11 +0000461 bp = target->CreateBreakpoint (&(m_options.m_modules),
Jim Ingham03c8ee52011-09-21 01:17:13 +0000462 file,
463 m_options.m_line_num,
464 m_options.m_check_inlines).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000465 }
Greg Clayton887aa282010-10-11 01:05:37 +0000466 break;
467
Chris Lattner24943d22010-06-08 16:52:24 +0000468 case eSetTypeAddress: // Breakpoint by address
469 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
470 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000471
Chris Lattner24943d22010-06-08 16:52:24 +0000472 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000473 {
Greg Clayton12bec712010-06-28 21:30:43 +0000474 uint32_t name_type_mask = m_options.m_func_name_type_mask;
475
476 if (name_type_mask == 0)
Greg Clayton48fbdf72010-10-12 04:29:14 +0000477 name_type_mask = eFunctionNameTypeAuto;
Jim Ingham4722b102012-03-06 00:37:27 +0000478
Jim Inghamd6d47972011-09-23 00:54:11 +0000479 bp = target->CreateBreakpoint (&(m_options.m_modules),
480 &(m_options.m_filenames),
Jim Ingham4722b102012-03-06 00:37:27 +0000481 m_options.m_func_names,
482 name_type_mask,
Jim Ingham03c8ee52011-09-21 01:17:13 +0000483 Breakpoint::Exact).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000484 }
Chris Lattner24943d22010-06-08 16:52:24 +0000485 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000486
Chris Lattner24943d22010-06-08 16:52:24 +0000487 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
488 {
489 RegularExpression regexp(m_options.m_func_regexp.c_str());
Jim Ingham03c8ee52011-09-21 01:17:13 +0000490 if (!regexp.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000491 {
Jim Ingham03c8ee52011-09-21 01:17:13 +0000492 char err_str[1024];
493 regexp.GetErrorAsCString(err_str, sizeof(err_str));
494 result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
495 err_str);
496 result.SetStatus (eReturnStatusFailed);
497 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000498 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000499
500 bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000501 }
502 break;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000503 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
504 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000505 int num_files = m_options.m_filenames.GetSize();
506
507 if (num_files == 0)
508 {
509 FileSpec file;
510 if (!GetDefaultFile (target, file, result))
511 {
512 result.AppendError ("No files provided and could not find default file.");
513 result.SetStatus (eReturnStatusFailed);
514 return false;
515 }
516 else
517 {
518 m_options.m_filenames.Append (file);
519 }
520 }
521
Jim Ingham03c8ee52011-09-21 01:17:13 +0000522 RegularExpression regexp(m_options.m_source_text_regexp.c_str());
523 if (!regexp.IsValid())
524 {
525 char err_str[1024];
526 regexp.GetErrorAsCString(err_str, sizeof(err_str));
527 result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
528 err_str);
529 result.SetStatus (eReturnStatusFailed);
530 return false;
531 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000532 bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000533 }
534 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000535 case eSetTypeException:
536 {
537 bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
538 }
539 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000540 default:
541 break;
542 }
543
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000544 // Now set the various options that were passed in:
545 if (bp)
546 {
547 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
548 bp->SetThreadID (m_options.m_thread_id);
549
Greg Clayton54e7afa2010-07-09 20:39:50 +0000550 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000551 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
552
553 if (!m_options.m_thread_name.empty())
554 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
555
556 if (!m_options.m_queue_name.empty())
557 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
558
Greg Clayton54e7afa2010-07-09 20:39:50 +0000559 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000560 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
561 }
562
Jim Ingham03c8ee52011-09-21 01:17:13 +0000563 if (bp)
Chris Lattner24943d22010-06-08 16:52:24 +0000564 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000565 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000566 output_stream.Printf ("Breakpoint created: ");
567 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
568 output_stream.EOL();
Jim Ingham4722b102012-03-06 00:37:27 +0000569 // Don't print out this warning for exception breakpoints. They can get set before the target
570 // is set, but we won't know how to actually set the breakpoint till we run.
571 if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
Caroline Ticecf2f3052010-10-28 16:28:56 +0000572 output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n");
Chris Lattner24943d22010-06-08 16:52:24 +0000573 result.SetStatus (eReturnStatusSuccessFinishResult);
574 }
575 else if (!bp)
576 {
577 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
578 result.SetStatus (eReturnStatusFailed);
579 }
580
581 return result.Succeeded();
582}
583
Chris Lattner24943d22010-06-08 16:52:24 +0000584//-------------------------------------------------------------------------
585// CommandObjectMultiwordBreakpoint
586//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000587#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000588
Greg Clayton63094e02010-06-23 01:19:29 +0000589CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000590 CommandObjectMultiword (interpreter,
591 "breakpoint",
Jim Ingham7224aab2011-05-26 20:39:01 +0000592 "A set of commands for operating on breakpoints. Also see _regexp-break.",
Greg Clayton238c0a12010-09-18 01:14:36 +0000593 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000594{
595 bool status;
596
Greg Clayton238c0a12010-09-18 01:14:36 +0000597 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000598 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
599 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
Johnny Chena62ad7c2010-10-28 17:27:46 +0000600 CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
601 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000602 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000603 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000604 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000605
Johnny Chena62ad7c2010-10-28 17:27:46 +0000606 list_command_object->SetCommandName ("breakpoint list");
Chris Lattner24943d22010-06-08 16:52:24 +0000607 enable_command_object->SetCommandName("breakpoint enable");
608 disable_command_object->SetCommandName("breakpoint disable");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000609 clear_command_object->SetCommandName("breakpoint clear");
610 delete_command_object->SetCommandName("breakpoint delete");
Jim Ingham10622a22010-06-18 00:58:52 +0000611 set_command_object->SetCommandName("breakpoint set");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000612 command_command_object->SetCommandName ("breakpoint command");
613 modify_command_object->SetCommandName ("breakpoint modify");
Chris Lattner24943d22010-06-08 16:52:24 +0000614
Greg Clayton238c0a12010-09-18 01:14:36 +0000615 status = LoadSubCommand ("list", list_command_object);
616 status = LoadSubCommand ("enable", enable_command_object);
617 status = LoadSubCommand ("disable", disable_command_object);
Johnny Chena62ad7c2010-10-28 17:27:46 +0000618 status = LoadSubCommand ("clear", clear_command_object);
Greg Clayton238c0a12010-09-18 01:14:36 +0000619 status = LoadSubCommand ("delete", delete_command_object);
620 status = LoadSubCommand ("set", set_command_object);
621 status = LoadSubCommand ("command", command_command_object);
622 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000623}
624
625CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
626{
627}
628
629void
630CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
631 BreakpointIDList *valid_ids)
632{
633 // args can be strings representing 1). integers (for breakpoint ids)
634 // 2). the full breakpoint & location canonical representation
635 // 3). the word "to" or a hyphen, representing a range (in which case there
636 // had *better* be an entry both before & after of one of the first two types.
Jim Inghamd1686902010-10-14 23:45:03 +0000637 // If args is empty, we will use the last created breakpoint (if there is one.)
Chris Lattner24943d22010-06-08 16:52:24 +0000638
639 Args temp_args;
640
Jim Inghamd1686902010-10-14 23:45:03 +0000641 if (args.GetArgumentCount() == 0)
642 {
Greg Clayton987c7eb2011-09-17 08:33:22 +0000643 if (target->GetLastCreatedBreakpoint())
Jim Inghamd1686902010-10-14 23:45:03 +0000644 {
645 valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
646 result.SetStatus (eReturnStatusSuccessFinishNoResult);
647 }
648 else
649 {
650 result.AppendError("No breakpoint specified and no last created breakpoint.");
651 result.SetStatus (eReturnStatusFailed);
652 }
653 return;
654 }
655
Chris Lattner24943d22010-06-08 16:52:24 +0000656 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
657 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
658 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
659
660 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
661
662 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
663
Greg Clayton54e7afa2010-07-09 20:39:50 +0000664 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000665
666 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
667 // and put into valid_ids.
668
669 if (result.Succeeded())
670 {
671 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
672 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
673
Greg Clayton54e7afa2010-07-09 20:39:50 +0000674 const size_t count = valid_ids->GetSize();
675 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000676 {
677 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
678 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
679 if (breakpoint != NULL)
680 {
681 int num_locations = breakpoint->GetNumLocations();
682 if (cur_bp_id.GetLocationID() > num_locations)
683 {
684 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000685 BreakpointID::GetCanonicalReference (&id_str,
686 cur_bp_id.GetBreakpointID(),
687 cur_bp_id.GetLocationID());
688 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000689 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
690 id_str.GetData());
691 result.SetStatus (eReturnStatusFailed);
692 }
693 }
694 else
695 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000696 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000697 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
698 result.SetStatus (eReturnStatusFailed);
699 }
700 }
701 }
702}
703
704//-------------------------------------------------------------------------
705// CommandObjectBreakpointList::Options
706//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000707#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000708
Greg Claytonf15996e2011-04-07 22:46:35 +0000709CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
710 Options (interpreter),
Caroline Tice41950cc2011-02-04 22:59:41 +0000711 m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions
Chris Lattner24943d22010-06-08 16:52:24 +0000712{
Chris Lattner24943d22010-06-08 16:52:24 +0000713}
714
715CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
716{
717}
718
Greg Claytonb3448432011-03-24 21:19:54 +0000719OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000720CommandObjectBreakpointList::CommandOptions::g_option_table[] =
721{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000722 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000723 "Show debugger internal breakpoints" },
724
Caroline Tice4d6675c2010-10-01 19:59:14 +0000725 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000726 "Give a brief description of the breakpoint (no location info)."},
727
728 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
729 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000730 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000731 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000732
Caroline Tice4d6675c2010-10-01 19:59:14 +0000733 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000734 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000735
Caroline Tice4d6675c2010-10-01 19:59:14 +0000736 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000737};
738
Greg Claytonb3448432011-03-24 21:19:54 +0000739const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000740CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
741{
742 return g_option_table;
743}
744
745Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000746CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000747{
748 Error error;
749 char short_option = (char) m_getopt_table[option_idx].val;
750
751 switch (short_option)
752 {
753 case 'b':
754 m_level = lldb::eDescriptionLevelBrief;
755 break;
756 case 'f':
757 m_level = lldb::eDescriptionLevelFull;
758 break;
759 case 'v':
760 m_level = lldb::eDescriptionLevelVerbose;
761 break;
762 case 'i':
763 m_internal = true;
764 break;
765 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000766 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000767 break;
768 }
769
770 return error;
771}
772
773void
Greg Clayton143fcc32011-04-13 00:18:08 +0000774CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000775{
Jim Inghamdc259052011-05-17 01:21:41 +0000776 m_level = lldb::eDescriptionLevelFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000777 m_internal = false;
778}
779
780//-------------------------------------------------------------------------
781// CommandObjectBreakpointList
782//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000783#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000784
Greg Clayton238c0a12010-09-18 01:14:36 +0000785CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
786 CommandObject (interpreter,
787 "breakpoint list",
788 "List some or all breakpoints at configurable levels of detail.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000789 NULL),
790 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000791{
Caroline Ticefb355112010-10-01 17:46:38 +0000792 CommandArgumentEntry arg;
793 CommandArgumentData bp_id_arg;
794
795 // Define the first (and only) variant of this arg.
796 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000797 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000798
799 // There is only one variant this argument could be; put it into the argument entry.
800 arg.push_back (bp_id_arg);
801
802 // Push the data for the first argument into the m_arguments vector.
803 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000804}
805
806CommandObjectBreakpointList::~CommandObjectBreakpointList ()
807{
808}
809
810Options *
811CommandObjectBreakpointList::GetOptions ()
812{
813 return &m_options;
814}
815
816bool
817CommandObjectBreakpointList::Execute
818(
819 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000820 CommandReturnObject &result
821)
822{
Greg Clayton238c0a12010-09-18 01:14:36 +0000823 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000824 if (target == NULL)
825 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000826 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000827 result.SetStatus (eReturnStatusSuccessFinishNoResult);
828 return true;
829 }
830
831 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000832 Mutex::Locker locker;
833 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
834
Chris Lattner24943d22010-06-08 16:52:24 +0000835 size_t num_breakpoints = breakpoints.GetSize();
836
837 if (num_breakpoints == 0)
838 {
839 result.AppendMessage ("No breakpoints currently set.");
840 result.SetStatus (eReturnStatusSuccessFinishNoResult);
841 return true;
842 }
843
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000844 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000845
846 if (args.GetArgumentCount() == 0)
847 {
848 // No breakpoint selected; show info about all currently set breakpoints.
849 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000850 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000851 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000852 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000853 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000854 }
855 result.SetStatus (eReturnStatusSuccessFinishNoResult);
856 }
857 else
858 {
859 // Particular breakpoints selected; show info about that breakpoint.
860 BreakpointIDList valid_bp_ids;
861 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
862
863 if (result.Succeeded())
864 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000865 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000866 {
867 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
868 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000869 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000870 }
871 result.SetStatus (eReturnStatusSuccessFinishNoResult);
872 }
873 else
874 {
875 result.AppendError ("Invalid breakpoint id.");
876 result.SetStatus (eReturnStatusFailed);
877 }
878 }
879
880 return result.Succeeded();
881}
882
883//-------------------------------------------------------------------------
884// CommandObjectBreakpointEnable
885//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000886#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000887
Greg Clayton238c0a12010-09-18 01:14:36 +0000888CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
889 CommandObject (interpreter,
890 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000891 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
892 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000893{
Caroline Ticefb355112010-10-01 17:46:38 +0000894 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000895 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000896 // Add the entry for the first argument for this command to the object's arguments vector.
897 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000898}
899
900
901CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
902{
903}
904
905
906bool
Greg Clayton63094e02010-06-23 01:19:29 +0000907CommandObjectBreakpointEnable::Execute
908(
Greg Clayton63094e02010-06-23 01:19:29 +0000909 Args& args,
910 CommandReturnObject &result
911)
Chris Lattner24943d22010-06-08 16:52:24 +0000912{
Greg Clayton238c0a12010-09-18 01:14:36 +0000913 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000914 if (target == NULL)
915 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000916 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000917 result.SetStatus (eReturnStatusFailed);
918 return false;
919 }
920
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000921 Mutex::Locker locker;
922 target->GetBreakpointList().GetListMutex(locker);
923
Chris Lattner24943d22010-06-08 16:52:24 +0000924 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000925
Chris Lattner24943d22010-06-08 16:52:24 +0000926 size_t num_breakpoints = breakpoints.GetSize();
927
928 if (num_breakpoints == 0)
929 {
930 result.AppendError ("No breakpoints exist to be enabled.");
931 result.SetStatus (eReturnStatusFailed);
932 return false;
933 }
934
935 if (args.GetArgumentCount() == 0)
936 {
937 // No breakpoint selected; enable all currently set breakpoints.
938 target->EnableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000939 result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +0000940 result.SetStatus (eReturnStatusSuccessFinishNoResult);
941 }
942 else
943 {
944 // Particular breakpoint selected; enable that breakpoint.
945 BreakpointIDList valid_bp_ids;
946 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
947
948 if (result.Succeeded())
949 {
950 int enable_count = 0;
951 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000952 const size_t count = valid_bp_ids.GetSize();
953 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000954 {
955 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
956
957 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
958 {
959 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
960 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
961 {
962 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
963 if (location)
964 {
965 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000966 ++loc_count;
967 }
968 }
969 else
970 {
Jim Ingham10622a22010-06-18 00:58:52 +0000971 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000972 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +0000973 }
974 }
975 }
976 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
977 result.SetStatus (eReturnStatusSuccessFinishNoResult);
978 }
979 }
980
981 return result.Succeeded();
982}
983
984//-------------------------------------------------------------------------
985// CommandObjectBreakpointDisable
986//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000987#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +0000988
Greg Clayton238c0a12010-09-18 01:14:36 +0000989CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
990 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +0000991 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +0000992 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +0000993 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000994{
Caroline Ticefb355112010-10-01 17:46:38 +0000995 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000996 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000997 // Add the entry for the first argument for this command to the object's arguments vector.
998 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000999}
1000
1001CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
1002{
1003}
1004
1005bool
Greg Clayton63094e02010-06-23 01:19:29 +00001006CommandObjectBreakpointDisable::Execute
1007(
Greg Clayton63094e02010-06-23 01:19:29 +00001008 Args& args,
1009 CommandReturnObject &result
1010)
Chris Lattner24943d22010-06-08 16:52:24 +00001011{
Greg Clayton238c0a12010-09-18 01:14:36 +00001012 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001013 if (target == NULL)
1014 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001015 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001016 result.SetStatus (eReturnStatusFailed);
1017 return false;
1018 }
1019
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001020 Mutex::Locker locker;
1021 target->GetBreakpointList().GetListMutex(locker);
1022
Chris Lattner24943d22010-06-08 16:52:24 +00001023 const BreakpointList &breakpoints = target->GetBreakpointList();
1024 size_t num_breakpoints = breakpoints.GetSize();
1025
1026 if (num_breakpoints == 0)
1027 {
1028 result.AppendError ("No breakpoints exist to be disabled.");
1029 result.SetStatus (eReturnStatusFailed);
1030 return false;
1031 }
1032
1033 if (args.GetArgumentCount() == 0)
1034 {
1035 // No breakpoint selected; disable all currently set breakpoints.
1036 target->DisableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001037 result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +00001038 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1039 }
1040 else
1041 {
1042 // Particular breakpoint selected; disable that breakpoint.
1043 BreakpointIDList valid_bp_ids;
1044
1045 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1046
1047 if (result.Succeeded())
1048 {
1049 int disable_count = 0;
1050 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001051 const size_t count = valid_bp_ids.GetSize();
1052 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001053 {
1054 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1055
1056 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1057 {
1058 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1059 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1060 {
1061 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1062 if (location)
1063 {
1064 location->SetEnabled (false);
1065 ++loc_count;
1066 }
1067 }
1068 else
1069 {
Jim Ingham10622a22010-06-18 00:58:52 +00001070 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001071 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001072 }
1073 }
1074 }
1075 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1076 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1077 }
1078 }
1079
1080 return result.Succeeded();
1081}
1082
1083//-------------------------------------------------------------------------
Johnny Chena62ad7c2010-10-28 17:27:46 +00001084// CommandObjectBreakpointClear::CommandOptions
1085//-------------------------------------------------------------------------
1086#pragma mark Clear::CommandOptions
1087
Greg Claytonf15996e2011-04-07 22:46:35 +00001088CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1089 Options (interpreter),
Johnny Chena62ad7c2010-10-28 17:27:46 +00001090 m_filename (),
1091 m_line_num (0)
1092{
1093}
1094
1095CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
1096{
1097}
1098
Greg Claytonb3448432011-03-24 21:19:54 +00001099OptionDefinition
Johnny Chena62ad7c2010-10-28 17:27:46 +00001100CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
1101{
1102 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
1103 "Specify the breakpoint by source location in this particular file."},
1104
1105 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
1106 "Specify the breakpoint by source location at this particular line."},
1107
1108 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1109};
1110
Greg Claytonb3448432011-03-24 21:19:54 +00001111const OptionDefinition*
Johnny Chena62ad7c2010-10-28 17:27:46 +00001112CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
1113{
1114 return g_option_table;
1115}
1116
1117Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001118CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001119{
1120 Error error;
1121 char short_option = (char) m_getopt_table[option_idx].val;
1122
1123 switch (short_option)
1124 {
1125 case 'f':
Greg Clayton889fbd02011-03-26 19:14:58 +00001126 m_filename.assign (option_arg);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001127 break;
1128
1129 case 'l':
1130 m_line_num = Args::StringToUInt32 (option_arg, 0);
1131 break;
1132
1133 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001134 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001135 break;
1136 }
1137
1138 return error;
1139}
1140
1141void
Greg Clayton143fcc32011-04-13 00:18:08 +00001142CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
Johnny Chena62ad7c2010-10-28 17:27:46 +00001143{
Johnny Chena62ad7c2010-10-28 17:27:46 +00001144 m_filename.clear();
1145 m_line_num = 0;
1146}
1147
1148//-------------------------------------------------------------------------
1149// CommandObjectBreakpointClear
1150//-------------------------------------------------------------------------
1151#pragma mark Clear
1152
1153CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
1154 CommandObject (interpreter,
1155 "breakpoint clear",
1156 "Clears a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001157 "breakpoint clear <cmd-options>"),
1158 m_options (interpreter)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001159{
1160}
1161
1162CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
1163{
1164}
1165
1166Options *
1167CommandObjectBreakpointClear::GetOptions ()
1168{
1169 return &m_options;
1170}
1171
1172bool
1173CommandObjectBreakpointClear::Execute
1174(
1175 Args& command,
1176 CommandReturnObject &result
1177)
1178{
1179 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
1180 if (target == NULL)
1181 {
1182 result.AppendError ("Invalid target. No existing target or breakpoints.");
1183 result.SetStatus (eReturnStatusFailed);
1184 return false;
1185 }
1186
1187 // The following are the various types of breakpoints that could be cleared:
1188 // 1). -f -l (clearing breakpoint by source location)
1189
1190 BreakpointClearType break_type = eClearTypeInvalid;
1191
1192 if (m_options.m_line_num != 0)
1193 break_type = eClearTypeFileAndLine;
1194
1195 Mutex::Locker locker;
1196 target->GetBreakpointList().GetListMutex(locker);
1197
1198 BreakpointList &breakpoints = target->GetBreakpointList();
1199 size_t num_breakpoints = breakpoints.GetSize();
1200
1201 // Early return if there's no breakpoint at all.
1202 if (num_breakpoints == 0)
1203 {
1204 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1205 result.SetStatus (eReturnStatusFailed);
1206 return result.Succeeded();
1207 }
1208
1209 // Find matching breakpoints and delete them.
1210
1211 // First create a copy of all the IDs.
1212 std::vector<break_id_t> BreakIDs;
1213 for (size_t i = 0; i < num_breakpoints; ++i)
1214 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
1215
1216 int num_cleared = 0;
1217 StreamString ss;
1218 switch (break_type)
1219 {
1220 case eClearTypeFileAndLine: // Breakpoint by source position
1221 {
1222 const ConstString filename(m_options.m_filename.c_str());
1223 BreakpointLocationCollection loc_coll;
1224
1225 for (size_t i = 0; i < num_breakpoints; ++i)
1226 {
1227 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
1228
1229 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
1230 {
1231 // If the collection size is 0, it's a full match and we can just remove the breakpoint.
1232 if (loc_coll.GetSize() == 0)
1233 {
1234 bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
1235 ss.EOL();
1236 target->RemoveBreakpointByID (bp->GetID());
1237 ++num_cleared;
1238 }
1239 }
1240 }
1241 }
1242 break;
1243
1244 default:
1245 break;
1246 }
1247
1248 if (num_cleared > 0)
1249 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +00001250 Stream &output_stream = result.GetOutputStream();
Johnny Chena62ad7c2010-10-28 17:27:46 +00001251 output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
1252 output_stream << ss.GetData();
1253 output_stream.EOL();
1254 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1255 }
1256 else
1257 {
1258 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1259 result.SetStatus (eReturnStatusFailed);
1260 }
1261
1262 return result.Succeeded();
1263}
1264
1265//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001266// CommandObjectBreakpointDelete
1267//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001268#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001269
Greg Clayton238c0a12010-09-18 01:14:36 +00001270CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1271 CommandObject (interpreter,
1272 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001273 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001274 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001275{
Caroline Ticefb355112010-10-01 17:46:38 +00001276 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001277 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001278 // Add the entry for the first argument for this command to the object's arguments vector.
1279 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001280}
1281
1282
1283CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1284{
1285}
1286
1287bool
Greg Clayton63094e02010-06-23 01:19:29 +00001288CommandObjectBreakpointDelete::Execute
1289(
Greg Clayton63094e02010-06-23 01:19:29 +00001290 Args& args,
1291 CommandReturnObject &result
1292)
Chris Lattner24943d22010-06-08 16:52:24 +00001293{
Greg Clayton238c0a12010-09-18 01:14:36 +00001294 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001295 if (target == NULL)
1296 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001297 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001298 result.SetStatus (eReturnStatusFailed);
1299 return false;
1300 }
1301
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001302 Mutex::Locker locker;
1303 target->GetBreakpointList().GetListMutex(locker);
1304
Chris Lattner24943d22010-06-08 16:52:24 +00001305 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001306
Chris Lattner24943d22010-06-08 16:52:24 +00001307 size_t num_breakpoints = breakpoints.GetSize();
1308
1309 if (num_breakpoints == 0)
1310 {
1311 result.AppendError ("No breakpoints exist to be deleted.");
1312 result.SetStatus (eReturnStatusFailed);
1313 return false;
1314 }
1315
1316 if (args.GetArgumentCount() == 0)
1317 {
Jim Inghamd1686902010-10-14 23:45:03 +00001318 if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
Chris Lattner24943d22010-06-08 16:52:24 +00001319 {
Jim Inghamd1686902010-10-14 23:45:03 +00001320 result.AppendMessage("Operation cancelled...");
Chris Lattner24943d22010-06-08 16:52:24 +00001321 }
Jim Inghamd1686902010-10-14 23:45:03 +00001322 else
1323 {
1324 target->RemoveAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001325 result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
Jim Inghamd1686902010-10-14 23:45:03 +00001326 }
Chris Lattner24943d22010-06-08 16:52:24 +00001327 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1328 }
1329 else
1330 {
1331 // Particular breakpoint selected; disable that breakpoint.
1332 BreakpointIDList valid_bp_ids;
1333 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1334
1335 if (result.Succeeded())
1336 {
1337 int delete_count = 0;
1338 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001339 const size_t count = valid_bp_ids.GetSize();
1340 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001341 {
1342 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1343
1344 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1345 {
1346 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1347 {
1348 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1349 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1350 // It makes no sense to try to delete individual locations, so we disable them instead.
1351 if (location)
1352 {
1353 location->SetEnabled (false);
1354 ++disable_count;
1355 }
1356 }
1357 else
1358 {
1359 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1360 ++delete_count;
1361 }
1362 }
1363 }
1364 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1365 delete_count, disable_count);
1366 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1367 }
1368 }
1369 return result.Succeeded();
1370}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001371
1372//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001373// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001374//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001375#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001376
Greg Claytonf15996e2011-04-07 22:46:35 +00001377CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1378 Options (interpreter),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001379 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001380 m_thread_id(LLDB_INVALID_THREAD_ID),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001381 m_thread_id_passed(false),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001382 m_thread_index (UINT32_MAX),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001383 m_thread_index_passed(false),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001384 m_thread_name(),
1385 m_queue_name(),
Jim Inghamd1686902010-10-14 23:45:03 +00001386 m_condition (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001387 m_enable_passed (false),
1388 m_enable_value (false),
1389 m_name_passed (false),
Jim Inghamd1686902010-10-14 23:45:03 +00001390 m_queue_passed (false),
1391 m_condition_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001392{
1393}
1394
Jim Ingham10622a22010-06-18 00:58:52 +00001395CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001396{
1397}
1398
Greg Claytonb3448432011-03-24 21:19:54 +00001399OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001400CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001401{
Bill Wendlingff7df6d2012-04-03 04:13:41 +00001402{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1403{ 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."},
1404{ 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."},
1405{ 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."},
1406{ 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."},
1407{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
1408{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."},
1409{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."},
Jim Inghamd1686902010-10-14 23:45:03 +00001410{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001411};
1412
Greg Claytonb3448432011-03-24 21:19:54 +00001413const OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001414CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001415{
1416 return g_option_table;
1417}
1418
1419Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001420CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001421{
1422 Error error;
1423 char short_option = (char) m_getopt_table[option_idx].val;
1424
1425 switch (short_option)
1426 {
Jim Inghamd1686902010-10-14 23:45:03 +00001427 case 'c':
1428 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001429 m_condition.assign (option_arg);
Jim Inghamd1686902010-10-14 23:45:03 +00001430 else
1431 m_condition.clear();
1432 m_condition_passed = true;
1433 break;
Jim Ingham10622a22010-06-18 00:58:52 +00001434 case 'd':
1435 m_enable_passed = true;
1436 m_enable_value = false;
1437 break;
1438 case 'e':
1439 m_enable_passed = true;
1440 m_enable_value = true;
1441 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001442 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001443 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001444 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +00001445 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001446 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001447 }
Jim Ingham10622a22010-06-18 00:58:52 +00001448 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001449 case 't' :
1450 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001451 if (option_arg[0] == '\0')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001452 {
1453 m_thread_id = LLDB_INVALID_THREAD_ID;
1454 m_thread_id_passed = true;
1455 }
1456 else
1457 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001458 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001459 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +00001460 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001461 else
1462 m_thread_id_passed = true;
1463 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001464 }
1465 break;
1466 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001467 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001468 m_thread_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001469 else
1470 m_thread_name.clear();
1471 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001472 break;
1473 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001474 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001475 m_queue_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001476 else
1477 m_queue_name.clear();
1478 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001479 break;
1480 case 'x':
1481 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001482 if (option_arg[0] == '\n')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001483 {
1484 m_thread_index = UINT32_MAX;
1485 m_thread_index_passed = true;
1486 }
1487 else
1488 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001489 m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001490 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001491 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001492 else
1493 m_thread_index_passed = true;
1494 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001495 }
1496 break;
1497 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001498 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001499 break;
1500 }
1501
1502 return error;
1503}
1504
1505void
Greg Clayton143fcc32011-04-13 00:18:08 +00001506CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001507{
Greg Clayton54e7afa2010-07-09 20:39:50 +00001508 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001509 m_thread_id = LLDB_INVALID_THREAD_ID;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001510 m_thread_id_passed = false;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001511 m_thread_index = UINT32_MAX;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001512 m_thread_index_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001513 m_thread_name.clear();
1514 m_queue_name.clear();
Jim Inghamd1686902010-10-14 23:45:03 +00001515 m_condition.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001516 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001517 m_queue_passed = false;
1518 m_name_passed = false;
Jim Inghamd1686902010-10-14 23:45:03 +00001519 m_condition_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001520}
1521
1522//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001523// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001524//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001525#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001526
Greg Clayton238c0a12010-09-18 01:14:36 +00001527CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1528 CommandObject (interpreter,
1529 "breakpoint modify",
Jim Ingham19ac0bd2010-12-03 22:37:19 +00001530 "Modify the options on a breakpoint or set of breakpoints in the executable. "
Jim Ingham9a7b2912010-12-03 23:04:19 +00001531 "If no breakpoint is specified, acts on the last created breakpoint. "
1532 "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001533 NULL),
1534 m_options (interpreter)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001535{
Caroline Ticefb355112010-10-01 17:46:38 +00001536 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001537 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001538 // Add the entry for the first argument for this command to the object's arguments vector.
1539 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001540}
1541
Jim Ingham10622a22010-06-18 00:58:52 +00001542CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001543{
1544}
1545
1546Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001547CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001548{
1549 return &m_options;
1550}
1551
1552bool
Jim Ingham10622a22010-06-18 00:58:52 +00001553CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001554(
1555 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001556 CommandReturnObject &result
1557)
1558{
Greg Clayton238c0a12010-09-18 01:14:36 +00001559 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001560 if (target == NULL)
1561 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001562 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001563 result.SetStatus (eReturnStatusFailed);
1564 return false;
1565 }
1566
1567 Mutex::Locker locker;
1568 target->GetBreakpointList().GetListMutex(locker);
1569
1570 BreakpointIDList valid_bp_ids;
1571
1572 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1573
1574 if (result.Succeeded())
1575 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001576 const size_t count = valid_bp_ids.GetSize();
1577 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001578 {
1579 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1580
1581 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1582 {
1583 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1584 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1585 {
1586 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1587 if (location)
1588 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001589 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001590 location->SetThreadID (m_options.m_thread_id);
1591
Jim Ingham9a7b2912010-12-03 23:04:19 +00001592 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001593 location->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001594
Jim Inghamd4571222010-06-19 04:35:20 +00001595 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001596 location->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001597
Jim Inghamd4571222010-06-19 04:35:20 +00001598 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001599 location->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001600
Greg Clayton54e7afa2010-07-09 20:39:50 +00001601 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001602 location->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001603
1604 if (m_options.m_enable_passed)
1605 location->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001606
1607 if (m_options.m_condition_passed)
1608 location->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001609 }
1610 }
1611 else
1612 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001613 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001614 bp->SetThreadID (m_options.m_thread_id);
1615
Jim Ingham9a7b2912010-12-03 23:04:19 +00001616 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001617 bp->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001618
Jim Inghamd4571222010-06-19 04:35:20 +00001619 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001620 bp->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001621
Jim Inghamd4571222010-06-19 04:35:20 +00001622 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001623 bp->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001624
Greg Clayton54e7afa2010-07-09 20:39:50 +00001625 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001626 bp->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001627
1628 if (m_options.m_enable_passed)
1629 bp->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001630
1631 if (m_options.m_condition_passed)
1632 bp->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001633 }
1634 }
1635 }
1636 }
1637
1638 return result.Succeeded();
1639}
1640
1641