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; |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 310 | FileSpec module_spec; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 357 | file.SetFile(m_options.m_filename.c_str(), false); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | if (use_module) |
| 361 | { |
| 362 | for (int i = 0; i < num_modules; ++i) |
| 363 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 364 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 365 | bp = target->CreateBreakpoint (&module_spec, |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 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(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame^] | 375 | if (bp->GetNumLocations() == 0) |
| 376 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 377 | " locations.\n"); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 378 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 379 | } |
| 380 | else |
| 381 | { |
| 382 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 383 | m_options.m_modules[i].c_str()); |
| 384 | result.SetStatus (eReturnStatusFailed); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | else |
| 389 | bp = target->CreateBreakpoint (NULL, |
| 390 | file, |
| 391 | m_options.m_line_num, |
| 392 | m_options.m_ignore_inlines).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 393 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 394 | break; |
| 395 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 396 | case eSetTypeAddress: // Breakpoint by address |
| 397 | bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); |
| 398 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 399 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 400 | case eSetTypeFunctionName: // Breakpoint by function name |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 401 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 402 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 403 | |
| 404 | if (name_type_mask == 0) |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 405 | name_type_mask = eFunctionNameTypeAuto; |
| 406 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 407 | if (use_module) |
| 408 | { |
| 409 | for (int i = 0; i < num_modules; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 410 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 411 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 412 | bp = target->CreateBreakpoint (&module_spec, |
| 413 | m_options.m_func_name.c_str(), |
| 414 | name_type_mask, |
| 415 | Breakpoint::Exact).get(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 416 | if (bp) |
| 417 | { |
| 418 | StreamString &output_stream = result.GetOutputStream(); |
| 419 | output_stream.Printf ("Breakpoint created: "); |
| 420 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 421 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame^] | 422 | if (bp->GetNumLocations() == 0) |
| 423 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 424 | " locations.\n"); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 425 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 426 | } |
| 427 | else |
| 428 | { |
| 429 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 430 | m_options.m_modules[i].c_str()); |
| 431 | result.SetStatus (eReturnStatusFailed); |
| 432 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 433 | } |
| 434 | } |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 435 | else |
| 436 | 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] | 437 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 438 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 439 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 440 | case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name |
| 441 | { |
| 442 | RegularExpression regexp(m_options.m_func_regexp.c_str()); |
| 443 | if (use_module) |
| 444 | { |
| 445 | for (int i = 0; i < num_modules; ++i) |
| 446 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 447 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 448 | bp = target->CreateBreakpoint (&module_spec, regexp).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 449 | if (bp) |
| 450 | { |
| 451 | StreamString &output_stream = result.GetOutputStream(); |
| 452 | output_stream.Printf ("Breakpoint created: "); |
| 453 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 454 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame^] | 455 | if (bp->GetNumLocations() == 0) |
| 456 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 457 | " locations.\n"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 458 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 463 | m_options.m_modules[i].c_str()); |
| 464 | result.SetStatus (eReturnStatusFailed); |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | else |
| 469 | bp = target->CreateBreakpoint (NULL, regexp).get(); |
| 470 | } |
| 471 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 472 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 473 | default: |
| 474 | break; |
| 475 | } |
| 476 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 477 | // Now set the various options that were passed in: |
| 478 | if (bp) |
| 479 | { |
| 480 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 481 | bp->SetThreadID (m_options.m_thread_id); |
| 482 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 483 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 484 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 485 | |
| 486 | if (!m_options.m_thread_name.empty()) |
| 487 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 488 | |
| 489 | if (!m_options.m_queue_name.empty()) |
| 490 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 491 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 492 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 493 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
| 494 | } |
| 495 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 496 | if (bp && !use_module) |
| 497 | { |
| 498 | StreamString &output_stream = result.GetOutputStream(); |
| 499 | output_stream.Printf ("Breakpoint created: "); |
| 500 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 501 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame^] | 502 | if (bp->GetNumLocations() == 0) |
| 503 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 504 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 505 | } |
| 506 | else if (!bp) |
| 507 | { |
| 508 | result.AppendError ("Breakpoint creation failed: No breakpoint created."); |
| 509 | result.SetStatus (eReturnStatusFailed); |
| 510 | } |
| 511 | |
| 512 | return result.Succeeded(); |
| 513 | } |
| 514 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 515 | //------------------------------------------------------------------------- |
| 516 | // CommandObjectMultiwordBreakpoint |
| 517 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 518 | #pragma mark MultiwordBreakpoint |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 519 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 520 | CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 521 | CommandObjectMultiword (interpreter, |
| 522 | "breakpoint", |
| 523 | "A set of commands for operating on breakpoints. Also see regexp-break.", |
| 524 | "breakpoint <command> [<command-options>]") |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 525 | { |
| 526 | bool status; |
| 527 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 528 | CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); |
| 529 | CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); |
| 530 | CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); |
| 531 | CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); |
| 532 | CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 533 | CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 534 | CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 535 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 536 | command_command_object->SetCommandName ("breakpoint command"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 537 | enable_command_object->SetCommandName("breakpoint enable"); |
| 538 | disable_command_object->SetCommandName("breakpoint disable"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 539 | list_command_object->SetCommandName ("breakpoint list"); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 540 | modify_command_object->SetCommandName ("breakpoint modify"); |
| 541 | set_command_object->SetCommandName("breakpoint set"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 542 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 543 | status = LoadSubCommand ("list", list_command_object); |
| 544 | status = LoadSubCommand ("enable", enable_command_object); |
| 545 | status = LoadSubCommand ("disable", disable_command_object); |
| 546 | status = LoadSubCommand ("delete", delete_command_object); |
| 547 | status = LoadSubCommand ("set", set_command_object); |
| 548 | status = LoadSubCommand ("command", command_command_object); |
| 549 | status = LoadSubCommand ("modify", modify_command_object); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () |
| 553 | { |
| 554 | } |
| 555 | |
| 556 | void |
| 557 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result, |
| 558 | BreakpointIDList *valid_ids) |
| 559 | { |
| 560 | // args can be strings representing 1). integers (for breakpoint ids) |
| 561 | // 2). the full breakpoint & location canonical representation |
| 562 | // 3). the word "to" or a hyphen, representing a range (in which case there |
| 563 | // 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] | 564 | // 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] | 565 | |
| 566 | Args temp_args; |
| 567 | |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 568 | if (args.GetArgumentCount() == 0) |
| 569 | { |
| 570 | if (target->GetLastCreatedBreakpoint() != NULL) |
| 571 | { |
| 572 | valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); |
| 573 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 574 | } |
| 575 | else |
| 576 | { |
| 577 | result.AppendError("No breakpoint specified and no last created breakpoint."); |
| 578 | result.SetStatus (eReturnStatusFailed); |
| 579 | } |
| 580 | return; |
| 581 | } |
| 582 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 583 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 584 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 585 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 586 | |
| 587 | BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); |
| 588 | |
| 589 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 590 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 591 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 592 | |
| 593 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 594 | // and put into valid_ids. |
| 595 | |
| 596 | if (result.Succeeded()) |
| 597 | { |
| 598 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 599 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 600 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 601 | const size_t count = valid_ids->GetSize(); |
| 602 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 603 | { |
| 604 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 605 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 606 | if (breakpoint != NULL) |
| 607 | { |
| 608 | int num_locations = breakpoint->GetNumLocations(); |
| 609 | if (cur_bp_id.GetLocationID() > num_locations) |
| 610 | { |
| 611 | StreamString id_str; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 612 | BreakpointID::GetCanonicalReference (&id_str, |
| 613 | cur_bp_id.GetBreakpointID(), |
| 614 | cur_bp_id.GetLocationID()); |
| 615 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 616 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 617 | id_str.GetData()); |
| 618 | result.SetStatus (eReturnStatusFailed); |
| 619 | } |
| 620 | } |
| 621 | else |
| 622 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 623 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 624 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 625 | result.SetStatus (eReturnStatusFailed); |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | //------------------------------------------------------------------------- |
| 632 | // CommandObjectBreakpointList::Options |
| 633 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 634 | #pragma mark List::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 635 | |
| 636 | CommandObjectBreakpointList::CommandOptions::CommandOptions() : |
| 637 | Options (), |
| 638 | m_level (lldb::eDescriptionLevelFull) // Breakpoint List defaults to brief descriptions |
| 639 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | CommandObjectBreakpointList::CommandOptions::~CommandOptions () |
| 643 | { |
| 644 | } |
| 645 | |
| 646 | lldb::OptionDefinition |
| 647 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 648 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 649 | { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 650 | "Show debugger internal breakpoints" }, |
| 651 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 652 | { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 653 | "Give a brief description of the breakpoint (no location info)."}, |
| 654 | |
| 655 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 656 | // 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] | 657 | { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 658 | "Give a full description of the breakpoint and its locations."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 659 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 660 | { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 661 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 662 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 663 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 664 | }; |
| 665 | |
| 666 | const lldb::OptionDefinition* |
| 667 | CommandObjectBreakpointList::CommandOptions::GetDefinitions () |
| 668 | { |
| 669 | return g_option_table; |
| 670 | } |
| 671 | |
| 672 | Error |
| 673 | CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
| 674 | { |
| 675 | Error error; |
| 676 | char short_option = (char) m_getopt_table[option_idx].val; |
| 677 | |
| 678 | switch (short_option) |
| 679 | { |
| 680 | case 'b': |
| 681 | m_level = lldb::eDescriptionLevelBrief; |
| 682 | break; |
| 683 | case 'f': |
| 684 | m_level = lldb::eDescriptionLevelFull; |
| 685 | break; |
| 686 | case 'v': |
| 687 | m_level = lldb::eDescriptionLevelVerbose; |
| 688 | break; |
| 689 | case 'i': |
| 690 | m_internal = true; |
| 691 | break; |
| 692 | default: |
| 693 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 694 | break; |
| 695 | } |
| 696 | |
| 697 | return error; |
| 698 | } |
| 699 | |
| 700 | void |
| 701 | CommandObjectBreakpointList::CommandOptions::ResetOptionValues () |
| 702 | { |
| 703 | Options::ResetOptionValues(); |
| 704 | |
| 705 | m_level = lldb::eDescriptionLevelFull; |
| 706 | m_internal = false; |
| 707 | } |
| 708 | |
| 709 | //------------------------------------------------------------------------- |
| 710 | // CommandObjectBreakpointList |
| 711 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 712 | #pragma mark List |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 713 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 714 | CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 715 | CommandObject (interpreter, |
| 716 | "breakpoint list", |
| 717 | "List some or all breakpoints at configurable levels of detail.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 718 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 719 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 720 | CommandArgumentEntry arg; |
| 721 | CommandArgumentData bp_id_arg; |
| 722 | |
| 723 | // Define the first (and only) variant of this arg. |
| 724 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 725 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 726 | |
| 727 | // There is only one variant this argument could be; put it into the argument entry. |
| 728 | arg.push_back (bp_id_arg); |
| 729 | |
| 730 | // Push the data for the first argument into the m_arguments vector. |
| 731 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | CommandObjectBreakpointList::~CommandObjectBreakpointList () |
| 735 | { |
| 736 | } |
| 737 | |
| 738 | Options * |
| 739 | CommandObjectBreakpointList::GetOptions () |
| 740 | { |
| 741 | return &m_options; |
| 742 | } |
| 743 | |
| 744 | bool |
| 745 | CommandObjectBreakpointList::Execute |
| 746 | ( |
| 747 | Args& args, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 748 | CommandReturnObject &result |
| 749 | ) |
| 750 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 751 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 752 | if (target == NULL) |
| 753 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 754 | result.AppendError ("Invalid target. No current target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 755 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 756 | return true; |
| 757 | } |
| 758 | |
| 759 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 760 | Mutex::Locker locker; |
| 761 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 762 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 763 | size_t num_breakpoints = breakpoints.GetSize(); |
| 764 | |
| 765 | if (num_breakpoints == 0) |
| 766 | { |
| 767 | result.AppendMessage ("No breakpoints currently set."); |
| 768 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 769 | return true; |
| 770 | } |
| 771 | |
| 772 | StreamString &output_stream = result.GetOutputStream(); |
| 773 | |
| 774 | if (args.GetArgumentCount() == 0) |
| 775 | { |
| 776 | // No breakpoint selected; show info about all currently set breakpoints. |
| 777 | result.AppendMessage ("Current breakpoints:"); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 778 | for (size_t i = 0; i < num_breakpoints; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 779 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 780 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 781 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 782 | } |
| 783 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 784 | } |
| 785 | else |
| 786 | { |
| 787 | // Particular breakpoints selected; show info about that breakpoint. |
| 788 | BreakpointIDList valid_bp_ids; |
| 789 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 790 | |
| 791 | if (result.Succeeded()) |
| 792 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 793 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 794 | { |
| 795 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 796 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 797 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 798 | } |
| 799 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 800 | } |
| 801 | else |
| 802 | { |
| 803 | result.AppendError ("Invalid breakpoint id."); |
| 804 | result.SetStatus (eReturnStatusFailed); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | return result.Succeeded(); |
| 809 | } |
| 810 | |
| 811 | //------------------------------------------------------------------------- |
| 812 | // CommandObjectBreakpointEnable |
| 813 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 814 | #pragma mark Enable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 815 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 816 | CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 817 | CommandObject (interpreter, |
| 818 | "enable", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 819 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 820 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 821 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 822 | CommandArgumentEntry arg; |
| 823 | CommandArgumentData bp_id_arg; |
| 824 | CommandArgumentData bp_id_range_arg; |
| 825 | |
| 826 | // Create the first variant for the first (and only) argument for this command. |
| 827 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 828 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 829 | |
| 830 | // Create the second variant for the first (and only) argument for this command. |
| 831 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 832 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 833 | |
| 834 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 835 | // Push both variants into the entry for the first argument for this command. |
| 836 | arg.push_back (bp_id_arg); |
| 837 | arg.push_back (bp_id_range_arg); |
| 838 | |
| 839 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 840 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | |
| 844 | CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () |
| 845 | { |
| 846 | } |
| 847 | |
| 848 | |
| 849 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 850 | CommandObjectBreakpointEnable::Execute |
| 851 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 852 | Args& args, |
| 853 | CommandReturnObject &result |
| 854 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 855 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 856 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 857 | if (target == NULL) |
| 858 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 859 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 860 | result.SetStatus (eReturnStatusFailed); |
| 861 | return false; |
| 862 | } |
| 863 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 864 | Mutex::Locker locker; |
| 865 | target->GetBreakpointList().GetListMutex(locker); |
| 866 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 867 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 868 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 869 | size_t num_breakpoints = breakpoints.GetSize(); |
| 870 | |
| 871 | if (num_breakpoints == 0) |
| 872 | { |
| 873 | result.AppendError ("No breakpoints exist to be enabled."); |
| 874 | result.SetStatus (eReturnStatusFailed); |
| 875 | return false; |
| 876 | } |
| 877 | |
| 878 | if (args.GetArgumentCount() == 0) |
| 879 | { |
| 880 | // No breakpoint selected; enable all currently set breakpoints. |
| 881 | target->EnableAllBreakpoints (); |
| 882 | result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints); |
| 883 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 884 | } |
| 885 | else |
| 886 | { |
| 887 | // Particular breakpoint selected; enable that breakpoint. |
| 888 | BreakpointIDList valid_bp_ids; |
| 889 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 890 | |
| 891 | if (result.Succeeded()) |
| 892 | { |
| 893 | int enable_count = 0; |
| 894 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 895 | const size_t count = valid_bp_ids.GetSize(); |
| 896 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 897 | { |
| 898 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 899 | |
| 900 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 901 | { |
| 902 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 903 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 904 | { |
| 905 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 906 | if (location) |
| 907 | { |
| 908 | location->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 909 | ++loc_count; |
| 910 | } |
| 911 | } |
| 912 | else |
| 913 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 914 | breakpoint->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 915 | ++enable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 916 | } |
| 917 | } |
| 918 | } |
| 919 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 920 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | return result.Succeeded(); |
| 925 | } |
| 926 | |
| 927 | //------------------------------------------------------------------------- |
| 928 | // CommandObjectBreakpointDisable |
| 929 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 930 | #pragma mark Disable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 931 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 932 | CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 933 | CommandObject (interpreter, |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 934 | "breakpoint disable", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 935 | "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] | 936 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 937 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 938 | CommandArgumentEntry arg; |
| 939 | CommandArgumentData bp_id_arg; |
| 940 | CommandArgumentData bp_id_range_arg; |
| 941 | |
| 942 | // Create the first variant for the first (and only) argument for this command. |
| 943 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 944 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 945 | |
| 946 | // Create the second variant for the first (and only) argument for this command. |
| 947 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 948 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 949 | |
| 950 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 951 | // Push both variants into the entry for the first argument for this command. |
| 952 | arg.push_back (bp_id_arg); |
| 953 | arg.push_back (bp_id_range_arg); |
| 954 | |
| 955 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 956 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () |
| 960 | { |
| 961 | } |
| 962 | |
| 963 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 964 | CommandObjectBreakpointDisable::Execute |
| 965 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 966 | Args& args, |
| 967 | CommandReturnObject &result |
| 968 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 969 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 970 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 971 | if (target == NULL) |
| 972 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 973 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 974 | result.SetStatus (eReturnStatusFailed); |
| 975 | return false; |
| 976 | } |
| 977 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 978 | Mutex::Locker locker; |
| 979 | target->GetBreakpointList().GetListMutex(locker); |
| 980 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 981 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 982 | size_t num_breakpoints = breakpoints.GetSize(); |
| 983 | |
| 984 | if (num_breakpoints == 0) |
| 985 | { |
| 986 | result.AppendError ("No breakpoints exist to be disabled."); |
| 987 | result.SetStatus (eReturnStatusFailed); |
| 988 | return false; |
| 989 | } |
| 990 | |
| 991 | if (args.GetArgumentCount() == 0) |
| 992 | { |
| 993 | // No breakpoint selected; disable all currently set breakpoints. |
| 994 | target->DisableAllBreakpoints (); |
| 995 | result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints); |
| 996 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 997 | } |
| 998 | else |
| 999 | { |
| 1000 | // Particular breakpoint selected; disable that breakpoint. |
| 1001 | BreakpointIDList valid_bp_ids; |
| 1002 | |
| 1003 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1004 | |
| 1005 | if (result.Succeeded()) |
| 1006 | { |
| 1007 | int disable_count = 0; |
| 1008 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1009 | const size_t count = valid_bp_ids.GetSize(); |
| 1010 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1011 | { |
| 1012 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1013 | |
| 1014 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1015 | { |
| 1016 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1017 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1018 | { |
| 1019 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1020 | if (location) |
| 1021 | { |
| 1022 | location->SetEnabled (false); |
| 1023 | ++loc_count; |
| 1024 | } |
| 1025 | } |
| 1026 | else |
| 1027 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1028 | breakpoint->SetEnabled (false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1029 | ++disable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1034 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | return result.Succeeded(); |
| 1039 | } |
| 1040 | |
| 1041 | //------------------------------------------------------------------------- |
| 1042 | // CommandObjectBreakpointDelete |
| 1043 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1044 | #pragma mark Delete |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1045 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1046 | CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : |
| 1047 | CommandObject (interpreter, |
| 1048 | "breakpoint delete", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 1049 | "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] | 1050 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1051 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1052 | CommandArgumentEntry arg; |
| 1053 | CommandArgumentData bp_id_arg; |
| 1054 | CommandArgumentData bp_id_range_arg; |
| 1055 | |
| 1056 | // Create the first variant for the first (and only) argument for this command. |
| 1057 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1058 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1059 | |
| 1060 | // Create the second variant for the first (and only) argument for this command. |
| 1061 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1062 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1063 | |
| 1064 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1065 | // Push both variants into the entry for the first argument for this command. |
| 1066 | arg.push_back (bp_id_arg); |
| 1067 | arg.push_back (bp_id_range_arg); |
| 1068 | |
| 1069 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1070 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () |
| 1075 | { |
| 1076 | } |
| 1077 | |
| 1078 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1079 | CommandObjectBreakpointDelete::Execute |
| 1080 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1081 | Args& args, |
| 1082 | CommandReturnObject &result |
| 1083 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1084 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1085 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1086 | if (target == NULL) |
| 1087 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1088 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1089 | result.SetStatus (eReturnStatusFailed); |
| 1090 | return false; |
| 1091 | } |
| 1092 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1093 | Mutex::Locker locker; |
| 1094 | target->GetBreakpointList().GetListMutex(locker); |
| 1095 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1096 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1097 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1098 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1099 | |
| 1100 | if (num_breakpoints == 0) |
| 1101 | { |
| 1102 | result.AppendError ("No breakpoints exist to be deleted."); |
| 1103 | result.SetStatus (eReturnStatusFailed); |
| 1104 | return false; |
| 1105 | } |
| 1106 | |
| 1107 | if (args.GetArgumentCount() == 0) |
| 1108 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1109 | 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] | 1110 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1111 | result.AppendMessage("Operation cancelled..."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1112 | } |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1113 | else |
| 1114 | { |
| 1115 | target->RemoveAllBreakpoints (); |
| 1116 | result.AppendMessageWithFormat ("All breakpoints removed. (%d breakpoints)\n", num_breakpoints); |
| 1117 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1118 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1119 | } |
| 1120 | else |
| 1121 | { |
| 1122 | // Particular breakpoint selected; disable that breakpoint. |
| 1123 | BreakpointIDList valid_bp_ids; |
| 1124 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1125 | |
| 1126 | if (result.Succeeded()) |
| 1127 | { |
| 1128 | int delete_count = 0; |
| 1129 | int disable_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1130 | const size_t count = valid_bp_ids.GetSize(); |
| 1131 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1132 | { |
| 1133 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1134 | |
| 1135 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1136 | { |
| 1137 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1138 | { |
| 1139 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1140 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1141 | // It makes no sense to try to delete individual locations, so we disable them instead. |
| 1142 | if (location) |
| 1143 | { |
| 1144 | location->SetEnabled (false); |
| 1145 | ++disable_count; |
| 1146 | } |
| 1147 | } |
| 1148 | else |
| 1149 | { |
| 1150 | target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); |
| 1151 | ++delete_count; |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", |
| 1156 | delete_count, disable_count); |
| 1157 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1158 | } |
| 1159 | } |
| 1160 | return result.Succeeded(); |
| 1161 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1162 | |
| 1163 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1164 | // CommandObjectBreakpointModify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1165 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1166 | #pragma mark Modify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1167 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1168 | CommandObjectBreakpointModify::CommandOptions::CommandOptions() : |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1169 | Options (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1170 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1171 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1172 | m_thread_index (UINT32_MAX), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1173 | m_thread_name(), |
| 1174 | m_queue_name(), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1175 | m_condition (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1176 | m_enable_passed (false), |
| 1177 | m_enable_value (false), |
| 1178 | m_name_passed (false), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1179 | m_queue_passed (false), |
| 1180 | m_condition_passed (false) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1181 | { |
| 1182 | } |
| 1183 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1184 | CommandObjectBreakpointModify::CommandOptions::~CommandOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1185 | { |
| 1186 | } |
| 1187 | |
| 1188 | lldb::OptionDefinition |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1189 | CommandObjectBreakpointModify::CommandOptions::g_option_table[] = |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1190 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 1191 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, |
| 1192 | { 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."}, |
| 1193 | { 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."}, |
| 1194 | { 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."}, |
| 1195 | { 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] | 1196 | { 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] | 1197 | { LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, eArgTypeNone, "Enable the breakpoint."}, |
| 1198 | { 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] | 1199 | { 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1200 | }; |
| 1201 | |
| 1202 | const lldb::OptionDefinition* |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1203 | CommandObjectBreakpointModify::CommandOptions::GetDefinitions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1204 | { |
| 1205 | return g_option_table; |
| 1206 | } |
| 1207 | |
| 1208 | Error |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1209 | CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1210 | { |
| 1211 | Error error; |
| 1212 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1213 | |
| 1214 | switch (short_option) |
| 1215 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1216 | case 'c': |
| 1217 | if (option_arg != NULL) |
| 1218 | m_condition = option_arg; |
| 1219 | else |
| 1220 | m_condition.clear(); |
| 1221 | m_condition_passed = true; |
| 1222 | break; |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1223 | case 'd': |
| 1224 | m_enable_passed = true; |
| 1225 | m_enable_value = false; |
| 1226 | break; |
| 1227 | case 'e': |
| 1228 | m_enable_passed = true; |
| 1229 | m_enable_value = true; |
| 1230 | break; |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 1231 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1232 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1233 | m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); |
| 1234 | if (m_ignore_count == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1235 | error.SetErrorStringWithFormat ("Invalid ignore count '%s'.\n", optarg); |
| 1236 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1237 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1238 | case 't' : |
| 1239 | { |
| 1240 | m_thread_id = Args::StringToUInt64(optarg, LLDB_INVALID_THREAD_ID, 0); |
| 1241 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 1242 | error.SetErrorStringWithFormat ("Invalid thread id string '%s'.\n", optarg); |
| 1243 | } |
| 1244 | break; |
| 1245 | case 'T': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1246 | if (option_arg != NULL) |
| 1247 | m_thread_name = option_arg; |
| 1248 | else |
| 1249 | m_thread_name.clear(); |
| 1250 | m_name_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1251 | break; |
| 1252 | case 'q': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1253 | if (option_arg != NULL) |
| 1254 | m_queue_name = option_arg; |
| 1255 | else |
| 1256 | m_queue_name.clear(); |
| 1257 | m_queue_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1258 | break; |
| 1259 | case 'x': |
| 1260 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1261 | m_thread_index = Args::StringToUInt32 (optarg, UINT32_MAX, 0); |
| 1262 | if (m_thread_id == UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1263 | error.SetErrorStringWithFormat ("Invalid thread index string '%s'.\n", optarg); |
| 1264 | |
| 1265 | } |
| 1266 | break; |
| 1267 | default: |
| 1268 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 1269 | break; |
| 1270 | } |
| 1271 | |
| 1272 | return error; |
| 1273 | } |
| 1274 | |
| 1275 | void |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1276 | CommandObjectBreakpointModify::CommandOptions::ResetOptionValues () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1277 | { |
| 1278 | Options::ResetOptionValues(); |
| 1279 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1280 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1281 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1282 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1283 | m_thread_name.clear(); |
| 1284 | m_queue_name.clear(); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1285 | m_condition.clear(); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1286 | m_enable_passed = false; |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1287 | m_queue_passed = false; |
| 1288 | m_name_passed = false; |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1289 | m_condition_passed = false; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1290 | } |
| 1291 | |
| 1292 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1293 | // CommandObjectBreakpointModify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1294 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1295 | #pragma mark Modify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1296 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1297 | CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : |
| 1298 | CommandObject (interpreter, |
| 1299 | "breakpoint modify", |
| 1300 | "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] | 1301 | NULL) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1302 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1303 | CommandArgumentEntry arg; |
| 1304 | CommandArgumentData bp_id_arg; |
| 1305 | CommandArgumentData bp_id_range_arg; |
| 1306 | |
| 1307 | // Create the first variant for the first (and only) argument for this command. |
| 1308 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1309 | bp_id_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1310 | |
| 1311 | // Create the second variant for the first (and only) argument for this command. |
| 1312 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1313 | bp_id_range_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1314 | |
| 1315 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1316 | // Push both variants into the entry for the first argument for this command. |
| 1317 | arg.push_back (bp_id_arg); |
| 1318 | arg.push_back (bp_id_range_arg); |
| 1319 | |
| 1320 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1321 | m_arguments.push_back (arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1322 | } |
| 1323 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1324 | CommandObjectBreakpointModify::~CommandObjectBreakpointModify () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1325 | { |
| 1326 | } |
| 1327 | |
| 1328 | Options * |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1329 | CommandObjectBreakpointModify::GetOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1330 | { |
| 1331 | return &m_options; |
| 1332 | } |
| 1333 | |
| 1334 | bool |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1335 | CommandObjectBreakpointModify::Execute |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1336 | ( |
| 1337 | Args& command, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1338 | CommandReturnObject &result |
| 1339 | ) |
| 1340 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1341 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1342 | if (target == NULL) |
| 1343 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1344 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1345 | result.SetStatus (eReturnStatusFailed); |
| 1346 | return false; |
| 1347 | } |
| 1348 | |
| 1349 | Mutex::Locker locker; |
| 1350 | target->GetBreakpointList().GetListMutex(locker); |
| 1351 | |
| 1352 | BreakpointIDList valid_bp_ids; |
| 1353 | |
| 1354 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 1355 | |
| 1356 | if (result.Succeeded()) |
| 1357 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1358 | const size_t count = valid_bp_ids.GetSize(); |
| 1359 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1360 | { |
| 1361 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1362 | |
| 1363 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1364 | { |
| 1365 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1366 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1367 | { |
| 1368 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1369 | if (location) |
| 1370 | { |
| 1371 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1372 | location->SetThreadID (m_options.m_thread_id); |
| 1373 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1374 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1375 | location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1376 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1377 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1378 | location->GetLocationOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1379 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1380 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1381 | location->GetLocationOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1382 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1383 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1384 | location->GetLocationOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1385 | |
| 1386 | if (m_options.m_enable_passed) |
| 1387 | location->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1388 | |
| 1389 | if (m_options.m_condition_passed) |
| 1390 | location->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1391 | } |
| 1392 | } |
| 1393 | else |
| 1394 | { |
| 1395 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 1396 | bp->SetThreadID (m_options.m_thread_id); |
| 1397 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1398 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1399 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1400 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1401 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1402 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1403 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1404 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1405 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1406 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1407 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1408 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1409 | |
| 1410 | if (m_options.m_enable_passed) |
| 1411 | bp->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1412 | |
| 1413 | if (m_options.m_condition_passed) |
| 1414 | bp->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1415 | } |
| 1416 | } |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | return result.Succeeded(); |
| 1421 | } |
| 1422 | |
| 1423 | |