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 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 74 | { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 77 | { 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 Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 79 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 80 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, eArgTypeThreadIndex, |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 83 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, eArgTypeThreadID, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 86 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, eArgTypeThreadName, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 89 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 92 | { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 93 | "Set the breakpoint by source location in this particular file."}, |
| 94 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 95 | { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 103 | { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | "Set the breakpoint by address, at the specified address."}, |
| 105 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 106 | { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 107 | "Set the breakpoint by function name." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 109 | { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, |
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 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 113 | { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector, |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 114 | "Set the breakpoint by ObjC selector name." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 115 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 116 | { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod, |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 117 | "Set the breakpoint by C++ method names." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 118 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 119 | { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression, |
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 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 122 | { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
| 123 | "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored)." }, |
| 124 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 125 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | const lldb::OptionDefinition* |
| 129 | CommandObjectBreakpointSet::CommandOptions::GetDefinitions () |
| 130 | { |
| 131 | return g_option_table; |
| 132 | } |
| 133 | |
| 134 | Error |
| 135 | CommandObjectBreakpointSet::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
| 136 | { |
| 137 | Error error; |
| 138 | char short_option = (char) m_getopt_table[option_idx].val; |
| 139 | |
| 140 | switch (short_option) |
| 141 | { |
| 142 | case 'a': |
| 143 | m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 0); |
| 144 | if (m_load_addr == LLDB_INVALID_ADDRESS) |
| 145 | m_load_addr = Args::StringToUInt64(optarg, LLDB_INVALID_ADDRESS, 16); |
| 146 | |
| 147 | if (m_load_addr == LLDB_INVALID_ADDRESS) |
| 148 | error.SetErrorStringWithFormat ("Invalid address string '%s'.\n", optarg); |
| 149 | break; |
| 150 | |
| 151 | case 'c': |
| 152 | m_column = Args::StringToUInt32 (option_arg, 0); |
| 153 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 154 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 155 | case 'f': |
| 156 | m_filename = option_arg; |
| 157 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 158 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 159 | case 'l': |
| 160 | m_line_num = Args::StringToUInt32 (option_arg, 0); |
| 161 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 162 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 163 | case 'b': |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 164 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 165 | m_func_name_type_mask |= eFunctionNameTypeBase; |
| 166 | break; |
| 167 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 168 | case 'n': |
| 169 | m_func_name = option_arg; |
| 170 | m_func_name_type_mask |= eFunctionNameTypeAuto; |
| 171 | break; |
| 172 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 173 | case 'F': |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 174 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 175 | m_func_name_type_mask |= eFunctionNameTypeFull; |
| 176 | break; |
| 177 | |
| 178 | case 'S': |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 179 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 180 | m_func_name_type_mask |= eFunctionNameTypeSelector; |
| 181 | break; |
| 182 | |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 183 | case 'M': |
| 184 | m_func_name = option_arg; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 185 | m_func_name_type_mask |= eFunctionNameTypeMethod; |
| 186 | break; |
| 187 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 188 | case 'r': |
| 189 | m_func_regexp = option_arg; |
| 190 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 191 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 192 | case 's': |
| 193 | { |
| 194 | m_modules.push_back (std::string (option_arg)); |
| 195 | break; |
| 196 | } |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 197 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 198 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 199 | m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 200 | if (m_ignore_count == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 201 | error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); |
| 202 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 203 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 204 | case 't' : |
| 205 | { |
| 206 | m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); |
| 207 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 208 | error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); |
| 209 | } |
| 210 | break; |
| 211 | case 'T': |
| 212 | m_thread_name = option_arg; |
| 213 | break; |
| 214 | case 'q': |
| 215 | m_queue_name = option_arg; |
| 216 | break; |
| 217 | case 'x': |
| 218 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 219 | m_thread_index = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 220 | if (m_thread_id == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 221 | error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); |
| 222 | |
| 223 | } |
| 224 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 225 | default: |
| 226 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 227 | break; |
| 228 | } |
| 229 | |
| 230 | return error; |
| 231 | } |
| 232 | |
| 233 | void |
| 234 | CommandObjectBreakpointSet::CommandOptions::ResetOptionValues () |
| 235 | { |
| 236 | Options::ResetOptionValues(); |
| 237 | |
| 238 | m_filename.clear(); |
| 239 | m_line_num = 0; |
| 240 | m_column = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 241 | m_func_name.clear(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 242 | m_func_name_type_mask = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 243 | m_func_regexp.clear(); |
| 244 | m_load_addr = LLDB_INVALID_ADDRESS; |
| 245 | m_modules.clear(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 246 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 247 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 248 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 249 | m_thread_name.clear(); |
| 250 | m_queue_name.clear(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | //------------------------------------------------------------------------- |
| 254 | // CommandObjectBreakpointSet |
| 255 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 256 | #pragma mark Set |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 257 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 258 | CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) : |
| 259 | CommandObject (interpreter, |
| 260 | "breakpoint set", |
| 261 | "Sets a breakpoint or set of breakpoints in the executable.", |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 262 | "breakpoint set <cmd-options>") |
| 263 | { |
| 264 | } |
| 265 | |
| 266 | CommandObjectBreakpointSet::~CommandObjectBreakpointSet () |
| 267 | { |
| 268 | } |
| 269 | |
| 270 | Options * |
| 271 | CommandObjectBreakpointSet::GetOptions () |
| 272 | { |
| 273 | return &m_options; |
| 274 | } |
| 275 | |
| 276 | bool |
| 277 | CommandObjectBreakpointSet::Execute |
| 278 | ( |
| 279 | Args& command, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 280 | CommandReturnObject &result |
| 281 | ) |
| 282 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 283 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 284 | if (target == NULL) |
| 285 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 286 | 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] | 287 | result.SetStatus (eReturnStatusFailed); |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | // The following are the various types of breakpoints that could be set: |
| 292 | // 1). -f -l -p [-s -g] (setting breakpoint by source location) |
| 293 | // 2). -a [-s -g] (setting breakpoint by address) |
| 294 | // 3). -n [-s -g] (setting breakpoint by function name) |
| 295 | // 4). -r [-s -g] (setting breakpoint by function name regular expression) |
| 296 | |
| 297 | BreakpointSetType break_type = eSetTypeInvalid; |
| 298 | |
| 299 | if (m_options.m_line_num != 0) |
| 300 | break_type = eSetTypeFileAndLine; |
| 301 | else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) |
| 302 | break_type = eSetTypeAddress; |
| 303 | else if (!m_options.m_func_name.empty()) |
| 304 | break_type = eSetTypeFunctionName; |
| 305 | else if (!m_options.m_func_regexp.empty()) |
| 306 | break_type = eSetTypeFunctionRegexp; |
| 307 | |
| 308 | ModuleSP module_sp = target->GetExecutableModule(); |
| 309 | Breakpoint *bp = NULL; |
| 310 | FileSpec module; |
| 311 | bool use_module = false; |
| 312 | int num_modules = m_options.m_modules.size(); |
| 313 | |
| 314 | if ((num_modules > 0) && (break_type != eSetTypeAddress)) |
| 315 | use_module = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 316 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 317 | switch (break_type) |
| 318 | { |
| 319 | case eSetTypeFileAndLine: // Breakpoint by source position |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 320 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 321 | FileSpec file; |
| 322 | if (m_options.m_filename.empty()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 323 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 324 | StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; |
| 325 | if (cur_frame == NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 326 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 327 | result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 328 | result.SetStatus (eReturnStatusFailed); |
| 329 | break; |
| 330 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 331 | else if (!cur_frame->HasDebugInformation()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 332 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 333 | result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); |
| 334 | result.SetStatus (eReturnStatusFailed); |
| 335 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 336 | } |
| 337 | else |
| 338 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 339 | const SymbolContext &context = cur_frame->GetSymbolContext(true); |
| 340 | if (context.line_entry.file) |
| 341 | { |
| 342 | file = context.line_entry.file; |
| 343 | } |
| 344 | else if (context.comp_unit != NULL) |
| 345 | { file = context.comp_unit; |
| 346 | } |
| 347 | else |
| 348 | { |
| 349 | result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); |
| 350 | result.SetStatus (eReturnStatusFailed); |
| 351 | break; |
| 352 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 353 | } |
| 354 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 355 | else |
| 356 | { |
| 357 | file.SetFile(m_options.m_filename.c_str()); |
| 358 | } |
| 359 | |
| 360 | if (use_module) |
| 361 | { |
| 362 | for (int i = 0; i < num_modules; ++i) |
| 363 | { |
| 364 | module.SetFile(m_options.m_modules[i].c_str()); |
| 365 | bp = target->CreateBreakpoint (&module, |
| 366 | file, |
| 367 | m_options.m_line_num, |
| 368 | m_options.m_ignore_inlines).get(); |
| 369 | if (bp) |
| 370 | { |
| 371 | StreamString &output_stream = result.GetOutputStream(); |
| 372 | output_stream.Printf ("Breakpoint created: "); |
| 373 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 374 | output_stream.EOL(); |
| 375 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 380 | m_options.m_modules[i].c_str()); |
| 381 | result.SetStatus (eReturnStatusFailed); |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | else |
| 386 | bp = target->CreateBreakpoint (NULL, |
| 387 | file, |
| 388 | m_options.m_line_num, |
| 389 | m_options.m_ignore_inlines).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 391 | break; |
| 392 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 393 | case eSetTypeAddress: // Breakpoint by address |
| 394 | bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); |
| 395 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 396 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 397 | case eSetTypeFunctionName: // Breakpoint by function name |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 398 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 399 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 400 | |
| 401 | if (name_type_mask == 0) |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 402 | name_type_mask = eFunctionNameTypeAuto; |
| 403 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 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. |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 550 | // If args is empty, we will use the last created breakpoint (if there is one.) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 551 | |
| 552 | Args temp_args; |
| 553 | |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 554 | if (args.GetArgumentCount() == 0) |
| 555 | { |
| 556 | if (target->GetLastCreatedBreakpoint() != NULL) |
| 557 | { |
| 558 | valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); |
| 559 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 560 | } |
| 561 | else |
| 562 | { |
| 563 | result.AppendError("No breakpoint specified and no last created breakpoint."); |
| 564 | result.SetStatus (eReturnStatusFailed); |
| 565 | } |
| 566 | return; |
| 567 | } |
| 568 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 569 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 570 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 571 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 572 | |
| 573 | BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); |
| 574 | |
| 575 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 576 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 577 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 578 | |
| 579 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 580 | // and put into valid_ids. |
| 581 | |
| 582 | if (result.Succeeded()) |
| 583 | { |
| 584 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 585 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 586 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 587 | const size_t count = valid_ids->GetSize(); |
| 588 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 589 | { |
| 590 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 591 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 592 | if (breakpoint != NULL) |
| 593 | { |
| 594 | int num_locations = breakpoint->GetNumLocations(); |
| 595 | if (cur_bp_id.GetLocationID() > num_locations) |
| 596 | { |
| 597 | StreamString id_str; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 598 | BreakpointID::GetCanonicalReference (&id_str, |
| 599 | cur_bp_id.GetBreakpointID(), |
| 600 | cur_bp_id.GetLocationID()); |
| 601 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 602 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 603 | id_str.GetData()); |
| 604 | result.SetStatus (eReturnStatusFailed); |
| 605 | } |
| 606 | } |
| 607 | else |
| 608 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 609 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 610 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 611 | result.SetStatus (eReturnStatusFailed); |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | //------------------------------------------------------------------------- |
| 618 | // CommandObjectBreakpointList::Options |
| 619 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 620 | #pragma mark List::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 621 | |
| 622 | CommandObjectBreakpointList::CommandOptions::CommandOptions() : |
| 623 | Options (), |
| 624 | m_level (lldb::eDescriptionLevelFull) // Breakpoint List defaults to brief descriptions |
| 625 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | CommandObjectBreakpointList::CommandOptions::~CommandOptions () |
| 629 | { |
| 630 | } |
| 631 | |
| 632 | lldb::OptionDefinition |
| 633 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 634 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 635 | { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 636 | "Show debugger internal breakpoints" }, |
| 637 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 638 | { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 639 | "Give a brief description of the breakpoint (no location info)."}, |
| 640 | |
| 641 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 642 | // But I need to see it for now, and don't want to wait. |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 643 | { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 644 | "Give a full description of the breakpoint and its locations."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 645 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 646 | { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 647 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 648 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 649 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 650 | }; |
| 651 | |
| 652 | const lldb::OptionDefinition* |
| 653 | CommandObjectBreakpointList::CommandOptions::GetDefinitions () |
| 654 | { |
| 655 | return g_option_table; |
| 656 | } |
| 657 | |
| 658 | Error |
| 659 | CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
| 660 | { |
| 661 | Error error; |
| 662 | char short_option = (char) m_getopt_table[option_idx].val; |
| 663 | |
| 664 | switch (short_option) |
| 665 | { |
| 666 | case 'b': |
| 667 | m_level = lldb::eDescriptionLevelBrief; |
| 668 | break; |
| 669 | case 'f': |
| 670 | m_level = lldb::eDescriptionLevelFull; |
| 671 | break; |
| 672 | case 'v': |
| 673 | m_level = lldb::eDescriptionLevelVerbose; |
| 674 | break; |
| 675 | case 'i': |
| 676 | m_internal = true; |
| 677 | break; |
| 678 | default: |
| 679 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 680 | break; |
| 681 | } |
| 682 | |
| 683 | return error; |
| 684 | } |
| 685 | |
| 686 | void |
| 687 | CommandObjectBreakpointList::CommandOptions::ResetOptionValues () |
| 688 | { |
| 689 | Options::ResetOptionValues(); |
| 690 | |
| 691 | m_level = lldb::eDescriptionLevelFull; |
| 692 | m_internal = false; |
| 693 | } |
| 694 | |
| 695 | //------------------------------------------------------------------------- |
| 696 | // CommandObjectBreakpointList |
| 697 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 698 | #pragma mark List |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 699 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 700 | CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 701 | CommandObject (interpreter, |
| 702 | "breakpoint list", |
| 703 | "List some or all breakpoints at configurable levels of detail.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 704 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 705 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 706 | CommandArgumentEntry arg; |
| 707 | CommandArgumentData bp_id_arg; |
| 708 | |
| 709 | // Define the first (and only) variant of this arg. |
| 710 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 711 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 712 | |
| 713 | // There is only one variant this argument could be; put it into the argument entry. |
| 714 | arg.push_back (bp_id_arg); |
| 715 | |
| 716 | // Push the data for the first argument into the m_arguments vector. |
| 717 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | CommandObjectBreakpointList::~CommandObjectBreakpointList () |
| 721 | { |
| 722 | } |
| 723 | |
| 724 | Options * |
| 725 | CommandObjectBreakpointList::GetOptions () |
| 726 | { |
| 727 | return &m_options; |
| 728 | } |
| 729 | |
| 730 | bool |
| 731 | CommandObjectBreakpointList::Execute |
| 732 | ( |
| 733 | Args& args, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 734 | CommandReturnObject &result |
| 735 | ) |
| 736 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 737 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 738 | if (target == NULL) |
| 739 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 740 | result.AppendError ("Invalid target. No current target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 741 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 742 | return true; |
| 743 | } |
| 744 | |
| 745 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 746 | Mutex::Locker locker; |
| 747 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 748 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 749 | size_t num_breakpoints = breakpoints.GetSize(); |
| 750 | |
| 751 | if (num_breakpoints == 0) |
| 752 | { |
| 753 | result.AppendMessage ("No breakpoints currently set."); |
| 754 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 755 | return true; |
| 756 | } |
| 757 | |
| 758 | StreamString &output_stream = result.GetOutputStream(); |
| 759 | |
| 760 | if (args.GetArgumentCount() == 0) |
| 761 | { |
| 762 | // No breakpoint selected; show info about all currently set breakpoints. |
| 763 | result.AppendMessage ("Current breakpoints:"); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 764 | for (size_t i = 0; i < num_breakpoints; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 765 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 766 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).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 | // Particular breakpoints selected; show info about that breakpoint. |
| 774 | BreakpointIDList valid_bp_ids; |
| 775 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 776 | |
| 777 | if (result.Succeeded()) |
| 778 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 779 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 780 | { |
| 781 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 782 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 783 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 784 | } |
| 785 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 786 | } |
| 787 | else |
| 788 | { |
| 789 | result.AppendError ("Invalid breakpoint id."); |
| 790 | result.SetStatus (eReturnStatusFailed); |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | return result.Succeeded(); |
| 795 | } |
| 796 | |
| 797 | //------------------------------------------------------------------------- |
| 798 | // CommandObjectBreakpointEnable |
| 799 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 800 | #pragma mark Enable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 801 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 802 | CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 803 | CommandObject (interpreter, |
| 804 | "enable", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 805 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 806 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 807 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 808 | CommandArgumentEntry arg; |
| 809 | CommandArgumentData bp_id_arg; |
| 810 | CommandArgumentData bp_id_range_arg; |
| 811 | |
| 812 | // Create the first variant for the first (and only) argument for this command. |
| 813 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 814 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 815 | |
| 816 | // Create the second variant for the first (and only) argument for this command. |
| 817 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 818 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 819 | |
| 820 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 821 | // Push both variants into the entry for the first argument for this command. |
| 822 | arg.push_back (bp_id_arg); |
| 823 | arg.push_back (bp_id_range_arg); |
| 824 | |
| 825 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 826 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | |
| 830 | CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () |
| 831 | { |
| 832 | } |
| 833 | |
| 834 | |
| 835 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 836 | CommandObjectBreakpointEnable::Execute |
| 837 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 838 | Args& args, |
| 839 | CommandReturnObject &result |
| 840 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 841 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 842 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 843 | if (target == NULL) |
| 844 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 845 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 846 | result.SetStatus (eReturnStatusFailed); |
| 847 | return false; |
| 848 | } |
| 849 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 850 | Mutex::Locker locker; |
| 851 | target->GetBreakpointList().GetListMutex(locker); |
| 852 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 853 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 854 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 855 | size_t num_breakpoints = breakpoints.GetSize(); |
| 856 | |
| 857 | if (num_breakpoints == 0) |
| 858 | { |
| 859 | result.AppendError ("No breakpoints exist to be enabled."); |
| 860 | result.SetStatus (eReturnStatusFailed); |
| 861 | return false; |
| 862 | } |
| 863 | |
| 864 | if (args.GetArgumentCount() == 0) |
| 865 | { |
| 866 | // No breakpoint selected; enable all currently set breakpoints. |
| 867 | target->EnableAllBreakpoints (); |
| 868 | result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints); |
| 869 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 870 | } |
| 871 | else |
| 872 | { |
| 873 | // Particular breakpoint selected; enable that breakpoint. |
| 874 | BreakpointIDList valid_bp_ids; |
| 875 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 876 | |
| 877 | if (result.Succeeded()) |
| 878 | { |
| 879 | int enable_count = 0; |
| 880 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 881 | const size_t count = valid_bp_ids.GetSize(); |
| 882 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 883 | { |
| 884 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 885 | |
| 886 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 887 | { |
| 888 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 889 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 890 | { |
| 891 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 892 | if (location) |
| 893 | { |
| 894 | location->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 895 | ++loc_count; |
| 896 | } |
| 897 | } |
| 898 | else |
| 899 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 900 | breakpoint->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 901 | ++enable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 902 | } |
| 903 | } |
| 904 | } |
| 905 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 906 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | return result.Succeeded(); |
| 911 | } |
| 912 | |
| 913 | //------------------------------------------------------------------------- |
| 914 | // CommandObjectBreakpointDisable |
| 915 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 916 | #pragma mark Disable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 917 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 918 | CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 919 | CommandObject (interpreter, |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 920 | "breakpoint disable", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 921 | "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] | 922 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 923 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 924 | CommandArgumentEntry arg; |
| 925 | CommandArgumentData bp_id_arg; |
| 926 | CommandArgumentData bp_id_range_arg; |
| 927 | |
| 928 | // Create the first variant for the first (and only) argument for this command. |
| 929 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 930 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 931 | |
| 932 | // Create the second variant for the first (and only) argument for this command. |
| 933 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 934 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 935 | |
| 936 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 937 | // Push both variants into the entry for the first argument for this command. |
| 938 | arg.push_back (bp_id_arg); |
| 939 | arg.push_back (bp_id_range_arg); |
| 940 | |
| 941 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 942 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () |
| 946 | { |
| 947 | } |
| 948 | |
| 949 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 950 | CommandObjectBreakpointDisable::Execute |
| 951 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 952 | Args& args, |
| 953 | CommandReturnObject &result |
| 954 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 955 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 956 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 957 | if (target == NULL) |
| 958 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 959 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 960 | result.SetStatus (eReturnStatusFailed); |
| 961 | return false; |
| 962 | } |
| 963 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 964 | Mutex::Locker locker; |
| 965 | target->GetBreakpointList().GetListMutex(locker); |
| 966 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 967 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 968 | size_t num_breakpoints = breakpoints.GetSize(); |
| 969 | |
| 970 | if (num_breakpoints == 0) |
| 971 | { |
| 972 | result.AppendError ("No breakpoints exist to be disabled."); |
| 973 | result.SetStatus (eReturnStatusFailed); |
| 974 | return false; |
| 975 | } |
| 976 | |
| 977 | if (args.GetArgumentCount() == 0) |
| 978 | { |
| 979 | // No breakpoint selected; disable all currently set breakpoints. |
| 980 | target->DisableAllBreakpoints (); |
| 981 | result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints); |
| 982 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 983 | } |
| 984 | else |
| 985 | { |
| 986 | // Particular breakpoint selected; disable that breakpoint. |
| 987 | BreakpointIDList valid_bp_ids; |
| 988 | |
| 989 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 990 | |
| 991 | if (result.Succeeded()) |
| 992 | { |
| 993 | int disable_count = 0; |
| 994 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 995 | const size_t count = valid_bp_ids.GetSize(); |
| 996 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 997 | { |
| 998 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 999 | |
| 1000 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1001 | { |
| 1002 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1003 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1004 | { |
| 1005 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1006 | if (location) |
| 1007 | { |
| 1008 | location->SetEnabled (false); |
| 1009 | ++loc_count; |
| 1010 | } |
| 1011 | } |
| 1012 | else |
| 1013 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1014 | breakpoint->SetEnabled (false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1015 | ++disable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1020 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1021 | } |
| 1022 | } |
| 1023 | |
| 1024 | return result.Succeeded(); |
| 1025 | } |
| 1026 | |
| 1027 | //------------------------------------------------------------------------- |
| 1028 | // CommandObjectBreakpointDelete |
| 1029 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1030 | #pragma mark Delete |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1031 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1032 | CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : |
| 1033 | CommandObject (interpreter, |
| 1034 | "breakpoint delete", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 1035 | "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] | 1036 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1037 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1038 | CommandArgumentEntry arg; |
| 1039 | CommandArgumentData bp_id_arg; |
| 1040 | CommandArgumentData bp_id_range_arg; |
| 1041 | |
| 1042 | // Create the first variant for the first (and only) argument for this command. |
| 1043 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1044 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1045 | |
| 1046 | // Create the second variant for the first (and only) argument for this command. |
| 1047 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1048 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1049 | |
| 1050 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1051 | // Push both variants into the entry for the first argument for this command. |
| 1052 | arg.push_back (bp_id_arg); |
| 1053 | arg.push_back (bp_id_range_arg); |
| 1054 | |
| 1055 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1056 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1057 | } |
| 1058 | |
| 1059 | |
| 1060 | CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () |
| 1061 | { |
| 1062 | } |
| 1063 | |
| 1064 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1065 | CommandObjectBreakpointDelete::Execute |
| 1066 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1067 | Args& args, |
| 1068 | CommandReturnObject &result |
| 1069 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1070 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1071 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1072 | if (target == NULL) |
| 1073 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1074 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1075 | result.SetStatus (eReturnStatusFailed); |
| 1076 | return false; |
| 1077 | } |
| 1078 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1079 | Mutex::Locker locker; |
| 1080 | target->GetBreakpointList().GetListMutex(locker); |
| 1081 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1082 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1083 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1084 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1085 | |
| 1086 | if (num_breakpoints == 0) |
| 1087 | { |
| 1088 | result.AppendError ("No breakpoints exist to be deleted."); |
| 1089 | result.SetStatus (eReturnStatusFailed); |
| 1090 | return false; |
| 1091 | } |
| 1092 | |
| 1093 | if (args.GetArgumentCount() == 0) |
| 1094 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1095 | if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1096 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1097 | result.AppendMessage("Operation cancelled..."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1098 | } |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1099 | else |
| 1100 | { |
| 1101 | target->RemoveAllBreakpoints (); |
| 1102 | result.AppendMessageWithFormat ("All breakpoints removed. (%d breakpoints)\n", num_breakpoints); |
| 1103 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1104 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1105 | } |
| 1106 | else |
| 1107 | { |
| 1108 | // Particular breakpoint selected; disable that breakpoint. |
| 1109 | BreakpointIDList valid_bp_ids; |
| 1110 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1111 | |
| 1112 | if (result.Succeeded()) |
| 1113 | { |
| 1114 | int delete_count = 0; |
| 1115 | int disable_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1116 | const size_t count = valid_bp_ids.GetSize(); |
| 1117 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1118 | { |
| 1119 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1120 | |
| 1121 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1122 | { |
| 1123 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1124 | { |
| 1125 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1126 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1127 | // It makes no sense to try to delete individual locations, so we disable them instead. |
| 1128 | if (location) |
| 1129 | { |
| 1130 | location->SetEnabled (false); |
| 1131 | ++disable_count; |
| 1132 | } |
| 1133 | } |
| 1134 | else |
| 1135 | { |
| 1136 | target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); |
| 1137 | ++delete_count; |
| 1138 | } |
| 1139 | } |
| 1140 | } |
| 1141 | result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", |
| 1142 | delete_count, disable_count); |
| 1143 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1144 | } |
| 1145 | } |
| 1146 | return result.Succeeded(); |
| 1147 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1148 | |
| 1149 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1150 | // CommandObjectBreakpointModify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1151 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1152 | #pragma mark Modify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1153 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1154 | CommandObjectBreakpointModify::CommandOptions::CommandOptions() : |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1155 | Options (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1156 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1157 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1158 | m_thread_index (UINT32_MAX), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1159 | m_thread_name(), |
| 1160 | m_queue_name(), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1161 | m_condition (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1162 | m_enable_passed (false), |
| 1163 | m_enable_value (false), |
| 1164 | m_name_passed (false), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1165 | m_queue_passed (false), |
| 1166 | m_condition_passed (false) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1167 | { |
| 1168 | } |
| 1169 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1170 | CommandObjectBreakpointModify::CommandOptions::~CommandOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1171 | { |
| 1172 | } |
| 1173 | |
| 1174 | lldb::OptionDefinition |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1175 | CommandObjectBreakpointModify::CommandOptions::g_option_table[] = |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1176 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 1177 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, |
| 1178 | { 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."}, |
| 1179 | { 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."}, |
| 1180 | { 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."}, |
| 1181 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1182 | { LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, NULL, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."}, |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 1183 | { LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, eArgTypeNone, "Enable the breakpoint."}, |
| 1184 | { LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, eArgTypeNone, "Disable the breakpoint."}, |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1185 | { 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1186 | }; |
| 1187 | |
| 1188 | const lldb::OptionDefinition* |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1189 | CommandObjectBreakpointModify::CommandOptions::GetDefinitions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1190 | { |
| 1191 | return g_option_table; |
| 1192 | } |
| 1193 | |
| 1194 | Error |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1195 | CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1196 | { |
| 1197 | Error error; |
| 1198 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1199 | |
| 1200 | switch (short_option) |
| 1201 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1202 | case 'c': |
| 1203 | if (option_arg != NULL) |
| 1204 | m_condition = option_arg; |
| 1205 | else |
| 1206 | m_condition.clear(); |
| 1207 | m_condition_passed = true; |
| 1208 | break; |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1209 | case 'd': |
| 1210 | m_enable_passed = true; |
| 1211 | m_enable_value = false; |
| 1212 | break; |
| 1213 | case 'e': |
| 1214 | m_enable_passed = true; |
| 1215 | m_enable_value = true; |
| 1216 | break; |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 1217 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1218 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1219 | m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 1220 | if (m_ignore_count == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1221 | error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); |
| 1222 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1223 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1224 | case 't' : |
| 1225 | { |
| 1226 | m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); |
| 1227 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 1228 | error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); |
| 1229 | } |
| 1230 | break; |
| 1231 | case 'T': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1232 | if (option_arg != NULL) |
| 1233 | m_thread_name = option_arg; |
| 1234 | else |
| 1235 | m_thread_name.clear(); |
| 1236 | m_name_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1237 | break; |
| 1238 | case 'q': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1239 | if (option_arg != NULL) |
| 1240 | m_queue_name = option_arg; |
| 1241 | else |
| 1242 | m_queue_name.clear(); |
| 1243 | m_queue_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1244 | break; |
| 1245 | case 'x': |
| 1246 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1247 | m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); |
| 1248 | if (m_thread_id == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1249 | error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); |
| 1250 | |
| 1251 | } |
| 1252 | break; |
| 1253 | default: |
| 1254 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 1255 | break; |
| 1256 | } |
| 1257 | |
| 1258 | return error; |
| 1259 | } |
| 1260 | |
| 1261 | void |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1262 | CommandObjectBreakpointModify::CommandOptions::ResetOptionValues () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1263 | { |
| 1264 | Options::ResetOptionValues(); |
| 1265 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1266 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1267 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1268 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1269 | m_thread_name.clear(); |
| 1270 | m_queue_name.clear(); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1271 | m_condition.clear(); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1272 | m_enable_passed = false; |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1273 | m_queue_passed = false; |
| 1274 | m_name_passed = false; |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1275 | m_condition_passed = false; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1276 | } |
| 1277 | |
| 1278 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1279 | // CommandObjectBreakpointModify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1280 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1281 | #pragma mark Modify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1282 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1283 | CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : |
| 1284 | CommandObject (interpreter, |
| 1285 | "breakpoint modify", |
| 1286 | "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] | 1287 | NULL) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1288 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1289 | CommandArgumentEntry arg; |
| 1290 | CommandArgumentData bp_id_arg; |
| 1291 | CommandArgumentData bp_id_range_arg; |
| 1292 | |
| 1293 | // Create the first variant for the first (and only) argument for this command. |
| 1294 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1295 | bp_id_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1296 | |
| 1297 | // Create the second variant for the first (and only) argument for this command. |
| 1298 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1299 | bp_id_range_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1300 | |
| 1301 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1302 | // Push both variants into the entry for the first argument for this command. |
| 1303 | arg.push_back (bp_id_arg); |
| 1304 | arg.push_back (bp_id_range_arg); |
| 1305 | |
| 1306 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1307 | m_arguments.push_back (arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1308 | } |
| 1309 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1310 | CommandObjectBreakpointModify::~CommandObjectBreakpointModify () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1311 | { |
| 1312 | } |
| 1313 | |
| 1314 | Options * |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1315 | CommandObjectBreakpointModify::GetOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1316 | { |
| 1317 | return &m_options; |
| 1318 | } |
| 1319 | |
| 1320 | bool |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1321 | CommandObjectBreakpointModify::Execute |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1322 | ( |
| 1323 | Args& command, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1324 | CommandReturnObject &result |
| 1325 | ) |
| 1326 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1327 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1328 | if (target == NULL) |
| 1329 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1330 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1331 | result.SetStatus (eReturnStatusFailed); |
| 1332 | return false; |
| 1333 | } |
| 1334 | |
| 1335 | Mutex::Locker locker; |
| 1336 | target->GetBreakpointList().GetListMutex(locker); |
| 1337 | |
| 1338 | BreakpointIDList valid_bp_ids; |
| 1339 | |
| 1340 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 1341 | |
| 1342 | if (result.Succeeded()) |
| 1343 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1344 | const size_t count = valid_bp_ids.GetSize(); |
| 1345 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1346 | { |
| 1347 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1348 | |
| 1349 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1350 | { |
| 1351 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1352 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1353 | { |
| 1354 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1355 | if (location) |
| 1356 | { |
| 1357 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1358 | location->SetThreadID (m_options.m_thread_id); |
| 1359 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1360 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1361 | location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1362 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1363 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1364 | location->GetLocationOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1365 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1366 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1367 | location->GetLocationOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1368 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1369 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1370 | location->GetLocationOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1371 | |
| 1372 | if (m_options.m_enable_passed) |
| 1373 | location->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1374 | |
| 1375 | if (m_options.m_condition_passed) |
| 1376 | location->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1377 | } |
| 1378 | } |
| 1379 | else |
| 1380 | { |
| 1381 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1382 | bp->SetThreadID (m_options.m_thread_id); |
| 1383 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1384 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1385 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1386 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1387 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1388 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1389 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1390 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1391 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1392 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1393 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1394 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1395 | |
| 1396 | if (m_options.m_enable_passed) |
| 1397 | bp->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame^] | 1398 | |
| 1399 | if (m_options.m_condition_passed) |
| 1400 | bp->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1401 | } |
| 1402 | } |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | return result.Succeeded(); |
| 1407 | } |
| 1408 | |
| 1409 | |