Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 Ingham | 84cdc15 | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 20 | #include "lldb/Interpreter/Options.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #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 Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 28 | #include "lldb/Target/Thread.h" |
| 29 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
| 31 | using namespace lldb; |
| 32 | using namespace lldb_private; |
| 33 | |
| 34 | static void |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 35 | AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | { |
| 37 | s->IndentMore(); |
| 38 | bp->GetDescription (s, level, true); |
| 39 | s->IndentLess(); |
| 40 | s->EOL(); |
| 41 | } |
| 42 | |
| 43 | //------------------------------------------------------------------------- |
| 44 | // CommandObjectBreakpointSet::CommandOptions |
| 45 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 46 | #pragma mark Set::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 47 | |
| 48 | CommandObjectBreakpointSet::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 Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 55 | m_func_name_type_mask (0), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | m_func_regexp (), |
| 57 | m_modules (), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 58 | m_load_addr(), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 59 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 60 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 61 | m_thread_index (UINT32_MAX), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 62 | m_thread_name(), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 63 | m_queue_name() |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 64 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | CommandObjectBreakpointSet::CommandOptions::~CommandOptions () |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | lldb::OptionDefinition |
| 72 | CommandObjectBreakpointSet::CommandOptions::g_option_table[] = |
| 73 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 74 | { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "<shlib-name>", |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 75 | "Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."}, |
| 76 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 77 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, "<n>", |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 78 | "Set the number of times this breakpoint is sKipped before stopping." }, |
| 79 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 80 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "<thread-index>", |
| 81 | "The breakpoint stops only for the thread whose index matches this argument."}, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 82 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 83 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "<thread-id>", |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 84 | "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 85 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 86 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "<thread-name>", |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 87 | "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 88 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 89 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "<queue-name>", |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 90 | "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 91 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 92 | { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<filename>", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 93 | "Set the breakpoint by source location in this particular file."}, |
| 94 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 95 | { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, "<linenum>", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 96 | "Set the breakpoint by source location at this particular line."}, |
| 97 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 98 | // 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 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 103 | { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, "<address>", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | "Set the breakpoint by address, at the specified address."}, |
| 105 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 106 | { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "<name>", |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 107 | "Set the breakpoint by function name - for C++ this means namespaces and arguments will be ignored." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | |
Jim Ingham | b0f55d4 | 2010-09-08 17:52:03 +0000 | [diff] [blame] | 109 | { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, "<fullname>", |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 110 | "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 Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 112 | |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 113 | { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, "<selector>", |
| 114 | "Set the breakpoint by ObjC selector name." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 115 | |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 116 | { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, "<method>", |
| 117 | "Set the breakpoint by C++ method names." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 118 | |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 119 | { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, "<regex>", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 120 | "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, |
| 121 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 122 | { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } |
| 123 | }; |
| 124 | |
| 125 | const lldb::OptionDefinition* |
| 126 | CommandObjectBreakpointSet::CommandOptions::GetDefinitions () |
| 127 | { |
| 128 | return g_option_table; |
| 129 | } |
| 130 | |
| 131 | Error |
| 132 | CommandObjectBreakpointSet::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 Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 151 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | case 'f': |
| 153 | m_filename = option_arg; |
| 154 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 155 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 156 | case 'l': |
| 157 | m_line_num = Args::StringToUInt32 (option_arg, 0); |
| 158 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 159 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 160 | case 'n': |
| 161 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 162 | m_func_name_type_mask |= eFunctionNameTypeBase; |
| 163 | break; |
| 164 | |
| 165 | case 'F': |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 166 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 167 | m_func_name_type_mask |= eFunctionNameTypeFull; |
| 168 | break; |
| 169 | |
| 170 | case 'S': |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 171 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 172 | m_func_name_type_mask |= eFunctionNameTypeSelector; |
| 173 | break; |
| 174 | |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 175 | case 'M': |
| 176 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 177 | m_func_name_type_mask |= eFunctionNameTypeMethod; |
| 178 | break; |
| 179 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 180 | case 'r': |
| 181 | m_func_regexp = option_arg; |
| 182 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 183 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 184 | case 's': |
| 185 | { |
| 186 | m_modules.push_back (std::string (option_arg)); |
| 187 | break; |
| 188 | } |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 189 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 190 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 191 | m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 192 | if (m_ignore_count == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 193 | error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); |
| 194 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 195 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 196 | 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 Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 211 | m_thread_index = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 212 | if (m_thread_id == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 213 | error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); |
| 214 | |
| 215 | } |
| 216 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 217 | default: |
| 218 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 219 | break; |
| 220 | } |
| 221 | |
| 222 | return error; |
| 223 | } |
| 224 | |
| 225 | void |
| 226 | CommandObjectBreakpointSet::CommandOptions::ResetOptionValues () |
| 227 | { |
| 228 | Options::ResetOptionValues(); |
| 229 | |
| 230 | m_filename.clear(); |
| 231 | m_line_num = 0; |
| 232 | m_column = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 233 | m_func_name.clear(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 234 | m_func_name_type_mask = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 235 | m_func_regexp.clear(); |
| 236 | m_load_addr = LLDB_INVALID_ADDRESS; |
| 237 | m_modules.clear(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 238 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 239 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 240 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 241 | m_thread_name.clear(); |
| 242 | m_queue_name.clear(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | //------------------------------------------------------------------------- |
| 246 | // CommandObjectBreakpointSet |
| 247 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 248 | #pragma mark Set |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 249 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 250 | CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) : |
| 251 | CommandObject (interpreter, |
| 252 | "breakpoint set", |
| 253 | "Sets a breakpoint or set of breakpoints in the executable.", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 254 | "breakpoint set <cmd-options>") |
| 255 | { |
| 256 | } |
| 257 | |
| 258 | CommandObjectBreakpointSet::~CommandObjectBreakpointSet () |
| 259 | { |
| 260 | } |
| 261 | |
| 262 | Options * |
| 263 | CommandObjectBreakpointSet::GetOptions () |
| 264 | { |
| 265 | return &m_options; |
| 266 | } |
| 267 | |
| 268 | bool |
| 269 | CommandObjectBreakpointSet::Execute |
| 270 | ( |
| 271 | Args& command, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 272 | CommandReturnObject &result |
| 273 | ) |
| 274 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 275 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 276 | if (target == NULL) |
| 277 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 278 | result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'file' command)."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 279 | 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 Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 308 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 309 | switch (break_type) |
| 310 | { |
| 311 | case eSetTypeFileAndLine: // Breakpoint by source position |
| 312 | { |
| 313 | FileSpec file; |
| 314 | if (m_options.m_filename.empty()) |
| 315 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 316 | StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 317 | if (cur_frame == NULL) |
| 318 | { |
| 319 | result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); |
| 320 | result.SetStatus (eReturnStatusFailed); |
| 321 | break; |
| 322 | } |
| 323 | else if (!cur_frame->HasDebugInformation()) |
| 324 | { |
| 325 | result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); |
| 326 | result.SetStatus (eReturnStatusFailed); |
| 327 | break; |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | 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 | } |
| 345 | } |
| 346 | } |
| 347 | 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(); |
| 382 | } |
| 383 | break; |
| 384 | case eSetTypeAddress: // Breakpoint by address |
| 385 | bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); |
| 386 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 387 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 388 | case eSetTypeFunctionName: // Breakpoint by function name |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 389 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 390 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 391 | |
| 392 | if (name_type_mask == 0) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 393 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 394 | |
| 395 | if (m_options.m_func_name.find('(') != std::string::npos || |
| 396 | m_options.m_func_name.find("-[") == 0 || |
| 397 | m_options.m_func_name.find("+[") == 0) |
| 398 | name_type_mask |= eFunctionNameTypeFull; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 399 | else |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 400 | name_type_mask |= eFunctionNameTypeBase; |
| 401 | } |
| 402 | |
| 403 | |
| 404 | if (use_module) |
| 405 | { |
| 406 | for (int i = 0; i < num_modules; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 407 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 408 | module.SetFile(m_options.m_modules[i].c_str()); |
| 409 | bp = target->CreateBreakpoint (&module, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get(); |
| 410 | if (bp) |
| 411 | { |
| 412 | StreamString &output_stream = result.GetOutputStream(); |
| 413 | output_stream.Printf ("Breakpoint created: "); |
| 414 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 415 | output_stream.EOL(); |
| 416 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 421 | m_options.m_modules[i].c_str()); |
| 422 | result.SetStatus (eReturnStatusFailed); |
| 423 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 424 | } |
| 425 | } |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 426 | else |
| 427 | bp = target->CreateBreakpoint (NULL, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 428 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 430 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name |
| 432 | { |
| 433 | RegularExpression regexp(m_options.m_func_regexp.c_str()); |
| 434 | if (use_module) |
| 435 | { |
| 436 | for (int i = 0; i < num_modules; ++i) |
| 437 | { |
| 438 | module.SetFile(m_options.m_modules[i].c_str()); |
| 439 | bp = target->CreateBreakpoint (&module, regexp).get(); |
| 440 | if (bp) |
| 441 | { |
| 442 | StreamString &output_stream = result.GetOutputStream(); |
| 443 | output_stream.Printf ("Breakpoint created: "); |
| 444 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 445 | output_stream.EOL(); |
| 446 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 447 | } |
| 448 | else |
| 449 | { |
| 450 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 451 | m_options.m_modules[i].c_str()); |
| 452 | result.SetStatus (eReturnStatusFailed); |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | else |
| 457 | bp = target->CreateBreakpoint (NULL, regexp).get(); |
| 458 | } |
| 459 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 460 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 461 | default: |
| 462 | break; |
| 463 | } |
| 464 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 465 | // Now set the various options that were passed in: |
| 466 | if (bp) |
| 467 | { |
| 468 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 469 | bp->SetThreadID (m_options.m_thread_id); |
| 470 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 471 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 472 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 473 | |
| 474 | if (!m_options.m_thread_name.empty()) |
| 475 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 476 | |
| 477 | if (!m_options.m_queue_name.empty()) |
| 478 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 479 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 480 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 481 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
| 482 | } |
| 483 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | if (bp && !use_module) |
| 485 | { |
| 486 | StreamString &output_stream = result.GetOutputStream(); |
| 487 | output_stream.Printf ("Breakpoint created: "); |
| 488 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 489 | output_stream.EOL(); |
| 490 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 491 | } |
| 492 | else if (!bp) |
| 493 | { |
| 494 | result.AppendError ("Breakpoint creation failed: No breakpoint created."); |
| 495 | result.SetStatus (eReturnStatusFailed); |
| 496 | } |
| 497 | |
| 498 | return result.Succeeded(); |
| 499 | } |
| 500 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 501 | //------------------------------------------------------------------------- |
| 502 | // CommandObjectMultiwordBreakpoint |
| 503 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 504 | #pragma mark MultiwordBreakpoint |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 505 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 506 | CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 507 | CommandObjectMultiword (interpreter, |
| 508 | "breakpoint", |
| 509 | "A set of commands for operating on breakpoints. Also see regexp-break.", |
| 510 | "breakpoint <command> [<command-options>]") |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 511 | { |
| 512 | bool status; |
| 513 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 514 | CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); |
| 515 | CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); |
| 516 | CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); |
| 517 | CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); |
| 518 | CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 519 | CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 520 | CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 521 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 522 | command_command_object->SetCommandName ("breakpoint command"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 523 | enable_command_object->SetCommandName("breakpoint enable"); |
| 524 | disable_command_object->SetCommandName("breakpoint disable"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 525 | list_command_object->SetCommandName ("breakpoint list"); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 526 | modify_command_object->SetCommandName ("breakpoint modify"); |
| 527 | set_command_object->SetCommandName("breakpoint set"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 528 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 529 | status = LoadSubCommand ("list", list_command_object); |
| 530 | status = LoadSubCommand ("enable", enable_command_object); |
| 531 | status = LoadSubCommand ("disable", disable_command_object); |
| 532 | status = LoadSubCommand ("delete", delete_command_object); |
| 533 | status = LoadSubCommand ("set", set_command_object); |
| 534 | status = LoadSubCommand ("command", command_command_object); |
| 535 | status = LoadSubCommand ("modify", modify_command_object); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () |
| 539 | { |
| 540 | } |
| 541 | |
| 542 | void |
| 543 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result, |
| 544 | BreakpointIDList *valid_ids) |
| 545 | { |
| 546 | // args can be strings representing 1). integers (for breakpoint ids) |
| 547 | // 2). the full breakpoint & location canonical representation |
| 548 | // 3). the word "to" or a hyphen, representing a range (in which case there |
| 549 | // had *better* be an entry both before & after of one of the first two types. |
| 550 | |
| 551 | Args temp_args; |
| 552 | |
| 553 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 554 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 555 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 556 | |
| 557 | BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); |
| 558 | |
| 559 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 560 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 561 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 562 | |
| 563 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 564 | // and put into valid_ids. |
| 565 | |
| 566 | if (result.Succeeded()) |
| 567 | { |
| 568 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 569 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 570 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 571 | const size_t count = valid_ids->GetSize(); |
| 572 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 573 | { |
| 574 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 575 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 576 | if (breakpoint != NULL) |
| 577 | { |
| 578 | int num_locations = breakpoint->GetNumLocations(); |
| 579 | if (cur_bp_id.GetLocationID() > num_locations) |
| 580 | { |
| 581 | StreamString id_str; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 582 | BreakpointID::GetCanonicalReference (&id_str, |
| 583 | cur_bp_id.GetBreakpointID(), |
| 584 | cur_bp_id.GetLocationID()); |
| 585 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 586 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 587 | id_str.GetData()); |
| 588 | result.SetStatus (eReturnStatusFailed); |
| 589 | } |
| 590 | } |
| 591 | else |
| 592 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 593 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 594 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 595 | result.SetStatus (eReturnStatusFailed); |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | //------------------------------------------------------------------------- |
| 602 | // CommandObjectBreakpointList::Options |
| 603 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 604 | #pragma mark List::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 605 | |
| 606 | CommandObjectBreakpointList::CommandOptions::CommandOptions() : |
| 607 | Options (), |
| 608 | m_level (lldb::eDescriptionLevelFull) // Breakpoint List defaults to brief descriptions |
| 609 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | CommandObjectBreakpointList::CommandOptions::~CommandOptions () |
| 613 | { |
| 614 | } |
| 615 | |
| 616 | lldb::OptionDefinition |
| 617 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 618 | { |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 619 | { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, NULL, |
| 620 | "Show debugger internal breakpoints" }, |
| 621 | |
| 622 | { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, NULL, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 623 | "Give a brief description of the breakpoint (no location info)."}, |
| 624 | |
| 625 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 626 | // But I need to see it for now, and don't want to wait. |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 627 | { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, NULL, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 628 | "Give a full description of the breakpoint and its locations."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 629 | |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 630 | { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, NULL, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 631 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 632 | |
| 633 | { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } |
| 634 | }; |
| 635 | |
| 636 | const lldb::OptionDefinition* |
| 637 | CommandObjectBreakpointList::CommandOptions::GetDefinitions () |
| 638 | { |
| 639 | return g_option_table; |
| 640 | } |
| 641 | |
| 642 | Error |
| 643 | CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
| 644 | { |
| 645 | Error error; |
| 646 | char short_option = (char) m_getopt_table[option_idx].val; |
| 647 | |
| 648 | switch (short_option) |
| 649 | { |
| 650 | case 'b': |
| 651 | m_level = lldb::eDescriptionLevelBrief; |
| 652 | break; |
| 653 | case 'f': |
| 654 | m_level = lldb::eDescriptionLevelFull; |
| 655 | break; |
| 656 | case 'v': |
| 657 | m_level = lldb::eDescriptionLevelVerbose; |
| 658 | break; |
| 659 | case 'i': |
| 660 | m_internal = true; |
| 661 | break; |
| 662 | default: |
| 663 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 664 | break; |
| 665 | } |
| 666 | |
| 667 | return error; |
| 668 | } |
| 669 | |
| 670 | void |
| 671 | CommandObjectBreakpointList::CommandOptions::ResetOptionValues () |
| 672 | { |
| 673 | Options::ResetOptionValues(); |
| 674 | |
| 675 | m_level = lldb::eDescriptionLevelFull; |
| 676 | m_internal = false; |
| 677 | } |
| 678 | |
| 679 | //------------------------------------------------------------------------- |
| 680 | // CommandObjectBreakpointList |
| 681 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 682 | #pragma mark List |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 683 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 684 | CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 685 | CommandObject (interpreter, |
| 686 | "breakpoint list", |
| 687 | "List some or all breakpoints at configurable levels of detail.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 688 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 689 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 690 | CommandArgumentEntry arg; |
| 691 | CommandArgumentData bp_id_arg; |
| 692 | |
| 693 | // Define the first (and only) variant of this arg. |
| 694 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 695 | bp_id_arg.arg_repetition = eArgRepeatStar; |
| 696 | |
| 697 | // There is only one variant this argument could be; put it into the argument entry. |
| 698 | arg.push_back (bp_id_arg); |
| 699 | |
| 700 | // Push the data for the first argument into the m_arguments vector. |
| 701 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | CommandObjectBreakpointList::~CommandObjectBreakpointList () |
| 705 | { |
| 706 | } |
| 707 | |
| 708 | Options * |
| 709 | CommandObjectBreakpointList::GetOptions () |
| 710 | { |
| 711 | return &m_options; |
| 712 | } |
| 713 | |
| 714 | bool |
| 715 | CommandObjectBreakpointList::Execute |
| 716 | ( |
| 717 | Args& args, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | CommandReturnObject &result |
| 719 | ) |
| 720 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 721 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 722 | if (target == NULL) |
| 723 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 724 | result.AppendError ("Invalid target. No current target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 725 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 726 | return true; |
| 727 | } |
| 728 | |
| 729 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 730 | Mutex::Locker locker; |
| 731 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 732 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 733 | size_t num_breakpoints = breakpoints.GetSize(); |
| 734 | |
| 735 | if (num_breakpoints == 0) |
| 736 | { |
| 737 | result.AppendMessage ("No breakpoints currently set."); |
| 738 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 739 | return true; |
| 740 | } |
| 741 | |
| 742 | StreamString &output_stream = result.GetOutputStream(); |
| 743 | |
| 744 | if (args.GetArgumentCount() == 0) |
| 745 | { |
| 746 | // No breakpoint selected; show info about all currently set breakpoints. |
| 747 | result.AppendMessage ("Current breakpoints:"); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 748 | for (size_t i = 0; i < num_breakpoints; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 749 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 750 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 751 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 752 | } |
| 753 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 754 | } |
| 755 | else |
| 756 | { |
| 757 | // Particular breakpoints selected; show info about that breakpoint. |
| 758 | BreakpointIDList valid_bp_ids; |
| 759 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 760 | |
| 761 | if (result.Succeeded()) |
| 762 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 763 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 764 | { |
| 765 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 766 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 767 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 768 | } |
| 769 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 770 | } |
| 771 | else |
| 772 | { |
| 773 | result.AppendError ("Invalid breakpoint id."); |
| 774 | result.SetStatus (eReturnStatusFailed); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | return result.Succeeded(); |
| 779 | } |
| 780 | |
| 781 | //------------------------------------------------------------------------- |
| 782 | // CommandObjectBreakpointEnable |
| 783 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 784 | #pragma mark Enable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 785 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 786 | CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 787 | CommandObject (interpreter, |
| 788 | "enable", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 789 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 790 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 791 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 792 | CommandArgumentEntry arg; |
| 793 | CommandArgumentData bp_id_arg; |
| 794 | CommandArgumentData bp_id_range_arg; |
| 795 | |
| 796 | // Create the first variant for the first (and only) argument for this command. |
| 797 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 798 | bp_id_arg.arg_repetition = eArgRepeatStar; |
| 799 | |
| 800 | // Create the second variant for the first (and only) argument for this command. |
| 801 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
| 802 | bp_id_range_arg.arg_repetition = eArgRepeatStar; |
| 803 | |
| 804 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 805 | // Push both variants into the entry for the first argument for this command. |
| 806 | arg.push_back (bp_id_arg); |
| 807 | arg.push_back (bp_id_range_arg); |
| 808 | |
| 809 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 810 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | |
| 814 | CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () |
| 815 | { |
| 816 | } |
| 817 | |
| 818 | |
| 819 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 820 | CommandObjectBreakpointEnable::Execute |
| 821 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 822 | Args& args, |
| 823 | CommandReturnObject &result |
| 824 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 825 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 826 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 827 | if (target == NULL) |
| 828 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 829 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 830 | result.SetStatus (eReturnStatusFailed); |
| 831 | return false; |
| 832 | } |
| 833 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 834 | Mutex::Locker locker; |
| 835 | target->GetBreakpointList().GetListMutex(locker); |
| 836 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 837 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 838 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 839 | size_t num_breakpoints = breakpoints.GetSize(); |
| 840 | |
| 841 | if (num_breakpoints == 0) |
| 842 | { |
| 843 | result.AppendError ("No breakpoints exist to be enabled."); |
| 844 | result.SetStatus (eReturnStatusFailed); |
| 845 | return false; |
| 846 | } |
| 847 | |
| 848 | if (args.GetArgumentCount() == 0) |
| 849 | { |
| 850 | // No breakpoint selected; enable all currently set breakpoints. |
| 851 | target->EnableAllBreakpoints (); |
| 852 | result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints); |
| 853 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 854 | } |
| 855 | else |
| 856 | { |
| 857 | // Particular breakpoint selected; enable that breakpoint. |
| 858 | BreakpointIDList valid_bp_ids; |
| 859 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 860 | |
| 861 | if (result.Succeeded()) |
| 862 | { |
| 863 | int enable_count = 0; |
| 864 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 865 | const size_t count = valid_bp_ids.GetSize(); |
| 866 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 867 | { |
| 868 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 869 | |
| 870 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 871 | { |
| 872 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 873 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 874 | { |
| 875 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 876 | if (location) |
| 877 | { |
| 878 | location->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 879 | ++loc_count; |
| 880 | } |
| 881 | } |
| 882 | else |
| 883 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 884 | breakpoint->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 885 | ++enable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 886 | } |
| 887 | } |
| 888 | } |
| 889 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 890 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | return result.Succeeded(); |
| 895 | } |
| 896 | |
| 897 | //------------------------------------------------------------------------- |
| 898 | // CommandObjectBreakpointDisable |
| 899 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 900 | #pragma mark Disable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 901 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 902 | CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 903 | CommandObject (interpreter, |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 904 | "breakpoint disable", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 905 | "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 906 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 907 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 908 | CommandArgumentEntry arg; |
| 909 | CommandArgumentData bp_id_arg; |
| 910 | CommandArgumentData bp_id_range_arg; |
| 911 | |
| 912 | // Create the first variant for the first (and only) argument for this command. |
| 913 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 914 | bp_id_arg.arg_repetition = eArgRepeatStar; |
| 915 | |
| 916 | // Create the second variant for the first (and only) argument for this command. |
| 917 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
| 918 | bp_id_range_arg.arg_repetition = eArgRepeatStar; |
| 919 | |
| 920 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 921 | // Push both variants into the entry for the first argument for this command. |
| 922 | arg.push_back (bp_id_arg); |
| 923 | arg.push_back (bp_id_range_arg); |
| 924 | |
| 925 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 926 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () |
| 930 | { |
| 931 | } |
| 932 | |
| 933 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 934 | CommandObjectBreakpointDisable::Execute |
| 935 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 936 | Args& args, |
| 937 | CommandReturnObject &result |
| 938 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 939 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 940 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 941 | if (target == NULL) |
| 942 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 943 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 944 | result.SetStatus (eReturnStatusFailed); |
| 945 | return false; |
| 946 | } |
| 947 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 948 | Mutex::Locker locker; |
| 949 | target->GetBreakpointList().GetListMutex(locker); |
| 950 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 951 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 952 | size_t num_breakpoints = breakpoints.GetSize(); |
| 953 | |
| 954 | if (num_breakpoints == 0) |
| 955 | { |
| 956 | result.AppendError ("No breakpoints exist to be disabled."); |
| 957 | result.SetStatus (eReturnStatusFailed); |
| 958 | return false; |
| 959 | } |
| 960 | |
| 961 | if (args.GetArgumentCount() == 0) |
| 962 | { |
| 963 | // No breakpoint selected; disable all currently set breakpoints. |
| 964 | target->DisableAllBreakpoints (); |
| 965 | result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints); |
| 966 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 967 | } |
| 968 | else |
| 969 | { |
| 970 | // Particular breakpoint selected; disable that breakpoint. |
| 971 | BreakpointIDList valid_bp_ids; |
| 972 | |
| 973 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 974 | |
| 975 | if (result.Succeeded()) |
| 976 | { |
| 977 | int disable_count = 0; |
| 978 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 979 | const size_t count = valid_bp_ids.GetSize(); |
| 980 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 981 | { |
| 982 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 983 | |
| 984 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 985 | { |
| 986 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 987 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 988 | { |
| 989 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 990 | if (location) |
| 991 | { |
| 992 | location->SetEnabled (false); |
| 993 | ++loc_count; |
| 994 | } |
| 995 | } |
| 996 | else |
| 997 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 998 | breakpoint->SetEnabled (false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 999 | ++disable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1004 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | return result.Succeeded(); |
| 1009 | } |
| 1010 | |
| 1011 | //------------------------------------------------------------------------- |
| 1012 | // CommandObjectBreakpointDelete |
| 1013 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1014 | #pragma mark Delete |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1015 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1016 | CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : |
| 1017 | CommandObject (interpreter, |
| 1018 | "breakpoint delete", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 1019 | "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 1020 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1021 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 1022 | CommandArgumentEntry arg; |
| 1023 | CommandArgumentData bp_id_arg; |
| 1024 | CommandArgumentData bp_id_range_arg; |
| 1025 | |
| 1026 | // Create the first variant for the first (and only) argument for this command. |
| 1027 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 1028 | bp_id_arg.arg_repetition = eArgRepeatStar; |
| 1029 | |
| 1030 | // Create the second variant for the first (and only) argument for this command. |
| 1031 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
| 1032 | bp_id_range_arg.arg_repetition = eArgRepeatStar; |
| 1033 | |
| 1034 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1035 | // Push both variants into the entry for the first argument for this command. |
| 1036 | arg.push_back (bp_id_arg); |
| 1037 | arg.push_back (bp_id_range_arg); |
| 1038 | |
| 1039 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1040 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | |
| 1044 | CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () |
| 1045 | { |
| 1046 | } |
| 1047 | |
| 1048 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1049 | CommandObjectBreakpointDelete::Execute |
| 1050 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1051 | Args& args, |
| 1052 | CommandReturnObject &result |
| 1053 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1054 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1055 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1056 | if (target == NULL) |
| 1057 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1058 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1059 | result.SetStatus (eReturnStatusFailed); |
| 1060 | return false; |
| 1061 | } |
| 1062 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1063 | Mutex::Locker locker; |
| 1064 | target->GetBreakpointList().GetListMutex(locker); |
| 1065 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1066 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1067 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1068 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1069 | |
| 1070 | if (num_breakpoints == 0) |
| 1071 | { |
| 1072 | result.AppendError ("No breakpoints exist to be deleted."); |
| 1073 | result.SetStatus (eReturnStatusFailed); |
| 1074 | return false; |
| 1075 | } |
| 1076 | |
| 1077 | if (args.GetArgumentCount() == 0) |
| 1078 | { |
| 1079 | // No breakpoint selected; disable all currently set breakpoints. |
| 1080 | if (args.GetArgumentCount() != 0) |
| 1081 | { |
| 1082 | result.AppendErrorWithFormat ("Specify breakpoints to delete with the -i option.\n"); |
| 1083 | result.SetStatus (eReturnStatusFailed); |
| 1084 | return false; |
| 1085 | } |
| 1086 | |
| 1087 | target->RemoveAllBreakpoints (); |
| 1088 | result.AppendMessageWithFormat ("All breakpoints removed. (%d breakpoints)\n", num_breakpoints); |
| 1089 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1090 | } |
| 1091 | else |
| 1092 | { |
| 1093 | // Particular breakpoint selected; disable that breakpoint. |
| 1094 | BreakpointIDList valid_bp_ids; |
| 1095 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1096 | |
| 1097 | if (result.Succeeded()) |
| 1098 | { |
| 1099 | int delete_count = 0; |
| 1100 | int disable_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1101 | const size_t count = valid_bp_ids.GetSize(); |
| 1102 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1103 | { |
| 1104 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1105 | |
| 1106 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1107 | { |
| 1108 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1109 | { |
| 1110 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1111 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1112 | // It makes no sense to try to delete individual locations, so we disable them instead. |
| 1113 | if (location) |
| 1114 | { |
| 1115 | location->SetEnabled (false); |
| 1116 | ++disable_count; |
| 1117 | } |
| 1118 | } |
| 1119 | else |
| 1120 | { |
| 1121 | target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); |
| 1122 | ++delete_count; |
| 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", |
| 1127 | delete_count, disable_count); |
| 1128 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1129 | } |
| 1130 | } |
| 1131 | return result.Succeeded(); |
| 1132 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1133 | |
| 1134 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1135 | // CommandObjectBreakpointModify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1136 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1137 | #pragma mark Modify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1138 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1139 | CommandObjectBreakpointModify::CommandOptions::CommandOptions() : |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1140 | Options (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1141 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1142 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1143 | m_thread_index (UINT32_MAX), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1144 | m_thread_name(), |
| 1145 | m_queue_name(), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1146 | m_enable_passed (false), |
| 1147 | m_enable_value (false), |
| 1148 | m_name_passed (false), |
| 1149 | m_queue_passed (false) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1150 | { |
| 1151 | } |
| 1152 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1153 | CommandObjectBreakpointModify::CommandOptions::~CommandOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1154 | { |
| 1155 | } |
| 1156 | |
| 1157 | lldb::OptionDefinition |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1158 | CommandObjectBreakpointModify::CommandOptions::g_option_table[] = |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1159 | { |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 1160 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, "<n>", "Set the number of times this breakpoint is skipped before stopping." }, |
| 1161 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "<thread-index>", "The breakpoint stops only for the thread whose indeX matches this argument."}, |
| 1162 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "<thread-id>", "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 1163 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "<thread-name>", "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 1164 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "<queue-name>", "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 1165 | { LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, NULL, "Enable the breakpoint."}, |
| 1166 | { LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, NULL, "Disable the breakpoint."}, |
| 1167 | { 0, false, NULL, 0 , 0, NULL, 0, NULL, NULL } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1168 | }; |
| 1169 | |
| 1170 | const lldb::OptionDefinition* |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1171 | CommandObjectBreakpointModify::CommandOptions::GetDefinitions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1172 | { |
| 1173 | return g_option_table; |
| 1174 | } |
| 1175 | |
| 1176 | Error |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1177 | CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1178 | { |
| 1179 | Error error; |
| 1180 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1181 | |
| 1182 | switch (short_option) |
| 1183 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1184 | case 'd': |
| 1185 | m_enable_passed = true; |
| 1186 | m_enable_value = false; |
| 1187 | break; |
| 1188 | case 'e': |
| 1189 | m_enable_passed = true; |
| 1190 | m_enable_value = true; |
| 1191 | break; |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 1192 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1193 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1194 | m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 1195 | if (m_ignore_count == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1196 | error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); |
| 1197 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1198 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1199 | case 't' : |
| 1200 | { |
| 1201 | m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); |
| 1202 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 1203 | error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); |
| 1204 | } |
| 1205 | break; |
| 1206 | case 'T': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1207 | if (option_arg != NULL) |
| 1208 | m_thread_name = option_arg; |
| 1209 | else |
| 1210 | m_thread_name.clear(); |
| 1211 | m_name_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1212 | break; |
| 1213 | case 'q': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1214 | if (option_arg != NULL) |
| 1215 | m_queue_name = option_arg; |
| 1216 | else |
| 1217 | m_queue_name.clear(); |
| 1218 | m_queue_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1219 | break; |
| 1220 | case 'x': |
| 1221 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1222 | m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); |
| 1223 | if (m_thread_id == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1224 | error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); |
| 1225 | |
| 1226 | } |
| 1227 | break; |
| 1228 | default: |
| 1229 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 1230 | break; |
| 1231 | } |
| 1232 | |
| 1233 | return error; |
| 1234 | } |
| 1235 | |
| 1236 | void |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1237 | CommandObjectBreakpointModify::CommandOptions::ResetOptionValues () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1238 | { |
| 1239 | Options::ResetOptionValues(); |
| 1240 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1241 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1242 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1243 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1244 | m_thread_name.clear(); |
| 1245 | m_queue_name.clear(); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1246 | m_enable_passed = false; |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1247 | m_queue_passed = false; |
| 1248 | m_name_passed = false; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1252 | // CommandObjectBreakpointModify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1253 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1254 | #pragma mark Modify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1255 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1256 | CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : |
| 1257 | CommandObject (interpreter, |
| 1258 | "breakpoint modify", |
| 1259 | "Modify the options on a breakpoint or set of breakpoints in the executable.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 1260 | NULL) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1261 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame^] | 1262 | CommandArgumentEntry arg; |
| 1263 | CommandArgumentData bp_id_arg; |
| 1264 | CommandArgumentData bp_id_range_arg; |
| 1265 | |
| 1266 | // Create the first variant for the first (and only) argument for this command. |
| 1267 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 1268 | bp_id_arg.arg_repetition = eArgRepeatPlus; |
| 1269 | |
| 1270 | // Create the second variant for the first (and only) argument for this command. |
| 1271 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
| 1272 | bp_id_range_arg.arg_repetition = eArgRepeatPlus; |
| 1273 | |
| 1274 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1275 | // Push both variants into the entry for the first argument for this command. |
| 1276 | arg.push_back (bp_id_arg); |
| 1277 | arg.push_back (bp_id_range_arg); |
| 1278 | |
| 1279 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1280 | m_arguments.push_back (arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1281 | } |
| 1282 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1283 | CommandObjectBreakpointModify::~CommandObjectBreakpointModify () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1284 | { |
| 1285 | } |
| 1286 | |
| 1287 | Options * |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1288 | CommandObjectBreakpointModify::GetOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1289 | { |
| 1290 | return &m_options; |
| 1291 | } |
| 1292 | |
| 1293 | bool |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1294 | CommandObjectBreakpointModify::Execute |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1295 | ( |
| 1296 | Args& command, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1297 | CommandReturnObject &result |
| 1298 | ) |
| 1299 | { |
| 1300 | if (command.GetArgumentCount() == 0) |
| 1301 | { |
| 1302 | result.AppendError ("No breakpoints specified."); |
| 1303 | result.SetStatus (eReturnStatusFailed); |
| 1304 | return false; |
| 1305 | } |
| 1306 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1307 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1308 | if (target == NULL) |
| 1309 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1310 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1311 | result.SetStatus (eReturnStatusFailed); |
| 1312 | return false; |
| 1313 | } |
| 1314 | |
| 1315 | Mutex::Locker locker; |
| 1316 | target->GetBreakpointList().GetListMutex(locker); |
| 1317 | |
| 1318 | BreakpointIDList valid_bp_ids; |
| 1319 | |
| 1320 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 1321 | |
| 1322 | if (result.Succeeded()) |
| 1323 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1324 | const size_t count = valid_bp_ids.GetSize(); |
| 1325 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1326 | { |
| 1327 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1328 | |
| 1329 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1330 | { |
| 1331 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1332 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1333 | { |
| 1334 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1335 | if (location) |
| 1336 | { |
| 1337 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1338 | location->SetThreadID (m_options.m_thread_id); |
| 1339 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1340 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1341 | location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1342 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1343 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1344 | location->GetLocationOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1345 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1346 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1347 | location->GetLocationOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1348 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1349 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1350 | location->GetLocationOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1351 | |
| 1352 | if (m_options.m_enable_passed) |
| 1353 | location->SetEnabled (m_options.m_enable_value); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1354 | } |
| 1355 | } |
| 1356 | else |
| 1357 | { |
| 1358 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1359 | bp->SetThreadID (m_options.m_thread_id); |
| 1360 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1361 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1362 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1363 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1364 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1365 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1366 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1367 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1368 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1369 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1370 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1371 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1372 | |
| 1373 | if (m_options.m_enable_passed) |
| 1374 | bp->SetEnabled (m_options.m_enable_value); |
| 1375 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1376 | } |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | return result.Succeeded(); |
| 1382 | } |
| 1383 | |
| 1384 | |