blob: e7cf0a8bb95a08ad45ed6b8958e4d09090b05bd0 [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
31using namespace lldb;
32using namespace lldb_private;
33
34static void
Greg Clayton63094e02010-06-23 01:19:29 +000035AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level)
Chris Lattner24943d22010-06-08 16:52:24 +000036{
37 s->IndentMore();
38 bp->GetDescription (s, level, true);
39 s->IndentLess();
40 s->EOL();
41}
42
43//-------------------------------------------------------------------------
44// CommandObjectBreakpointSet::CommandOptions
45//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +000046#pragma mark Set::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +000047
48CommandObjectBreakpointSet::CommandOptions::CommandOptions() :
49 Options (),
50 m_filename (),
51 m_line_num (0),
52 m_column (0),
53 m_ignore_inlines (false),
54 m_func_name (),
Greg Clayton12bec712010-06-28 21:30:43 +000055 m_func_name_type_mask (0),
Chris Lattner24943d22010-06-08 16:52:24 +000056 m_func_regexp (),
57 m_modules (),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000058 m_load_addr(),
Greg Clayton54e7afa2010-07-09 20:39:50 +000059 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000060 m_thread_id(LLDB_INVALID_THREAD_ID),
Greg Clayton54e7afa2010-07-09 20:39:50 +000061 m_thread_index (UINT32_MAX),
Jim Ingham3c7b5b92010-06-16 02:00:15 +000062 m_thread_name(),
Greg Clayton54e7afa2010-07-09 20:39:50 +000063 m_queue_name()
Chris Lattner24943d22010-06-08 16:52:24 +000064{
Chris Lattner24943d22010-06-08 16:52:24 +000065}
66
67CommandObjectBreakpointSet::CommandOptions::~CommandOptions ()
68{
69}
70
71lldb::OptionDefinition
72CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
73{
Caroline Tice4d6675c2010-10-01 19:59:14 +000074 { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName,
Jim Ingham34e9a982010-06-15 18:47:14 +000075 "Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."},
76
Caroline Tice4d6675c2010-10-01 19:59:14 +000077 { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount,
78 "Set the number of times this breakpoint is skipped before stopping." },
Jim Ingham3c7b5b92010-06-16 02:00:15 +000079
Caroline Tice4d6675c2010-10-01 19:59:14 +000080 { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex,
Greg Claytonfe424a92010-09-18 03:37:20 +000081 "The breakpoint stops only for the thread whose index matches this argument."},
Jim Ingham3c7b5b92010-06-16 02:00:15 +000082
Caroline Tice4d6675c2010-10-01 19:59:14 +000083 { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000084 "The breakpoint stops only for the thread whose TID matches this argument."},
85
Caroline Tice4d6675c2010-10-01 19:59:14 +000086 { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000087 "The breakpoint stops only for the thread whose thread name matches this argument."},
88
Caroline Tice4d6675c2010-10-01 19:59:14 +000089 { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName,
Jim Ingham3c7b5b92010-06-16 02:00:15 +000090 "The breakpoint stops only for threads in the queue whose name is given by this argument."},
91
Caroline Tice4d6675c2010-10-01 19:59:14 +000092 { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename,
Chris Lattner24943d22010-06-08 16:52:24 +000093 "Set the breakpoint by source location in this particular file."},
94
Caroline Tice4d6675c2010-10-01 19:59:14 +000095 { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum,
Chris Lattner24943d22010-06-08 16:52:24 +000096 "Set the breakpoint by source location at this particular line."},
97
Chris Lattner24943d22010-06-08 16:52:24 +000098 // Comment out this option for the moment, as we don't actually use it, but will in the future.
99 // This way users won't see it, but the infrastructure is left in place.
100 // { 0, false, "column", 'c', required_argument, NULL, "<column>",
101 // "Set the breakpoint by source location at this particular column."},
102
Caroline Tice4d6675c2010-10-01 19:59:14 +0000103 { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress,
Chris Lattner24943d22010-06-08 16:52:24 +0000104 "Set the breakpoint by address, at the specified address."},
105
Caroline Tice4d6675c2010-10-01 19:59:14 +0000106 { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000107 "Set the breakpoint by function name - for C++ this means namespaces and arguments will be ignored." },
Chris Lattner24943d22010-06-08 16:52:24 +0000108
Caroline Tice4d6675c2010-10-01 19:59:14 +0000109 { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000110 "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguemnts, and "
111 "for Objective C this means a full function prototype with class and selector." },
Greg Clayton12bec712010-06-28 21:30:43 +0000112
Caroline Tice4d6675c2010-10-01 19:59:14 +0000113 { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000114 "Set the breakpoint by ObjC selector name." },
Greg Clayton12bec712010-06-28 21:30:43 +0000115
Caroline Tice4d6675c2010-10-01 19:59:14 +0000116 { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod,
Jim Inghamd9e2b762010-08-26 23:56:11 +0000117 "Set the breakpoint by C++ method names." },
Greg Clayton12bec712010-06-28 21:30:43 +0000118
Caroline Tice4d6675c2010-10-01 19:59:14 +0000119 { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression,
Chris Lattner24943d22010-06-08 16:52:24 +0000120 "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
121
Caroline Tice4d6675c2010-10-01 19:59:14 +0000122 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000123};
124
125const lldb::OptionDefinition*
126CommandObjectBreakpointSet::CommandOptions::GetDefinitions ()
127{
128 return g_option_table;
129}
130
131Error
132CommandObjectBreakpointSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
133{
134 Error error;
135 char short_option = (char) m_getopt_table[option_idx].val;
136
137 switch (short_option)
138 {
139 case 'a':
140 m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 0);
141 if (m_load_addr == LLDB_INVALID_ADDRESS)
142 m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 16);
143
144 if (m_load_addr == LLDB_INVALID_ADDRESS)
145 error.SetErrorStringWithFormat ("Invalid address string '%s'.\n", optarg);
146 break;
147
148 case 'c':
149 m_column = Args::StringToUInt32 (option_arg, 0);
150 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000151
Chris Lattner24943d22010-06-08 16:52:24 +0000152 case 'f':
153 m_filename = option_arg;
154 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000155
Chris Lattner24943d22010-06-08 16:52:24 +0000156 case 'l':
157 m_line_num = Args::StringToUInt32 (option_arg, 0);
158 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000159
Chris Lattner24943d22010-06-08 16:52:24 +0000160 case 'n':
161 m_func_name = option_arg;
Greg Clayton12bec712010-06-28 21:30:43 +0000162 m_func_name_type_mask |= eFunctionNameTypeBase;
163 break;
164
165 case 'F':
Jim Inghamd9e2b762010-08-26 23:56:11 +0000166 m_func_name = option_arg;
Greg Clayton12bec712010-06-28 21:30:43 +0000167 m_func_name_type_mask |= eFunctionNameTypeFull;
168 break;
169
170 case 'S':
Jim Inghamd9e2b762010-08-26 23:56:11 +0000171 m_func_name = option_arg;
Greg Clayton12bec712010-06-28 21:30:43 +0000172 m_func_name_type_mask |= eFunctionNameTypeSelector;
173 break;
174
Jim Inghamd9e2b762010-08-26 23:56:11 +0000175 case 'M':
176 m_func_name = option_arg;
Greg Clayton12bec712010-06-28 21:30:43 +0000177 m_func_name_type_mask |= eFunctionNameTypeMethod;
178 break;
179
Chris Lattner24943d22010-06-08 16:52:24 +0000180 case 'r':
181 m_func_regexp = option_arg;
182 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000183
Chris Lattner24943d22010-06-08 16:52:24 +0000184 case 's':
185 {
186 m_modules.push_back (std::string (option_arg));
187 break;
188 }
Greg Claytonfe424a92010-09-18 03:37:20 +0000189 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000190 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000191 m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0);
192 if (m_ignore_count == UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000193 error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg);
194 }
Jim Ingham10622a22010-06-18 00:58:52 +0000195 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000196 case 't' :
197 {
198 m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0);
199 if (m_thread_id == LLDB_INVALID_THREAD_ID)
200 error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg);
201 }
202 break;
203 case 'T':
204 m_thread_name = option_arg;
205 break;
206 case 'q':
207 m_queue_name = option_arg;
208 break;
209 case 'x':
210 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000211 m_thread_index = Args::StringToUInt32(optarg, UINT32_MAX, 0);
212 if (m_thread_id == UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000213 error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg);
214
215 }
216 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000217 default:
218 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
219 break;
220 }
221
222 return error;
223}
224
225void
226CommandObjectBreakpointSet::CommandOptions::ResetOptionValues ()
227{
228 Options::ResetOptionValues();
229
230 m_filename.clear();
231 m_line_num = 0;
232 m_column = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000233 m_func_name.clear();
Greg Clayton12bec712010-06-28 21:30:43 +0000234 m_func_name_type_mask = 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000235 m_func_regexp.clear();
236 m_load_addr = LLDB_INVALID_ADDRESS;
237 m_modules.clear();
Greg Clayton54e7afa2010-07-09 20:39:50 +0000238 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000239 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000240 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000241 m_thread_name.clear();
242 m_queue_name.clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000243}
244
245//-------------------------------------------------------------------------
246// CommandObjectBreakpointSet
247//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000248#pragma mark Set
Chris Lattner24943d22010-06-08 16:52:24 +0000249
Greg Clayton238c0a12010-09-18 01:14:36 +0000250CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) :
251 CommandObject (interpreter,
252 "breakpoint set",
253 "Sets a breakpoint or set of breakpoints in the executable.",
Chris Lattner24943d22010-06-08 16:52:24 +0000254 "breakpoint set <cmd-options>")
255{
256}
257
258CommandObjectBreakpointSet::~CommandObjectBreakpointSet ()
259{
260}
261
262Options *
263CommandObjectBreakpointSet::GetOptions ()
264{
265 return &m_options;
266}
267
268bool
269CommandObjectBreakpointSet::Execute
270(
271 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +0000272 CommandReturnObject &result
273)
274{
Greg Clayton238c0a12010-09-18 01:14:36 +0000275 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000276 if (target == NULL)
277 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000278 result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'file' command).");
Chris Lattner24943d22010-06-08 16:52:24 +0000279 result.SetStatus (eReturnStatusFailed);
280 return false;
281 }
282
283 // The following are the various types of breakpoints that could be set:
284 // 1). -f -l -p [-s -g] (setting breakpoint by source location)
285 // 2). -a [-s -g] (setting breakpoint by address)
286 // 3). -n [-s -g] (setting breakpoint by function name)
287 // 4). -r [-s -g] (setting breakpoint by function name regular expression)
288
289 BreakpointSetType break_type = eSetTypeInvalid;
290
291 if (m_options.m_line_num != 0)
292 break_type = eSetTypeFileAndLine;
293 else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS)
294 break_type = eSetTypeAddress;
295 else if (!m_options.m_func_name.empty())
296 break_type = eSetTypeFunctionName;
297 else if (!m_options.m_func_regexp.empty())
298 break_type = eSetTypeFunctionRegexp;
299
300 ModuleSP module_sp = target->GetExecutableModule();
301 Breakpoint *bp = NULL;
302 FileSpec module;
303 bool use_module = false;
304 int num_modules = m_options.m_modules.size();
305
306 if ((num_modules > 0) && (break_type != eSetTypeAddress))
307 use_module = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000308
Chris Lattner24943d22010-06-08 16:52:24 +0000309 switch (break_type)
310 {
311 case eSetTypeFileAndLine: // Breakpoint by source position
Chris Lattner24943d22010-06-08 16:52:24 +0000312 {
Greg Clayton887aa282010-10-11 01:05:37 +0000313 FileSpec file;
314 if (m_options.m_filename.empty())
Chris Lattner24943d22010-06-08 16:52:24 +0000315 {
Greg Clayton887aa282010-10-11 01:05:37 +0000316 StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame;
317 if (cur_frame == NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000318 {
Greg Clayton887aa282010-10-11 01:05:37 +0000319 result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
Chris Lattner24943d22010-06-08 16:52:24 +0000320 result.SetStatus (eReturnStatusFailed);
321 break;
322 }
Greg Clayton887aa282010-10-11 01:05:37 +0000323 else if (!cur_frame->HasDebugInformation())
Chris Lattner24943d22010-06-08 16:52:24 +0000324 {
Greg Clayton887aa282010-10-11 01:05:37 +0000325 result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info.");
326 result.SetStatus (eReturnStatusFailed);
327 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000328 }
329 else
330 {
Greg Clayton887aa282010-10-11 01:05:37 +0000331 const SymbolContext &context = cur_frame->GetSymbolContext(true);
332 if (context.line_entry.file)
333 {
334 file = context.line_entry.file;
335 }
336 else if (context.comp_unit != NULL)
337 { file = context.comp_unit;
338 }
339 else
340 {
341 result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
342 result.SetStatus (eReturnStatusFailed);
343 break;
344 }
Chris Lattner24943d22010-06-08 16:52:24 +0000345 }
346 }
Greg Clayton887aa282010-10-11 01:05:37 +0000347 else
348 {
349 file.SetFile(m_options.m_filename.c_str());
350 }
351
352 if (use_module)
353 {
354 for (int i = 0; i < num_modules; ++i)
355 {
356 module.SetFile(m_options.m_modules[i].c_str());
357 bp = target->CreateBreakpoint (&module,
358 file,
359 m_options.m_line_num,
360 m_options.m_ignore_inlines).get();
361 if (bp)
362 {
363 StreamString &output_stream = result.GetOutputStream();
364 output_stream.Printf ("Breakpoint created: ");
365 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
366 output_stream.EOL();
367 result.SetStatus (eReturnStatusSuccessFinishResult);
368 }
369 else
370 {
371 result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
372 m_options.m_modules[i].c_str());
373 result.SetStatus (eReturnStatusFailed);
374 }
375 }
376 }
377 else
378 bp = target->CreateBreakpoint (NULL,
379 file,
380 m_options.m_line_num,
381 m_options.m_ignore_inlines).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000382 }
Greg Clayton887aa282010-10-11 01:05:37 +0000383 break;
384
Chris Lattner24943d22010-06-08 16:52:24 +0000385 case eSetTypeAddress: // Breakpoint by address
386 bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
387 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000388
Chris Lattner24943d22010-06-08 16:52:24 +0000389 case eSetTypeFunctionName: // Breakpoint by function name
Chris Lattner24943d22010-06-08 16:52:24 +0000390 {
Greg Clayton12bec712010-06-28 21:30:43 +0000391 uint32_t name_type_mask = m_options.m_func_name_type_mask;
392
393 if (name_type_mask == 0)
Chris Lattner24943d22010-06-08 16:52:24 +0000394 {
Greg Clayton12bec712010-06-28 21:30:43 +0000395
396 if (m_options.m_func_name.find('(') != std::string::npos ||
397 m_options.m_func_name.find("-[") == 0 ||
398 m_options.m_func_name.find("+[") == 0)
399 name_type_mask |= eFunctionNameTypeFull;
Chris Lattner24943d22010-06-08 16:52:24 +0000400 else
Greg Clayton12bec712010-06-28 21:30:43 +0000401 name_type_mask |= eFunctionNameTypeBase;
402 }
403
404
405 if (use_module)
406 {
407 for (int i = 0; i < num_modules; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000408 {
Greg Clayton12bec712010-06-28 21:30:43 +0000409 module.SetFile(m_options.m_modules[i].c_str());
410 bp = target->CreateBreakpoint (&module, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get();
411 if (bp)
412 {
413 StreamString &output_stream = result.GetOutputStream();
414 output_stream.Printf ("Breakpoint created: ");
415 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
416 output_stream.EOL();
417 result.SetStatus (eReturnStatusSuccessFinishResult);
418 }
419 else
420 {
421 result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
422 m_options.m_modules[i].c_str());
423 result.SetStatus (eReturnStatusFailed);
424 }
Chris Lattner24943d22010-06-08 16:52:24 +0000425 }
426 }
Greg Clayton12bec712010-06-28 21:30:43 +0000427 else
428 bp = target->CreateBreakpoint (NULL, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get();
Chris Lattner24943d22010-06-08 16:52:24 +0000429 }
Chris Lattner24943d22010-06-08 16:52:24 +0000430 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000431
Chris Lattner24943d22010-06-08 16:52:24 +0000432 case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
433 {
434 RegularExpression regexp(m_options.m_func_regexp.c_str());
435 if (use_module)
436 {
437 for (int i = 0; i < num_modules; ++i)
438 {
439 module.SetFile(m_options.m_modules[i].c_str());
440 bp = target->CreateBreakpoint (&module, regexp).get();
441 if (bp)
442 {
443 StreamString &output_stream = result.GetOutputStream();
444 output_stream.Printf ("Breakpoint created: ");
445 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
446 output_stream.EOL();
447 result.SetStatus (eReturnStatusSuccessFinishResult);
448 }
449 else
450 {
451 result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
452 m_options.m_modules[i].c_str());
453 result.SetStatus (eReturnStatusFailed);
454 }
455 }
456 }
457 else
458 bp = target->CreateBreakpoint (NULL, regexp).get();
459 }
460 break;
Greg Clayton12bec712010-06-28 21:30:43 +0000461
Chris Lattner24943d22010-06-08 16:52:24 +0000462 default:
463 break;
464 }
465
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000466 // Now set the various options that were passed in:
467 if (bp)
468 {
469 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
470 bp->SetThreadID (m_options.m_thread_id);
471
Greg Clayton54e7afa2010-07-09 20:39:50 +0000472 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000473 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
474
475 if (!m_options.m_thread_name.empty())
476 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
477
478 if (!m_options.m_queue_name.empty())
479 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
480
Greg Clayton54e7afa2010-07-09 20:39:50 +0000481 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000482 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
483 }
484
Chris Lattner24943d22010-06-08 16:52:24 +0000485 if (bp && !use_module)
486 {
487 StreamString &output_stream = result.GetOutputStream();
488 output_stream.Printf ("Breakpoint created: ");
489 bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
490 output_stream.EOL();
491 result.SetStatus (eReturnStatusSuccessFinishResult);
492 }
493 else if (!bp)
494 {
495 result.AppendError ("Breakpoint creation failed: No breakpoint created.");
496 result.SetStatus (eReturnStatusFailed);
497 }
498
499 return result.Succeeded();
500}
501
Chris Lattner24943d22010-06-08 16:52:24 +0000502//-------------------------------------------------------------------------
503// CommandObjectMultiwordBreakpoint
504//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000505#pragma mark MultiwordBreakpoint
Chris Lattner24943d22010-06-08 16:52:24 +0000506
Greg Clayton63094e02010-06-23 01:19:29 +0000507CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +0000508 CommandObjectMultiword (interpreter,
509 "breakpoint",
510 "A set of commands for operating on breakpoints. Also see regexp-break.",
511 "breakpoint <command> [<command-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +0000512{
513 bool status;
514
Greg Clayton238c0a12010-09-18 01:14:36 +0000515 CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter));
516 CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter));
517 CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter));
518 CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter));
519 CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000520 CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter));
Greg Clayton238c0a12010-09-18 01:14:36 +0000521 CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter));
Chris Lattner24943d22010-06-08 16:52:24 +0000522
Jim Ingham10622a22010-06-18 00:58:52 +0000523 command_command_object->SetCommandName ("breakpoint command");
Chris Lattner24943d22010-06-08 16:52:24 +0000524 enable_command_object->SetCommandName("breakpoint enable");
525 disable_command_object->SetCommandName("breakpoint disable");
Chris Lattner24943d22010-06-08 16:52:24 +0000526 list_command_object->SetCommandName ("breakpoint list");
Jim Ingham10622a22010-06-18 00:58:52 +0000527 modify_command_object->SetCommandName ("breakpoint modify");
528 set_command_object->SetCommandName("breakpoint set");
Chris Lattner24943d22010-06-08 16:52:24 +0000529
Greg Clayton238c0a12010-09-18 01:14:36 +0000530 status = LoadSubCommand ("list", list_command_object);
531 status = LoadSubCommand ("enable", enable_command_object);
532 status = LoadSubCommand ("disable", disable_command_object);
533 status = LoadSubCommand ("delete", delete_command_object);
534 status = LoadSubCommand ("set", set_command_object);
535 status = LoadSubCommand ("command", command_command_object);
536 status = LoadSubCommand ("modify", modify_command_object);
Chris Lattner24943d22010-06-08 16:52:24 +0000537}
538
539CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint ()
540{
541}
542
543void
544CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result,
545 BreakpointIDList *valid_ids)
546{
547 // args can be strings representing 1). integers (for breakpoint ids)
548 // 2). the full breakpoint & location canonical representation
549 // 3). the word "to" or a hyphen, representing a range (in which case there
550 // had *better* be an entry both before & after of one of the first two types.
551
552 Args temp_args;
553
554 // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to
555 // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for
556 // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS.
557
558 BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args);
559
560 // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList:
561
Greg Clayton54e7afa2010-07-09 20:39:50 +0000562 valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result);
Chris Lattner24943d22010-06-08 16:52:24 +0000563
564 // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs
565 // and put into valid_ids.
566
567 if (result.Succeeded())
568 {
569 // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list
570 // of breakpoint id's and verify that they correspond to valid/currently set breakpoints.
571
Greg Clayton54e7afa2010-07-09 20:39:50 +0000572 const size_t count = valid_ids->GetSize();
573 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000574 {
575 BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i);
576 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
577 if (breakpoint != NULL)
578 {
579 int num_locations = breakpoint->GetNumLocations();
580 if (cur_bp_id.GetLocationID() > num_locations)
581 {
582 StreamString id_str;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000583 BreakpointID::GetCanonicalReference (&id_str,
584 cur_bp_id.GetBreakpointID(),
585 cur_bp_id.GetLocationID());
586 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000587 result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n",
588 id_str.GetData());
589 result.SetStatus (eReturnStatusFailed);
590 }
591 }
592 else
593 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000594 i = valid_ids->GetSize() + 1;
Chris Lattner24943d22010-06-08 16:52:24 +0000595 result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID());
596 result.SetStatus (eReturnStatusFailed);
597 }
598 }
599 }
600}
601
602//-------------------------------------------------------------------------
603// CommandObjectBreakpointList::Options
604//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000605#pragma mark List::CommandOptions
Chris Lattner24943d22010-06-08 16:52:24 +0000606
607CommandObjectBreakpointList::CommandOptions::CommandOptions() :
608 Options (),
609 m_level (lldb::eDescriptionLevelFull) // Breakpoint List defaults to brief descriptions
610{
Chris Lattner24943d22010-06-08 16:52:24 +0000611}
612
613CommandObjectBreakpointList::CommandOptions::~CommandOptions ()
614{
615}
616
617lldb::OptionDefinition
618CommandObjectBreakpointList::CommandOptions::g_option_table[] =
619{
Caroline Tice4d6675c2010-10-01 19:59:14 +0000620 { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone,
Jim Ingham34e9a982010-06-15 18:47:14 +0000621 "Show debugger internal breakpoints" },
622
Caroline Tice4d6675c2010-10-01 19:59:14 +0000623 { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000624 "Give a brief description of the breakpoint (no location info)."},
625
626 // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
627 // But I need to see it for now, and don't want to wait.
Caroline Tice4d6675c2010-10-01 19:59:14 +0000628 { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000629 "Give a full description of the breakpoint and its locations."},
Chris Lattner24943d22010-06-08 16:52:24 +0000630
Caroline Tice4d6675c2010-10-01 19:59:14 +0000631 { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone,
Chris Lattner24943d22010-06-08 16:52:24 +0000632 "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
Chris Lattner24943d22010-06-08 16:52:24 +0000633
Caroline Tice4d6675c2010-10-01 19:59:14 +0000634 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000635};
636
637const lldb::OptionDefinition*
638CommandObjectBreakpointList::CommandOptions::GetDefinitions ()
639{
640 return g_option_table;
641}
642
643Error
644CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
645{
646 Error error;
647 char short_option = (char) m_getopt_table[option_idx].val;
648
649 switch (short_option)
650 {
651 case 'b':
652 m_level = lldb::eDescriptionLevelBrief;
653 break;
654 case 'f':
655 m_level = lldb::eDescriptionLevelFull;
656 break;
657 case 'v':
658 m_level = lldb::eDescriptionLevelVerbose;
659 break;
660 case 'i':
661 m_internal = true;
662 break;
663 default:
664 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
665 break;
666 }
667
668 return error;
669}
670
671void
672CommandObjectBreakpointList::CommandOptions::ResetOptionValues ()
673{
674 Options::ResetOptionValues();
675
676 m_level = lldb::eDescriptionLevelFull;
677 m_internal = false;
678}
679
680//-------------------------------------------------------------------------
681// CommandObjectBreakpointList
682//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000683#pragma mark List
Chris Lattner24943d22010-06-08 16:52:24 +0000684
Greg Clayton238c0a12010-09-18 01:14:36 +0000685CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) :
686 CommandObject (interpreter,
687 "breakpoint list",
688 "List some or all breakpoints at configurable levels of detail.",
Caroline Ticefb355112010-10-01 17:46:38 +0000689 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000690{
Caroline Ticefb355112010-10-01 17:46:38 +0000691 CommandArgumentEntry arg;
692 CommandArgumentData bp_id_arg;
693
694 // Define the first (and only) variant of this arg.
695 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000696 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000697
698 // There is only one variant this argument could be; put it into the argument entry.
699 arg.push_back (bp_id_arg);
700
701 // Push the data for the first argument into the m_arguments vector.
702 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000703}
704
705CommandObjectBreakpointList::~CommandObjectBreakpointList ()
706{
707}
708
709Options *
710CommandObjectBreakpointList::GetOptions ()
711{
712 return &m_options;
713}
714
715bool
716CommandObjectBreakpointList::Execute
717(
718 Args& args,
Chris Lattner24943d22010-06-08 16:52:24 +0000719 CommandReturnObject &result
720)
721{
Greg Clayton238c0a12010-09-18 01:14:36 +0000722 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000723 if (target == NULL)
724 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000725 result.AppendError ("Invalid target. No current target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000726 result.SetStatus (eReturnStatusSuccessFinishNoResult);
727 return true;
728 }
729
730 const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal);
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000731 Mutex::Locker locker;
732 target->GetBreakpointList(m_options.m_internal).GetListMutex(locker);
733
Chris Lattner24943d22010-06-08 16:52:24 +0000734 size_t num_breakpoints = breakpoints.GetSize();
735
736 if (num_breakpoints == 0)
737 {
738 result.AppendMessage ("No breakpoints currently set.");
739 result.SetStatus (eReturnStatusSuccessFinishNoResult);
740 return true;
741 }
742
743 StreamString &output_stream = result.GetOutputStream();
744
745 if (args.GetArgumentCount() == 0)
746 {
747 // No breakpoint selected; show info about all currently set breakpoints.
748 result.AppendMessage ("Current breakpoints:");
Greg Clayton54e7afa2010-07-09 20:39:50 +0000749 for (size_t i = 0; i < num_breakpoints; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000750 {
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000751 Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000752 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000753 }
754 result.SetStatus (eReturnStatusSuccessFinishNoResult);
755 }
756 else
757 {
758 // Particular breakpoints selected; show info about that breakpoint.
759 BreakpointIDList valid_bp_ids;
760 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
761
762 if (result.Succeeded())
763 {
Greg Clayton54e7afa2010-07-09 20:39:50 +0000764 for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000765 {
766 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
767 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
Greg Clayton63094e02010-06-23 01:19:29 +0000768 AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level);
Chris Lattner24943d22010-06-08 16:52:24 +0000769 }
770 result.SetStatus (eReturnStatusSuccessFinishNoResult);
771 }
772 else
773 {
774 result.AppendError ("Invalid breakpoint id.");
775 result.SetStatus (eReturnStatusFailed);
776 }
777 }
778
779 return result.Succeeded();
780}
781
782//-------------------------------------------------------------------------
783// CommandObjectBreakpointEnable
784//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000785#pragma mark Enable
Chris Lattner24943d22010-06-08 16:52:24 +0000786
Greg Clayton238c0a12010-09-18 01:14:36 +0000787CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
788 CommandObject (interpreter,
789 "enable",
Caroline Ticefb355112010-10-01 17:46:38 +0000790 "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
791 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000792{
Caroline Ticefb355112010-10-01 17:46:38 +0000793 CommandArgumentEntry arg;
794 CommandArgumentData bp_id_arg;
795 CommandArgumentData bp_id_range_arg;
796
797 // Create the first variant for the first (and only) argument for this command.
798 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000799 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000800
801 // Create the second variant for the first (and only) argument for this command.
802 bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
Caroline Tice43b014a2010-10-04 22:28:36 +0000803 bp_id_range_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000804
805 // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
806 // Push both variants into the entry for the first argument for this command.
807 arg.push_back (bp_id_arg);
808 arg.push_back (bp_id_range_arg);
809
810 // Add the entry for the first argument for this command to the object's arguments vector.
811 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000812}
813
814
815CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable ()
816{
817}
818
819
820bool
Greg Clayton63094e02010-06-23 01:19:29 +0000821CommandObjectBreakpointEnable::Execute
822(
Greg Clayton63094e02010-06-23 01:19:29 +0000823 Args& args,
824 CommandReturnObject &result
825)
Chris Lattner24943d22010-06-08 16:52:24 +0000826{
Greg Clayton238c0a12010-09-18 01:14:36 +0000827 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000828 if (target == NULL)
829 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000830 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000831 result.SetStatus (eReturnStatusFailed);
832 return false;
833 }
834
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000835 Mutex::Locker locker;
836 target->GetBreakpointList().GetListMutex(locker);
837
Chris Lattner24943d22010-06-08 16:52:24 +0000838 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000839
Chris Lattner24943d22010-06-08 16:52:24 +0000840 size_t num_breakpoints = breakpoints.GetSize();
841
842 if (num_breakpoints == 0)
843 {
844 result.AppendError ("No breakpoints exist to be enabled.");
845 result.SetStatus (eReturnStatusFailed);
846 return false;
847 }
848
849 if (args.GetArgumentCount() == 0)
850 {
851 // No breakpoint selected; enable all currently set breakpoints.
852 target->EnableAllBreakpoints ();
853 result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints);
854 result.SetStatus (eReturnStatusSuccessFinishNoResult);
855 }
856 else
857 {
858 // Particular breakpoint selected; enable that breakpoint.
859 BreakpointIDList valid_bp_ids;
860 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
861
862 if (result.Succeeded())
863 {
864 int enable_count = 0;
865 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000866 const size_t count = valid_bp_ids.GetSize();
867 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000868 {
869 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
870
871 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
872 {
873 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
874 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
875 {
876 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
877 if (location)
878 {
879 location->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000880 ++loc_count;
881 }
882 }
883 else
884 {
Jim Ingham10622a22010-06-18 00:58:52 +0000885 breakpoint->SetEnabled (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000886 ++enable_count;
Chris Lattner24943d22010-06-08 16:52:24 +0000887 }
888 }
889 }
890 result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count);
891 result.SetStatus (eReturnStatusSuccessFinishNoResult);
892 }
893 }
894
895 return result.Succeeded();
896}
897
898//-------------------------------------------------------------------------
899// CommandObjectBreakpointDisable
900//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +0000901#pragma mark Disable
Chris Lattner24943d22010-06-08 16:52:24 +0000902
Greg Clayton238c0a12010-09-18 01:14:36 +0000903CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
904 CommandObject (interpreter,
Caroline Ticefb355112010-10-01 17:46:38 +0000905 "breakpoint disable",
Caroline Ticeabb507a2010-09-08 21:06:11 +0000906 "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
Caroline Ticefb355112010-10-01 17:46:38 +0000907 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +0000908{
Caroline Ticefb355112010-10-01 17:46:38 +0000909 CommandArgumentEntry arg;
910 CommandArgumentData bp_id_arg;
911 CommandArgumentData bp_id_range_arg;
912
913 // Create the first variant for the first (and only) argument for this command.
914 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +0000915 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000916
917 // Create the second variant for the first (and only) argument for this command.
918 bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
Caroline Tice43b014a2010-10-04 22:28:36 +0000919 bp_id_range_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +0000920
921 // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
922 // Push both variants into the entry for the first argument for this command.
923 arg.push_back (bp_id_arg);
924 arg.push_back (bp_id_range_arg);
925
926 // Add the entry for the first argument for this command to the object's arguments vector.
927 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000928}
929
930CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
931{
932}
933
934bool
Greg Clayton63094e02010-06-23 01:19:29 +0000935CommandObjectBreakpointDisable::Execute
936(
Greg Clayton63094e02010-06-23 01:19:29 +0000937 Args& args,
938 CommandReturnObject &result
939)
Chris Lattner24943d22010-06-08 16:52:24 +0000940{
Greg Clayton238c0a12010-09-18 01:14:36 +0000941 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000942 if (target == NULL)
943 {
Caroline Tice17dce1c2010-09-29 19:42:33 +0000944 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +0000945 result.SetStatus (eReturnStatusFailed);
946 return false;
947 }
948
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000949 Mutex::Locker locker;
950 target->GetBreakpointList().GetListMutex(locker);
951
Chris Lattner24943d22010-06-08 16:52:24 +0000952 const BreakpointList &breakpoints = target->GetBreakpointList();
953 size_t num_breakpoints = breakpoints.GetSize();
954
955 if (num_breakpoints == 0)
956 {
957 result.AppendError ("No breakpoints exist to be disabled.");
958 result.SetStatus (eReturnStatusFailed);
959 return false;
960 }
961
962 if (args.GetArgumentCount() == 0)
963 {
964 // No breakpoint selected; disable all currently set breakpoints.
965 target->DisableAllBreakpoints ();
966 result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints);
967 result.SetStatus (eReturnStatusSuccessFinishNoResult);
968 }
969 else
970 {
971 // Particular breakpoint selected; disable that breakpoint.
972 BreakpointIDList valid_bp_ids;
973
974 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
975
976 if (result.Succeeded())
977 {
978 int disable_count = 0;
979 int loc_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000980 const size_t count = valid_bp_ids.GetSize();
981 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000982 {
983 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
984
985 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
986 {
987 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
988 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
989 {
990 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
991 if (location)
992 {
993 location->SetEnabled (false);
994 ++loc_count;
995 }
996 }
997 else
998 {
Jim Ingham10622a22010-06-18 00:58:52 +0000999 breakpoint->SetEnabled (false);
Chris Lattner24943d22010-06-08 16:52:24 +00001000 ++disable_count;
Chris Lattner24943d22010-06-08 16:52:24 +00001001 }
1002 }
1003 }
1004 result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count);
1005 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1006 }
1007 }
1008
1009 return result.Succeeded();
1010}
1011
1012//-------------------------------------------------------------------------
1013// CommandObjectBreakpointDelete
1014//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001015#pragma mark Delete
Chris Lattner24943d22010-06-08 16:52:24 +00001016
Greg Clayton238c0a12010-09-18 01:14:36 +00001017CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) :
1018 CommandObject (interpreter,
1019 "breakpoint delete",
Caroline Ticeabb507a2010-09-08 21:06:11 +00001020 "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
Caroline Ticefb355112010-10-01 17:46:38 +00001021 NULL)
Chris Lattner24943d22010-06-08 16:52:24 +00001022{
Caroline Ticefb355112010-10-01 17:46:38 +00001023 CommandArgumentEntry arg;
1024 CommandArgumentData bp_id_arg;
1025 CommandArgumentData bp_id_range_arg;
1026
1027 // Create the first variant for the first (and only) argument for this command.
1028 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +00001029 bp_id_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +00001030
1031 // Create the second variant for the first (and only) argument for this command.
1032 bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
Caroline Tice43b014a2010-10-04 22:28:36 +00001033 bp_id_range_arg.arg_repetition = eArgRepeatOptional;
Caroline Ticefb355112010-10-01 17:46:38 +00001034
1035 // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
1036 // Push both variants into the entry for the first argument for this command.
1037 arg.push_back (bp_id_arg);
1038 arg.push_back (bp_id_range_arg);
1039
1040 // Add the entry for the first argument for this command to the object's arguments vector.
1041 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001042}
1043
1044
1045CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete ()
1046{
1047}
1048
1049bool
Greg Clayton63094e02010-06-23 01:19:29 +00001050CommandObjectBreakpointDelete::Execute
1051(
Greg Clayton63094e02010-06-23 01:19:29 +00001052 Args& args,
1053 CommandReturnObject &result
1054)
Chris Lattner24943d22010-06-08 16:52:24 +00001055{
Greg Clayton238c0a12010-09-18 01:14:36 +00001056 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Chris Lattner24943d22010-06-08 16:52:24 +00001057 if (target == NULL)
1058 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001059 result.AppendError ("Invalid target. No existing target or breakpoints.");
Chris Lattner24943d22010-06-08 16:52:24 +00001060 result.SetStatus (eReturnStatusFailed);
1061 return false;
1062 }
1063
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001064 Mutex::Locker locker;
1065 target->GetBreakpointList().GetListMutex(locker);
1066
Chris Lattner24943d22010-06-08 16:52:24 +00001067 const BreakpointList &breakpoints = target->GetBreakpointList();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001068
Chris Lattner24943d22010-06-08 16:52:24 +00001069 size_t num_breakpoints = breakpoints.GetSize();
1070
1071 if (num_breakpoints == 0)
1072 {
1073 result.AppendError ("No breakpoints exist to be deleted.");
1074 result.SetStatus (eReturnStatusFailed);
1075 return false;
1076 }
1077
1078 if (args.GetArgumentCount() == 0)
1079 {
1080 // No breakpoint selected; disable all currently set breakpoints.
1081 if (args.GetArgumentCount() != 0)
1082 {
1083 result.AppendErrorWithFormat ("Specify breakpoints to delete with the -i option.\n");
1084 result.SetStatus (eReturnStatusFailed);
1085 return false;
1086 }
1087
1088 target->RemoveAllBreakpoints ();
1089 result.AppendMessageWithFormat ("All breakpoints removed. (%d breakpoints)\n", num_breakpoints);
1090 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1091 }
1092 else
1093 {
1094 // Particular breakpoint selected; disable that breakpoint.
1095 BreakpointIDList valid_bp_ids;
1096 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids);
1097
1098 if (result.Succeeded())
1099 {
1100 int delete_count = 0;
1101 int disable_count = 0;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001102 const size_t count = valid_bp_ids.GetSize();
1103 for (size_t i = 0; i < count; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +00001104 {
1105 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1106
1107 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1108 {
1109 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1110 {
1111 Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1112 BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get();
1113 // It makes no sense to try to delete individual locations, so we disable them instead.
1114 if (location)
1115 {
1116 location->SetEnabled (false);
1117 ++disable_count;
1118 }
1119 }
1120 else
1121 {
1122 target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID());
1123 ++delete_count;
1124 }
1125 }
1126 }
1127 result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n",
1128 delete_count, disable_count);
1129 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1130 }
1131 }
1132 return result.Succeeded();
1133}
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001134
1135//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001136// CommandObjectBreakpointModify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001137//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001138#pragma mark Modify::CommandOptions
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001139
Jim Ingham10622a22010-06-18 00:58:52 +00001140CommandObjectBreakpointModify::CommandOptions::CommandOptions() :
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001141 Options (),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001142 m_ignore_count (0),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001143 m_thread_id(LLDB_INVALID_THREAD_ID),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001144 m_thread_index (UINT32_MAX),
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001145 m_thread_name(),
1146 m_queue_name(),
Greg Clayton54e7afa2010-07-09 20:39:50 +00001147 m_enable_passed (false),
1148 m_enable_value (false),
1149 m_name_passed (false),
1150 m_queue_passed (false)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001151{
1152}
1153
Jim Ingham10622a22010-06-18 00:58:52 +00001154CommandObjectBreakpointModify::CommandOptions::~CommandOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001155{
1156}
1157
1158lldb::OptionDefinition
Jim Ingham10622a22010-06-18 00:58:52 +00001159CommandObjectBreakpointModify::CommandOptions::g_option_table[] =
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001160{
Caroline Tice4d6675c2010-10-01 19:59:14 +00001161{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." },
1162{ 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."},
1163{ 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."},
1164{ 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."},
1165{ 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."},
1166{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, eArgTypeNone, "Enable the breakpoint."},
1167{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, eArgTypeNone, "Disable the breakpoint."},
1168{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001169};
1170
1171const lldb::OptionDefinition*
Jim Ingham10622a22010-06-18 00:58:52 +00001172CommandObjectBreakpointModify::CommandOptions::GetDefinitions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001173{
1174 return g_option_table;
1175}
1176
1177Error
Jim Ingham10622a22010-06-18 00:58:52 +00001178CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001179{
1180 Error error;
1181 char short_option = (char) m_getopt_table[option_idx].val;
1182
1183 switch (short_option)
1184 {
Jim Ingham10622a22010-06-18 00:58:52 +00001185 case 'd':
1186 m_enable_passed = true;
1187 m_enable_value = false;
1188 break;
1189 case 'e':
1190 m_enable_passed = true;
1191 m_enable_value = true;
1192 break;
Greg Claytonfe424a92010-09-18 03:37:20 +00001193 case 'i':
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001194 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001195 m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0);
1196 if (m_ignore_count == UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001197 error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg);
1198 }
Jim Ingham10622a22010-06-18 00:58:52 +00001199 break;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001200 case 't' :
1201 {
1202 m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0);
1203 if (m_thread_id == LLDB_INVALID_THREAD_ID)
1204 error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg);
1205 }
1206 break;
1207 case 'T':
Jim Inghamd4571222010-06-19 04:35:20 +00001208 if (option_arg != NULL)
1209 m_thread_name = option_arg;
1210 else
1211 m_thread_name.clear();
1212 m_name_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001213 break;
1214 case 'q':
Jim Inghamd4571222010-06-19 04:35:20 +00001215 if (option_arg != NULL)
1216 m_queue_name = option_arg;
1217 else
1218 m_queue_name.clear();
1219 m_queue_passed = true;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001220 break;
1221 case 'x':
1222 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001223 m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0);
1224 if (m_thread_id == UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001225 error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg);
1226
1227 }
1228 break;
1229 default:
1230 error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
1231 break;
1232 }
1233
1234 return error;
1235}
1236
1237void
Jim Ingham10622a22010-06-18 00:58:52 +00001238CommandObjectBreakpointModify::CommandOptions::ResetOptionValues ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001239{
1240 Options::ResetOptionValues();
1241
Greg Clayton54e7afa2010-07-09 20:39:50 +00001242 m_ignore_count = 0;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001243 m_thread_id = LLDB_INVALID_THREAD_ID;
Greg Clayton54e7afa2010-07-09 20:39:50 +00001244 m_thread_index = UINT32_MAX;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001245 m_thread_name.clear();
1246 m_queue_name.clear();
Jim Ingham10622a22010-06-18 00:58:52 +00001247 m_enable_passed = false;
Jim Inghamd4571222010-06-19 04:35:20 +00001248 m_queue_passed = false;
1249 m_name_passed = false;
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001250}
1251
1252//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001253// CommandObjectBreakpointModify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001254//-------------------------------------------------------------------------
Jim Ingham10622a22010-06-18 00:58:52 +00001255#pragma mark Modify
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001256
Greg Clayton238c0a12010-09-18 01:14:36 +00001257CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) :
1258 CommandObject (interpreter,
1259 "breakpoint modify",
1260 "Modify the options on a breakpoint or set of breakpoints in the executable.",
Caroline Ticefb355112010-10-01 17:46:38 +00001261 NULL)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001262{
Caroline Ticefb355112010-10-01 17:46:38 +00001263 CommandArgumentEntry arg;
1264 CommandArgumentData bp_id_arg;
1265 CommandArgumentData bp_id_range_arg;
1266
1267 // Create the first variant for the first (and only) argument for this command.
1268 bp_id_arg.arg_type = eArgTypeBreakpointID;
Caroline Tice43b014a2010-10-04 22:28:36 +00001269 bp_id_arg.arg_repetition = eArgRepeatPlain;
Caroline Ticefb355112010-10-01 17:46:38 +00001270
1271 // Create the second variant for the first (and only) argument for this command.
1272 bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
Caroline Tice43b014a2010-10-04 22:28:36 +00001273 bp_id_range_arg.arg_repetition = eArgRepeatPlain;
Caroline Ticefb355112010-10-01 17:46:38 +00001274
1275 // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
1276 // Push both variants into the entry for the first argument for this command.
1277 arg.push_back (bp_id_arg);
1278 arg.push_back (bp_id_range_arg);
1279
1280 // Add the entry for the first argument for this command to the object's arguments vector.
1281 m_arguments.push_back (arg);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001282}
1283
Jim Ingham10622a22010-06-18 00:58:52 +00001284CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001285{
1286}
1287
1288Options *
Jim Ingham10622a22010-06-18 00:58:52 +00001289CommandObjectBreakpointModify::GetOptions ()
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001290{
1291 return &m_options;
1292}
1293
1294bool
Jim Ingham10622a22010-06-18 00:58:52 +00001295CommandObjectBreakpointModify::Execute
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001296(
1297 Args& command,
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001298 CommandReturnObject &result
1299)
1300{
1301 if (command.GetArgumentCount() == 0)
1302 {
1303 result.AppendError ("No breakpoints specified.");
1304 result.SetStatus (eReturnStatusFailed);
1305 return false;
1306 }
1307
Greg Clayton238c0a12010-09-18 01:14:36 +00001308 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001309 if (target == NULL)
1310 {
Caroline Tice17dce1c2010-09-29 19:42:33 +00001311 result.AppendError ("Invalid target. No existing target or breakpoints.");
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001312 result.SetStatus (eReturnStatusFailed);
1313 return false;
1314 }
1315
1316 Mutex::Locker locker;
1317 target->GetBreakpointList().GetListMutex(locker);
1318
1319 BreakpointIDList valid_bp_ids;
1320
1321 CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids);
1322
1323 if (result.Succeeded())
1324 {
Greg Clayton54e7afa2010-07-09 20:39:50 +00001325 const size_t count = valid_bp_ids.GetSize();
1326 for (size_t i = 0; i < count; ++i)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001327 {
1328 BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i);
1329
1330 if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID)
1331 {
1332 Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get();
1333 if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID)
1334 {
1335 BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get();
1336 if (location)
1337 {
1338 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
1339 location->SetThreadID (m_options.m_thread_id);
1340
Greg Clayton54e7afa2010-07-09 20:39:50 +00001341 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001342 location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
1343
Jim Inghamd4571222010-06-19 04:35:20 +00001344 if (m_options.m_name_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001345 location->GetLocationOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
1346
Jim Inghamd4571222010-06-19 04:35:20 +00001347 if (m_options.m_queue_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001348 location->GetLocationOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
1349
Greg Clayton54e7afa2010-07-09 20:39:50 +00001350 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001351 location->GetLocationOptions()->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001352
1353 if (m_options.m_enable_passed)
1354 location->SetEnabled (m_options.m_enable_value);
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001355 }
1356 }
1357 else
1358 {
1359 if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID)
1360 bp->SetThreadID (m_options.m_thread_id);
1361
Greg Clayton54e7afa2010-07-09 20:39:50 +00001362 if (m_options.m_thread_index != UINT32_MAX)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001363 bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index);
1364
Jim Inghamd4571222010-06-19 04:35:20 +00001365 if (m_options.m_name_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001366 bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str());
1367
Jim Inghamd4571222010-06-19 04:35:20 +00001368 if (m_options.m_queue_passed)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001369 bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str());
1370
Greg Clayton54e7afa2010-07-09 20:39:50 +00001371 if (m_options.m_ignore_count != 0)
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001372 bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count);
Jim Ingham10622a22010-06-18 00:58:52 +00001373
1374 if (m_options.m_enable_passed)
1375 bp->SetEnabled (m_options.m_enable_value);
1376
Jim Ingham3c7b5b92010-06-16 02:00:15 +00001377 }
1378 }
1379 }
1380 }
1381
1382 return result.Succeeded();
1383}
1384
1385