blob: 63bcb62ef83a9d4b03c0e5d61f6f50c42624d29a [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),
Jim Ingham2cf5ccb2012-05-22 00:12:20 +000069 m_language (eLanguageTypeUnknown),
70 m_skip_prologue (eLazyBoolCalculate)
Chris Lattner24943d22010-06-08 16:52:24 +000071{
Chris Lattner24943d22010-06-08 16:52:24 +000072}
73
74CommandObjectBreakpointSet::CommandOptions::~CommandOptions ()
75{
76}
77
Johnny Chen8d03c6f2012-05-08 00:43:20 +000078// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to
79// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately.
Johnny Chen6f4a1152012-05-07 23:23:41 +000080#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
81#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
Jim Ingham2cf5ccb2012-05-22 00:12:20 +000082#define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) )
Jim Inghamd6d47972011-09-23 00:54:11 +000083
Greg Claytonb3448432011-03-24 21:19:54 +000084OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +000085CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
86{
Jim Ingham4722b102012-03-06 00:37:27 +000087 { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
Jim Inghamee033f22012-05-03 20:30:08 +000088 "Set the breakpoint only in this shared library. "
89 "Can repeat this option multiple times to specify multiple shared libraries."},
Jim Ingham34e9a982010-06-15 18:47:14 +000090
Caroline Tice4d6675c2010-10-01 19:59:14 +000091 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
92 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000093
Bill Wendlingff7df6d2012-04-03 04:13:41 +000094 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000095 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +000096
Bill Wendlingff7df6d2012-04-03 04:13:41 +000097 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000098 "The breakpoint stops only for the thread whose TID matches this argument."},
99
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000100 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000101 "The breakpoint stops only for the thread whose thread name matches this argument."},
102
Bill Wendlingff7df6d2012-04-03 04:13:41 +0000103 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000104 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
105
Jim Inghamd6d47972011-09-23 00:54:11 +0000106 { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
107 "Specifies the source file in which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000108
Caroline Tice4d6675c2010-10-01 19:59:14 +0000109 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Jim Inghamd6d47972011-09-23 00:54:11 +0000110 "Specifies the line number on which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000111
Chris Lattner24943d22010-06-08 16:52:24 +0000112 // Comment out this option for the moment, as we don't actually use it, but will in the future.
113 // This way users won't see it, but the infrastructure is left in place.
114 // { 0, false, "column", 'c', required_argument, NULL, "<column>",
115 // "Set the breakpoint by source location at this particular column."},
116
Caroline Tice4d6675c2010-10-01 19:59:14 +0000117 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000118 "Set the breakpoint by address, at the specified address."},
119
Caroline Tice4d6675c2010-10-01 19:59:14 +0000120 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000121 "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 +0000122
Caroline Tice4d6675c2010-10-01 19:59:14 +0000123 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamee033f22012-05-03 20:30:08 +0000124 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
125 "for Objective C this means a full function prototype with class and selector. "
126 "Can be repeated multiple times to make one breakpoint for multiple names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000127
Caroline Tice4d6675c2010-10-01 19:59:14 +0000128 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamee033f22012-05-03 20:30:08 +0000129 "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 +0000130
Caroline Tice4d6675c2010-10-01 19:59:14 +0000131 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamee033f22012-05-03 20:30:08 +0000132 "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 +0000133
Caroline Tice4d6675c2010-10-01 19:59:14 +0000134 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000135 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
136
Greg Clayton48fbdf72010-10-12 04:29:14 +0000137 { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000138 "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). "
139 "Can be repeated multiple times to make one breakpoint for multiple symbols." },
Greg Clayton48fbdf72010-10-12 04:29:14 +0000140
Jim Ingham03c8ee52011-09-21 01:17:13 +0000141 { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression,
142 "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." },
143
Jim Ingham4722b102012-03-06 00:37:27 +0000144 { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage,
145 "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
146
147 { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean,
148 "Set the breakpoint on exception throW." },
149
150 { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
151 "Set the breakpoint on exception catcH." },
Jim Ingham03c8ee52011-09-21 01:17:13 +0000152
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000153 { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', required_argument, NULL, 0, eArgTypeBoolean,
154 "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." },
155
Caroline Tice4d6675c2010-10-01 19:59:14 +0000156 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000157};
158
Greg Claytonb3448432011-03-24 21:19:54 +0000159const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000160CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
161{
162 return g_option_table;
163}
164
165Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000166CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000167{
168 Error error;
169 char short_option = (char) m_getopt_table[option_idx].val;
170
171 switch (short_option)
172 {
173 case 'a':
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000174 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
Chris Lattner24943d22010-06-08 16:52:24 +0000175 if (m_load_addr == LLDB_INVALID_ADDRESS)
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000176 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
Chris Lattner24943d22010-06-08 16:52:24 +0000177
178 if (m_load_addr == LLDB_INVALID_ADDRESS)
Greg Clayton9c236732011-10-26 00:56:27 +0000179 error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000180 break;
181
182 case 'c':
183 m_column = Args::StringToUInt32 (option_arg, 0);
184 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000185
Chris Lattner24943d22010-06-08 16:52:24 +0000186 case 'f':
Jim Inghamd6d47972011-09-23 00:54:11 +0000187 m_filenames.AppendIfUnique (FileSpec(option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000188 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000189
Chris Lattner24943d22010-06-08 16:52:24 +0000190 case 'l':
191 m_line_num = Args::StringToUInt32 (option_arg, 0);
192 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000193
Greg Clayton48fbdf72010-10-12 04:29:14 +0000194 case 'b':
Jim Ingham4722b102012-03-06 00:37:27 +0000195 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000196 m_func_name_type_mask |= eFunctionNameTypeBase;
197 break;
198
Greg Clayton48fbdf72010-10-12 04:29:14 +0000199 case 'n':
Jim Ingham4722b102012-03-06 00:37:27 +0000200 m_func_names.push_back (option_arg);
Greg Clayton48fbdf72010-10-12 04:29:14 +0000201 m_func_name_type_mask |= eFunctionNameTypeAuto;
202 break;
203
Greg Clayton12bec712010-06-28 21:30:43 +0000204 case 'F':
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 |= eFunctionNameTypeFull;
207 break;
208
209 case 'S':
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 |= eFunctionNameTypeSelector;
212 break;
213
Jim Inghamd9e2b762010-08-26 23:56:11 +0000214 case 'M':
Jim Ingham4722b102012-03-06 00:37:27 +0000215 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000216 m_func_name_type_mask |= eFunctionNameTypeMethod;
217 break;
218
Jim Ingham03c8ee52011-09-21 01:17:13 +0000219 case 'p':
220 m_source_text_regexp.assign (option_arg);
221 break;
222
Chris Lattner24943d22010-06-08 16:52:24 +0000223 case 'r':
Greg Clayton889fbd02011-03-26 19:14:58 +0000224 m_func_regexp.assign (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000225 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000226
Chris Lattner24943d22010-06-08 16:52:24 +0000227 case 's':
228 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000229 m_modules.AppendIfUnique (FileSpec (option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000230 break;
231 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000232 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000233 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000234 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000235 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000236 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000237 }
Jim Ingham10622a22010-06-18 00:58:52 +0000238 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000239 case 't' :
240 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000241 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000242 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +0000243 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000244 }
245 break;
246 case 'T':
Greg Clayton889fbd02011-03-26 19:14:58 +0000247 m_thread_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000248 break;
249 case 'q':
Greg Clayton889fbd02011-03-26 19:14:58 +0000250 m_queue_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000251 break;
252 case 'x':
253 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000254 m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000255 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000256 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000257
258 }
259 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000260 case 'E':
261 {
262 LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
263
264 switch (language)
265 {
266 case eLanguageTypeC89:
267 case eLanguageTypeC:
268 case eLanguageTypeC99:
269 m_language = eLanguageTypeC;
270 break;
271 case eLanguageTypeC_plus_plus:
272 m_language = eLanguageTypeC_plus_plus;
273 break;
274 case eLanguageTypeObjC:
275 m_language = eLanguageTypeObjC;
276 break;
277 case eLanguageTypeObjC_plus_plus:
278 error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
279 break;
280 case eLanguageTypeUnknown:
281 error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
282 break;
283 default:
284 error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
285 }
286 }
287 break;
288 case 'w':
289 {
290 bool success;
291 m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
292 if (!success)
293 error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
294 }
295 break;
296 case 'h':
297 {
298 bool success;
299 m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
300 if (!success)
301 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
302 }
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000303 case 'K':
304 {
305 bool success;
306 bool value;
307 value = Args::StringToBoolean (option_arg, true, &success);
308 if (value)
309 m_skip_prologue = eLazyBoolYes;
310 else
311 m_skip_prologue = eLazyBoolNo;
312
313 if (!success)
314 error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg);
315 }
Jim Ingham4722b102012-03-06 00:37:27 +0000316 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000317 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000318 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000319 break;
320 }
321
322 return error;
323}
324
325void
Greg Clayton143fcc32011-04-13 00:18:08 +0000326CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000327{
Jim Inghamd6d47972011-09-23 00:54:11 +0000328 m_filenames.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000329 m_line_num = 0;
330 m_column = 0;
Jim Ingham4722b102012-03-06 00:37:27 +0000331 m_func_names.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000332 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000333 m_func_regexp.clear();
334 m_load_addr = LLDB_INVALID_ADDRESS;
Jim Inghamd6d47972011-09-23 00:54:11 +0000335 m_modules.Clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000336 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000337 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000338 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000339 m_thread_name.clear();
340 m_queue_name.clear();
Jim Ingham4722b102012-03-06 00:37:27 +0000341 m_language = eLanguageTypeUnknown;
342 m_catch_bp = false;
343 m_throw_bp = true;
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000344 m_skip_prologue = eLazyBoolCalculate;
Chris Lattner24943d22010-06-08 16:52:24 +0000345}
346
347//-------------------------------------------------------------------------
348// CommandObjectBreakpointSet
349//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000350#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000351
Greg Clayton238c0a12010-09-18 01:14:36 +0000352CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
353 CommandObject (interpreter,
354 "breakpoint set",
355 "Sets a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000356 "breakpoint set <cmd-options>"),
357 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000358{
359}
360
361CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
362{
363}
364
365Options *
366CommandObjectBreakpointSet::GetOptions ()
367{
368 return &m_options;
369}
370
371bool
Jim Inghamd6d47972011-09-23 00:54:11 +0000372CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000373{
Jim Inghamd6d47972011-09-23 00:54:11 +0000374 uint32_t default_line;
375 // First use the Source Manager's default file.
376 // Then use the current stack frame's file.
377 if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
Jim Ingham03c8ee52011-09-21 01:17:13 +0000378 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000379 StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
380 if (cur_frame == NULL)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000381 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000382 result.AppendError ("No selected frame to use to find the default file.");
383 result.SetStatus (eReturnStatusFailed);
384 return false;
385 }
386 else if (!cur_frame->HasDebugInformation())
387 {
388 result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
389 result.SetStatus (eReturnStatusFailed);
390 return false;
391 }
392 else
393 {
394 const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
395 if (sc.line_entry.file)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000396 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000397 file = sc.line_entry.file;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000398 }
399 else
400 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000401 result.AppendError ("Can't find the file for the selected frame to use as the default file.");
402 result.SetStatus (eReturnStatusFailed);
403 return false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000404 }
405 }
406 }
Jim Ingham03c8ee52011-09-21 01:17:13 +0000407 return true;
408}
409
410bool
Chris Lattner24943d22010-06-08 16:52:24 +0000411CommandObjectBreakpointSet::Execute
412(
413 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000414 CommandReturnObject &result
415)
416{
Greg Clayton238c0a12010-09-18 01:14:36 +0000417 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000418 if (target == NULL)
419 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000420 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000421 result.SetStatus (eReturnStatusFailed);
422 return false;
423 }
424
425 // The following are the various types of breakpoints that could be set:
426 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
427 // 2). -a [-s -g] (setting breakpoint by address)
428 // 3). -n [-s -g] (setting breakpoint by function name)
429 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000430 // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
Jim Ingham4722b102012-03-06 00:37:27 +0000431 // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.)
Chris Lattner24943d22010-06-08 16:52:24 +0000432
433 BreakpointSetType break_type = eSetTypeInvalid;
434
435 if (m_options.m_line_num != 0)
436 break_type = eSetTypeFileAndLine;
437 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
438 break_type = eSetTypeAddress;
Jim Ingham4722b102012-03-06 00:37:27 +0000439 else if (!m_options.m_func_names.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000440 break_type = eSetTypeFunctionName;
441 else if (!m_options.m_func_regexp.empty())
442 break_type = eSetTypeFunctionRegexp;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000443 else if (!m_options.m_source_text_regexp.empty())
444 break_type = eSetTypeSourceRegexp;
Jim Ingham4722b102012-03-06 00:37:27 +0000445 else if (m_options.m_language != eLanguageTypeUnknown)
446 break_type = eSetTypeException;
Chris Lattner24943d22010-06-08 16:52:24 +0000447
Chris Lattner24943d22010-06-08 16:52:24 +0000448 Breakpoint *bp = NULL;
Greg Clayton537a7a82010-10-20 20:54:39 +0000449 FileSpec module_spec;
Chris Lattner24943d22010-06-08 16:52:24 +0000450 bool use_module = false;
Jim Inghamd6d47972011-09-23 00:54:11 +0000451 int num_modules = m_options.m_modules.GetSize();
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000452
453 const bool internal = false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000454
Chris Lattner24943d22010-06-08 16:52:24 +0000455 if ((num_modules > 0) && (break_type != eSetTypeAddress))
456 use_module = true;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000457
Chris Lattner24943d22010-06-08 16:52:24 +0000458 switch (break_type)
459 {
460 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000461 {
Greg Clayton887aa282010-10-11 01:05:37 +0000462 FileSpec file;
Jim Inghamd6d47972011-09-23 00:54:11 +0000463 uint32_t num_files = m_options.m_filenames.GetSize();
464 if (num_files == 0)
465 {
466 if (!GetDefaultFile (target, file, result))
467 {
468 result.AppendError("No file supplied and no default file available.");
469 result.SetStatus (eReturnStatusFailed);
470 return false;
471 }
472 }
473 else if (num_files > 1)
474 {
475 result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
476 result.SetStatus (eReturnStatusFailed);
477 return false;
478 }
479 else
480 file = m_options.m_filenames.GetFileSpecAtIndex(0);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000481
Jim Inghamd6d47972011-09-23 00:54:11 +0000482 bp = target->CreateBreakpoint (&(m_options.m_modules),
Jim Ingham03c8ee52011-09-21 01:17:13 +0000483 file,
484 m_options.m_line_num,
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000485 m_options.m_check_inlines,
486 m_options.m_skip_prologue,
487 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000488 }
Greg Clayton887aa282010-10-11 01:05:37 +0000489 break;
490
Chris Lattner24943d22010-06-08 16:52:24 +0000491 case eSetTypeAddress: // Breakpoint by address
492 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
493 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000494
Chris Lattner24943d22010-06-08 16:52:24 +0000495 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000496 {
Greg Clayton12bec712010-06-28 21:30:43 +0000497 uint32_t name_type_mask = m_options.m_func_name_type_mask;
498
499 if (name_type_mask == 0)
Greg Clayton48fbdf72010-10-12 04:29:14 +0000500 name_type_mask = eFunctionNameTypeAuto;
Jim Ingham4722b102012-03-06 00:37:27 +0000501
Jim Inghamd6d47972011-09-23 00:54:11 +0000502 bp = target->CreateBreakpoint (&(m_options.m_modules),
503 &(m_options.m_filenames),
Jim Ingham4722b102012-03-06 00:37:27 +0000504 m_options.m_func_names,
505 name_type_mask,
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000506 m_options.m_skip_prologue,
507 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000508 }
Chris Lattner24943d22010-06-08 16:52:24 +0000509 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000510
Chris Lattner24943d22010-06-08 16:52:24 +0000511 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
512 {
513 RegularExpression regexp(m_options.m_func_regexp.c_str());
Jim Ingham03c8ee52011-09-21 01:17:13 +0000514 if (!regexp.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000515 {
Jim Ingham03c8ee52011-09-21 01:17:13 +0000516 char err_str[1024];
517 regexp.GetErrorAsCString(err_str, sizeof(err_str));
518 result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
519 err_str);
520 result.SetStatus (eReturnStatusFailed);
521 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000522 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000523
Jim Ingham2cf5ccb2012-05-22 00:12:20 +0000524 bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules),
525 &(m_options.m_filenames),
526 regexp,
527 m_options.m_skip_prologue,
528 internal).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000529 }
530 break;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000531 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
532 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000533 int num_files = m_options.m_filenames.GetSize();
534
535 if (num_files == 0)
536 {
537 FileSpec file;
538 if (!GetDefaultFile (target, file, result))
539 {
540 result.AppendError ("No files provided and could not find default file.");
541 result.SetStatus (eReturnStatusFailed);
542 return false;
543 }
544 else
545 {
546 m_options.m_filenames.Append (file);
547 }
548 }
549
Jim Ingham03c8ee52011-09-21 01:17:13 +0000550 RegularExpression regexp(m_options.m_source_text_regexp.c_str());
551 if (!regexp.IsValid())
552 {
553 char err_str[1024];
554 regexp.GetErrorAsCString(err_str, sizeof(err_str));
555 result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
556 err_str);
557 result.SetStatus (eReturnStatusFailed);
558 return false;
559 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000560 bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000561 }
562 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000563 case eSetTypeException:
564 {
565 bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
566 }
567 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000568 default:
569 break;
570 }
571
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000572 // Now set the various options that were passed in:
573 if (bp)
574 {
575 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
576 bp->SetThreadID (m_options.m_thread_id);
577
Greg Clayton54e7afa2010-07-09 20:39:50 +0000578 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000579 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
580
581 if (!m_options.m_thread_name.empty())
582 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
583
584 if (!m_options.m_queue_name.empty())
585 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
586
Greg Clayton54e7afa2010-07-09 20:39:50 +0000587 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000588 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
589 }
590
Jim Ingham03c8ee52011-09-21 01:17:13 +0000591 if (bp)
Chris Lattner24943d22010-06-08 16:52:24 +0000592 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000593 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000594 output_stream.Printf ("Breakpoint created: ");
595 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
596 output_stream.EOL();
Jim Ingham4722b102012-03-06 00:37:27 +0000597 // Don't print out this warning for exception breakpoints. They can get set before the target
598 // is set, but we won't know how to actually set the breakpoint till we run.
599 if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
Caroline Ticecf2f3052010-10-28 16:28:56 +0000600 output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n");
Chris Lattner24943d22010-06-08 16:52:24 +0000601 result.SetStatus (eReturnStatusSuccessFinishResult);
602 }
603 else if (!bp)
604 {
605 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
606 result.SetStatus (eReturnStatusFailed);
607 }
608
609 return result.Succeeded();
610}
611
Chris Lattner24943d22010-06-08 16:52:24 +0000612//-------------------------------------------------------------------------
613// CommandObjectMultiwordBreakpoint
614//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000615#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000616
Greg Clayton63094e02010-06-23 01:19:29 +0000617CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000618 CommandObjectMultiword (interpreter,
619 "breakpoint",
Jim Ingham7224aab2011-05-26 20:39:01 +0000620 "A set of commands for operating on breakpoints. Also see _regexp-break.",
Greg Clayton238c0a12010-09-18 01:14:36 +0000621 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000622{
623 bool status;
624
Greg Clayton238c0a12010-09-18 01:14:36 +0000625 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000626 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
627 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
Johnny Chena62ad7c2010-10-28 17:27:46 +0000628 CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
629 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000630 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000631 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000632 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000633
Johnny Chena62ad7c2010-10-28 17:27:46 +0000634 list_command_object->SetCommandName ("breakpoint list");
Chris Lattner24943d22010-06-08 16:52:24 +0000635 enable_command_object->SetCommandName("breakpoint enable");
636 disable_command_object->SetCommandName("breakpoint disable");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000637 clear_command_object->SetCommandName("breakpoint clear");
638 delete_command_object->SetCommandName("breakpoint delete");
Jim Ingham10622a22010-06-18 00:58:52 +0000639 set_command_object->SetCommandName("breakpoint set");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000640 command_command_object->SetCommandName ("breakpoint command");
641 modify_command_object->SetCommandName ("breakpoint modify");
Chris Lattner24943d22010-06-08 16:52:24 +0000642
Greg Clayton238c0a12010-09-18 01:14:36 +0000643 status = LoadSubCommand ("list", list_command_object);
644 status = LoadSubCommand ("enable", enable_command_object);
645 status = LoadSubCommand ("disable", disable_command_object);
Johnny Chena62ad7c2010-10-28 17:27:46 +0000646 status = LoadSubCommand ("clear", clear_command_object);
Greg Clayton238c0a12010-09-18 01:14:36 +0000647 status = LoadSubCommand ("delete", delete_command_object);
648 status = LoadSubCommand ("set", set_command_object);
649 status = LoadSubCommand ("command", command_command_object);
650 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000651}
652
653CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
654{
655}
656
657void
658CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
659 BreakpointIDList *valid_ids)
660{
661 // args can be strings representing 1). integers (for breakpoint ids)
662 // 2). the full breakpoint & location canonical representation
663 // 3). the word "to" or a hyphen, representing a range (in which case there
664 // had *better* be an entry both before & after of one of the first two types.
Jim Inghamd1686902010-10-14 23:45:03 +0000665 // If args is empty, we will use the last created breakpoint (if there is one.)
Chris Lattner24943d22010-06-08 16:52:24 +0000666
667 Args temp_args;
668
Jim Inghamd1686902010-10-14 23:45:03 +0000669 if (args.GetArgumentCount() == 0)
670 {
Greg Clayton987c7eb2011-09-17 08:33:22 +0000671 if (target->GetLastCreatedBreakpoint())
Jim Inghamd1686902010-10-14 23:45:03 +0000672 {
673 valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
674 result.SetStatus (eReturnStatusSuccessFinishNoResult);
675 }
676 else
677 {
678 result.AppendError("No breakpoint specified and no last created breakpoint.");
679 result.SetStatus (eReturnStatusFailed);
680 }
681 return;
682 }
683
Chris Lattner24943d22010-06-08 16:52:24 +0000684 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
685 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
686 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
687
688 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
689
690 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
691
Greg Clayton54e7afa2010-07-09 20:39:50 +0000692 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000693
694 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
695 // and put into valid_ids.
696
697 if (result.Succeeded())
698 {
699 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
700 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
701
Greg Clayton54e7afa2010-07-09 20:39:50 +0000702 const size_t count = valid_ids->GetSize();
703 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000704 {
705 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
706 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
707 if (breakpoint != NULL)
708 {
709 int num_locations = breakpoint->GetNumLocations();
710 if (cur_bp_id.GetLocationID() > num_locations)
711 {
712 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000713 BreakpointID::GetCanonicalReference (&id_str,
714 cur_bp_id.GetBreakpointID(),
715 cur_bp_id.GetLocationID());
716 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000717 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
718 id_str.GetData());
719 result.SetStatus (eReturnStatusFailed);
720 }
721 }
722 else
723 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000724 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000725 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
726 result.SetStatus (eReturnStatusFailed);
727 }
728 }
729 }
730}
731
732//-------------------------------------------------------------------------
733// CommandObjectBreakpointList::Options
734//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000735#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000736
Greg Claytonf15996e2011-04-07 22:46:35 +0000737CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
738 Options (interpreter),
Caroline Tice41950cc2011-02-04 22:59:41 +0000739 m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions
Chris Lattner24943d22010-06-08 16:52:24 +0000740{
Chris Lattner24943d22010-06-08 16:52:24 +0000741}
742
743CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
744{
745}
746
Greg Claytonb3448432011-03-24 21:19:54 +0000747OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000748CommandObjectBreakpointList::CommandOptions::g_option_table[] =
749{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000750 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000751 "Show debugger internal breakpoints" },
752
Caroline Tice4d6675c2010-10-01 19:59:14 +0000753 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000754 "Give a brief description of the breakpoint (no location info)."},
755
756 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
757 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000758 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000759 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000760
Caroline Tice4d6675c2010-10-01 19:59:14 +0000761 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000762 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000763
Caroline Tice4d6675c2010-10-01 19:59:14 +0000764 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000765};
766
Greg Claytonb3448432011-03-24 21:19:54 +0000767const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000768CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
769{
770 return g_option_table;
771}
772
773Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000774CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000775{
776 Error error;
777 char short_option = (char) m_getopt_table[option_idx].val;
778
779 switch (short_option)
780 {
781 case 'b':
782 m_level = lldb::eDescriptionLevelBrief;
783 break;
784 case 'f':
785 m_level = lldb::eDescriptionLevelFull;
786 break;
787 case 'v':
788 m_level = lldb::eDescriptionLevelVerbose;
789 break;
790 case 'i':
791 m_internal = true;
792 break;
793 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000794 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000795 break;
796 }
797
798 return error;
799}
800
801void
Greg Clayton143fcc32011-04-13 00:18:08 +0000802CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000803{
Jim Inghamdc259052011-05-17 01:21:41 +0000804 m_level = lldb::eDescriptionLevelFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000805 m_internal = false;
806}
807
808//-------------------------------------------------------------------------
809// CommandObjectBreakpointList
810//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000811#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000812
Greg Clayton238c0a12010-09-18 01:14:36 +0000813CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
814 CommandObject (interpreter,
815 "breakpoint list",
816 "List some or all breakpoints at configurable levels of detail.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000817 NULL),
818 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000819{
Caroline Ticefb355112010-10-01 17:46:38 +0000820 CommandArgumentEntry arg;
821 CommandArgumentData bp_id_arg;
822
823 // Define the first (and only) variant of this arg.
824 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000825 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000826
827 // There is only one variant this argument could be; put it into the argument entry.
828 arg.push_back (bp_id_arg);
829
830 // Push the data for the first argument into the m_arguments vector.
831 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000832}
833
834CommandObjectBreakpointList::~CommandObjectBreakpointList ()
835{
836}
837
838Options *
839CommandObjectBreakpointList::GetOptions ()
840{
841 return &m_options;
842}
843
844bool
845CommandObjectBreakpointList::Execute
846(
847 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000848 CommandReturnObject &result
849)
850{
Greg Clayton238c0a12010-09-18 01:14:36 +0000851 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000852 if (target == NULL)
853 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000854 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000855 result.SetStatus (eReturnStatusSuccessFinishNoResult);
856 return true;
857 }
858
859 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000860 Mutex::Locker locker;
861 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
862
Chris Lattner24943d22010-06-08 16:52:24 +0000863 size_t num_breakpoints = breakpoints.GetSize();
864
865 if (num_breakpoints == 0)
866 {
867 result.AppendMessage ("No breakpoints currently set.");
868 result.SetStatus (eReturnStatusSuccessFinishNoResult);
869 return true;
870 }
871
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000872 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000873
874 if (args.GetArgumentCount() == 0)
875 {
876 // No breakpoint selected; show info about all currently set breakpoints.
877 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000878 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000879 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000880 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000881 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000882 }
883 result.SetStatus (eReturnStatusSuccessFinishNoResult);
884 }
885 else
886 {
887 // Particular breakpoints selected; show info about that breakpoint.
888 BreakpointIDList valid_bp_ids;
889 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
890
891 if (result.Succeeded())
892 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000893 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000894 {
895 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
896 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000897 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000898 }
899 result.SetStatus (eReturnStatusSuccessFinishNoResult);
900 }
901 else
902 {
903 result.AppendError ("Invalid breakpoint id.");
904 result.SetStatus (eReturnStatusFailed);
905 }
906 }
907
908 return result.Succeeded();
909}
910
911//-------------------------------------------------------------------------
912// CommandObjectBreakpointEnable
913//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000914#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000915
Greg Clayton238c0a12010-09-18 01:14:36 +0000916CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
917 CommandObject (interpreter,
918 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000919 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
920 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000921{
Caroline Ticefb355112010-10-01 17:46:38 +0000922 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000923 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000924 // Add the entry for the first argument for this command to the object's arguments vector.
925 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000926}
927
928
929CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
930{
931}
932
933
934bool
Greg Clayton63094e02010-06-23 01:19:29 +0000935CommandObjectBreakpointEnable::Execute
936(
Greg Clayton63094e02010-06-23 01:19:29 +0000937 Args& args,
938 CommandReturnObject &result
939)
Chris Lattner24943d22010-06-08 16:52:24 +0000940{
Greg Clayton238c0a12010-09-18 01:14:36 +0000941 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000942 if (target == NULL)
943 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000944 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000945 result.SetStatus (eReturnStatusFailed);
946 return false;
947 }
948
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000949 Mutex::Locker locker;
950 target->GetBreakpointList().GetListMutex(locker);
951
Chris Lattner24943d22010-06-08 16:52:24 +0000952 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000953
Chris Lattner24943d22010-06-08 16:52:24 +0000954 size_t num_breakpoints = breakpoints.GetSize();
955
956 if (num_breakpoints == 0)
957 {
958 result.AppendError ("No breakpoints exist to be enabled.");
959 result.SetStatus (eReturnStatusFailed);
960 return false;
961 }
962
963 if (args.GetArgumentCount() == 0)
964 {
965 // No breakpoint selected; enable all currently set breakpoints.
966 target->EnableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000967 result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +0000968 result.SetStatus (eReturnStatusSuccessFinishNoResult);
969 }
970 else
971 {
972 // Particular breakpoint selected; enable that breakpoint.
973 BreakpointIDList valid_bp_ids;
974 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
975
976 if (result.Succeeded())
977 {
978 int enable_count = 0;
979 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000980 const size_t count = valid_bp_ids.GetSize();
981 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000982 {
983 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
984
985 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
986 {
987 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
988 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
989 {
990 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
991 if (location)
992 {
993 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000994 ++loc_count;
995 }
996 }
997 else
998 {
Jim Ingham10622a22010-06-18 00:58:52 +0000999 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +00001000 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001001 }
1002 }
1003 }
1004 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
1005 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1006 }
1007 }
1008
1009 return result.Succeeded();
1010}
1011
1012//-------------------------------------------------------------------------
1013// CommandObjectBreakpointDisable
1014//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001015#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +00001016
Greg Clayton238c0a12010-09-18 01:14:36 +00001017CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
1018 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +00001019 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001020 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001021 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001022{
Caroline Ticefb355112010-10-01 17:46:38 +00001023 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001024 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001025 // Add the entry for the first argument for this command to the object's arguments vector.
1026 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001027}
1028
1029CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
1030{
1031}
1032
1033bool
Greg Clayton63094e02010-06-23 01:19:29 +00001034CommandObjectBreakpointDisable::Execute
1035(
Greg Clayton63094e02010-06-23 01:19:29 +00001036 Args& args,
1037 CommandReturnObject &result
1038)
Chris Lattner24943d22010-06-08 16:52:24 +00001039{
Greg Clayton238c0a12010-09-18 01:14:36 +00001040 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001041 if (target == NULL)
1042 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001043 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001044 result.SetStatus (eReturnStatusFailed);
1045 return false;
1046 }
1047
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001048 Mutex::Locker locker;
1049 target->GetBreakpointList().GetListMutex(locker);
1050
Chris Lattner24943d22010-06-08 16:52:24 +00001051 const BreakpointList &breakpoints = target->GetBreakpointList();
1052 size_t num_breakpoints = breakpoints.GetSize();
1053
1054 if (num_breakpoints == 0)
1055 {
1056 result.AppendError ("No breakpoints exist to be disabled.");
1057 result.SetStatus (eReturnStatusFailed);
1058 return false;
1059 }
1060
1061 if (args.GetArgumentCount() == 0)
1062 {
1063 // No breakpoint selected; disable all currently set breakpoints.
1064 target->DisableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001065 result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +00001066 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1067 }
1068 else
1069 {
1070 // Particular breakpoint selected; disable that breakpoint.
1071 BreakpointIDList valid_bp_ids;
1072
1073 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1074
1075 if (result.Succeeded())
1076 {
1077 int disable_count = 0;
1078 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001079 const size_t count = valid_bp_ids.GetSize();
1080 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001081 {
1082 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1083
1084 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1085 {
1086 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1087 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1088 {
1089 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1090 if (location)
1091 {
1092 location->SetEnabled (false);
1093 ++loc_count;
1094 }
1095 }
1096 else
1097 {
Jim Ingham10622a22010-06-18 00:58:52 +00001098 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001099 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001100 }
1101 }
1102 }
1103 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1104 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1105 }
1106 }
1107
1108 return result.Succeeded();
1109}
1110
1111//-------------------------------------------------------------------------
Johnny Chena62ad7c2010-10-28 17:27:46 +00001112// CommandObjectBreakpointClear::CommandOptions
1113//-------------------------------------------------------------------------
1114#pragma mark Clear::CommandOptions
1115
Greg Claytonf15996e2011-04-07 22:46:35 +00001116CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1117 Options (interpreter),
Johnny Chena62ad7c2010-10-28 17:27:46 +00001118 m_filename (),
1119 m_line_num (0)
1120{
1121}
1122
1123CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
1124{
1125}
1126
Greg Claytonb3448432011-03-24 21:19:54 +00001127OptionDefinition
Johnny Chena62ad7c2010-10-28 17:27:46 +00001128CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
1129{
1130 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
1131 "Specify the breakpoint by source location in this particular file."},
1132
1133 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
1134 "Specify the breakpoint by source location at this particular line."},
1135
1136 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1137};
1138
Greg Claytonb3448432011-03-24 21:19:54 +00001139const OptionDefinition*
Johnny Chena62ad7c2010-10-28 17:27:46 +00001140CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
1141{
1142 return g_option_table;
1143}
1144
1145Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001146CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001147{
1148 Error error;
1149 char short_option = (char) m_getopt_table[option_idx].val;
1150
1151 switch (short_option)
1152 {
1153 case 'f':
Greg Clayton889fbd02011-03-26 19:14:58 +00001154 m_filename.assign (option_arg);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001155 break;
1156
1157 case 'l':
1158 m_line_num = Args::StringToUInt32 (option_arg, 0);
1159 break;
1160
1161 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001162 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001163 break;
1164 }
1165
1166 return error;
1167}
1168
1169void
Greg Clayton143fcc32011-04-13 00:18:08 +00001170CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
Johnny Chena62ad7c2010-10-28 17:27:46 +00001171{
Johnny Chena62ad7c2010-10-28 17:27:46 +00001172 m_filename.clear();
1173 m_line_num = 0;
1174}
1175
1176//-------------------------------------------------------------------------
1177// CommandObjectBreakpointClear
1178//-------------------------------------------------------------------------
1179#pragma mark Clear
1180
1181CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
1182 CommandObject (interpreter,
1183 "breakpoint clear",
1184 "Clears a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001185 "breakpoint clear <cmd-options>"),
1186 m_options (interpreter)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001187{
1188}
1189
1190CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
1191{
1192}
1193
1194Options *
1195CommandObjectBreakpointClear::GetOptions ()
1196{
1197 return &m_options;
1198}
1199
1200bool
1201CommandObjectBreakpointClear::Execute
1202(
1203 Args& command,
1204 CommandReturnObject &result
1205)
1206{
1207 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
1208 if (target == NULL)
1209 {
1210 result.AppendError ("Invalid target. No existing target or breakpoints.");
1211 result.SetStatus (eReturnStatusFailed);
1212 return false;
1213 }
1214
1215 // The following are the various types of breakpoints that could be cleared:
1216 // 1). -f -l (clearing breakpoint by source location)
1217
1218 BreakpointClearType break_type = eClearTypeInvalid;
1219
1220 if (m_options.m_line_num != 0)
1221 break_type = eClearTypeFileAndLine;
1222
1223 Mutex::Locker locker;
1224 target->GetBreakpointList().GetListMutex(locker);
1225
1226 BreakpointList &breakpoints = target->GetBreakpointList();
1227 size_t num_breakpoints = breakpoints.GetSize();
1228
1229 // Early return if there's no breakpoint at all.
1230 if (num_breakpoints == 0)
1231 {
1232 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1233 result.SetStatus (eReturnStatusFailed);
1234 return result.Succeeded();
1235 }
1236
1237 // Find matching breakpoints and delete them.
1238
1239 // First create a copy of all the IDs.
1240 std::vector<break_id_t> BreakIDs;
1241 for (size_t i = 0; i < num_breakpoints; ++i)
1242 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
1243
1244 int num_cleared = 0;
1245 StreamString ss;
1246 switch (break_type)
1247 {
1248 case eClearTypeFileAndLine: // Breakpoint by source position
1249 {
1250 const ConstString filename(m_options.m_filename.c_str());
1251 BreakpointLocationCollection loc_coll;
1252
1253 for (size_t i = 0; i < num_breakpoints; ++i)
1254 {
1255 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
1256
1257 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
1258 {
1259 // If the collection size is 0, it's a full match and we can just remove the breakpoint.
1260 if (loc_coll.GetSize() == 0)
1261 {
1262 bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
1263 ss.EOL();
1264 target->RemoveBreakpointByID (bp->GetID());
1265 ++num_cleared;
1266 }
1267 }
1268 }
1269 }
1270 break;
1271
1272 default:
1273 break;
1274 }
1275
1276 if (num_cleared > 0)
1277 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +00001278 Stream &output_stream = result.GetOutputStream();
Johnny Chena62ad7c2010-10-28 17:27:46 +00001279 output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
1280 output_stream << ss.GetData();
1281 output_stream.EOL();
1282 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1283 }
1284 else
1285 {
1286 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1287 result.SetStatus (eReturnStatusFailed);
1288 }
1289
1290 return result.Succeeded();
1291}
1292
1293//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001294// CommandObjectBreakpointDelete
1295//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001296#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001297
Greg Clayton238c0a12010-09-18 01:14:36 +00001298CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1299 CommandObject (interpreter,
1300 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001301 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001302 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001303{
Caroline Ticefb355112010-10-01 17:46:38 +00001304 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001305 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001306 // Add the entry for the first argument for this command to the object's arguments vector.
1307 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001308}
1309
1310
1311CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1312{
1313}
1314
1315bool
Greg Clayton63094e02010-06-23 01:19:29 +00001316CommandObjectBreakpointDelete::Execute
1317(
Greg Clayton63094e02010-06-23 01:19:29 +00001318 Args& args,
1319 CommandReturnObject &result
1320)
Chris Lattner24943d22010-06-08 16:52:24 +00001321{
Greg Clayton238c0a12010-09-18 01:14:36 +00001322 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001323 if (target == NULL)
1324 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001325 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001326 result.SetStatus (eReturnStatusFailed);
1327 return false;
1328 }
1329
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001330 Mutex::Locker locker;
1331 target->GetBreakpointList().GetListMutex(locker);
1332
Chris Lattner24943d22010-06-08 16:52:24 +00001333 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001334
Chris Lattner24943d22010-06-08 16:52:24 +00001335 size_t num_breakpoints = breakpoints.GetSize();
1336
1337 if (num_breakpoints == 0)
1338 {
1339 result.AppendError ("No breakpoints exist to be deleted.");
1340 result.SetStatus (eReturnStatusFailed);
1341 return false;
1342 }
1343
1344 if (args.GetArgumentCount() == 0)
1345 {
Jim Inghamd1686902010-10-14 23:45:03 +00001346 if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
Chris Lattner24943d22010-06-08 16:52:24 +00001347 {
Jim Inghamd1686902010-10-14 23:45:03 +00001348 result.AppendMessage("Operation cancelled...");
Chris Lattner24943d22010-06-08 16:52:24 +00001349 }
Jim Inghamd1686902010-10-14 23:45:03 +00001350 else
1351 {
1352 target->RemoveAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001353 result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
Jim Inghamd1686902010-10-14 23:45:03 +00001354 }
Chris Lattner24943d22010-06-08 16:52:24 +00001355 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1356 }
1357 else
1358 {
1359 // Particular breakpoint selected; disable that breakpoint.
1360 BreakpointIDList valid_bp_ids;
1361 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1362
1363 if (result.Succeeded())
1364 {
1365 int delete_count = 0;
1366 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001367 const size_t count = valid_bp_ids.GetSize();
1368 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001369 {
1370 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1371
1372 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1373 {
1374 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1375 {
1376 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1377 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1378 // It makes no sense to try to delete individual locations, so we disable them instead.
1379 if (location)
1380 {
1381 location->SetEnabled (false);
1382 ++disable_count;
1383 }
1384 }
1385 else
1386 {
1387 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1388 ++delete_count;
1389 }
1390 }
1391 }
1392 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1393 delete_count, disable_count);
1394 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1395 }
1396 }
1397 return result.Succeeded();
1398}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001399
1400//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001401// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001402//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001403#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001404
Greg Claytonf15996e2011-04-07 22:46:35 +00001405CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1406 Options (interpreter),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001407 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001408 m_thread_id(LLDB_INVALID_THREAD_ID),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001409 m_thread_id_passed(false),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001410 m_thread_index (UINT32_MAX),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001411 m_thread_index_passed(false),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001412 m_thread_name(),
1413 m_queue_name(),
Jim Inghamd1686902010-10-14 23:45:03 +00001414 m_condition (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001415 m_enable_passed (false),
1416 m_enable_value (false),
1417 m_name_passed (false),
Jim Inghamd1686902010-10-14 23:45:03 +00001418 m_queue_passed (false),
1419 m_condition_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001420{
1421}
1422
Jim Ingham10622a22010-06-18 00:58:52 +00001423CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001424{
1425}
1426
Greg Claytonb3448432011-03-24 21:19:54 +00001427OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001428CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001429{
Bill Wendlingff7df6d2012-04-03 04:13:41 +00001430{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1431{ 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."},
1432{ 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."},
1433{ 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."},
1434{ 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."},
1435{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
1436{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."},
1437{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."},
Jim Inghamd1686902010-10-14 23:45:03 +00001438{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001439};
1440
Greg Claytonb3448432011-03-24 21:19:54 +00001441const OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001442CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001443{
1444 return g_option_table;
1445}
1446
1447Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001448CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001449{
1450 Error error;
1451 char short_option = (char) m_getopt_table[option_idx].val;
1452
1453 switch (short_option)
1454 {
Jim Inghamd1686902010-10-14 23:45:03 +00001455 case 'c':
1456 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001457 m_condition.assign (option_arg);
Jim Inghamd1686902010-10-14 23:45:03 +00001458 else
1459 m_condition.clear();
1460 m_condition_passed = true;
1461 break;
Jim Ingham10622a22010-06-18 00:58:52 +00001462 case 'd':
1463 m_enable_passed = true;
1464 m_enable_value = false;
1465 break;
1466 case 'e':
1467 m_enable_passed = true;
1468 m_enable_value = true;
1469 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001470 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001471 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001472 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +00001473 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001474 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001475 }
Jim Ingham10622a22010-06-18 00:58:52 +00001476 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001477 case 't' :
1478 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001479 if (option_arg[0] == '\0')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001480 {
1481 m_thread_id = LLDB_INVALID_THREAD_ID;
1482 m_thread_id_passed = true;
1483 }
1484 else
1485 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001486 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001487 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +00001488 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001489 else
1490 m_thread_id_passed = true;
1491 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001492 }
1493 break;
1494 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001495 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001496 m_thread_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001497 else
1498 m_thread_name.clear();
1499 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001500 break;
1501 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001502 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001503 m_queue_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001504 else
1505 m_queue_name.clear();
1506 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001507 break;
1508 case 'x':
1509 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001510 if (option_arg[0] == '\n')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001511 {
1512 m_thread_index = UINT32_MAX;
1513 m_thread_index_passed = true;
1514 }
1515 else
1516 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001517 m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001518 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001519 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001520 else
1521 m_thread_index_passed = true;
1522 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001523 }
1524 break;
1525 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001526 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001527 break;
1528 }
1529
1530 return error;
1531}
1532
1533void
Greg Clayton143fcc32011-04-13 00:18:08 +00001534CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001535{
Greg Clayton54e7afa2010-07-09 20:39:50 +00001536 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001537 m_thread_id = LLDB_INVALID_THREAD_ID;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001538 m_thread_id_passed = false;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001539 m_thread_index = UINT32_MAX;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001540 m_thread_index_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001541 m_thread_name.clear();
1542 m_queue_name.clear();
Jim Inghamd1686902010-10-14 23:45:03 +00001543 m_condition.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001544 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001545 m_queue_passed = false;
1546 m_name_passed = false;
Jim Inghamd1686902010-10-14 23:45:03 +00001547 m_condition_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001548}
1549
1550//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001551// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001552//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001553#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001554
Greg Clayton238c0a12010-09-18 01:14:36 +00001555CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1556 CommandObject (interpreter,
1557 "breakpoint modify",
Jim Ingham19ac0bd2010-12-03 22:37:19 +00001558 "Modify the options on a breakpoint or set of breakpoints in the executable. "
Jim Ingham9a7b2912010-12-03 23:04:19 +00001559 "If no breakpoint is specified, acts on the last created breakpoint. "
1560 "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001561 NULL),
1562 m_options (interpreter)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001563{
Caroline Ticefb355112010-10-01 17:46:38 +00001564 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001565 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001566 // Add the entry for the first argument for this command to the object's arguments vector.
1567 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001568}
1569
Jim Ingham10622a22010-06-18 00:58:52 +00001570CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001571{
1572}
1573
1574Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001575CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001576{
1577 return &m_options;
1578}
1579
1580bool
Jim Ingham10622a22010-06-18 00:58:52 +00001581CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001582(
1583 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001584 CommandReturnObject &result
1585)
1586{
Greg Clayton238c0a12010-09-18 01:14:36 +00001587 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001588 if (target == NULL)
1589 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001590 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001591 result.SetStatus (eReturnStatusFailed);
1592 return false;
1593 }
1594
1595 Mutex::Locker locker;
1596 target->GetBreakpointList().GetListMutex(locker);
1597
1598 BreakpointIDList valid_bp_ids;
1599
1600 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1601
1602 if (result.Succeeded())
1603 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001604 const size_t count = valid_bp_ids.GetSize();
1605 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001606 {
1607 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1608
1609 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1610 {
1611 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1612 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1613 {
1614 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1615 if (location)
1616 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001617 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001618 location->SetThreadID (m_options.m_thread_id);
1619
Jim Ingham9a7b2912010-12-03 23:04:19 +00001620 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001621 location->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001622
Jim Inghamd4571222010-06-19 04:35:20 +00001623 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001624 location->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001625
Jim Inghamd4571222010-06-19 04:35:20 +00001626 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001627 location->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001628
Greg Clayton54e7afa2010-07-09 20:39:50 +00001629 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001630 location->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001631
1632 if (m_options.m_enable_passed)
1633 location->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001634
1635 if (m_options.m_condition_passed)
1636 location->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001637 }
1638 }
1639 else
1640 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001641 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001642 bp->SetThreadID (m_options.m_thread_id);
1643
Jim Ingham9a7b2912010-12-03 23:04:19 +00001644 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001645 bp->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001646
Jim Inghamd4571222010-06-19 04:35:20 +00001647 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001648 bp->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001649
Jim Inghamd4571222010-06-19 04:35:20 +00001650 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001651 bp->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001652
Greg Clayton54e7afa2010-07-09 20:39:50 +00001653 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001654 bp->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001655
1656 if (m_options.m_enable_passed)
1657 bp->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001658
1659 if (m_options.m_condition_passed)
1660 bp->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001661 }
1662 }
1663 }
1664 }
1665
1666 return result.Succeeded();
1667}
1668
1669