blob: a3c2e182bbf429c4289785e7e5c01f3c90a165e6 [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 Chen6f4a1152012-05-07 23:23:41 +000077#define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 )
78#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 )
Jim Inghamd6d47972011-09-23 00:54:11 +000079
Greg Claytonb3448432011-03-24 21:19:54 +000080OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +000081CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
82{
Jim Ingham4722b102012-03-06 00:37:27 +000083 { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
Jim Inghamee033f22012-05-03 20:30:08 +000084 "Set the breakpoint only in this shared library. "
85 "Can repeat this option multiple times to specify multiple shared libraries."},
Jim Ingham34e9a982010-06-15 18:47:14 +000086
Caroline Tice4d6675c2010-10-01 19:59:14 +000087 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
88 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000089
Bill Wendlingff7df6d2012-04-03 04:13:41 +000090 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000091 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +000092
Bill Wendlingff7df6d2012-04-03 04:13:41 +000093 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000094 "The breakpoint stops only for the thread whose TID matches this argument."},
95
Bill Wendlingff7df6d2012-04-03 04:13:41 +000096 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000097 "The breakpoint stops only for the thread whose thread name matches this argument."},
98
Bill Wendlingff7df6d2012-04-03 04:13:41 +000099 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000100 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
101
Jim Inghamd6d47972011-09-23 00:54:11 +0000102 { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
103 "Specifies the source file in which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000104
Caroline Tice4d6675c2010-10-01 19:59:14 +0000105 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Jim Inghamd6d47972011-09-23 00:54:11 +0000106 "Specifies the line number on which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000107
Chris Lattner24943d22010-06-08 16:52:24 +0000108 // Comment out this option for the moment, as we don't actually use it, but will in the future.
109 // This way users won't see it, but the infrastructure is left in place.
110 // { 0, false, "column", 'c', required_argument, NULL, "<column>",
111 // "Set the breakpoint by source location at this particular column."},
112
Caroline Tice4d6675c2010-10-01 19:59:14 +0000113 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000114 "Set the breakpoint by address, at the specified address."},
115
Caroline Tice4d6675c2010-10-01 19:59:14 +0000116 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000117 "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 +0000118
Caroline Tice4d6675c2010-10-01 19:59:14 +0000119 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamee033f22012-05-03 20:30:08 +0000120 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and "
121 "for Objective C this means a full function prototype with class and selector. "
122 "Can be repeated multiple times to make one breakpoint for multiple names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000123
Caroline Tice4d6675c2010-10-01 19:59:14 +0000124 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamee033f22012-05-03 20:30:08 +0000125 "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 +0000126
Caroline Tice4d6675c2010-10-01 19:59:14 +0000127 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamee033f22012-05-03 20:30:08 +0000128 "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 +0000129
Caroline Tice4d6675c2010-10-01 19:59:14 +0000130 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000131 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
132
Greg Clayton48fbdf72010-10-12 04:29:14 +0000133 { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamee033f22012-05-03 20:30:08 +0000134 "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). "
135 "Can be repeated multiple times to make one breakpoint for multiple symbols." },
Greg Clayton48fbdf72010-10-12 04:29:14 +0000136
Jim Ingham03c8ee52011-09-21 01:17:13 +0000137 { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression,
138 "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." },
139
Jim Ingham4722b102012-03-06 00:37:27 +0000140 { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage,
141 "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
142
143 { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean,
144 "Set the breakpoint on exception throW." },
145
146 { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
147 "Set the breakpoint on exception catcH." },
Jim Ingham03c8ee52011-09-21 01:17:13 +0000148
Caroline Tice4d6675c2010-10-01 19:59:14 +0000149 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000150};
151
Greg Claytonb3448432011-03-24 21:19:54 +0000152const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000153CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
154{
155 return g_option_table;
156}
157
158Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000159CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000160{
161 Error error;
162 char short_option = (char) m_getopt_table[option_idx].val;
163
164 switch (short_option)
165 {
166 case 'a':
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000167 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
Chris Lattner24943d22010-06-08 16:52:24 +0000168 if (m_load_addr == LLDB_INVALID_ADDRESS)
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000169 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
Chris Lattner24943d22010-06-08 16:52:24 +0000170
171 if (m_load_addr == LLDB_INVALID_ADDRESS)
Greg Clayton9c236732011-10-26 00:56:27 +0000172 error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000173 break;
174
175 case 'c':
176 m_column = Args::StringToUInt32 (option_arg, 0);
177 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000178
Chris Lattner24943d22010-06-08 16:52:24 +0000179 case 'f':
Jim Inghamd6d47972011-09-23 00:54:11 +0000180 m_filenames.AppendIfUnique (FileSpec(option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000181 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000182
Chris Lattner24943d22010-06-08 16:52:24 +0000183 case 'l':
184 m_line_num = Args::StringToUInt32 (option_arg, 0);
185 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000186
Greg Clayton48fbdf72010-10-12 04:29:14 +0000187 case 'b':
Jim Ingham4722b102012-03-06 00:37:27 +0000188 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000189 m_func_name_type_mask |= eFunctionNameTypeBase;
190 break;
191
Greg Clayton48fbdf72010-10-12 04:29:14 +0000192 case 'n':
Jim Ingham4722b102012-03-06 00:37:27 +0000193 m_func_names.push_back (option_arg);
Greg Clayton48fbdf72010-10-12 04:29:14 +0000194 m_func_name_type_mask |= eFunctionNameTypeAuto;
195 break;
196
Greg Clayton12bec712010-06-28 21:30:43 +0000197 case 'F':
Jim Ingham4722b102012-03-06 00:37:27 +0000198 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000199 m_func_name_type_mask |= eFunctionNameTypeFull;
200 break;
201
202 case 'S':
Jim Ingham4722b102012-03-06 00:37:27 +0000203 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000204 m_func_name_type_mask |= eFunctionNameTypeSelector;
205 break;
206
Jim Inghamd9e2b762010-08-26 23:56:11 +0000207 case 'M':
Jim Ingham4722b102012-03-06 00:37:27 +0000208 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000209 m_func_name_type_mask |= eFunctionNameTypeMethod;
210 break;
211
Jim Ingham03c8ee52011-09-21 01:17:13 +0000212 case 'p':
213 m_source_text_regexp.assign (option_arg);
214 break;
215
Chris Lattner24943d22010-06-08 16:52:24 +0000216 case 'r':
Greg Clayton889fbd02011-03-26 19:14:58 +0000217 m_func_regexp.assign (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000218 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000219
Chris Lattner24943d22010-06-08 16:52:24 +0000220 case 's':
221 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000222 m_modules.AppendIfUnique (FileSpec (option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000223 break;
224 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000225 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000226 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000227 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000228 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000229 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000230 }
Jim Ingham10622a22010-06-18 00:58:52 +0000231 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000232 case 't' :
233 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000234 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000235 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +0000236 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000237 }
238 break;
239 case 'T':
Greg Clayton889fbd02011-03-26 19:14:58 +0000240 m_thread_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000241 break;
242 case 'q':
Greg Clayton889fbd02011-03-26 19:14:58 +0000243 m_queue_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000244 break;
245 case 'x':
246 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000247 m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000248 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000249 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000250
251 }
252 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000253 case 'E':
254 {
255 LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
256
257 switch (language)
258 {
259 case eLanguageTypeC89:
260 case eLanguageTypeC:
261 case eLanguageTypeC99:
262 m_language = eLanguageTypeC;
263 break;
264 case eLanguageTypeC_plus_plus:
265 m_language = eLanguageTypeC_plus_plus;
266 break;
267 case eLanguageTypeObjC:
268 m_language = eLanguageTypeObjC;
269 break;
270 case eLanguageTypeObjC_plus_plus:
271 error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
272 break;
273 case eLanguageTypeUnknown:
274 error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
275 break;
276 default:
277 error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
278 }
279 }
280 break;
281 case 'w':
282 {
283 bool success;
284 m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
285 if (!success)
286 error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
287 }
288 break;
289 case 'h':
290 {
291 bool success;
292 m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
293 if (!success)
294 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
295 }
296 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000297 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000298 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000299 break;
300 }
301
302 return error;
303}
304
305void
Greg Clayton143fcc32011-04-13 00:18:08 +0000306CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000307{
Jim Inghamd6d47972011-09-23 00:54:11 +0000308 m_filenames.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000309 m_line_num = 0;
310 m_column = 0;
Jim Ingham4722b102012-03-06 00:37:27 +0000311 m_func_names.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000312 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000313 m_func_regexp.clear();
314 m_load_addr = LLDB_INVALID_ADDRESS;
Jim Inghamd6d47972011-09-23 00:54:11 +0000315 m_modules.Clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000316 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000317 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000318 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000319 m_thread_name.clear();
320 m_queue_name.clear();
Jim Ingham4722b102012-03-06 00:37:27 +0000321 m_language = eLanguageTypeUnknown;
322 m_catch_bp = false;
323 m_throw_bp = true;
Chris Lattner24943d22010-06-08 16:52:24 +0000324}
325
326//-------------------------------------------------------------------------
327// CommandObjectBreakpointSet
328//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000329#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000330
Greg Clayton238c0a12010-09-18 01:14:36 +0000331CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
332 CommandObject (interpreter,
333 "breakpoint set",
334 "Sets a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000335 "breakpoint set <cmd-options>"),
336 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000337{
338}
339
340CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
341{
342}
343
344Options *
345CommandObjectBreakpointSet::GetOptions ()
346{
347 return &m_options;
348}
349
350bool
Jim Inghamd6d47972011-09-23 00:54:11 +0000351CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000352{
Jim Inghamd6d47972011-09-23 00:54:11 +0000353 uint32_t default_line;
354 // First use the Source Manager's default file.
355 // Then use the current stack frame's file.
356 if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
Jim Ingham03c8ee52011-09-21 01:17:13 +0000357 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000358 StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
359 if (cur_frame == NULL)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000360 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000361 result.AppendError ("No selected frame to use to find the default file.");
362 result.SetStatus (eReturnStatusFailed);
363 return false;
364 }
365 else if (!cur_frame->HasDebugInformation())
366 {
367 result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
368 result.SetStatus (eReturnStatusFailed);
369 return false;
370 }
371 else
372 {
373 const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
374 if (sc.line_entry.file)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000375 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000376 file = sc.line_entry.file;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000377 }
378 else
379 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000380 result.AppendError ("Can't find the file for the selected frame to use as the default file.");
381 result.SetStatus (eReturnStatusFailed);
382 return false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000383 }
384 }
385 }
Jim Ingham03c8ee52011-09-21 01:17:13 +0000386 return true;
387}
388
389bool
Chris Lattner24943d22010-06-08 16:52:24 +0000390CommandObjectBreakpointSet::Execute
391(
392 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000393 CommandReturnObject &result
394)
395{
Greg Clayton238c0a12010-09-18 01:14:36 +0000396 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000397 if (target == NULL)
398 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000399 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000400 result.SetStatus (eReturnStatusFailed);
401 return false;
402 }
403
404 // The following are the various types of breakpoints that could be set:
405 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
406 // 2). -a [-s -g] (setting breakpoint by address)
407 // 3). -n [-s -g] (setting breakpoint by function name)
408 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000409 // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
Jim Ingham4722b102012-03-06 00:37:27 +0000410 // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.)
Chris Lattner24943d22010-06-08 16:52:24 +0000411
412 BreakpointSetType break_type = eSetTypeInvalid;
413
414 if (m_options.m_line_num != 0)
415 break_type = eSetTypeFileAndLine;
416 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
417 break_type = eSetTypeAddress;
Jim Ingham4722b102012-03-06 00:37:27 +0000418 else if (!m_options.m_func_names.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000419 break_type = eSetTypeFunctionName;
420 else if (!m_options.m_func_regexp.empty())
421 break_type = eSetTypeFunctionRegexp;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000422 else if (!m_options.m_source_text_regexp.empty())
423 break_type = eSetTypeSourceRegexp;
Jim Ingham4722b102012-03-06 00:37:27 +0000424 else if (m_options.m_language != eLanguageTypeUnknown)
425 break_type = eSetTypeException;
Chris Lattner24943d22010-06-08 16:52:24 +0000426
Chris Lattner24943d22010-06-08 16:52:24 +0000427 Breakpoint *bp = NULL;
Greg Clayton537a7a82010-10-20 20:54:39 +0000428 FileSpec module_spec;
Chris Lattner24943d22010-06-08 16:52:24 +0000429 bool use_module = false;
Jim Inghamd6d47972011-09-23 00:54:11 +0000430 int num_modules = m_options.m_modules.GetSize();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000431
Chris Lattner24943d22010-06-08 16:52:24 +0000432 if ((num_modules > 0) && (break_type != eSetTypeAddress))
433 use_module = true;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000434
Chris Lattner24943d22010-06-08 16:52:24 +0000435 switch (break_type)
436 {
437 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000438 {
Greg Clayton887aa282010-10-11 01:05:37 +0000439 FileSpec file;
Jim Inghamd6d47972011-09-23 00:54:11 +0000440 uint32_t num_files = m_options.m_filenames.GetSize();
441 if (num_files == 0)
442 {
443 if (!GetDefaultFile (target, file, result))
444 {
445 result.AppendError("No file supplied and no default file available.");
446 result.SetStatus (eReturnStatusFailed);
447 return false;
448 }
449 }
450 else if (num_files > 1)
451 {
452 result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
453 result.SetStatus (eReturnStatusFailed);
454 return false;
455 }
456 else
457 file = m_options.m_filenames.GetFileSpecAtIndex(0);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000458
Jim Inghamd6d47972011-09-23 00:54:11 +0000459 bp = target->CreateBreakpoint (&(m_options.m_modules),
Jim Ingham03c8ee52011-09-21 01:17:13 +0000460 file,
461 m_options.m_line_num,
462 m_options.m_check_inlines).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000463 }
Greg Clayton887aa282010-10-11 01:05:37 +0000464 break;
465
Chris Lattner24943d22010-06-08 16:52:24 +0000466 case eSetTypeAddress: // Breakpoint by address
467 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
468 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000469
Chris Lattner24943d22010-06-08 16:52:24 +0000470 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000471 {
Greg Clayton12bec712010-06-28 21:30:43 +0000472 uint32_t name_type_mask = m_options.m_func_name_type_mask;
473
474 if (name_type_mask == 0)
Greg Clayton48fbdf72010-10-12 04:29:14 +0000475 name_type_mask = eFunctionNameTypeAuto;
Jim Ingham4722b102012-03-06 00:37:27 +0000476
Jim Inghamd6d47972011-09-23 00:54:11 +0000477 bp = target->CreateBreakpoint (&(m_options.m_modules),
478 &(m_options.m_filenames),
Jim Ingham4722b102012-03-06 00:37:27 +0000479 m_options.m_func_names,
480 name_type_mask,
Jim Ingham03c8ee52011-09-21 01:17:13 +0000481 Breakpoint::Exact).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000482 }
Chris Lattner24943d22010-06-08 16:52:24 +0000483 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000484
Chris Lattner24943d22010-06-08 16:52:24 +0000485 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
486 {
487 RegularExpression regexp(m_options.m_func_regexp.c_str());
Jim Ingham03c8ee52011-09-21 01:17:13 +0000488 if (!regexp.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000489 {
Jim Ingham03c8ee52011-09-21 01:17:13 +0000490 char err_str[1024];
491 regexp.GetErrorAsCString(err_str, sizeof(err_str));
492 result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
493 err_str);
494 result.SetStatus (eReturnStatusFailed);
495 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000496 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000497
498 bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000499 }
500 break;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000501 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
502 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000503 int num_files = m_options.m_filenames.GetSize();
504
505 if (num_files == 0)
506 {
507 FileSpec file;
508 if (!GetDefaultFile (target, file, result))
509 {
510 result.AppendError ("No files provided and could not find default file.");
511 result.SetStatus (eReturnStatusFailed);
512 return false;
513 }
514 else
515 {
516 m_options.m_filenames.Append (file);
517 }
518 }
519
Jim Ingham03c8ee52011-09-21 01:17:13 +0000520 RegularExpression regexp(m_options.m_source_text_regexp.c_str());
521 if (!regexp.IsValid())
522 {
523 char err_str[1024];
524 regexp.GetErrorAsCString(err_str, sizeof(err_str));
525 result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
526 err_str);
527 result.SetStatus (eReturnStatusFailed);
528 return false;
529 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000530 bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000531 }
532 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000533 case eSetTypeException:
534 {
535 bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
536 }
537 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000538 default:
539 break;
540 }
541
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000542 // Now set the various options that were passed in:
543 if (bp)
544 {
545 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
546 bp->SetThreadID (m_options.m_thread_id);
547
Greg Clayton54e7afa2010-07-09 20:39:50 +0000548 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000549 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
550
551 if (!m_options.m_thread_name.empty())
552 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
553
554 if (!m_options.m_queue_name.empty())
555 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
556
Greg Clayton54e7afa2010-07-09 20:39:50 +0000557 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000558 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
559 }
560
Jim Ingham03c8ee52011-09-21 01:17:13 +0000561 if (bp)
Chris Lattner24943d22010-06-08 16:52:24 +0000562 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000563 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000564 output_stream.Printf ("Breakpoint created: ");
565 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
566 output_stream.EOL();
Jim Ingham4722b102012-03-06 00:37:27 +0000567 // Don't print out this warning for exception breakpoints. They can get set before the target
568 // is set, but we won't know how to actually set the breakpoint till we run.
569 if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
Caroline Ticecf2f3052010-10-28 16:28:56 +0000570 output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n");
Chris Lattner24943d22010-06-08 16:52:24 +0000571 result.SetStatus (eReturnStatusSuccessFinishResult);
572 }
573 else if (!bp)
574 {
575 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
576 result.SetStatus (eReturnStatusFailed);
577 }
578
579 return result.Succeeded();
580}
581
Chris Lattner24943d22010-06-08 16:52:24 +0000582//-------------------------------------------------------------------------
583// CommandObjectMultiwordBreakpoint
584//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000585#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000586
Greg Clayton63094e02010-06-23 01:19:29 +0000587CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000588 CommandObjectMultiword (interpreter,
589 "breakpoint",
Jim Ingham7224aab2011-05-26 20:39:01 +0000590 "A set of commands for operating on breakpoints. Also see _regexp-break.",
Greg Clayton238c0a12010-09-18 01:14:36 +0000591 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000592{
593 bool status;
594
Greg Clayton238c0a12010-09-18 01:14:36 +0000595 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000596 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
597 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
Johnny Chena62ad7c2010-10-28 17:27:46 +0000598 CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
599 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000600 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000601 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000602 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000603
Johnny Chena62ad7c2010-10-28 17:27:46 +0000604 list_command_object->SetCommandName ("breakpoint list");
Chris Lattner24943d22010-06-08 16:52:24 +0000605 enable_command_object->SetCommandName("breakpoint enable");
606 disable_command_object->SetCommandName("breakpoint disable");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000607 clear_command_object->SetCommandName("breakpoint clear");
608 delete_command_object->SetCommandName("breakpoint delete");
Jim Ingham10622a22010-06-18 00:58:52 +0000609 set_command_object->SetCommandName("breakpoint set");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000610 command_command_object->SetCommandName ("breakpoint command");
611 modify_command_object->SetCommandName ("breakpoint modify");
Chris Lattner24943d22010-06-08 16:52:24 +0000612
Greg Clayton238c0a12010-09-18 01:14:36 +0000613 status = LoadSubCommand ("list", list_command_object);
614 status = LoadSubCommand ("enable", enable_command_object);
615 status = LoadSubCommand ("disable", disable_command_object);
Johnny Chena62ad7c2010-10-28 17:27:46 +0000616 status = LoadSubCommand ("clear", clear_command_object);
Greg Clayton238c0a12010-09-18 01:14:36 +0000617 status = LoadSubCommand ("delete", delete_command_object);
618 status = LoadSubCommand ("set", set_command_object);
619 status = LoadSubCommand ("command", command_command_object);
620 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000621}
622
623CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
624{
625}
626
627void
628CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
629 BreakpointIDList *valid_ids)
630{
631 // args can be strings representing 1). integers (for breakpoint ids)
632 // 2). the full breakpoint & location canonical representation
633 // 3). the word "to" or a hyphen, representing a range (in which case there
634 // had *better* be an entry both before & after of one of the first two types.
Jim Inghamd1686902010-10-14 23:45:03 +0000635 // If args is empty, we will use the last created breakpoint (if there is one.)
Chris Lattner24943d22010-06-08 16:52:24 +0000636
637 Args temp_args;
638
Jim Inghamd1686902010-10-14 23:45:03 +0000639 if (args.GetArgumentCount() == 0)
640 {
Greg Clayton987c7eb2011-09-17 08:33:22 +0000641 if (target->GetLastCreatedBreakpoint())
Jim Inghamd1686902010-10-14 23:45:03 +0000642 {
643 valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
644 result.SetStatus (eReturnStatusSuccessFinishNoResult);
645 }
646 else
647 {
648 result.AppendError("No breakpoint specified and no last created breakpoint.");
649 result.SetStatus (eReturnStatusFailed);
650 }
651 return;
652 }
653
Chris Lattner24943d22010-06-08 16:52:24 +0000654 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
655 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
656 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
657
658 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
659
660 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
661
Greg Clayton54e7afa2010-07-09 20:39:50 +0000662 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000663
664 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
665 // and put into valid_ids.
666
667 if (result.Succeeded())
668 {
669 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
670 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
671
Greg Clayton54e7afa2010-07-09 20:39:50 +0000672 const size_t count = valid_ids->GetSize();
673 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000674 {
675 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
676 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
677 if (breakpoint != NULL)
678 {
679 int num_locations = breakpoint->GetNumLocations();
680 if (cur_bp_id.GetLocationID() > num_locations)
681 {
682 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000683 BreakpointID::GetCanonicalReference (&id_str,
684 cur_bp_id.GetBreakpointID(),
685 cur_bp_id.GetLocationID());
686 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000687 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
688 id_str.GetData());
689 result.SetStatus (eReturnStatusFailed);
690 }
691 }
692 else
693 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000694 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000695 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
696 result.SetStatus (eReturnStatusFailed);
697 }
698 }
699 }
700}
701
702//-------------------------------------------------------------------------
703// CommandObjectBreakpointList::Options
704//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000705#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000706
Greg Claytonf15996e2011-04-07 22:46:35 +0000707CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
708 Options (interpreter),
Caroline Tice41950cc2011-02-04 22:59:41 +0000709 m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions
Chris Lattner24943d22010-06-08 16:52:24 +0000710{
Chris Lattner24943d22010-06-08 16:52:24 +0000711}
712
713CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
714{
715}
716
Greg Claytonb3448432011-03-24 21:19:54 +0000717OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000718CommandObjectBreakpointList::CommandOptions::g_option_table[] =
719{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000720 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000721 "Show debugger internal breakpoints" },
722
Caroline Tice4d6675c2010-10-01 19:59:14 +0000723 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000724 "Give a brief description of the breakpoint (no location info)."},
725
726 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
727 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000728 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000729 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000730
Caroline Tice4d6675c2010-10-01 19:59:14 +0000731 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000732 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000733
Caroline Tice4d6675c2010-10-01 19:59:14 +0000734 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000735};
736
Greg Claytonb3448432011-03-24 21:19:54 +0000737const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000738CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
739{
740 return g_option_table;
741}
742
743Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000744CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000745{
746 Error error;
747 char short_option = (char) m_getopt_table[option_idx].val;
748
749 switch (short_option)
750 {
751 case 'b':
752 m_level = lldb::eDescriptionLevelBrief;
753 break;
754 case 'f':
755 m_level = lldb::eDescriptionLevelFull;
756 break;
757 case 'v':
758 m_level = lldb::eDescriptionLevelVerbose;
759 break;
760 case 'i':
761 m_internal = true;
762 break;
763 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000764 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000765 break;
766 }
767
768 return error;
769}
770
771void
Greg Clayton143fcc32011-04-13 00:18:08 +0000772CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000773{
Jim Inghamdc259052011-05-17 01:21:41 +0000774 m_level = lldb::eDescriptionLevelFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000775 m_internal = false;
776}
777
778//-------------------------------------------------------------------------
779// CommandObjectBreakpointList
780//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000781#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000782
Greg Clayton238c0a12010-09-18 01:14:36 +0000783CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
784 CommandObject (interpreter,
785 "breakpoint list",
786 "List some or all breakpoints at configurable levels of detail.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000787 NULL),
788 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000789{
Caroline Ticefb355112010-10-01 17:46:38 +0000790 CommandArgumentEntry arg;
791 CommandArgumentData bp_id_arg;
792
793 // Define the first (and only) variant of this arg.
794 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000795 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000796
797 // There is only one variant this argument could be; put it into the argument entry.
798 arg.push_back (bp_id_arg);
799
800 // Push the data for the first argument into the m_arguments vector.
801 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000802}
803
804CommandObjectBreakpointList::~CommandObjectBreakpointList ()
805{
806}
807
808Options *
809CommandObjectBreakpointList::GetOptions ()
810{
811 return &m_options;
812}
813
814bool
815CommandObjectBreakpointList::Execute
816(
817 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000818 CommandReturnObject &result
819)
820{
Greg Clayton238c0a12010-09-18 01:14:36 +0000821 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000822 if (target == NULL)
823 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000824 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000825 result.SetStatus (eReturnStatusSuccessFinishNoResult);
826 return true;
827 }
828
829 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000830 Mutex::Locker locker;
831 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
832
Chris Lattner24943d22010-06-08 16:52:24 +0000833 size_t num_breakpoints = breakpoints.GetSize();
834
835 if (num_breakpoints == 0)
836 {
837 result.AppendMessage ("No breakpoints currently set.");
838 result.SetStatus (eReturnStatusSuccessFinishNoResult);
839 return true;
840 }
841
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000842 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000843
844 if (args.GetArgumentCount() == 0)
845 {
846 // No breakpoint selected; show info about all currently set breakpoints.
847 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000848 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000849 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000850 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000851 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000852 }
853 result.SetStatus (eReturnStatusSuccessFinishNoResult);
854 }
855 else
856 {
857 // Particular breakpoints selected; show info about that breakpoint.
858 BreakpointIDList valid_bp_ids;
859 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
860
861 if (result.Succeeded())
862 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000863 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000864 {
865 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
866 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000867 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000868 }
869 result.SetStatus (eReturnStatusSuccessFinishNoResult);
870 }
871 else
872 {
873 result.AppendError ("Invalid breakpoint id.");
874 result.SetStatus (eReturnStatusFailed);
875 }
876 }
877
878 return result.Succeeded();
879}
880
881//-------------------------------------------------------------------------
882// CommandObjectBreakpointEnable
883//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000884#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000885
Greg Clayton238c0a12010-09-18 01:14:36 +0000886CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
887 CommandObject (interpreter,
888 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000889 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
890 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000891{
Caroline Ticefb355112010-10-01 17:46:38 +0000892 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000893 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000894 // Add the entry for the first argument for this command to the object's arguments vector.
895 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000896}
897
898
899CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
900{
901}
902
903
904bool
Greg Clayton63094e02010-06-23 01:19:29 +0000905CommandObjectBreakpointEnable::Execute
906(
Greg Clayton63094e02010-06-23 01:19:29 +0000907 Args& args,
908 CommandReturnObject &result
909)
Chris Lattner24943d22010-06-08 16:52:24 +0000910{
Greg Clayton238c0a12010-09-18 01:14:36 +0000911 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000912 if (target == NULL)
913 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000914 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000915 result.SetStatus (eReturnStatusFailed);
916 return false;
917 }
918
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000919 Mutex::Locker locker;
920 target->GetBreakpointList().GetListMutex(locker);
921
Chris Lattner24943d22010-06-08 16:52:24 +0000922 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000923
Chris Lattner24943d22010-06-08 16:52:24 +0000924 size_t num_breakpoints = breakpoints.GetSize();
925
926 if (num_breakpoints == 0)
927 {
928 result.AppendError ("No breakpoints exist to be enabled.");
929 result.SetStatus (eReturnStatusFailed);
930 return false;
931 }
932
933 if (args.GetArgumentCount() == 0)
934 {
935 // No breakpoint selected; enable all currently set breakpoints.
936 target->EnableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000937 result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +0000938 result.SetStatus (eReturnStatusSuccessFinishNoResult);
939 }
940 else
941 {
942 // Particular breakpoint selected; enable that breakpoint.
943 BreakpointIDList valid_bp_ids;
944 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
945
946 if (result.Succeeded())
947 {
948 int enable_count = 0;
949 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000950 const size_t count = valid_bp_ids.GetSize();
951 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000952 {
953 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
954
955 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
956 {
957 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
958 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
959 {
960 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
961 if (location)
962 {
963 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000964 ++loc_count;
965 }
966 }
967 else
968 {
Jim Ingham10622a22010-06-18 00:58:52 +0000969 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000970 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +0000971 }
972 }
973 }
974 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
975 result.SetStatus (eReturnStatusSuccessFinishNoResult);
976 }
977 }
978
979 return result.Succeeded();
980}
981
982//-------------------------------------------------------------------------
983// CommandObjectBreakpointDisable
984//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000985#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +0000986
Greg Clayton238c0a12010-09-18 01:14:36 +0000987CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
988 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +0000989 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +0000990 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +0000991 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000992{
Caroline Ticefb355112010-10-01 17:46:38 +0000993 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000994 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000995 // Add the entry for the first argument for this command to the object's arguments vector.
996 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000997}
998
999CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
1000{
1001}
1002
1003bool
Greg Clayton63094e02010-06-23 01:19:29 +00001004CommandObjectBreakpointDisable::Execute
1005(
Greg Clayton63094e02010-06-23 01:19:29 +00001006 Args& args,
1007 CommandReturnObject &result
1008)
Chris Lattner24943d22010-06-08 16:52:24 +00001009{
Greg Clayton238c0a12010-09-18 01:14:36 +00001010 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001011 if (target == NULL)
1012 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001013 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001014 result.SetStatus (eReturnStatusFailed);
1015 return false;
1016 }
1017
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001018 Mutex::Locker locker;
1019 target->GetBreakpointList().GetListMutex(locker);
1020
Chris Lattner24943d22010-06-08 16:52:24 +00001021 const BreakpointList &breakpoints = target->GetBreakpointList();
1022 size_t num_breakpoints = breakpoints.GetSize();
1023
1024 if (num_breakpoints == 0)
1025 {
1026 result.AppendError ("No breakpoints exist to be disabled.");
1027 result.SetStatus (eReturnStatusFailed);
1028 return false;
1029 }
1030
1031 if (args.GetArgumentCount() == 0)
1032 {
1033 // No breakpoint selected; disable all currently set breakpoints.
1034 target->DisableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001035 result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +00001036 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1037 }
1038 else
1039 {
1040 // Particular breakpoint selected; disable that breakpoint.
1041 BreakpointIDList valid_bp_ids;
1042
1043 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1044
1045 if (result.Succeeded())
1046 {
1047 int disable_count = 0;
1048 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001049 const size_t count = valid_bp_ids.GetSize();
1050 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001051 {
1052 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1053
1054 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1055 {
1056 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1057 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1058 {
1059 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1060 if (location)
1061 {
1062 location->SetEnabled (false);
1063 ++loc_count;
1064 }
1065 }
1066 else
1067 {
Jim Ingham10622a22010-06-18 00:58:52 +00001068 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001069 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001070 }
1071 }
1072 }
1073 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1074 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1075 }
1076 }
1077
1078 return result.Succeeded();
1079}
1080
1081//-------------------------------------------------------------------------
Johnny Chena62ad7c2010-10-28 17:27:46 +00001082// CommandObjectBreakpointClear::CommandOptions
1083//-------------------------------------------------------------------------
1084#pragma mark Clear::CommandOptions
1085
Greg Claytonf15996e2011-04-07 22:46:35 +00001086CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1087 Options (interpreter),
Johnny Chena62ad7c2010-10-28 17:27:46 +00001088 m_filename (),
1089 m_line_num (0)
1090{
1091}
1092
1093CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
1094{
1095}
1096
Greg Claytonb3448432011-03-24 21:19:54 +00001097OptionDefinition
Johnny Chena62ad7c2010-10-28 17:27:46 +00001098CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
1099{
1100 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
1101 "Specify the breakpoint by source location in this particular file."},
1102
1103 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
1104 "Specify the breakpoint by source location at this particular line."},
1105
1106 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1107};
1108
Greg Claytonb3448432011-03-24 21:19:54 +00001109const OptionDefinition*
Johnny Chena62ad7c2010-10-28 17:27:46 +00001110CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
1111{
1112 return g_option_table;
1113}
1114
1115Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001116CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001117{
1118 Error error;
1119 char short_option = (char) m_getopt_table[option_idx].val;
1120
1121 switch (short_option)
1122 {
1123 case 'f':
Greg Clayton889fbd02011-03-26 19:14:58 +00001124 m_filename.assign (option_arg);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001125 break;
1126
1127 case 'l':
1128 m_line_num = Args::StringToUInt32 (option_arg, 0);
1129 break;
1130
1131 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001132 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001133 break;
1134 }
1135
1136 return error;
1137}
1138
1139void
Greg Clayton143fcc32011-04-13 00:18:08 +00001140CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
Johnny Chena62ad7c2010-10-28 17:27:46 +00001141{
Johnny Chena62ad7c2010-10-28 17:27:46 +00001142 m_filename.clear();
1143 m_line_num = 0;
1144}
1145
1146//-------------------------------------------------------------------------
1147// CommandObjectBreakpointClear
1148//-------------------------------------------------------------------------
1149#pragma mark Clear
1150
1151CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
1152 CommandObject (interpreter,
1153 "breakpoint clear",
1154 "Clears a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001155 "breakpoint clear <cmd-options>"),
1156 m_options (interpreter)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001157{
1158}
1159
1160CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
1161{
1162}
1163
1164Options *
1165CommandObjectBreakpointClear::GetOptions ()
1166{
1167 return &m_options;
1168}
1169
1170bool
1171CommandObjectBreakpointClear::Execute
1172(
1173 Args& command,
1174 CommandReturnObject &result
1175)
1176{
1177 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
1178 if (target == NULL)
1179 {
1180 result.AppendError ("Invalid target. No existing target or breakpoints.");
1181 result.SetStatus (eReturnStatusFailed);
1182 return false;
1183 }
1184
1185 // The following are the various types of breakpoints that could be cleared:
1186 // 1). -f -l (clearing breakpoint by source location)
1187
1188 BreakpointClearType break_type = eClearTypeInvalid;
1189
1190 if (m_options.m_line_num != 0)
1191 break_type = eClearTypeFileAndLine;
1192
1193 Mutex::Locker locker;
1194 target->GetBreakpointList().GetListMutex(locker);
1195
1196 BreakpointList &breakpoints = target->GetBreakpointList();
1197 size_t num_breakpoints = breakpoints.GetSize();
1198
1199 // Early return if there's no breakpoint at all.
1200 if (num_breakpoints == 0)
1201 {
1202 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1203 result.SetStatus (eReturnStatusFailed);
1204 return result.Succeeded();
1205 }
1206
1207 // Find matching breakpoints and delete them.
1208
1209 // First create a copy of all the IDs.
1210 std::vector<break_id_t> BreakIDs;
1211 for (size_t i = 0; i < num_breakpoints; ++i)
1212 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
1213
1214 int num_cleared = 0;
1215 StreamString ss;
1216 switch (break_type)
1217 {
1218 case eClearTypeFileAndLine: // Breakpoint by source position
1219 {
1220 const ConstString filename(m_options.m_filename.c_str());
1221 BreakpointLocationCollection loc_coll;
1222
1223 for (size_t i = 0; i < num_breakpoints; ++i)
1224 {
1225 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
1226
1227 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
1228 {
1229 // If the collection size is 0, it's a full match and we can just remove the breakpoint.
1230 if (loc_coll.GetSize() == 0)
1231 {
1232 bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
1233 ss.EOL();
1234 target->RemoveBreakpointByID (bp->GetID());
1235 ++num_cleared;
1236 }
1237 }
1238 }
1239 }
1240 break;
1241
1242 default:
1243 break;
1244 }
1245
1246 if (num_cleared > 0)
1247 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +00001248 Stream &output_stream = result.GetOutputStream();
Johnny Chena62ad7c2010-10-28 17:27:46 +00001249 output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
1250 output_stream << ss.GetData();
1251 output_stream.EOL();
1252 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1253 }
1254 else
1255 {
1256 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1257 result.SetStatus (eReturnStatusFailed);
1258 }
1259
1260 return result.Succeeded();
1261}
1262
1263//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001264// CommandObjectBreakpointDelete
1265//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001266#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001267
Greg Clayton238c0a12010-09-18 01:14:36 +00001268CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1269 CommandObject (interpreter,
1270 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001271 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001272 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001273{
Caroline Ticefb355112010-10-01 17:46:38 +00001274 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001275 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001276 // Add the entry for the first argument for this command to the object's arguments vector.
1277 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001278}
1279
1280
1281CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1282{
1283}
1284
1285bool
Greg Clayton63094e02010-06-23 01:19:29 +00001286CommandObjectBreakpointDelete::Execute
1287(
Greg Clayton63094e02010-06-23 01:19:29 +00001288 Args& args,
1289 CommandReturnObject &result
1290)
Chris Lattner24943d22010-06-08 16:52:24 +00001291{
Greg Clayton238c0a12010-09-18 01:14:36 +00001292 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001293 if (target == NULL)
1294 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001295 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001296 result.SetStatus (eReturnStatusFailed);
1297 return false;
1298 }
1299
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001300 Mutex::Locker locker;
1301 target->GetBreakpointList().GetListMutex(locker);
1302
Chris Lattner24943d22010-06-08 16:52:24 +00001303 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001304
Chris Lattner24943d22010-06-08 16:52:24 +00001305 size_t num_breakpoints = breakpoints.GetSize();
1306
1307 if (num_breakpoints == 0)
1308 {
1309 result.AppendError ("No breakpoints exist to be deleted.");
1310 result.SetStatus (eReturnStatusFailed);
1311 return false;
1312 }
1313
1314 if (args.GetArgumentCount() == 0)
1315 {
Jim Inghamd1686902010-10-14 23:45:03 +00001316 if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
Chris Lattner24943d22010-06-08 16:52:24 +00001317 {
Jim Inghamd1686902010-10-14 23:45:03 +00001318 result.AppendMessage("Operation cancelled...");
Chris Lattner24943d22010-06-08 16:52:24 +00001319 }
Jim Inghamd1686902010-10-14 23:45:03 +00001320 else
1321 {
1322 target->RemoveAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001323 result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
Jim Inghamd1686902010-10-14 23:45:03 +00001324 }
Chris Lattner24943d22010-06-08 16:52:24 +00001325 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1326 }
1327 else
1328 {
1329 // Particular breakpoint selected; disable that breakpoint.
1330 BreakpointIDList valid_bp_ids;
1331 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1332
1333 if (result.Succeeded())
1334 {
1335 int delete_count = 0;
1336 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001337 const size_t count = valid_bp_ids.GetSize();
1338 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001339 {
1340 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1341
1342 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1343 {
1344 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1345 {
1346 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1347 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1348 // It makes no sense to try to delete individual locations, so we disable them instead.
1349 if (location)
1350 {
1351 location->SetEnabled (false);
1352 ++disable_count;
1353 }
1354 }
1355 else
1356 {
1357 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1358 ++delete_count;
1359 }
1360 }
1361 }
1362 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1363 delete_count, disable_count);
1364 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1365 }
1366 }
1367 return result.Succeeded();
1368}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001369
1370//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001371// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001372//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001373#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001374
Greg Claytonf15996e2011-04-07 22:46:35 +00001375CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1376 Options (interpreter),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001377 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001378 m_thread_id(LLDB_INVALID_THREAD_ID),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001379 m_thread_id_passed(false),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001380 m_thread_index (UINT32_MAX),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001381 m_thread_index_passed(false),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001382 m_thread_name(),
1383 m_queue_name(),
Jim Inghamd1686902010-10-14 23:45:03 +00001384 m_condition (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001385 m_enable_passed (false),
1386 m_enable_value (false),
1387 m_name_passed (false),
Jim Inghamd1686902010-10-14 23:45:03 +00001388 m_queue_passed (false),
1389 m_condition_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001390{
1391}
1392
Jim Ingham10622a22010-06-18 00:58:52 +00001393CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001394{
1395}
1396
Greg Claytonb3448432011-03-24 21:19:54 +00001397OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001398CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001399{
Bill Wendlingff7df6d2012-04-03 04:13:41 +00001400{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1401{ 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."},
1402{ 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."},
1403{ 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."},
1404{ 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."},
1405{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
1406{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."},
1407{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."},
Jim Inghamd1686902010-10-14 23:45:03 +00001408{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001409};
1410
Greg Claytonb3448432011-03-24 21:19:54 +00001411const OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001412CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001413{
1414 return g_option_table;
1415}
1416
1417Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001418CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001419{
1420 Error error;
1421 char short_option = (char) m_getopt_table[option_idx].val;
1422
1423 switch (short_option)
1424 {
Jim Inghamd1686902010-10-14 23:45:03 +00001425 case 'c':
1426 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001427 m_condition.assign (option_arg);
Jim Inghamd1686902010-10-14 23:45:03 +00001428 else
1429 m_condition.clear();
1430 m_condition_passed = true;
1431 break;
Jim Ingham10622a22010-06-18 00:58:52 +00001432 case 'd':
1433 m_enable_passed = true;
1434 m_enable_value = false;
1435 break;
1436 case 'e':
1437 m_enable_passed = true;
1438 m_enable_value = true;
1439 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001440 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001441 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001442 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +00001443 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001444 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001445 }
Jim Ingham10622a22010-06-18 00:58:52 +00001446 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001447 case 't' :
1448 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001449 if (option_arg[0] == '\0')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001450 {
1451 m_thread_id = LLDB_INVALID_THREAD_ID;
1452 m_thread_id_passed = true;
1453 }
1454 else
1455 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001456 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001457 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +00001458 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001459 else
1460 m_thread_id_passed = true;
1461 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001462 }
1463 break;
1464 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001465 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001466 m_thread_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001467 else
1468 m_thread_name.clear();
1469 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001470 break;
1471 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001472 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001473 m_queue_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001474 else
1475 m_queue_name.clear();
1476 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001477 break;
1478 case 'x':
1479 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001480 if (option_arg[0] == '\n')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001481 {
1482 m_thread_index = UINT32_MAX;
1483 m_thread_index_passed = true;
1484 }
1485 else
1486 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001487 m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001488 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001489 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001490 else
1491 m_thread_index_passed = true;
1492 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001493 }
1494 break;
1495 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001496 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001497 break;
1498 }
1499
1500 return error;
1501}
1502
1503void
Greg Clayton143fcc32011-04-13 00:18:08 +00001504CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001505{
Greg Clayton54e7afa2010-07-09 20:39:50 +00001506 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001507 m_thread_id = LLDB_INVALID_THREAD_ID;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001508 m_thread_id_passed = false;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001509 m_thread_index = UINT32_MAX;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001510 m_thread_index_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001511 m_thread_name.clear();
1512 m_queue_name.clear();
Jim Inghamd1686902010-10-14 23:45:03 +00001513 m_condition.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001514 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001515 m_queue_passed = false;
1516 m_name_passed = false;
Jim Inghamd1686902010-10-14 23:45:03 +00001517 m_condition_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001518}
1519
1520//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001521// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001522//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001523#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001524
Greg Clayton238c0a12010-09-18 01:14:36 +00001525CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1526 CommandObject (interpreter,
1527 "breakpoint modify",
Jim Ingham19ac0bd2010-12-03 22:37:19 +00001528 "Modify the options on a breakpoint or set of breakpoints in the executable. "
Jim Ingham9a7b2912010-12-03 23:04:19 +00001529 "If no breakpoint is specified, acts on the last created breakpoint. "
1530 "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001531 NULL),
1532 m_options (interpreter)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001533{
Caroline Ticefb355112010-10-01 17:46:38 +00001534 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001535 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001536 // Add the entry for the first argument for this command to the object's arguments vector.
1537 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001538}
1539
Jim Ingham10622a22010-06-18 00:58:52 +00001540CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001541{
1542}
1543
1544Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001545CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001546{
1547 return &m_options;
1548}
1549
1550bool
Jim Ingham10622a22010-06-18 00:58:52 +00001551CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001552(
1553 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001554 CommandReturnObject &result
1555)
1556{
Greg Clayton238c0a12010-09-18 01:14:36 +00001557 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001558 if (target == NULL)
1559 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001560 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001561 result.SetStatus (eReturnStatusFailed);
1562 return false;
1563 }
1564
1565 Mutex::Locker locker;
1566 target->GetBreakpointList().GetListMutex(locker);
1567
1568 BreakpointIDList valid_bp_ids;
1569
1570 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1571
1572 if (result.Succeeded())
1573 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001574 const size_t count = valid_bp_ids.GetSize();
1575 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001576 {
1577 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1578
1579 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1580 {
1581 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1582 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1583 {
1584 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1585 if (location)
1586 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001587 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001588 location->SetThreadID (m_options.m_thread_id);
1589
Jim Ingham9a7b2912010-12-03 23:04:19 +00001590 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001591 location->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001592
Jim Inghamd4571222010-06-19 04:35:20 +00001593 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001594 location->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001595
Jim Inghamd4571222010-06-19 04:35:20 +00001596 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001597 location->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001598
Greg Clayton54e7afa2010-07-09 20:39:50 +00001599 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001600 location->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001601
1602 if (m_options.m_enable_passed)
1603 location->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001604
1605 if (m_options.m_condition_passed)
1606 location->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001607 }
1608 }
1609 else
1610 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001611 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001612 bp->SetThreadID (m_options.m_thread_id);
1613
Jim Ingham9a7b2912010-12-03 23:04:19 +00001614 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001615 bp->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001616
Jim Inghamd4571222010-06-19 04:35:20 +00001617 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001618 bp->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001619
Jim Inghamd4571222010-06-19 04:35:20 +00001620 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001621 bp->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001622
Greg Clayton54e7afa2010-07-09 20:39:50 +00001623 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001624 bp->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001625
1626 if (m_options.m_enable_passed)
1627 bp->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001628
1629 if (m_options.m_condition_passed)
1630 bp->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001631 }
1632 }
1633 }
1634 }
1635
1636 return result.Succeeded();
1637}
1638
1639