blob: a23e43c29a6bc9e87684fe62e6941bbab301c3a0 [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
Jim Ingham4722b102012-03-06 00:37:27 +000077#define LLDB_OPT_FILE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5 | LLDB_OPT_SET_6 | LLDB_OPT_SET_7 | LLDB_OPT_SET_8 | LLDB_OPT_SET_9 )
78#define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_ALL & ~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 Ingham34e9a982010-06-15 18:47:14 +000084 "Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."},
85
Caroline Tice4d6675c2010-10-01 19:59:14 +000086 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
87 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000088
Caroline Tice4d6675c2010-10-01 19:59:14 +000089 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000090 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +000091
Caroline Tice4d6675c2010-10-01 19:59:14 +000092 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000093 "The breakpoint stops only for the thread whose TID matches this argument."},
94
Caroline Tice4d6675c2010-10-01 19:59:14 +000095 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000096 "The breakpoint stops only for the thread whose thread name matches this argument."},
97
Caroline Tice4d6675c2010-10-01 19:59:14 +000098 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000099 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
100
Jim Inghamd6d47972011-09-23 00:54:11 +0000101 { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
102 "Specifies the source file in which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000103
Caroline Tice4d6675c2010-10-01 19:59:14 +0000104 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Jim Inghamd6d47972011-09-23 00:54:11 +0000105 "Specifies the line number on which to set this breakpoint."},
Chris Lattner24943d22010-06-08 16:52:24 +0000106
Chris Lattner24943d22010-06-08 16:52:24 +0000107 // Comment out this option for the moment, as we don't actually use it, but will in the future.
108 // This way users won't see it, but the infrastructure is left in place.
109 // { 0, false, "column", 'c', required_argument, NULL, "<column>",
110 // "Set the breakpoint by source location at this particular column."},
111
Caroline Tice4d6675c2010-10-01 19:59:14 +0000112 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000113 "Set the breakpoint by address, at the specified address."},
114
Caroline Tice4d6675c2010-10-01 19:59:14 +0000115 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Greg Clayton48fbdf72010-10-12 04:29:14 +0000116 "Set the breakpoint by function name." },
Chris Lattner24943d22010-06-08 16:52:24 +0000117
Caroline Tice4d6675c2010-10-01 19:59:14 +0000118 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000119 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguemnts, and "
120 "for Objective C this means a full function prototype with class and selector." },
Greg Clayton12bec712010-06-28 21:30:43 +0000121
Caroline Tice4d6675c2010-10-01 19:59:14 +0000122 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000123 "Set the breakpoint by ObjC selector name." },
Greg Clayton12bec712010-06-28 21:30:43 +0000124
Caroline Tice4d6675c2010-10-01 19:59:14 +0000125 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000126 "Set the breakpoint by C++ method names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000127
Caroline Tice4d6675c2010-10-01 19:59:14 +0000128 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000129 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
130
Greg Clayton48fbdf72010-10-12 04:29:14 +0000131 { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
132 "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored)." },
133
Jim Ingham03c8ee52011-09-21 01:17:13 +0000134 { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression,
135 "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." },
136
Jim Ingham4722b102012-03-06 00:37:27 +0000137 { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage,
138 "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" },
139
140 { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean,
141 "Set the breakpoint on exception throW." },
142
143 { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean,
144 "Set the breakpoint on exception catcH." },
Jim Ingham03c8ee52011-09-21 01:17:13 +0000145
Caroline Tice4d6675c2010-10-01 19:59:14 +0000146 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000147};
148
Greg Claytonb3448432011-03-24 21:19:54 +0000149const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000150CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
151{
152 return g_option_table;
153}
154
155Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000156CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000157{
158 Error error;
159 char short_option = (char) m_getopt_table[option_idx].val;
160
161 switch (short_option)
162 {
163 case 'a':
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000164 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
Chris Lattner24943d22010-06-08 16:52:24 +0000165 if (m_load_addr == LLDB_INVALID_ADDRESS)
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000166 m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
Chris Lattner24943d22010-06-08 16:52:24 +0000167
168 if (m_load_addr == LLDB_INVALID_ADDRESS)
Greg Clayton9c236732011-10-26 00:56:27 +0000169 error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000170 break;
171
172 case 'c':
173 m_column = Args::StringToUInt32 (option_arg, 0);
174 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000175
Chris Lattner24943d22010-06-08 16:52:24 +0000176 case 'f':
Jim Inghamd6d47972011-09-23 00:54:11 +0000177 m_filenames.AppendIfUnique (FileSpec(option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000178 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000179
Chris Lattner24943d22010-06-08 16:52:24 +0000180 case 'l':
181 m_line_num = Args::StringToUInt32 (option_arg, 0);
182 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000183
Greg Clayton48fbdf72010-10-12 04:29:14 +0000184 case 'b':
Jim Ingham4722b102012-03-06 00:37:27 +0000185 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000186 m_func_name_type_mask |= eFunctionNameTypeBase;
187 break;
188
Greg Clayton48fbdf72010-10-12 04:29:14 +0000189 case 'n':
Jim Ingham4722b102012-03-06 00:37:27 +0000190 m_func_names.push_back (option_arg);
Greg Clayton48fbdf72010-10-12 04:29:14 +0000191 m_func_name_type_mask |= eFunctionNameTypeAuto;
192 break;
193
Greg Clayton12bec712010-06-28 21:30:43 +0000194 case 'F':
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 |= eFunctionNameTypeFull;
197 break;
198
199 case 'S':
Jim Ingham4722b102012-03-06 00:37:27 +0000200 m_func_names.push_back (option_arg);
Greg Clayton12bec712010-06-28 21:30:43 +0000201 m_func_name_type_mask |= eFunctionNameTypeSelector;
202 break;
203
Jim Inghamd9e2b762010-08-26 23:56:11 +0000204 case 'M':
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 |= eFunctionNameTypeMethod;
207 break;
208
Jim Ingham03c8ee52011-09-21 01:17:13 +0000209 case 'p':
210 m_source_text_regexp.assign (option_arg);
211 break;
212
Chris Lattner24943d22010-06-08 16:52:24 +0000213 case 'r':
Greg Clayton889fbd02011-03-26 19:14:58 +0000214 m_func_regexp.assign (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000215 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000216
Chris Lattner24943d22010-06-08 16:52:24 +0000217 case 's':
218 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000219 m_modules.AppendIfUnique (FileSpec (option_arg, false));
Chris Lattner24943d22010-06-08 16:52:24 +0000220 break;
221 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000222 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000223 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000224 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000225 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000226 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000227 }
Jim Ingham10622a22010-06-18 00:58:52 +0000228 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000229 case 't' :
230 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000231 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000232 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +0000233 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000234 }
235 break;
236 case 'T':
Greg Clayton889fbd02011-03-26 19:14:58 +0000237 m_thread_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000238 break;
239 case 'q':
Greg Clayton889fbd02011-03-26 19:14:58 +0000240 m_queue_name.assign (option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000241 break;
242 case 'x':
243 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +0000244 m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +0000245 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +0000246 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000247
248 }
249 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000250 case 'E':
251 {
252 LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg);
253
254 switch (language)
255 {
256 case eLanguageTypeC89:
257 case eLanguageTypeC:
258 case eLanguageTypeC99:
259 m_language = eLanguageTypeC;
260 break;
261 case eLanguageTypeC_plus_plus:
262 m_language = eLanguageTypeC_plus_plus;
263 break;
264 case eLanguageTypeObjC:
265 m_language = eLanguageTypeObjC;
266 break;
267 case eLanguageTypeObjC_plus_plus:
268 error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c");
269 break;
270 case eLanguageTypeUnknown:
271 error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg);
272 break;
273 default:
274 error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg);
275 }
276 }
277 break;
278 case 'w':
279 {
280 bool success;
281 m_throw_bp = Args::StringToBoolean (option_arg, true, &success);
282 if (!success)
283 error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg);
284 }
285 break;
286 case 'h':
287 {
288 bool success;
289 m_catch_bp = Args::StringToBoolean (option_arg, true, &success);
290 if (!success)
291 error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg);
292 }
293 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000294 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000295 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000296 break;
297 }
298
299 return error;
300}
301
302void
Greg Clayton143fcc32011-04-13 00:18:08 +0000303CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000304{
Jim Inghamd6d47972011-09-23 00:54:11 +0000305 m_filenames.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000306 m_line_num = 0;
307 m_column = 0;
Jim Ingham4722b102012-03-06 00:37:27 +0000308 m_func_names.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000309 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000310 m_func_regexp.clear();
311 m_load_addr = LLDB_INVALID_ADDRESS;
Jim Inghamd6d47972011-09-23 00:54:11 +0000312 m_modules.Clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000313 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000314 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000315 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000316 m_thread_name.clear();
317 m_queue_name.clear();
Jim Ingham4722b102012-03-06 00:37:27 +0000318 m_language = eLanguageTypeUnknown;
319 m_catch_bp = false;
320 m_throw_bp = true;
Chris Lattner24943d22010-06-08 16:52:24 +0000321}
322
323//-------------------------------------------------------------------------
324// CommandObjectBreakpointSet
325//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000326#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000327
Greg Clayton238c0a12010-09-18 01:14:36 +0000328CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
329 CommandObject (interpreter,
330 "breakpoint set",
331 "Sets a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000332 "breakpoint set <cmd-options>"),
333 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000334{
335}
336
337CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
338{
339}
340
341Options *
342CommandObjectBreakpointSet::GetOptions ()
343{
344 return &m_options;
345}
346
347bool
Jim Inghamd6d47972011-09-23 00:54:11 +0000348CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000349{
Jim Inghamd6d47972011-09-23 00:54:11 +0000350 uint32_t default_line;
351 // First use the Source Manager's default file.
352 // Then use the current stack frame's file.
353 if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line))
Jim Ingham03c8ee52011-09-21 01:17:13 +0000354 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000355 StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr();
356 if (cur_frame == NULL)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000357 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000358 result.AppendError ("No selected frame to use to find the default file.");
359 result.SetStatus (eReturnStatusFailed);
360 return false;
361 }
362 else if (!cur_frame->HasDebugInformation())
363 {
364 result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info.");
365 result.SetStatus (eReturnStatusFailed);
366 return false;
367 }
368 else
369 {
370 const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry);
371 if (sc.line_entry.file)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000372 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000373 file = sc.line_entry.file;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000374 }
375 else
376 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000377 result.AppendError ("Can't find the file for the selected frame to use as the default file.");
378 result.SetStatus (eReturnStatusFailed);
379 return false;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000380 }
381 }
382 }
Jim Ingham03c8ee52011-09-21 01:17:13 +0000383 return true;
384}
385
386bool
Chris Lattner24943d22010-06-08 16:52:24 +0000387CommandObjectBreakpointSet::Execute
388(
389 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000390 CommandReturnObject &result
391)
392{
Greg Clayton238c0a12010-09-18 01:14:36 +0000393 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000394 if (target == NULL)
395 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000396 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000397 result.SetStatus (eReturnStatusFailed);
398 return false;
399 }
400
401 // The following are the various types of breakpoints that could be set:
402 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
403 // 2). -a [-s -g] (setting breakpoint by address)
404 // 3). -n [-s -g] (setting breakpoint by function name)
405 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
Jim Ingham03c8ee52011-09-21 01:17:13 +0000406 // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text)
Jim Ingham4722b102012-03-06 00:37:27 +0000407 // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.)
Chris Lattner24943d22010-06-08 16:52:24 +0000408
409 BreakpointSetType break_type = eSetTypeInvalid;
410
411 if (m_options.m_line_num != 0)
412 break_type = eSetTypeFileAndLine;
413 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
414 break_type = eSetTypeAddress;
Jim Ingham4722b102012-03-06 00:37:27 +0000415 else if (!m_options.m_func_names.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000416 break_type = eSetTypeFunctionName;
417 else if (!m_options.m_func_regexp.empty())
418 break_type = eSetTypeFunctionRegexp;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000419 else if (!m_options.m_source_text_regexp.empty())
420 break_type = eSetTypeSourceRegexp;
Jim Ingham4722b102012-03-06 00:37:27 +0000421 else if (m_options.m_language != eLanguageTypeUnknown)
422 break_type = eSetTypeException;
Chris Lattner24943d22010-06-08 16:52:24 +0000423
Chris Lattner24943d22010-06-08 16:52:24 +0000424 Breakpoint *bp = NULL;
Greg Clayton537a7a82010-10-20 20:54:39 +0000425 FileSpec module_spec;
Chris Lattner24943d22010-06-08 16:52:24 +0000426 bool use_module = false;
Jim Inghamd6d47972011-09-23 00:54:11 +0000427 int num_modules = m_options.m_modules.GetSize();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000428
Chris Lattner24943d22010-06-08 16:52:24 +0000429 if ((num_modules > 0) && (break_type != eSetTypeAddress))
430 use_module = true;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000431
Chris Lattner24943d22010-06-08 16:52:24 +0000432 switch (break_type)
433 {
434 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000435 {
Greg Clayton887aa282010-10-11 01:05:37 +0000436 FileSpec file;
Jim Inghamd6d47972011-09-23 00:54:11 +0000437 uint32_t num_files = m_options.m_filenames.GetSize();
438 if (num_files == 0)
439 {
440 if (!GetDefaultFile (target, file, result))
441 {
442 result.AppendError("No file supplied and no default file available.");
443 result.SetStatus (eReturnStatusFailed);
444 return false;
445 }
446 }
447 else if (num_files > 1)
448 {
449 result.AppendError("Only one file at a time is allowed for file and line breakpoints.");
450 result.SetStatus (eReturnStatusFailed);
451 return false;
452 }
453 else
454 file = m_options.m_filenames.GetFileSpecAtIndex(0);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000455
Jim Inghamd6d47972011-09-23 00:54:11 +0000456 bp = target->CreateBreakpoint (&(m_options.m_modules),
Jim Ingham03c8ee52011-09-21 01:17:13 +0000457 file,
458 m_options.m_line_num,
459 m_options.m_check_inlines).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000460 }
Greg Clayton887aa282010-10-11 01:05:37 +0000461 break;
462
Chris Lattner24943d22010-06-08 16:52:24 +0000463 case eSetTypeAddress: // Breakpoint by address
464 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
465 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000466
Chris Lattner24943d22010-06-08 16:52:24 +0000467 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000468 {
Greg Clayton12bec712010-06-28 21:30:43 +0000469 uint32_t name_type_mask = m_options.m_func_name_type_mask;
470
471 if (name_type_mask == 0)
Greg Clayton48fbdf72010-10-12 04:29:14 +0000472 name_type_mask = eFunctionNameTypeAuto;
Jim Ingham4722b102012-03-06 00:37:27 +0000473
Jim Inghamd6d47972011-09-23 00:54:11 +0000474 bp = target->CreateBreakpoint (&(m_options.m_modules),
475 &(m_options.m_filenames),
Jim Ingham4722b102012-03-06 00:37:27 +0000476 m_options.m_func_names,
477 name_type_mask,
Jim Ingham03c8ee52011-09-21 01:17:13 +0000478 Breakpoint::Exact).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000479 }
Chris Lattner24943d22010-06-08 16:52:24 +0000480 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000481
Chris Lattner24943d22010-06-08 16:52:24 +0000482 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
483 {
484 RegularExpression regexp(m_options.m_func_regexp.c_str());
Jim Ingham03c8ee52011-09-21 01:17:13 +0000485 if (!regexp.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000486 {
Jim Ingham03c8ee52011-09-21 01:17:13 +0000487 char err_str[1024];
488 regexp.GetErrorAsCString(err_str, sizeof(err_str));
489 result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"",
490 err_str);
491 result.SetStatus (eReturnStatusFailed);
492 return false;
Chris Lattner24943d22010-06-08 16:52:24 +0000493 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000494
495 bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000496 }
497 break;
Jim Ingham03c8ee52011-09-21 01:17:13 +0000498 case eSetTypeSourceRegexp: // Breakpoint by regexp on source text.
499 {
Jim Inghamd6d47972011-09-23 00:54:11 +0000500 int num_files = m_options.m_filenames.GetSize();
501
502 if (num_files == 0)
503 {
504 FileSpec file;
505 if (!GetDefaultFile (target, file, result))
506 {
507 result.AppendError ("No files provided and could not find default file.");
508 result.SetStatus (eReturnStatusFailed);
509 return false;
510 }
511 else
512 {
513 m_options.m_filenames.Append (file);
514 }
515 }
516
Jim Ingham03c8ee52011-09-21 01:17:13 +0000517 RegularExpression regexp(m_options.m_source_text_regexp.c_str());
518 if (!regexp.IsValid())
519 {
520 char err_str[1024];
521 regexp.GetErrorAsCString(err_str, sizeof(err_str));
522 result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"",
523 err_str);
524 result.SetStatus (eReturnStatusFailed);
525 return false;
526 }
Jim Inghamd6d47972011-09-23 00:54:11 +0000527 bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get();
Jim Ingham03c8ee52011-09-21 01:17:13 +0000528 }
529 break;
Jim Ingham4722b102012-03-06 00:37:27 +0000530 case eSetTypeException:
531 {
532 bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get();
533 }
534 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000535 default:
536 break;
537 }
538
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000539 // Now set the various options that were passed in:
540 if (bp)
541 {
542 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
543 bp->SetThreadID (m_options.m_thread_id);
544
Greg Clayton54e7afa2010-07-09 20:39:50 +0000545 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000546 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
547
548 if (!m_options.m_thread_name.empty())
549 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
550
551 if (!m_options.m_queue_name.empty())
552 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
553
Greg Clayton54e7afa2010-07-09 20:39:50 +0000554 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000555 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
556 }
557
Jim Ingham03c8ee52011-09-21 01:17:13 +0000558 if (bp)
Chris Lattner24943d22010-06-08 16:52:24 +0000559 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000560 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000561 output_stream.Printf ("Breakpoint created: ");
562 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
563 output_stream.EOL();
Jim Ingham4722b102012-03-06 00:37:27 +0000564 // Don't print out this warning for exception breakpoints. They can get set before the target
565 // is set, but we won't know how to actually set the breakpoint till we run.
566 if (bp->GetNumLocations() == 0 && break_type != eSetTypeException)
Caroline Ticecf2f3052010-10-28 16:28:56 +0000567 output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n");
Chris Lattner24943d22010-06-08 16:52:24 +0000568 result.SetStatus (eReturnStatusSuccessFinishResult);
569 }
570 else if (!bp)
571 {
572 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
573 result.SetStatus (eReturnStatusFailed);
574 }
575
576 return result.Succeeded();
577}
578
Chris Lattner24943d22010-06-08 16:52:24 +0000579//-------------------------------------------------------------------------
580// CommandObjectMultiwordBreakpoint
581//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000582#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000583
Greg Clayton63094e02010-06-23 01:19:29 +0000584CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000585 CommandObjectMultiword (interpreter,
586 "breakpoint",
Jim Ingham7224aab2011-05-26 20:39:01 +0000587 "A set of commands for operating on breakpoints. Also see _regexp-break.",
Greg Clayton238c0a12010-09-18 01:14:36 +0000588 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000589{
590 bool status;
591
Greg Clayton238c0a12010-09-18 01:14:36 +0000592 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000593 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
594 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
Johnny Chena62ad7c2010-10-28 17:27:46 +0000595 CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter));
596 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000597 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000598 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000599 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000600
Johnny Chena62ad7c2010-10-28 17:27:46 +0000601 list_command_object->SetCommandName ("breakpoint list");
Chris Lattner24943d22010-06-08 16:52:24 +0000602 enable_command_object->SetCommandName("breakpoint enable");
603 disable_command_object->SetCommandName("breakpoint disable");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000604 clear_command_object->SetCommandName("breakpoint clear");
605 delete_command_object->SetCommandName("breakpoint delete");
Jim Ingham10622a22010-06-18 00:58:52 +0000606 set_command_object->SetCommandName("breakpoint set");
Johnny Chena62ad7c2010-10-28 17:27:46 +0000607 command_command_object->SetCommandName ("breakpoint command");
608 modify_command_object->SetCommandName ("breakpoint modify");
Chris Lattner24943d22010-06-08 16:52:24 +0000609
Greg Clayton238c0a12010-09-18 01:14:36 +0000610 status = LoadSubCommand ("list", list_command_object);
611 status = LoadSubCommand ("enable", enable_command_object);
612 status = LoadSubCommand ("disable", disable_command_object);
Johnny Chena62ad7c2010-10-28 17:27:46 +0000613 status = LoadSubCommand ("clear", clear_command_object);
Greg Clayton238c0a12010-09-18 01:14:36 +0000614 status = LoadSubCommand ("delete", delete_command_object);
615 status = LoadSubCommand ("set", set_command_object);
616 status = LoadSubCommand ("command", command_command_object);
617 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000618}
619
620CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
621{
622}
623
624void
625CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
626 BreakpointIDList *valid_ids)
627{
628 // args can be strings representing 1). integers (for breakpoint ids)
629 // 2). the full breakpoint & location canonical representation
630 // 3). the word "to" or a hyphen, representing a range (in which case there
631 // had *better* be an entry both before & after of one of the first two types.
Jim Inghamd1686902010-10-14 23:45:03 +0000632 // If args is empty, we will use the last created breakpoint (if there is one.)
Chris Lattner24943d22010-06-08 16:52:24 +0000633
634 Args temp_args;
635
Jim Inghamd1686902010-10-14 23:45:03 +0000636 if (args.GetArgumentCount() == 0)
637 {
Greg Clayton987c7eb2011-09-17 08:33:22 +0000638 if (target->GetLastCreatedBreakpoint())
Jim Inghamd1686902010-10-14 23:45:03 +0000639 {
640 valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID));
641 result.SetStatus (eReturnStatusSuccessFinishNoResult);
642 }
643 else
644 {
645 result.AppendError("No breakpoint specified and no last created breakpoint.");
646 result.SetStatus (eReturnStatusFailed);
647 }
648 return;
649 }
650
Chris Lattner24943d22010-06-08 16:52:24 +0000651 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
652 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
653 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
654
655 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
656
657 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
658
Greg Clayton54e7afa2010-07-09 20:39:50 +0000659 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000660
661 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
662 // and put into valid_ids.
663
664 if (result.Succeeded())
665 {
666 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
667 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
668
Greg Clayton54e7afa2010-07-09 20:39:50 +0000669 const size_t count = valid_ids->GetSize();
670 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000671 {
672 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
673 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
674 if (breakpoint != NULL)
675 {
676 int num_locations = breakpoint->GetNumLocations();
677 if (cur_bp_id.GetLocationID() > num_locations)
678 {
679 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000680 BreakpointID::GetCanonicalReference (&id_str,
681 cur_bp_id.GetBreakpointID(),
682 cur_bp_id.GetLocationID());
683 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000684 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
685 id_str.GetData());
686 result.SetStatus (eReturnStatusFailed);
687 }
688 }
689 else
690 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000691 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000692 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
693 result.SetStatus (eReturnStatusFailed);
694 }
695 }
696 }
697}
698
699//-------------------------------------------------------------------------
700// CommandObjectBreakpointList::Options
701//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000702#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000703
Greg Claytonf15996e2011-04-07 22:46:35 +0000704CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
705 Options (interpreter),
Caroline Tice41950cc2011-02-04 22:59:41 +0000706 m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions
Chris Lattner24943d22010-06-08 16:52:24 +0000707{
Chris Lattner24943d22010-06-08 16:52:24 +0000708}
709
710CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
711{
712}
713
Greg Claytonb3448432011-03-24 21:19:54 +0000714OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000715CommandObjectBreakpointList::CommandOptions::g_option_table[] =
716{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000717 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000718 "Show debugger internal breakpoints" },
719
Caroline Tice4d6675c2010-10-01 19:59:14 +0000720 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000721 "Give a brief description of the breakpoint (no location info)."},
722
723 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
724 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000725 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000726 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000727
Caroline Tice4d6675c2010-10-01 19:59:14 +0000728 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000729 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000730
Caroline Tice4d6675c2010-10-01 19:59:14 +0000731 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000732};
733
Greg Claytonb3448432011-03-24 21:19:54 +0000734const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000735CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
736{
737 return g_option_table;
738}
739
740Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000741CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000742{
743 Error error;
744 char short_option = (char) m_getopt_table[option_idx].val;
745
746 switch (short_option)
747 {
748 case 'b':
749 m_level = lldb::eDescriptionLevelBrief;
750 break;
751 case 'f':
752 m_level = lldb::eDescriptionLevelFull;
753 break;
754 case 'v':
755 m_level = lldb::eDescriptionLevelVerbose;
756 break;
757 case 'i':
758 m_internal = true;
759 break;
760 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000761 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000762 break;
763 }
764
765 return error;
766}
767
768void
Greg Clayton143fcc32011-04-13 00:18:08 +0000769CommandObjectBreakpointList::CommandOptions::OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000770{
Jim Inghamdc259052011-05-17 01:21:41 +0000771 m_level = lldb::eDescriptionLevelFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000772 m_internal = false;
773}
774
775//-------------------------------------------------------------------------
776// CommandObjectBreakpointList
777//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000778#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000779
Greg Clayton238c0a12010-09-18 01:14:36 +0000780CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
781 CommandObject (interpreter,
782 "breakpoint list",
783 "List some or all breakpoints at configurable levels of detail.",
Greg Claytonf15996e2011-04-07 22:46:35 +0000784 NULL),
785 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000786{
Caroline Ticefb355112010-10-01 17:46:38 +0000787 CommandArgumentEntry arg;
788 CommandArgumentData bp_id_arg;
789
790 // Define the first (and only) variant of this arg.
791 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000792 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000793
794 // There is only one variant this argument could be; put it into the argument entry.
795 arg.push_back (bp_id_arg);
796
797 // Push the data for the first argument into the m_arguments vector.
798 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000799}
800
801CommandObjectBreakpointList::~CommandObjectBreakpointList ()
802{
803}
804
805Options *
806CommandObjectBreakpointList::GetOptions ()
807{
808 return &m_options;
809}
810
811bool
812CommandObjectBreakpointList::Execute
813(
814 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000815 CommandReturnObject &result
816)
817{
Greg Clayton238c0a12010-09-18 01:14:36 +0000818 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000819 if (target == NULL)
820 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000821 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000822 result.SetStatus (eReturnStatusSuccessFinishNoResult);
823 return true;
824 }
825
826 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000827 Mutex::Locker locker;
828 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
829
Chris Lattner24943d22010-06-08 16:52:24 +0000830 size_t num_breakpoints = breakpoints.GetSize();
831
832 if (num_breakpoints == 0)
833 {
834 result.AppendMessage ("No breakpoints currently set.");
835 result.SetStatus (eReturnStatusSuccessFinishNoResult);
836 return true;
837 }
838
Jim Ingham2e8cb8a2011-02-19 02:53:09 +0000839 Stream &output_stream = result.GetOutputStream();
Chris Lattner24943d22010-06-08 16:52:24 +0000840
841 if (args.GetArgumentCount() == 0)
842 {
843 // No breakpoint selected; show info about all currently set breakpoints.
844 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000845 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000846 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000847 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000848 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000849 }
850 result.SetStatus (eReturnStatusSuccessFinishNoResult);
851 }
852 else
853 {
854 // Particular breakpoints selected; show info about that breakpoint.
855 BreakpointIDList valid_bp_ids;
856 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
857
858 if (result.Succeeded())
859 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000860 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000861 {
862 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
863 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000864 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000865 }
866 result.SetStatus (eReturnStatusSuccessFinishNoResult);
867 }
868 else
869 {
870 result.AppendError ("Invalid breakpoint id.");
871 result.SetStatus (eReturnStatusFailed);
872 }
873 }
874
875 return result.Succeeded();
876}
877
878//-------------------------------------------------------------------------
879// CommandObjectBreakpointEnable
880//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000881#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000882
Greg Clayton238c0a12010-09-18 01:14:36 +0000883CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
884 CommandObject (interpreter,
885 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000886 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
887 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000888{
Caroline Ticefb355112010-10-01 17:46:38 +0000889 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000890 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000891 // Add the entry for the first argument for this command to the object's arguments vector.
892 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000893}
894
895
896CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
897{
898}
899
900
901bool
Greg Clayton63094e02010-06-23 01:19:29 +0000902CommandObjectBreakpointEnable::Execute
903(
Greg Clayton63094e02010-06-23 01:19:29 +0000904 Args& args,
905 CommandReturnObject &result
906)
Chris Lattner24943d22010-06-08 16:52:24 +0000907{
Greg Clayton238c0a12010-09-18 01:14:36 +0000908 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000909 if (target == NULL)
910 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000911 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000912 result.SetStatus (eReturnStatusFailed);
913 return false;
914 }
915
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000916 Mutex::Locker locker;
917 target->GetBreakpointList().GetListMutex(locker);
918
Chris Lattner24943d22010-06-08 16:52:24 +0000919 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000920
Chris Lattner24943d22010-06-08 16:52:24 +0000921 size_t num_breakpoints = breakpoints.GetSize();
922
923 if (num_breakpoints == 0)
924 {
925 result.AppendError ("No breakpoints exist to be enabled.");
926 result.SetStatus (eReturnStatusFailed);
927 return false;
928 }
929
930 if (args.GetArgumentCount() == 0)
931 {
932 // No breakpoint selected; enable all currently set breakpoints.
933 target->EnableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000934 result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +0000935 result.SetStatus (eReturnStatusSuccessFinishNoResult);
936 }
937 else
938 {
939 // Particular breakpoint selected; enable that breakpoint.
940 BreakpointIDList valid_bp_ids;
941 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
942
943 if (result.Succeeded())
944 {
945 int enable_count = 0;
946 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000947 const size_t count = valid_bp_ids.GetSize();
948 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000949 {
950 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
951
952 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
953 {
954 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
955 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
956 {
957 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
958 if (location)
959 {
960 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000961 ++loc_count;
962 }
963 }
964 else
965 {
Jim Ingham10622a22010-06-18 00:58:52 +0000966 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000967 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +0000968 }
969 }
970 }
971 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
972 result.SetStatus (eReturnStatusSuccessFinishNoResult);
973 }
974 }
975
976 return result.Succeeded();
977}
978
979//-------------------------------------------------------------------------
980// CommandObjectBreakpointDisable
981//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000982#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +0000983
Greg Clayton238c0a12010-09-18 01:14:36 +0000984CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
985 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +0000986 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +0000987 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +0000988 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000989{
Caroline Ticefb355112010-10-01 17:46:38 +0000990 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +0000991 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +0000992 // Add the entry for the first argument for this command to the object's arguments vector.
993 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000994}
995
996CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
997{
998}
999
1000bool
Greg Clayton63094e02010-06-23 01:19:29 +00001001CommandObjectBreakpointDisable::Execute
1002(
Greg Clayton63094e02010-06-23 01:19:29 +00001003 Args& args,
1004 CommandReturnObject &result
1005)
Chris Lattner24943d22010-06-08 16:52:24 +00001006{
Greg Clayton238c0a12010-09-18 01:14:36 +00001007 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001008 if (target == NULL)
1009 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001010 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001011 result.SetStatus (eReturnStatusFailed);
1012 return false;
1013 }
1014
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001015 Mutex::Locker locker;
1016 target->GetBreakpointList().GetListMutex(locker);
1017
Chris Lattner24943d22010-06-08 16:52:24 +00001018 const BreakpointList &breakpoints = target->GetBreakpointList();
1019 size_t num_breakpoints = breakpoints.GetSize();
1020
1021 if (num_breakpoints == 0)
1022 {
1023 result.AppendError ("No breakpoints exist to be disabled.");
1024 result.SetStatus (eReturnStatusFailed);
1025 return false;
1026 }
1027
1028 if (args.GetArgumentCount() == 0)
1029 {
1030 // No breakpoint selected; disable all currently set breakpoints.
1031 target->DisableAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001032 result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints);
Chris Lattner24943d22010-06-08 16:52:24 +00001033 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1034 }
1035 else
1036 {
1037 // Particular breakpoint selected; disable that breakpoint.
1038 BreakpointIDList valid_bp_ids;
1039
1040 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1041
1042 if (result.Succeeded())
1043 {
1044 int disable_count = 0;
1045 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001046 const size_t count = valid_bp_ids.GetSize();
1047 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001048 {
1049 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1050
1051 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1052 {
1053 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1054 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1055 {
1056 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1057 if (location)
1058 {
1059 location->SetEnabled (false);
1060 ++loc_count;
1061 }
1062 }
1063 else
1064 {
Jim Ingham10622a22010-06-18 00:58:52 +00001065 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001066 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001067 }
1068 }
1069 }
1070 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1071 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1072 }
1073 }
1074
1075 return result.Succeeded();
1076}
1077
1078//-------------------------------------------------------------------------
Johnny Chena62ad7c2010-10-28 17:27:46 +00001079// CommandObjectBreakpointClear::CommandOptions
1080//-------------------------------------------------------------------------
1081#pragma mark Clear::CommandOptions
1082
Greg Claytonf15996e2011-04-07 22:46:35 +00001083CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1084 Options (interpreter),
Johnny Chena62ad7c2010-10-28 17:27:46 +00001085 m_filename (),
1086 m_line_num (0)
1087{
1088}
1089
1090CommandObjectBreakpointClear::CommandOptions::~CommandOptions ()
1091{
1092}
1093
Greg Claytonb3448432011-03-24 21:19:54 +00001094OptionDefinition
Johnny Chena62ad7c2010-10-28 17:27:46 +00001095CommandObjectBreakpointClear::CommandOptions::g_option_table[] =
1096{
1097 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
1098 "Specify the breakpoint by source location in this particular file."},
1099
1100 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
1101 "Specify the breakpoint by source location at this particular line."},
1102
1103 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1104};
1105
Greg Claytonb3448432011-03-24 21:19:54 +00001106const OptionDefinition*
Johnny Chena62ad7c2010-10-28 17:27:46 +00001107CommandObjectBreakpointClear::CommandOptions::GetDefinitions ()
1108{
1109 return g_option_table;
1110}
1111
1112Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001113CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001114{
1115 Error error;
1116 char short_option = (char) m_getopt_table[option_idx].val;
1117
1118 switch (short_option)
1119 {
1120 case 'f':
Greg Clayton889fbd02011-03-26 19:14:58 +00001121 m_filename.assign (option_arg);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001122 break;
1123
1124 case 'l':
1125 m_line_num = Args::StringToUInt32 (option_arg, 0);
1126 break;
1127
1128 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001129 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Johnny Chena62ad7c2010-10-28 17:27:46 +00001130 break;
1131 }
1132
1133 return error;
1134}
1135
1136void
Greg Clayton143fcc32011-04-13 00:18:08 +00001137CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting ()
Johnny Chena62ad7c2010-10-28 17:27:46 +00001138{
Johnny Chena62ad7c2010-10-28 17:27:46 +00001139 m_filename.clear();
1140 m_line_num = 0;
1141}
1142
1143//-------------------------------------------------------------------------
1144// CommandObjectBreakpointClear
1145//-------------------------------------------------------------------------
1146#pragma mark Clear
1147
1148CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) :
1149 CommandObject (interpreter,
1150 "breakpoint clear",
1151 "Clears a breakpoint or set of breakpoints in the executable.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001152 "breakpoint clear <cmd-options>"),
1153 m_options (interpreter)
Johnny Chena62ad7c2010-10-28 17:27:46 +00001154{
1155}
1156
1157CommandObjectBreakpointClear::~CommandObjectBreakpointClear ()
1158{
1159}
1160
1161Options *
1162CommandObjectBreakpointClear::GetOptions ()
1163{
1164 return &m_options;
1165}
1166
1167bool
1168CommandObjectBreakpointClear::Execute
1169(
1170 Args& command,
1171 CommandReturnObject &result
1172)
1173{
1174 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
1175 if (target == NULL)
1176 {
1177 result.AppendError ("Invalid target. No existing target or breakpoints.");
1178 result.SetStatus (eReturnStatusFailed);
1179 return false;
1180 }
1181
1182 // The following are the various types of breakpoints that could be cleared:
1183 // 1). -f -l (clearing breakpoint by source location)
1184
1185 BreakpointClearType break_type = eClearTypeInvalid;
1186
1187 if (m_options.m_line_num != 0)
1188 break_type = eClearTypeFileAndLine;
1189
1190 Mutex::Locker locker;
1191 target->GetBreakpointList().GetListMutex(locker);
1192
1193 BreakpointList &breakpoints = target->GetBreakpointList();
1194 size_t num_breakpoints = breakpoints.GetSize();
1195
1196 // Early return if there's no breakpoint at all.
1197 if (num_breakpoints == 0)
1198 {
1199 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1200 result.SetStatus (eReturnStatusFailed);
1201 return result.Succeeded();
1202 }
1203
1204 // Find matching breakpoints and delete them.
1205
1206 // First create a copy of all the IDs.
1207 std::vector<break_id_t> BreakIDs;
1208 for (size_t i = 0; i < num_breakpoints; ++i)
1209 BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID());
1210
1211 int num_cleared = 0;
1212 StreamString ss;
1213 switch (break_type)
1214 {
1215 case eClearTypeFileAndLine: // Breakpoint by source position
1216 {
1217 const ConstString filename(m_options.m_filename.c_str());
1218 BreakpointLocationCollection loc_coll;
1219
1220 for (size_t i = 0; i < num_breakpoints; ++i)
1221 {
1222 Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get();
1223
1224 if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll))
1225 {
1226 // If the collection size is 0, it's a full match and we can just remove the breakpoint.
1227 if (loc_coll.GetSize() == 0)
1228 {
1229 bp->GetDescription(&ss, lldb::eDescriptionLevelBrief);
1230 ss.EOL();
1231 target->RemoveBreakpointByID (bp->GetID());
1232 ++num_cleared;
1233 }
1234 }
1235 }
1236 }
1237 break;
1238
1239 default:
1240 break;
1241 }
1242
1243 if (num_cleared > 0)
1244 {
Jim Ingham2e8cb8a2011-02-19 02:53:09 +00001245 Stream &output_stream = result.GetOutputStream();
Johnny Chena62ad7c2010-10-28 17:27:46 +00001246 output_stream.Printf ("%d breakpoints cleared:\n", num_cleared);
1247 output_stream << ss.GetData();
1248 output_stream.EOL();
1249 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1250 }
1251 else
1252 {
1253 result.AppendError ("Breakpoint clear: No breakpoint cleared.");
1254 result.SetStatus (eReturnStatusFailed);
1255 }
1256
1257 return result.Succeeded();
1258}
1259
1260//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001261// CommandObjectBreakpointDelete
1262//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001263#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001264
Greg Clayton238c0a12010-09-18 01:14:36 +00001265CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1266 CommandObject (interpreter,
1267 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001268 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001269 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001270{
Caroline Ticefb355112010-10-01 17:46:38 +00001271 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001272 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001273 // Add the entry for the first argument for this command to the object's arguments vector.
1274 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001275}
1276
1277
1278CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1279{
1280}
1281
1282bool
Greg Clayton63094e02010-06-23 01:19:29 +00001283CommandObjectBreakpointDelete::Execute
1284(
Greg Clayton63094e02010-06-23 01:19:29 +00001285 Args& args,
1286 CommandReturnObject &result
1287)
Chris Lattner24943d22010-06-08 16:52:24 +00001288{
Greg Clayton238c0a12010-09-18 01:14:36 +00001289 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001290 if (target == NULL)
1291 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001292 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001293 result.SetStatus (eReturnStatusFailed);
1294 return false;
1295 }
1296
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001297 Mutex::Locker locker;
1298 target->GetBreakpointList().GetListMutex(locker);
1299
Chris Lattner24943d22010-06-08 16:52:24 +00001300 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001301
Chris Lattner24943d22010-06-08 16:52:24 +00001302 size_t num_breakpoints = breakpoints.GetSize();
1303
1304 if (num_breakpoints == 0)
1305 {
1306 result.AppendError ("No breakpoints exist to be deleted.");
1307 result.SetStatus (eReturnStatusFailed);
1308 return false;
1309 }
1310
1311 if (args.GetArgumentCount() == 0)
1312 {
Jim Inghamd1686902010-10-14 23:45:03 +00001313 if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true))
Chris Lattner24943d22010-06-08 16:52:24 +00001314 {
Jim Inghamd1686902010-10-14 23:45:03 +00001315 result.AppendMessage("Operation cancelled...");
Chris Lattner24943d22010-06-08 16:52:24 +00001316 }
Jim Inghamd1686902010-10-14 23:45:03 +00001317 else
1318 {
1319 target->RemoveAllBreakpoints ();
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001320 result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints);
Jim Inghamd1686902010-10-14 23:45:03 +00001321 }
Chris Lattner24943d22010-06-08 16:52:24 +00001322 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1323 }
1324 else
1325 {
1326 // Particular breakpoint selected; disable that breakpoint.
1327 BreakpointIDList valid_bp_ids;
1328 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1329
1330 if (result.Succeeded())
1331 {
1332 int delete_count = 0;
1333 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001334 const size_t count = valid_bp_ids.GetSize();
1335 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001336 {
1337 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1338
1339 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1340 {
1341 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1342 {
1343 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1344 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1345 // It makes no sense to try to delete individual locations, so we disable them instead.
1346 if (location)
1347 {
1348 location->SetEnabled (false);
1349 ++disable_count;
1350 }
1351 }
1352 else
1353 {
1354 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1355 ++delete_count;
1356 }
1357 }
1358 }
1359 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1360 delete_count, disable_count);
1361 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1362 }
1363 }
1364 return result.Succeeded();
1365}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001366
1367//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001368// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001369//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001370#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001371
Greg Claytonf15996e2011-04-07 22:46:35 +00001372CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) :
1373 Options (interpreter),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001374 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001375 m_thread_id(LLDB_INVALID_THREAD_ID),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001376 m_thread_id_passed(false),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001377 m_thread_index (UINT32_MAX),
Jim Ingham9a7b2912010-12-03 23:04:19 +00001378 m_thread_index_passed(false),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001379 m_thread_name(),
1380 m_queue_name(),
Jim Inghamd1686902010-10-14 23:45:03 +00001381 m_condition (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001382 m_enable_passed (false),
1383 m_enable_value (false),
1384 m_name_passed (false),
Jim Inghamd1686902010-10-14 23:45:03 +00001385 m_queue_passed (false),
1386 m_condition_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001387{
1388}
1389
Jim Ingham10622a22010-06-18 00:58:52 +00001390CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001391{
1392}
1393
Greg Claytonb3448432011-03-24 21:19:54 +00001394OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001395CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001396{
Caroline Tice4d6675c2010-10-01 19:59:14 +00001397{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1398{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."},
1399{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."},
1400{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."},
1401{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."},
Jim Inghamd1686902010-10-14 23:45:03 +00001402{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, NULL, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."},
Caroline Tice4d6675c2010-10-01 19:59:14 +00001403{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, eArgTypeNone, "Enable the breakpoint."},
1404{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, eArgTypeNone, "Disable the breakpoint."},
Jim Inghamd1686902010-10-14 23:45:03 +00001405{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001406};
1407
Greg Claytonb3448432011-03-24 21:19:54 +00001408const OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001409CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001410{
1411 return g_option_table;
1412}
1413
1414Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001415CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001416{
1417 Error error;
1418 char short_option = (char) m_getopt_table[option_idx].val;
1419
1420 switch (short_option)
1421 {
Jim Inghamd1686902010-10-14 23:45:03 +00001422 case 'c':
1423 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001424 m_condition.assign (option_arg);
Jim Inghamd1686902010-10-14 23:45:03 +00001425 else
1426 m_condition.clear();
1427 m_condition_passed = true;
1428 break;
Jim Ingham10622a22010-06-18 00:58:52 +00001429 case 'd':
1430 m_enable_passed = true;
1431 m_enable_value = false;
1432 break;
1433 case 'e':
1434 m_enable_passed = true;
1435 m_enable_value = true;
1436 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001437 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001438 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001439 m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
Greg Clayton54e7afa2010-07-09 20:39:50 +00001440 if (m_ignore_count == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001441 error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001442 }
Jim Ingham10622a22010-06-18 00:58:52 +00001443 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001444 case 't' :
1445 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001446 if (option_arg[0] == '\0')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001447 {
1448 m_thread_id = LLDB_INVALID_THREAD_ID;
1449 m_thread_id_passed = true;
1450 }
1451 else
1452 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001453 m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001454 if (m_thread_id == LLDB_INVALID_THREAD_ID)
Greg Clayton9c236732011-10-26 00:56:27 +00001455 error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001456 else
1457 m_thread_id_passed = true;
1458 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001459 }
1460 break;
1461 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001462 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001463 m_thread_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001464 else
1465 m_thread_name.clear();
1466 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001467 break;
1468 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001469 if (option_arg != NULL)
Greg Clayton889fbd02011-03-26 19:14:58 +00001470 m_queue_name.assign (option_arg);
Jim Inghamd4571222010-06-19 04:35:20 +00001471 else
1472 m_queue_name.clear();
1473 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001474 break;
1475 case 'x':
1476 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001477 if (option_arg[0] == '\n')
Jim Ingham9a7b2912010-12-03 23:04:19 +00001478 {
1479 m_thread_index = UINT32_MAX;
1480 m_thread_index_passed = true;
1481 }
1482 else
1483 {
Jim Ingham7a4c8ea2011-03-22 01:53:33 +00001484 m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001485 if (m_thread_id == UINT32_MAX)
Greg Clayton9c236732011-10-26 00:56:27 +00001486 error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
Jim Ingham9a7b2912010-12-03 23:04:19 +00001487 else
1488 m_thread_index_passed = true;
1489 }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001490 }
1491 break;
1492 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001493 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001494 break;
1495 }
1496
1497 return error;
1498}
1499
1500void
Greg Clayton143fcc32011-04-13 00:18:08 +00001501CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001502{
Greg Clayton54e7afa2010-07-09 20:39:50 +00001503 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001504 m_thread_id = LLDB_INVALID_THREAD_ID;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001505 m_thread_id_passed = false;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001506 m_thread_index = UINT32_MAX;
Jim Ingham9a7b2912010-12-03 23:04:19 +00001507 m_thread_index_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001508 m_thread_name.clear();
1509 m_queue_name.clear();
Jim Inghamd1686902010-10-14 23:45:03 +00001510 m_condition.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001511 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001512 m_queue_passed = false;
1513 m_name_passed = false;
Jim Inghamd1686902010-10-14 23:45:03 +00001514 m_condition_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001515}
1516
1517//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001518// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001519//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001520#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001521
Greg Clayton238c0a12010-09-18 01:14:36 +00001522CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1523 CommandObject (interpreter,
1524 "breakpoint modify",
Jim Ingham19ac0bd2010-12-03 22:37:19 +00001525 "Modify the options on a breakpoint or set of breakpoints in the executable. "
Jim Ingham9a7b2912010-12-03 23:04:19 +00001526 "If no breakpoint is specified, acts on the last created breakpoint. "
1527 "With the exception of -e, -d and -i, passing an empty argument clears the modification.",
Greg Claytonf15996e2011-04-07 22:46:35 +00001528 NULL),
1529 m_options (interpreter)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001530{
Caroline Ticefb355112010-10-01 17:46:38 +00001531 CommandArgumentEntry arg;
Johnny Chencacedfb2011-09-22 22:34:09 +00001532 CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange);
Caroline Ticefb355112010-10-01 17:46:38 +00001533 // Add the entry for the first argument for this command to the object's arguments vector.
1534 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001535}
1536
Jim Ingham10622a22010-06-18 00:58:52 +00001537CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001538{
1539}
1540
1541Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001542CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001543{
1544 return &m_options;
1545}
1546
1547bool
Jim Ingham10622a22010-06-18 00:58:52 +00001548CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001549(
1550 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001551 CommandReturnObject &result
1552)
1553{
Greg Clayton238c0a12010-09-18 01:14:36 +00001554 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001555 if (target == NULL)
1556 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001557 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001558 result.SetStatus (eReturnStatusFailed);
1559 return false;
1560 }
1561
1562 Mutex::Locker locker;
1563 target->GetBreakpointList().GetListMutex(locker);
1564
1565 BreakpointIDList valid_bp_ids;
1566
1567 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1568
1569 if (result.Succeeded())
1570 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001571 const size_t count = valid_bp_ids.GetSize();
1572 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001573 {
1574 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1575
1576 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1577 {
1578 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1579 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1580 {
1581 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1582 if (location)
1583 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001584 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001585 location->SetThreadID (m_options.m_thread_id);
1586
Jim Ingham9a7b2912010-12-03 23:04:19 +00001587 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001588 location->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001589
Jim Inghamd4571222010-06-19 04:35:20 +00001590 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001591 location->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001592
Jim Inghamd4571222010-06-19 04:35:20 +00001593 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001594 location->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001595
Greg Clayton54e7afa2010-07-09 20:39:50 +00001596 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001597 location->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001598
1599 if (m_options.m_enable_passed)
1600 location->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001601
1602 if (m_options.m_condition_passed)
1603 location->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001604 }
1605 }
1606 else
1607 {
Jim Ingham9a7b2912010-12-03 23:04:19 +00001608 if (m_options.m_thread_id_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001609 bp->SetThreadID (m_options.m_thread_id);
1610
Jim Ingham9a7b2912010-12-03 23:04:19 +00001611 if (m_options.m_thread_index_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001612 bp->SetThreadIndex(m_options.m_thread_index);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001613
Jim Inghamd4571222010-06-19 04:35:20 +00001614 if (m_options.m_name_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001615 bp->SetThreadName(m_options.m_thread_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001616
Jim Inghamd4571222010-06-19 04:35:20 +00001617 if (m_options.m_queue_passed)
Jim Ingham28e23862012-02-08 05:23:15 +00001618 bp->SetQueueName(m_options.m_queue_name.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001619
Greg Clayton54e7afa2010-07-09 20:39:50 +00001620 if (m_options.m_ignore_count != 0)
Jim Ingham28e23862012-02-08 05:23:15 +00001621 bp->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001622
1623 if (m_options.m_enable_passed)
1624 bp->SetEnabled (m_options.m_enable_value);
Jim Inghamd1686902010-10-14 23:45:03 +00001625
1626 if (m_options.m_condition_passed)
1627 bp->SetCondition (m_options.m_condition.c_str());
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001628 }
1629 }
1630 }
1631 }
1632
1633 return result.Succeeded();
1634}
1635
1636