Chris Lattner | 30fdc8d | 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" |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 20 | #include "lldb/Host/StringConvert.h" |
Jim Ingham | 40af72e | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 21 | #include "lldb/Interpreter/Options.h" |
Zachary Turner | 32abc6e | 2015-03-03 19:23:09 +0000 | [diff] [blame] | 22 | #include "lldb/Interpreter/OptionValueBoolean.h" |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 23 | #include "lldb/Interpreter/OptionValueString.h" |
| 24 | #include "lldb/Interpreter/OptionValueUInt64.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | #include "lldb/Core/RegularExpression.h" |
| 26 | #include "lldb/Core/StreamString.h" |
| 27 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 28 | #include "lldb/Interpreter/CommandReturnObject.h" |
Jim Ingham | 0e0984e | 2015-09-02 01:06:46 +0000 | [diff] [blame] | 29 | #include "lldb/Target/Language.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | #include "lldb/Target/Target.h" |
| 31 | #include "lldb/Interpreter/CommandCompletions.h" |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 32 | #include "lldb/Target/StackFrame.h" |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 33 | #include "lldb/Target/Thread.h" |
| 34 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
Johnny Chen | b7234e4 | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 36 | #include <vector> |
| 37 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | using namespace lldb; |
| 39 | using namespace lldb_private; |
| 40 | |
| 41 | static void |
Jim Ingham | 85e8b81 | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 42 | AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | { |
| 44 | s->IndentMore(); |
| 45 | bp->GetDescription (s, level, true); |
| 46 | s->IndentLess(); |
| 47 | s->EOL(); |
| 48 | } |
| 49 | |
| 50 | //------------------------------------------------------------------------- |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 51 | // CommandObjectBreakpointSet |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 52 | //------------------------------------------------------------------------- |
| 53 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 54 | |
| 55 | class CommandObjectBreakpointSet : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 57 | public: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 58 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 59 | typedef enum BreakpointSetType |
| 60 | { |
| 61 | eSetTypeInvalid, |
| 62 | eSetTypeFileAndLine, |
| 63 | eSetTypeAddress, |
| 64 | eSetTypeFunctionName, |
| 65 | eSetTypeFunctionRegexp, |
| 66 | eSetTypeSourceRegexp, |
| 67 | eSetTypeException |
| 68 | } BreakpointSetType; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 69 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 70 | CommandObjectBreakpointSet (CommandInterpreter &interpreter) : |
| 71 | CommandObjectParsed (interpreter, |
| 72 | "breakpoint set", |
| 73 | "Sets a breakpoint or set of breakpoints in the executable.", |
| 74 | "breakpoint set <cmd-options>"), |
| 75 | m_options (interpreter) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 80 | ~CommandObjectBreakpointSet () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 81 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 82 | Options * |
| 83 | GetOptions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 84 | { |
| 85 | return &m_options; |
| 86 | } |
| 87 | |
| 88 | class CommandOptions : public Options |
| 89 | { |
| 90 | public: |
| 91 | |
| 92 | CommandOptions (CommandInterpreter &interpreter) : |
| 93 | Options (interpreter), |
| 94 | m_condition (), |
| 95 | m_filenames (), |
| 96 | m_line_num (0), |
| 97 | m_column (0), |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 98 | m_func_names (), |
| 99 | m_func_name_type_mask (eFunctionNameTypeNone), |
| 100 | m_func_regexp (), |
| 101 | m_source_text_regexp(), |
| 102 | m_modules (), |
| 103 | m_load_addr(), |
| 104 | m_ignore_count (0), |
| 105 | m_thread_id(LLDB_INVALID_THREAD_ID), |
| 106 | m_thread_index (UINT32_MAX), |
| 107 | m_thread_name(), |
| 108 | m_queue_name(), |
| 109 | m_catch_bp (false), |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 110 | m_throw_bp (true), |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 111 | m_hardware (false), |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 112 | m_exception_language (eLanguageTypeUnknown), |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 113 | m_language (lldb::eLanguageTypeUnknown), |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 114 | m_skip_prologue (eLazyBoolCalculate), |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 115 | m_one_shot (false), |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 116 | m_all_files (false), |
| 117 | m_move_to_nearest_code (eLazyBoolCalculate) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 118 | { |
| 119 | } |
| 120 | |
| 121 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 122 | ~CommandOptions () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 123 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 124 | Error |
| 125 | SetOptionValue (uint32_t option_idx, const char *option_arg) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 126 | { |
| 127 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 128 | const int short_option = m_getopt_table[option_idx].val; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 129 | |
| 130 | switch (short_option) |
| 131 | { |
| 132 | case 'a': |
Greg Clayton | b9d5df5 | 2012-12-06 22:49:16 +0000 | [diff] [blame] | 133 | { |
| 134 | ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); |
| 135 | m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); |
| 136 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 137 | break; |
| 138 | |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 139 | case 'A': |
| 140 | m_all_files = true; |
| 141 | break; |
| 142 | |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 143 | case 'b': |
| 144 | m_func_names.push_back (option_arg); |
| 145 | m_func_name_type_mask |= eFunctionNameTypeBase; |
| 146 | break; |
| 147 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 148 | case 'C': |
Jim Ingham | 6312991 | 2015-03-16 22:47:38 +0000 | [diff] [blame] | 149 | { |
| 150 | bool success; |
| 151 | m_column = StringConvert::ToUInt32 (option_arg, 0, 0, &success); |
| 152 | if (!success) |
| 153 | error.SetErrorStringWithFormat("invalid column number: %s", option_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 154 | break; |
Jim Ingham | 6312991 | 2015-03-16 22:47:38 +0000 | [diff] [blame] | 155 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 156 | case 'c': |
| 157 | m_condition.assign(option_arg); |
| 158 | break; |
| 159 | |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 160 | case 'D': |
| 161 | m_use_dummy = true; |
| 162 | break; |
| 163 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 164 | case 'E': |
| 165 | { |
Jim Ingham | 0e0984e | 2015-09-02 01:06:46 +0000 | [diff] [blame] | 166 | LanguageType language = Language::GetLanguageTypeFromString (option_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 167 | |
| 168 | switch (language) |
| 169 | { |
| 170 | case eLanguageTypeC89: |
| 171 | case eLanguageTypeC: |
| 172 | case eLanguageTypeC99: |
Bruce Mitchener | 1d0089f | 2014-07-03 00:49:08 +0000 | [diff] [blame] | 173 | case eLanguageTypeC11: |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 174 | m_exception_language = eLanguageTypeC; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 175 | break; |
| 176 | case eLanguageTypeC_plus_plus: |
Bruce Mitchener | 1d0089f | 2014-07-03 00:49:08 +0000 | [diff] [blame] | 177 | case eLanguageTypeC_plus_plus_03: |
| 178 | case eLanguageTypeC_plus_plus_11: |
Bruce Mitchener | 2ba84a6 | 2015-02-06 06:46:52 +0000 | [diff] [blame] | 179 | case eLanguageTypeC_plus_plus_14: |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 180 | m_exception_language = eLanguageTypeC_plus_plus; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 181 | break; |
| 182 | case eLanguageTypeObjC: |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 183 | m_exception_language = eLanguageTypeObjC; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 184 | break; |
| 185 | case eLanguageTypeObjC_plus_plus: |
| 186 | error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c"); |
| 187 | break; |
| 188 | case eLanguageTypeUnknown: |
| 189 | error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg); |
| 190 | break; |
| 191 | default: |
| 192 | error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg); |
| 193 | } |
| 194 | } |
| 195 | break; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 196 | |
| 197 | case 'f': |
| 198 | m_filenames.AppendIfUnique (FileSpec(option_arg, false)); |
| 199 | break; |
| 200 | |
| 201 | case 'F': |
| 202 | m_func_names.push_back (option_arg); |
| 203 | m_func_name_type_mask |= eFunctionNameTypeFull; |
| 204 | break; |
| 205 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 206 | case 'h': |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 207 | { |
| 208 | bool success; |
| 209 | m_catch_bp = Args::StringToBoolean (option_arg, true, &success); |
| 210 | if (!success) |
| 211 | error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg); |
| 212 | } |
| 213 | break; |
| 214 | |
| 215 | case 'H': |
| 216 | m_hardware = true; |
| 217 | break; |
| 218 | |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 219 | case 'i': |
| 220 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 221 | m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 222 | if (m_ignore_count == UINT32_MAX) |
| 223 | error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); |
| 224 | break; |
| 225 | } |
| 226 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 227 | case 'K': |
| 228 | { |
| 229 | bool success; |
| 230 | bool value; |
| 231 | value = Args::StringToBoolean (option_arg, true, &success); |
| 232 | if (value) |
| 233 | m_skip_prologue = eLazyBoolYes; |
| 234 | else |
| 235 | m_skip_prologue = eLazyBoolNo; |
| 236 | |
| 237 | if (!success) |
| 238 | error.SetErrorStringWithFormat ("Invalid boolean value for skip prologue option: '%s'", option_arg); |
| 239 | } |
| 240 | break; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 241 | |
| 242 | case 'l': |
Jim Ingham | 6312991 | 2015-03-16 22:47:38 +0000 | [diff] [blame] | 243 | { |
| 244 | bool success; |
| 245 | m_line_num = StringConvert::ToUInt32 (option_arg, 0, 0, &success); |
| 246 | if (!success) |
| 247 | error.SetErrorStringWithFormat ("invalid line number: %s.", option_arg); |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 248 | break; |
Jim Ingham | 6312991 | 2015-03-16 22:47:38 +0000 | [diff] [blame] | 249 | } |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 250 | |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 251 | case 'L': |
Jim Ingham | 0e0984e | 2015-09-02 01:06:46 +0000 | [diff] [blame] | 252 | m_language = Language::GetLanguageTypeFromString (option_arg); |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 253 | if (m_language == eLanguageTypeUnknown) |
| 254 | error.SetErrorStringWithFormat ("Unknown language type: '%s' for breakpoint", option_arg); |
| 255 | break; |
| 256 | |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 257 | case 'm': |
| 258 | { |
| 259 | bool success; |
| 260 | bool value; |
| 261 | value = Args::StringToBoolean (option_arg, true, &success); |
| 262 | if (value) |
| 263 | m_move_to_nearest_code = eLazyBoolYes; |
| 264 | else |
| 265 | m_move_to_nearest_code = eLazyBoolNo; |
| 266 | |
| 267 | if (!success) |
| 268 | error.SetErrorStringWithFormat ("Invalid boolean value for move-to-nearest-code option: '%s'", option_arg); |
| 269 | break; |
| 270 | } |
| 271 | |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 272 | case 'M': |
| 273 | m_func_names.push_back (option_arg); |
| 274 | m_func_name_type_mask |= eFunctionNameTypeMethod; |
| 275 | break; |
| 276 | |
| 277 | case 'n': |
| 278 | m_func_names.push_back (option_arg); |
| 279 | m_func_name_type_mask |= eFunctionNameTypeAuto; |
| 280 | break; |
| 281 | |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 282 | case 'N': |
| 283 | if (BreakpointID::StringIsBreakpointName(option_arg, error)) |
| 284 | m_breakpoint_names.push_back (option_arg); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 285 | break; |
| 286 | |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 287 | case 'o': |
| 288 | m_one_shot = true; |
| 289 | break; |
| 290 | |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 291 | case 'O': |
| 292 | m_exception_extra_args.AppendArgument ("-O"); |
| 293 | m_exception_extra_args.AppendArgument (option_arg); |
| 294 | break; |
| 295 | |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 296 | case 'p': |
| 297 | m_source_text_regexp.assign (option_arg); |
| 298 | break; |
| 299 | |
| 300 | case 'q': |
| 301 | m_queue_name.assign (option_arg); |
| 302 | break; |
| 303 | |
| 304 | case 'r': |
| 305 | m_func_regexp.assign (option_arg); |
| 306 | break; |
| 307 | |
| 308 | case 's': |
| 309 | { |
| 310 | m_modules.AppendIfUnique (FileSpec (option_arg, false)); |
| 311 | break; |
| 312 | } |
| 313 | |
| 314 | case 'S': |
| 315 | m_func_names.push_back (option_arg); |
| 316 | m_func_name_type_mask |= eFunctionNameTypeSelector; |
| 317 | break; |
| 318 | |
| 319 | case 't' : |
| 320 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 321 | m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 322 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 323 | error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); |
| 324 | } |
| 325 | break; |
| 326 | |
| 327 | case 'T': |
| 328 | m_thread_name.assign (option_arg); |
| 329 | break; |
| 330 | |
| 331 | case 'w': |
| 332 | { |
| 333 | bool success; |
| 334 | m_throw_bp = Args::StringToBoolean (option_arg, true, &success); |
| 335 | if (!success) |
| 336 | error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg); |
| 337 | } |
| 338 | break; |
| 339 | |
| 340 | case 'x': |
| 341 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 342 | m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 343 | if (m_thread_id == UINT32_MAX) |
| 344 | error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); |
| 345 | |
| 346 | } |
| 347 | break; |
| 348 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 349 | default: |
| 350 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
| 351 | break; |
| 352 | } |
| 353 | |
| 354 | return error; |
| 355 | } |
| 356 | void |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 357 | OptionParsingStarting () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 358 | { |
| 359 | m_condition.clear(); |
| 360 | m_filenames.Clear(); |
| 361 | m_line_num = 0; |
| 362 | m_column = 0; |
| 363 | m_func_names.clear(); |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 364 | m_func_name_type_mask = eFunctionNameTypeNone; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 365 | m_func_regexp.clear(); |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 366 | m_source_text_regexp.clear(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 367 | m_modules.Clear(); |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 368 | m_load_addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 369 | m_ignore_count = 0; |
| 370 | m_thread_id = LLDB_INVALID_THREAD_ID; |
| 371 | m_thread_index = UINT32_MAX; |
| 372 | m_thread_name.clear(); |
| 373 | m_queue_name.clear(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 374 | m_catch_bp = false; |
| 375 | m_throw_bp = true; |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 376 | m_hardware = false; |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 377 | m_exception_language = eLanguageTypeUnknown; |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 378 | m_language = lldb::eLanguageTypeUnknown; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 379 | m_skip_prologue = eLazyBoolCalculate; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 380 | m_one_shot = false; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 381 | m_use_dummy = false; |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 382 | m_breakpoint_names.clear(); |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 383 | m_all_files = false; |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 384 | m_exception_extra_args.Clear(); |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 385 | m_move_to_nearest_code = eLazyBoolCalculate; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | const OptionDefinition* |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 389 | GetDefinitions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 390 | { |
| 391 | return g_option_table; |
| 392 | } |
| 393 | |
| 394 | // Options table: Required for subclasses of Options. |
| 395 | |
| 396 | static OptionDefinition g_option_table[]; |
| 397 | |
| 398 | // Instance variables to hold the values for command options. |
| 399 | |
| 400 | std::string m_condition; |
| 401 | FileSpecList m_filenames; |
| 402 | uint32_t m_line_num; |
| 403 | uint32_t m_column; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 404 | std::vector<std::string> m_func_names; |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 405 | std::vector<std::string> m_breakpoint_names; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 406 | uint32_t m_func_name_type_mask; |
| 407 | std::string m_func_regexp; |
| 408 | std::string m_source_text_regexp; |
| 409 | FileSpecList m_modules; |
| 410 | lldb::addr_t m_load_addr; |
| 411 | uint32_t m_ignore_count; |
| 412 | lldb::tid_t m_thread_id; |
| 413 | uint32_t m_thread_index; |
| 414 | std::string m_thread_name; |
| 415 | std::string m_queue_name; |
| 416 | bool m_catch_bp; |
| 417 | bool m_throw_bp; |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 418 | bool m_hardware; // Request to use hardware breakpoints |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 419 | lldb::LanguageType m_exception_language; |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 420 | lldb::LanguageType m_language; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 421 | LazyBool m_skip_prologue; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 422 | bool m_one_shot; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 423 | bool m_use_dummy; |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 424 | bool m_all_files; |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 425 | Args m_exception_extra_args; |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 426 | LazyBool m_move_to_nearest_code; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 427 | |
| 428 | }; |
| 429 | |
| 430 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 431 | bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 432 | DoExecute (Args& command, |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 433 | CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 434 | { |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 435 | Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); |
| 436 | |
Jim Ingham | 893c932 | 2014-11-22 01:42:44 +0000 | [diff] [blame] | 437 | if (target == nullptr) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 438 | { |
| 439 | result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command)."); |
| 440 | result.SetStatus (eReturnStatusFailed); |
| 441 | return false; |
| 442 | } |
| 443 | |
| 444 | // The following are the various types of breakpoints that could be set: |
| 445 | // 1). -f -l -p [-s -g] (setting breakpoint by source location) |
| 446 | // 2). -a [-s -g] (setting breakpoint by address) |
| 447 | // 3). -n [-s -g] (setting breakpoint by function name) |
| 448 | // 4). -r [-s -g] (setting breakpoint by function name regular expression) |
| 449 | // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text) |
| 450 | // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.) |
| 451 | |
| 452 | BreakpointSetType break_type = eSetTypeInvalid; |
| 453 | |
| 454 | if (m_options.m_line_num != 0) |
| 455 | break_type = eSetTypeFileAndLine; |
| 456 | else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) |
| 457 | break_type = eSetTypeAddress; |
| 458 | else if (!m_options.m_func_names.empty()) |
| 459 | break_type = eSetTypeFunctionName; |
| 460 | else if (!m_options.m_func_regexp.empty()) |
| 461 | break_type = eSetTypeFunctionRegexp; |
| 462 | else if (!m_options.m_source_text_regexp.empty()) |
| 463 | break_type = eSetTypeSourceRegexp; |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 464 | else if (m_options.m_exception_language != eLanguageTypeUnknown) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 465 | break_type = eSetTypeException; |
| 466 | |
| 467 | Breakpoint *bp = NULL; |
| 468 | FileSpec module_spec; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 469 | const bool internal = false; |
| 470 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 471 | switch (break_type) |
| 472 | { |
| 473 | case eSetTypeFileAndLine: // Breakpoint by source position |
| 474 | { |
| 475 | FileSpec file; |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 476 | const size_t num_files = m_options.m_filenames.GetSize(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 477 | if (num_files == 0) |
| 478 | { |
| 479 | if (!GetDefaultFile (target, file, result)) |
| 480 | { |
| 481 | result.AppendError("No file supplied and no default file available."); |
| 482 | result.SetStatus (eReturnStatusFailed); |
| 483 | return false; |
| 484 | } |
| 485 | } |
| 486 | else if (num_files > 1) |
| 487 | { |
| 488 | result.AppendError("Only one file at a time is allowed for file and line breakpoints."); |
| 489 | result.SetStatus (eReturnStatusFailed); |
| 490 | return false; |
| 491 | } |
| 492 | else |
| 493 | file = m_options.m_filenames.GetFileSpecAtIndex(0); |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 494 | |
| 495 | // Only check for inline functions if |
| 496 | LazyBool check_inlines = eLazyBoolCalculate; |
| 497 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 498 | bp = target->CreateBreakpoint (&(m_options.m_modules), |
| 499 | file, |
| 500 | m_options.m_line_num, |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 501 | check_inlines, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 502 | m_options.m_skip_prologue, |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 503 | internal, |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 504 | m_options.m_hardware, |
| 505 | m_options.m_move_to_nearest_code).get(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 506 | } |
| 507 | break; |
| 508 | |
| 509 | case eSetTypeAddress: // Breakpoint by address |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 510 | bp = target->CreateBreakpoint (m_options.m_load_addr, |
| 511 | internal, |
| 512 | m_options.m_hardware).get(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 513 | break; |
| 514 | |
| 515 | case eSetTypeFunctionName: // Breakpoint by function name |
| 516 | { |
| 517 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 518 | |
| 519 | if (name_type_mask == 0) |
| 520 | name_type_mask = eFunctionNameTypeAuto; |
| 521 | |
| 522 | bp = target->CreateBreakpoint (&(m_options.m_modules), |
| 523 | &(m_options.m_filenames), |
| 524 | m_options.m_func_names, |
| 525 | name_type_mask, |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 526 | m_options.m_language, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 527 | m_options.m_skip_prologue, |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 528 | internal, |
| 529 | m_options.m_hardware).get(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 530 | } |
| 531 | break; |
| 532 | |
| 533 | case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name |
| 534 | { |
| 535 | RegularExpression regexp(m_options.m_func_regexp.c_str()); |
| 536 | if (!regexp.IsValid()) |
| 537 | { |
| 538 | char err_str[1024]; |
| 539 | regexp.GetErrorAsCString(err_str, sizeof(err_str)); |
| 540 | result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"", |
| 541 | err_str); |
| 542 | result.SetStatus (eReturnStatusFailed); |
| 543 | return false; |
| 544 | } |
| 545 | |
| 546 | bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), |
| 547 | &(m_options.m_filenames), |
| 548 | regexp, |
Jim Ingham | 0fcdac3 | 2015-11-06 22:48:59 +0000 | [diff] [blame] | 549 | m_options.m_language, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 550 | m_options.m_skip_prologue, |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 551 | internal, |
| 552 | m_options.m_hardware).get(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 553 | } |
| 554 | break; |
| 555 | case eSetTypeSourceRegexp: // Breakpoint by regexp on source text. |
| 556 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 557 | const size_t num_files = m_options.m_filenames.GetSize(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 558 | |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 559 | if (num_files == 0 && !m_options.m_all_files) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 560 | { |
| 561 | FileSpec file; |
| 562 | if (!GetDefaultFile (target, file, result)) |
| 563 | { |
| 564 | result.AppendError ("No files provided and could not find default file."); |
| 565 | result.SetStatus (eReturnStatusFailed); |
| 566 | return false; |
| 567 | } |
| 568 | else |
| 569 | { |
| 570 | m_options.m_filenames.Append (file); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | RegularExpression regexp(m_options.m_source_text_regexp.c_str()); |
| 575 | if (!regexp.IsValid()) |
| 576 | { |
| 577 | char err_str[1024]; |
| 578 | regexp.GetErrorAsCString(err_str, sizeof(err_str)); |
| 579 | result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"", |
| 580 | err_str); |
| 581 | result.SetStatus (eReturnStatusFailed); |
| 582 | return false; |
| 583 | } |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 584 | bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), |
| 585 | &(m_options.m_filenames), |
| 586 | regexp, |
| 587 | internal, |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 588 | m_options.m_hardware, |
| 589 | m_options.m_move_to_nearest_code).get(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 590 | } |
| 591 | break; |
| 592 | case eSetTypeException: |
| 593 | { |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 594 | Error precond_error; |
| 595 | bp = target->CreateExceptionBreakpoint (m_options.m_exception_language, |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 596 | m_options.m_catch_bp, |
| 597 | m_options.m_throw_bp, |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 598 | internal, |
| 599 | &m_options.m_exception_extra_args, |
| 600 | &precond_error).get(); |
| 601 | if (precond_error.Fail()) |
| 602 | { |
| 603 | result.AppendErrorWithFormat("Error setting extra exception arguments: %s", |
| 604 | precond_error.AsCString()); |
| 605 | target->RemoveBreakpointByID(bp->GetID()); |
| 606 | result.SetStatus(eReturnStatusFailed); |
| 607 | return false; |
| 608 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 609 | } |
| 610 | break; |
| 611 | default: |
| 612 | break; |
| 613 | } |
| 614 | |
| 615 | // Now set the various options that were passed in: |
| 616 | if (bp) |
| 617 | { |
| 618 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 619 | bp->SetThreadID (m_options.m_thread_id); |
| 620 | |
| 621 | if (m_options.m_thread_index != UINT32_MAX) |
| 622 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 623 | |
| 624 | if (!m_options.m_thread_name.empty()) |
| 625 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 626 | |
| 627 | if (!m_options.m_queue_name.empty()) |
| 628 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 629 | |
| 630 | if (m_options.m_ignore_count != 0) |
| 631 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
| 632 | |
| 633 | if (!m_options.m_condition.empty()) |
| 634 | bp->GetOptions()->SetCondition(m_options.m_condition.c_str()); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 635 | |
| 636 | if (!m_options.m_breakpoint_names.empty()) |
| 637 | { |
| 638 | Error error; // We don't need to check the error here, since the option parser checked it... |
| 639 | for (auto name : m_options.m_breakpoint_names) |
| 640 | bp->AddName(name.c_str(), error); |
| 641 | } |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 642 | |
| 643 | bp->SetOneShot (m_options.m_one_shot); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 644 | } |
| 645 | |
| 646 | if (bp) |
| 647 | { |
| 648 | Stream &output_stream = result.GetOutputStream(); |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 649 | const bool show_locations = false; |
| 650 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial, show_locations); |
Jim Ingham | 4aeb198 | 2014-12-19 19:45:31 +0000 | [diff] [blame] | 651 | if (target == m_interpreter.GetDebugger().GetDummyTarget()) |
| 652 | output_stream.Printf ("Breakpoint set in dummy target, will get copied into future targets.\n"); |
| 653 | else |
| 654 | { |
| 655 | // Don't print out this warning for exception breakpoints. They can get set before the target |
| 656 | // is set, but we won't know how to actually set the breakpoint till we run. |
| 657 | if (bp->GetNumLocations() == 0 && break_type != eSetTypeException) |
| 658 | { |
| 659 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n"); |
| 660 | } |
| 661 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 662 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 663 | } |
| 664 | else if (!bp) |
| 665 | { |
| 666 | result.AppendError ("Breakpoint creation failed: No breakpoint created."); |
| 667 | result.SetStatus (eReturnStatusFailed); |
| 668 | } |
| 669 | |
| 670 | return result.Succeeded(); |
| 671 | } |
| 672 | |
| 673 | private: |
| 674 | bool |
| 675 | GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result) |
| 676 | { |
| 677 | uint32_t default_line; |
| 678 | // First use the Source Manager's default file. |
| 679 | // Then use the current stack frame's file. |
| 680 | if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) |
| 681 | { |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 682 | StackFrame *cur_frame = m_exe_ctx.GetFramePtr(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 683 | if (cur_frame == NULL) |
| 684 | { |
| 685 | result.AppendError ("No selected frame to use to find the default file."); |
| 686 | result.SetStatus (eReturnStatusFailed); |
| 687 | return false; |
| 688 | } |
| 689 | else if (!cur_frame->HasDebugInformation()) |
| 690 | { |
| 691 | result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info."); |
| 692 | result.SetStatus (eReturnStatusFailed); |
| 693 | return false; |
| 694 | } |
| 695 | else |
| 696 | { |
| 697 | const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); |
| 698 | if (sc.line_entry.file) |
| 699 | { |
| 700 | file = sc.line_entry.file; |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | result.AppendError ("Can't find the file for the selected frame to use as the default file."); |
| 705 | result.SetStatus (eReturnStatusFailed); |
| 706 | return false; |
| 707 | } |
| 708 | } |
| 709 | } |
| 710 | return true; |
| 711 | } |
| 712 | |
| 713 | CommandOptions m_options; |
| 714 | }; |
Johnny Chen | 6943e7c | 2012-05-08 00:43:20 +0000 | [diff] [blame] | 715 | // If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to |
| 716 | // update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately. |
Johnny Chen | 4ab2e6b | 2012-05-07 23:23:41 +0000 | [diff] [blame] | 717 | #define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 ) |
| 718 | #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) |
Jim Ingham | a8558b6 | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 719 | #define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) ) |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 720 | #define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 ) |
Jim Ingham | 0fcdac3 | 2015-11-06 22:48:59 +0000 | [diff] [blame] | 721 | #define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) ) |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 722 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 723 | OptionDefinition |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 724 | CommandObjectBreakpointSet::CommandOptions::g_option_table[] = |
| 725 | { |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 726 | { LLDB_OPT_NOT_10, false, "shlib", 's', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 727 | "Set the breakpoint only in this shared library. " |
| 728 | "Can repeat this option multiple times to specify multiple shared libraries."}, |
Jim Ingham | 8651121 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 729 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 730 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, |
Caroline Tice | deaab22 | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 731 | "Set the number of times this breakpoint is skipped before stopping." }, |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 732 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 733 | { LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Jim Ingham | b2b256a | 2013-04-09 18:05:22 +0000 | [diff] [blame] | 734 | "The breakpoint is deleted the first time it causes a stop." }, |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 735 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 736 | { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, |
Johnny Chen | 7d49c9c | 2012-05-25 21:10:46 +0000 | [diff] [blame] | 737 | "The breakpoint stops only if this condition expression evaluates to true."}, |
| 738 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 739 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, |
Jim Ingham | a89be91 | 2013-03-26 18:29:03 +0000 | [diff] [blame] | 740 | "The breakpoint stops only for the thread whose indeX matches this argument."}, |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 741 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 742 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID, |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 743 | "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 744 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 745 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName, |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 746 | "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 747 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 748 | { LLDB_OPT_SET_ALL, false, "hardware", 'H', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 749 | "Require the breakpoint to use hardware breakpoints."}, |
| 750 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 751 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName, |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 752 | "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 753 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 754 | { LLDB_OPT_FILE, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
Jim Ingham | 289aca6 | 2013-02-14 19:10:36 +0000 | [diff] [blame] | 755 | "Specifies the source file in which to set this breakpoint. " |
| 756 | "Note, by default lldb only looks for files that are #included if they use the standard include file extensions. " |
Jim Ingham | 6394479 | 2013-02-14 19:30:35 +0000 | [diff] [blame] | 757 | "To set breakpoints on .c/.cpp/.m/.mm files that are #included, set target.inline-breakpoint-strategy" |
Jim Ingham | 289aca6 | 2013-02-14 19:10:36 +0000 | [diff] [blame] | 758 | " to \"always\"."}, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 759 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 760 | { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 761 | "Specifies the line number on which to set this breakpoint."}, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 762 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 763 | // Comment out this option for the moment, as we don't actually use it, but will in the future. |
| 764 | // This way users won't see it, but the infrastructure is left in place. |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 765 | // { 0, false, "column", 'C', OptionParser::eRequiredArgument, NULL, "<column>", |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 766 | // "Set the breakpoint by source location at this particular column."}, |
| 767 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 768 | { LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 769 | "Set the breakpoint by address, at the specified address."}, |
| 770 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 771 | { LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
Jim Ingham | 551262d | 2013-03-27 17:36:54 +0000 | [diff] [blame] | 772 | "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" }, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 773 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 774 | { LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 775 | "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and " |
Jason Molenda | c8badb7 | 2015-09-28 23:02:00 +0000 | [diff] [blame] | 776 | "for Objective C this means a full function prototype with class and selector. " |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 777 | "Can be repeated multiple times to make one breakpoint for multiple names." }, |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 778 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 779 | { LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSelector, |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 780 | "Set the breakpoint by ObjC selector name. Can be repeated multiple times to make one breakpoint for multiple Selectors." }, |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 781 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 782 | { LLDB_OPT_SET_6, true, "method", 'M', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeMethod, |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 783 | "Set the breakpoint by C++ method names. Can be repeated multiple times to make one breakpoint for multiple methods." }, |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 784 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 785 | { LLDB_OPT_SET_7, true, "func-regex", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 786 | "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, |
| 787 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 788 | { LLDB_OPT_SET_8, true, "basename", 'b', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
Jim Ingham | 64cc29c | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 789 | "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). " |
| 790 | "Can be repeated multiple times to make one breakpoint for multiple symbols." }, |
Greg Clayton | e02b850 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 791 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 792 | { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeRegularExpression, |
Jim Ingham | e96ade8 | 2013-06-07 01:13:00 +0000 | [diff] [blame] | 793 | "Set the breakpoint by specifying a regular expression which is matched against the source text in a source file or files " |
| 794 | "specified with the -f option. The -f option can be specified more than once. " |
| 795 | "If no source files are specified, uses the current \"default source file\"" }, |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 796 | |
Jim Ingham | e732052 | 2015-02-12 17:37:46 +0000 | [diff] [blame] | 797 | { LLDB_OPT_SET_9, false, "all-files", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 798 | "All files are searched for source pattern matches." }, |
| 799 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 800 | { LLDB_OPT_SET_10, true, "language-exception", 'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 801 | "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" }, |
| 802 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 803 | { LLDB_OPT_SET_10, false, "on-throw", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 804 | "Set the breakpoint on exception throW." }, |
| 805 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 806 | { LLDB_OPT_SET_10, false, "on-catch", 'h', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 807 | "Set the breakpoint on exception catcH." }, |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 808 | |
Jim Ingham | a72b31c | 2015-04-22 19:42:18 +0000 | [diff] [blame] | 809 | // Don't add this option till it actually does something useful... |
| 810 | // { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName, |
| 811 | // "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" }, |
| 812 | |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 813 | { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, |
Dawn Perchik | 4112ab9 | 2015-07-22 02:01:32 +0000 | [diff] [blame] | 814 | "Specifies the Language to use when interpreting the breakpoint's expression (note: currently only implemented for setting breakpoints on identifiers). If not set the target.language setting is used." }, |
Dawn Perchik | 23b1dec | 2015-07-21 22:05:07 +0000 | [diff] [blame] | 815 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 816 | { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, |
Jim Ingham | a8558b6 | 2012-05-22 00:12:20 +0000 | [diff] [blame] | 817 | "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." }, |
| 818 | |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 819 | { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 820 | "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."}, |
| 821 | |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 822 | { LLDB_OPT_SET_ALL, false, "breakpoint-name", 'N', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointName, |
| 823 | "Adds this to the list of names for this breakopint."}, |
| 824 | |
Ilia K | 055ad9b | 2015-05-18 13:41:01 +0000 | [diff] [blame] | 825 | { LLDB_OPT_MOVE_TO_NEAREST_CODE, false, "move-to-nearest-code", 'm', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, |
| 826 | "Move breakpoints to nearest code. If not set the target.move-to-nearest-code setting is used." }, |
| 827 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 828 | { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 829 | }; |
| 830 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 831 | //------------------------------------------------------------------------- |
| 832 | // CommandObjectBreakpointModify |
| 833 | //------------------------------------------------------------------------- |
| 834 | #pragma mark Modify |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 835 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 836 | class CommandObjectBreakpointModify : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 837 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 838 | public: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 839 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 840 | CommandObjectBreakpointModify (CommandInterpreter &interpreter) : |
| 841 | CommandObjectParsed (interpreter, |
| 842 | "breakpoint modify", |
| 843 | "Modify the options on a breakpoint or set of breakpoints in the executable. " |
| 844 | "If no breakpoint is specified, acts on the last created breakpoint. " |
| 845 | "With the exception of -e, -d and -i, passing an empty argument clears the modification.", |
| 846 | NULL), |
| 847 | m_options (interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 848 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 849 | CommandArgumentEntry arg; |
| 850 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
| 851 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 852 | m_arguments.push_back (arg); |
| 853 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 854 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 855 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 856 | ~CommandObjectBreakpointModify () override {} |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 857 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 858 | Options * |
| 859 | GetOptions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 860 | { |
| 861 | return &m_options; |
| 862 | } |
Johnny Chen | 7d49c9c | 2012-05-25 21:10:46 +0000 | [diff] [blame] | 863 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 864 | class CommandOptions : public Options |
| 865 | { |
| 866 | public: |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 867 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 868 | CommandOptions (CommandInterpreter &interpreter) : |
| 869 | Options (interpreter), |
| 870 | m_ignore_count (0), |
| 871 | m_thread_id(LLDB_INVALID_THREAD_ID), |
| 872 | m_thread_id_passed(false), |
| 873 | m_thread_index (UINT32_MAX), |
| 874 | m_thread_index_passed(false), |
| 875 | m_thread_name(), |
| 876 | m_queue_name(), |
| 877 | m_condition (), |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 878 | m_one_shot (false), |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 879 | m_enable_passed (false), |
| 880 | m_enable_value (false), |
| 881 | m_name_passed (false), |
| 882 | m_queue_passed (false), |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 883 | m_condition_passed (false), |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 884 | m_one_shot_passed (false), |
| 885 | m_use_dummy (false) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 886 | { |
| 887 | } |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 888 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 889 | ~CommandOptions () override {} |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 890 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 891 | Error |
| 892 | SetOptionValue (uint32_t option_idx, const char *option_arg) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 893 | { |
| 894 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 895 | const int short_option = m_getopt_table[option_idx].val; |
Greg Clayton | e02b850 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 896 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 897 | switch (short_option) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 898 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 899 | case 'c': |
| 900 | if (option_arg != NULL) |
| 901 | m_condition.assign (option_arg); |
| 902 | else |
| 903 | m_condition.clear(); |
| 904 | m_condition_passed = true; |
| 905 | break; |
| 906 | case 'd': |
| 907 | m_enable_passed = true; |
| 908 | m_enable_value = false; |
| 909 | break; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 910 | case 'D': |
| 911 | m_use_dummy = true; |
| 912 | break; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 913 | case 'e': |
| 914 | m_enable_passed = true; |
| 915 | m_enable_value = true; |
| 916 | break; |
| 917 | case 'i': |
| 918 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 919 | m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 920 | if (m_ignore_count == UINT32_MAX) |
| 921 | error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); |
| 922 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 923 | break; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 924 | case 'o': |
| 925 | { |
| 926 | bool value, success; |
| 927 | value = Args::StringToBoolean(option_arg, false, &success); |
| 928 | if (success) |
| 929 | { |
| 930 | m_one_shot_passed = true; |
| 931 | m_one_shot = value; |
| 932 | } |
| 933 | else |
| 934 | error.SetErrorStringWithFormat("invalid boolean value '%s' passed for -o option", option_arg); |
| 935 | } |
| 936 | break; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 937 | case 't' : |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 938 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 939 | if (option_arg[0] == '\0') |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 940 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 941 | m_thread_id = LLDB_INVALID_THREAD_ID; |
| 942 | m_thread_id_passed = true; |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 943 | } |
| 944 | else |
| 945 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 946 | m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 947 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
| 948 | error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); |
| 949 | else |
| 950 | m_thread_id_passed = true; |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 951 | } |
| 952 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 953 | break; |
| 954 | case 'T': |
| 955 | if (option_arg != NULL) |
| 956 | m_thread_name.assign (option_arg); |
| 957 | else |
| 958 | m_thread_name.clear(); |
| 959 | m_name_passed = true; |
| 960 | break; |
| 961 | case 'q': |
| 962 | if (option_arg != NULL) |
| 963 | m_queue_name.assign (option_arg); |
| 964 | else |
| 965 | m_queue_name.clear(); |
| 966 | m_queue_passed = true; |
| 967 | break; |
| 968 | case 'x': |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 969 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 970 | if (option_arg[0] == '\n') |
| 971 | { |
| 972 | m_thread_index = UINT32_MAX; |
| 973 | m_thread_index_passed = true; |
| 974 | } |
| 975 | else |
| 976 | { |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 977 | m_thread_index = StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 978 | if (m_thread_id == UINT32_MAX) |
| 979 | error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); |
| 980 | else |
| 981 | m_thread_index_passed = true; |
| 982 | } |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 983 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 984 | break; |
| 985 | default: |
| 986 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
| 987 | break; |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 988 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 989 | |
| 990 | return error; |
| 991 | } |
| 992 | void |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 993 | OptionParsingStarting () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 994 | { |
| 995 | m_ignore_count = 0; |
| 996 | m_thread_id = LLDB_INVALID_THREAD_ID; |
| 997 | m_thread_id_passed = false; |
| 998 | m_thread_index = UINT32_MAX; |
| 999 | m_thread_index_passed = false; |
| 1000 | m_thread_name.clear(); |
| 1001 | m_queue_name.clear(); |
| 1002 | m_condition.clear(); |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 1003 | m_one_shot = false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1004 | m_enable_passed = false; |
| 1005 | m_queue_passed = false; |
| 1006 | m_name_passed = false; |
| 1007 | m_condition_passed = false; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 1008 | m_one_shot_passed = false; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1009 | m_use_dummy = false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | const OptionDefinition* |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1013 | GetDefinitions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1014 | { |
| 1015 | return g_option_table; |
| 1016 | } |
| 1017 | |
| 1018 | |
| 1019 | // Options table: Required for subclasses of Options. |
| 1020 | |
| 1021 | static OptionDefinition g_option_table[]; |
| 1022 | |
| 1023 | // Instance variables to hold the values for command options. |
| 1024 | |
| 1025 | uint32_t m_ignore_count; |
| 1026 | lldb::tid_t m_thread_id; |
| 1027 | bool m_thread_id_passed; |
| 1028 | uint32_t m_thread_index; |
| 1029 | bool m_thread_index_passed; |
| 1030 | std::string m_thread_name; |
| 1031 | std::string m_queue_name; |
| 1032 | std::string m_condition; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 1033 | bool m_one_shot; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1034 | bool m_enable_passed; |
| 1035 | bool m_enable_value; |
| 1036 | bool m_name_passed; |
| 1037 | bool m_queue_passed; |
| 1038 | bool m_condition_passed; |
Jim Ingham | ca36cd1 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 1039 | bool m_one_shot_passed; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1040 | bool m_use_dummy; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1041 | |
| 1042 | }; |
| 1043 | |
| 1044 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1045 | bool |
| 1046 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1047 | { |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1048 | Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1049 | if (target == NULL) |
| 1050 | { |
| 1051 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 1052 | result.SetStatus (eReturnStatusFailed); |
| 1053 | return false; |
| 1054 | } |
| 1055 | |
| 1056 | Mutex::Locker locker; |
| 1057 | target->GetBreakpointList().GetListMutex(locker); |
| 1058 | |
| 1059 | BreakpointIDList valid_bp_ids; |
| 1060 | |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1061 | CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1062 | |
| 1063 | if (result.Succeeded()) |
| 1064 | { |
| 1065 | const size_t count = valid_bp_ids.GetSize(); |
| 1066 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1067 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1068 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1069 | |
| 1070 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1071 | { |
| 1072 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1073 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1074 | { |
| 1075 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1076 | if (location) |
| 1077 | { |
| 1078 | if (m_options.m_thread_id_passed) |
| 1079 | location->SetThreadID (m_options.m_thread_id); |
| 1080 | |
| 1081 | if (m_options.m_thread_index_passed) |
| 1082 | location->SetThreadIndex(m_options.m_thread_index); |
| 1083 | |
| 1084 | if (m_options.m_name_passed) |
| 1085 | location->SetThreadName(m_options.m_thread_name.c_str()); |
| 1086 | |
| 1087 | if (m_options.m_queue_passed) |
| 1088 | location->SetQueueName(m_options.m_queue_name.c_str()); |
| 1089 | |
| 1090 | if (m_options.m_ignore_count != 0) |
| 1091 | location->SetIgnoreCount(m_options.m_ignore_count); |
| 1092 | |
| 1093 | if (m_options.m_enable_passed) |
| 1094 | location->SetEnabled (m_options.m_enable_value); |
| 1095 | |
| 1096 | if (m_options.m_condition_passed) |
| 1097 | location->SetCondition (m_options.m_condition.c_str()); |
| 1098 | } |
| 1099 | } |
| 1100 | else |
| 1101 | { |
| 1102 | if (m_options.m_thread_id_passed) |
| 1103 | bp->SetThreadID (m_options.m_thread_id); |
| 1104 | |
| 1105 | if (m_options.m_thread_index_passed) |
| 1106 | bp->SetThreadIndex(m_options.m_thread_index); |
| 1107 | |
| 1108 | if (m_options.m_name_passed) |
| 1109 | bp->SetThreadName(m_options.m_thread_name.c_str()); |
| 1110 | |
| 1111 | if (m_options.m_queue_passed) |
| 1112 | bp->SetQueueName(m_options.m_queue_name.c_str()); |
| 1113 | |
| 1114 | if (m_options.m_ignore_count != 0) |
| 1115 | bp->SetIgnoreCount(m_options.m_ignore_count); |
| 1116 | |
| 1117 | if (m_options.m_enable_passed) |
| 1118 | bp->SetEnabled (m_options.m_enable_value); |
| 1119 | |
| 1120 | if (m_options.m_condition_passed) |
| 1121 | bp->SetCondition (m_options.m_condition.c_str()); |
| 1122 | } |
| 1123 | } |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 1124 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | return result.Succeeded(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1128 | } |
| 1129 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1130 | private: |
| 1131 | CommandOptions m_options; |
| 1132 | }; |
Johnny Chen | 7d49c9c | 2012-05-25 21:10:46 +0000 | [diff] [blame] | 1133 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1134 | #pragma mark Modify::CommandOptions |
| 1135 | OptionDefinition |
| 1136 | CommandObjectBreakpointModify::CommandOptions::g_option_table[] = |
| 1137 | { |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1138 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, |
| 1139 | { LLDB_OPT_SET_ALL, false, "one-shot", 'o', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "The breakpoint is deleted the first time it stop causes a stop." }, |
| 1140 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose index matches this argument."}, |
| 1141 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 1142 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 1143 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 1144 | { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."}, |
| 1145 | { LLDB_OPT_SET_1, false, "enable", 'e', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable the breakpoint."}, |
| 1146 | { LLDB_OPT_SET_2, false, "disable", 'd', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Disable the breakpoint."}, |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1147 | { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Sets Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."}, |
| 1148 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1149 | { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1150 | }; |
| 1151 | |
| 1152 | //------------------------------------------------------------------------- |
| 1153 | // CommandObjectBreakpointEnable |
| 1154 | //------------------------------------------------------------------------- |
| 1155 | #pragma mark Enable |
| 1156 | |
| 1157 | class CommandObjectBreakpointEnable : public CommandObjectParsed |
| 1158 | { |
| 1159 | public: |
| 1160 | CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 1161 | CommandObjectParsed (interpreter, |
| 1162 | "enable", |
| 1163 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 1164 | NULL) |
| 1165 | { |
| 1166 | CommandArgumentEntry arg; |
| 1167 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
| 1168 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1169 | m_arguments.push_back (arg); |
| 1170 | } |
| 1171 | |
| 1172 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1173 | ~CommandObjectBreakpointEnable () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1174 | |
| 1175 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1176 | bool |
| 1177 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1178 | { |
Jim Ingham | 893c932 | 2014-11-22 01:42:44 +0000 | [diff] [blame] | 1179 | Target *target = GetSelectedOrDummyTarget(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1180 | if (target == NULL) |
| 1181 | { |
| 1182 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 1183 | result.SetStatus (eReturnStatusFailed); |
| 1184 | return false; |
| 1185 | } |
| 1186 | |
| 1187 | Mutex::Locker locker; |
| 1188 | target->GetBreakpointList().GetListMutex(locker); |
| 1189 | |
| 1190 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1191 | |
| 1192 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1193 | |
| 1194 | if (num_breakpoints == 0) |
| 1195 | { |
| 1196 | result.AppendError ("No breakpoints exist to be enabled."); |
| 1197 | result.SetStatus (eReturnStatusFailed); |
| 1198 | return false; |
| 1199 | } |
| 1200 | |
| 1201 | if (command.GetArgumentCount() == 0) |
| 1202 | { |
| 1203 | // No breakpoint selected; enable all currently set breakpoints. |
| 1204 | target->EnableAllBreakpoints (); |
Greg Clayton | 6fea17e | 2014-03-03 19:15:20 +0000 | [diff] [blame] | 1205 | result.AppendMessageWithFormat ("All breakpoints enabled. (%" PRIu64 " breakpoints)\n", (uint64_t)num_breakpoints); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1206 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1207 | } |
| 1208 | else |
| 1209 | { |
| 1210 | // Particular breakpoint selected; enable that breakpoint. |
| 1211 | BreakpointIDList valid_bp_ids; |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1212 | CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1213 | |
| 1214 | if (result.Succeeded()) |
| 1215 | { |
| 1216 | int enable_count = 0; |
| 1217 | int loc_count = 0; |
| 1218 | const size_t count = valid_bp_ids.GetSize(); |
| 1219 | for (size_t i = 0; i < count; ++i) |
| 1220 | { |
| 1221 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1222 | |
| 1223 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1224 | { |
| 1225 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1226 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1227 | { |
| 1228 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1229 | if (location) |
| 1230 | { |
| 1231 | location->SetEnabled (true); |
| 1232 | ++loc_count; |
| 1233 | } |
| 1234 | } |
| 1235 | else |
| 1236 | { |
| 1237 | breakpoint->SetEnabled (true); |
| 1238 | ++enable_count; |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 1243 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | return result.Succeeded(); |
| 1248 | } |
| 1249 | }; |
| 1250 | |
| 1251 | //------------------------------------------------------------------------- |
| 1252 | // CommandObjectBreakpointDisable |
| 1253 | //------------------------------------------------------------------------- |
| 1254 | #pragma mark Disable |
| 1255 | |
| 1256 | class CommandObjectBreakpointDisable : public CommandObjectParsed |
| 1257 | { |
| 1258 | public: |
| 1259 | CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 1260 | CommandObjectParsed (interpreter, |
| 1261 | "breakpoint disable", |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 1262 | "Disable the specified breakpoint(s) without removing them. If none are specified, disable all breakpoints.", |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1263 | NULL) |
| 1264 | { |
Jim Ingham | b0fac50 | 2013-03-08 00:31:40 +0000 | [diff] [blame] | 1265 | SetHelpLong( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 1266 | "Disable the specified breakpoint(s) without removing them. \ |
| 1267 | If none are specified, disable all breakpoints." R"( |
| 1268 | |
| 1269 | )" "Note: disabling a breakpoint will cause none of its locations to be hit \ |
| 1270 | regardless of whether they are enabled or disabled. After the sequence:" R"( |
| 1271 | |
| 1272 | (lldb) break disable 1 |
| 1273 | (lldb) break enable 1.1 |
| 1274 | |
| 1275 | execution will NOT stop at location 1.1. To achieve that, type: |
| 1276 | |
| 1277 | (lldb) break disable 1.* |
| 1278 | (lldb) break enable 1.1 |
| 1279 | |
| 1280 | )" "The first command disables all the locations of breakpoint 1, \ |
Jim Ingham | b0fac50 | 2013-03-08 00:31:40 +0000 | [diff] [blame] | 1281 | the second re-enables the first location." |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 1282 | ); |
Jim Ingham | b0fac50 | 2013-03-08 00:31:40 +0000 | [diff] [blame] | 1283 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1284 | CommandArgumentEntry arg; |
| 1285 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
| 1286 | // Add the entry for the first argument for this command to the object's arguments vector. |
Jim Ingham | b0fac50 | 2013-03-08 00:31:40 +0000 | [diff] [blame] | 1287 | m_arguments.push_back (arg); |
| 1288 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1289 | } |
| 1290 | |
| 1291 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1292 | ~CommandObjectBreakpointDisable () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1293 | |
| 1294 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1295 | bool |
| 1296 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1297 | { |
Jim Ingham | 893c932 | 2014-11-22 01:42:44 +0000 | [diff] [blame] | 1298 | Target *target = GetSelectedOrDummyTarget(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1299 | if (target == NULL) |
| 1300 | { |
| 1301 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 1302 | result.SetStatus (eReturnStatusFailed); |
| 1303 | return false; |
| 1304 | } |
| 1305 | |
| 1306 | Mutex::Locker locker; |
| 1307 | target->GetBreakpointList().GetListMutex(locker); |
| 1308 | |
| 1309 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1310 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1311 | |
| 1312 | if (num_breakpoints == 0) |
| 1313 | { |
| 1314 | result.AppendError ("No breakpoints exist to be disabled."); |
| 1315 | result.SetStatus (eReturnStatusFailed); |
| 1316 | return false; |
| 1317 | } |
| 1318 | |
| 1319 | if (command.GetArgumentCount() == 0) |
| 1320 | { |
| 1321 | // No breakpoint selected; disable all currently set breakpoints. |
| 1322 | target->DisableAllBreakpoints (); |
Greg Clayton | 6fea17e | 2014-03-03 19:15:20 +0000 | [diff] [blame] | 1323 | result.AppendMessageWithFormat ("All breakpoints disabled. (%" PRIu64 " breakpoints)\n", (uint64_t)num_breakpoints); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1324 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | // Particular breakpoint selected; disable that breakpoint. |
| 1329 | BreakpointIDList valid_bp_ids; |
| 1330 | |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1331 | CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1332 | |
| 1333 | if (result.Succeeded()) |
| 1334 | { |
| 1335 | int disable_count = 0; |
| 1336 | int loc_count = 0; |
| 1337 | const size_t count = valid_bp_ids.GetSize(); |
| 1338 | for (size_t i = 0; i < count; ++i) |
| 1339 | { |
| 1340 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1341 | |
| 1342 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1343 | { |
| 1344 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1345 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1346 | { |
| 1347 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1348 | if (location) |
| 1349 | { |
| 1350 | location->SetEnabled (false); |
| 1351 | ++loc_count; |
| 1352 | } |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | breakpoint->SetEnabled (false); |
| 1357 | ++disable_count; |
| 1358 | } |
| 1359 | } |
| 1360 | } |
| 1361 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1362 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | return result.Succeeded(); |
| 1367 | } |
| 1368 | |
| 1369 | }; |
| 1370 | |
| 1371 | //------------------------------------------------------------------------- |
| 1372 | // CommandObjectBreakpointList |
| 1373 | //------------------------------------------------------------------------- |
| 1374 | #pragma mark List |
| 1375 | |
| 1376 | class CommandObjectBreakpointList : public CommandObjectParsed |
| 1377 | { |
| 1378 | public: |
| 1379 | CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 1380 | CommandObjectParsed (interpreter, |
| 1381 | "breakpoint list", |
| 1382 | "List some or all breakpoints at configurable levels of detail.", |
| 1383 | NULL), |
| 1384 | m_options (interpreter) |
| 1385 | { |
| 1386 | CommandArgumentEntry arg; |
| 1387 | CommandArgumentData bp_id_arg; |
| 1388 | |
| 1389 | // Define the first (and only) variant of this arg. |
| 1390 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
| 1391 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
| 1392 | |
| 1393 | // There is only one variant this argument could be; put it into the argument entry. |
| 1394 | arg.push_back (bp_id_arg); |
| 1395 | |
| 1396 | // Push the data for the first argument into the m_arguments vector. |
| 1397 | m_arguments.push_back (arg); |
| 1398 | } |
| 1399 | |
| 1400 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1401 | ~CommandObjectBreakpointList () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1402 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1403 | Options * |
| 1404 | GetOptions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1405 | { |
| 1406 | return &m_options; |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1409 | class CommandOptions : public Options |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1410 | { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1411 | public: |
| 1412 | |
| 1413 | CommandOptions (CommandInterpreter &interpreter) : |
| 1414 | Options (interpreter), |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1415 | m_level (lldb::eDescriptionLevelBrief), |
| 1416 | m_use_dummy(false) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1417 | { |
| 1418 | } |
| 1419 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1420 | ~CommandOptions () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1421 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1422 | Error |
| 1423 | SetOptionValue (uint32_t option_idx, const char *option_arg) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1424 | { |
| 1425 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 1426 | const int short_option = m_getopt_table[option_idx].val; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1427 | |
| 1428 | switch (short_option) |
| 1429 | { |
| 1430 | case 'b': |
| 1431 | m_level = lldb::eDescriptionLevelBrief; |
| 1432 | break; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1433 | case 'D': |
| 1434 | m_use_dummy = true; |
| 1435 | break; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1436 | case 'f': |
| 1437 | m_level = lldb::eDescriptionLevelFull; |
| 1438 | break; |
| 1439 | case 'v': |
| 1440 | m_level = lldb::eDescriptionLevelVerbose; |
| 1441 | break; |
| 1442 | case 'i': |
| 1443 | m_internal = true; |
| 1444 | break; |
| 1445 | default: |
| 1446 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
| 1447 | break; |
| 1448 | } |
| 1449 | |
| 1450 | return error; |
| 1451 | } |
| 1452 | |
| 1453 | void |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1454 | OptionParsingStarting () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1455 | { |
| 1456 | m_level = lldb::eDescriptionLevelFull; |
| 1457 | m_internal = false; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1458 | m_use_dummy = false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1459 | } |
| 1460 | |
| 1461 | const OptionDefinition * |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1462 | GetDefinitions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1463 | { |
| 1464 | return g_option_table; |
| 1465 | } |
| 1466 | |
| 1467 | // Options table: Required for subclasses of Options. |
| 1468 | |
| 1469 | static OptionDefinition g_option_table[]; |
| 1470 | |
| 1471 | // Instance variables to hold the values for command options. |
| 1472 | |
| 1473 | lldb::DescriptionLevel m_level; |
| 1474 | |
| 1475 | bool m_internal; |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1476 | bool m_use_dummy; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1480 | bool |
| 1481 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1482 | { |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1483 | Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); |
| 1484 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1485 | if (target == NULL) |
| 1486 | { |
| 1487 | result.AppendError ("Invalid target. No current target or breakpoints."); |
| 1488 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1489 | return true; |
| 1490 | } |
| 1491 | |
| 1492 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
| 1493 | Mutex::Locker locker; |
| 1494 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 1495 | |
| 1496 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1497 | |
| 1498 | if (num_breakpoints == 0) |
| 1499 | { |
| 1500 | result.AppendMessage ("No breakpoints currently set."); |
| 1501 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1502 | return true; |
| 1503 | } |
| 1504 | |
Jim Ingham | 85e8b81 | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 1505 | Stream &output_stream = result.GetOutputStream(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1506 | |
| 1507 | if (command.GetArgumentCount() == 0) |
| 1508 | { |
| 1509 | // No breakpoint selected; show info about all currently set breakpoints. |
| 1510 | result.AppendMessage ("Current breakpoints:"); |
| 1511 | for (size_t i = 0; i < num_breakpoints; ++i) |
| 1512 | { |
| 1513 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); |
| 1514 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
| 1515 | } |
| 1516 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1517 | } |
| 1518 | else |
| 1519 | { |
| 1520 | // Particular breakpoints selected; show info about that breakpoint. |
| 1521 | BreakpointIDList valid_bp_ids; |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1522 | CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1523 | |
| 1524 | if (result.Succeeded()) |
| 1525 | { |
| 1526 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
| 1527 | { |
| 1528 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1529 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1530 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
| 1531 | } |
| 1532 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1533 | } |
| 1534 | else |
| 1535 | { |
| 1536 | result.AppendError ("Invalid breakpoint id."); |
| 1537 | result.SetStatus (eReturnStatusFailed); |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | return result.Succeeded(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1542 | } |
| 1543 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1544 | private: |
| 1545 | CommandOptions m_options; |
| 1546 | }; |
| 1547 | |
| 1548 | #pragma mark List::CommandOptions |
| 1549 | OptionDefinition |
| 1550 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 1551 | { |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1552 | { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1553 | "Show debugger internal breakpoints" }, |
| 1554 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1555 | { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1556 | "Give a brief description of the breakpoint (no location info)."}, |
| 1557 | |
| 1558 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 1559 | // But I need to see it for now, and don't want to wait. |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1560 | { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1561 | "Give a full description of the breakpoint and its locations."}, |
| 1562 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1563 | { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1564 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
| 1565 | |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1566 | { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 1567 | "List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."}, |
| 1568 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1569 | { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1570 | }; |
| 1571 | |
| 1572 | //------------------------------------------------------------------------- |
| 1573 | // CommandObjectBreakpointClear |
| 1574 | //------------------------------------------------------------------------- |
| 1575 | #pragma mark Clear |
| 1576 | |
| 1577 | class CommandObjectBreakpointClear : public CommandObjectParsed |
| 1578 | { |
| 1579 | public: |
| 1580 | |
| 1581 | typedef enum BreakpointClearType |
| 1582 | { |
| 1583 | eClearTypeInvalid, |
| 1584 | eClearTypeFileAndLine |
| 1585 | } BreakpointClearType; |
| 1586 | |
| 1587 | CommandObjectBreakpointClear (CommandInterpreter &interpreter) : |
| 1588 | CommandObjectParsed (interpreter, |
| 1589 | "breakpoint clear", |
| 1590 | "Clears a breakpoint or set of breakpoints in the executable.", |
| 1591 | "breakpoint clear <cmd-options>"), |
| 1592 | m_options (interpreter) |
| 1593 | { |
| 1594 | } |
| 1595 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1596 | ~CommandObjectBreakpointClear () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1597 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1598 | Options * |
| 1599 | GetOptions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1600 | { |
| 1601 | return &m_options; |
| 1602 | } |
| 1603 | |
| 1604 | class CommandOptions : public Options |
| 1605 | { |
| 1606 | public: |
| 1607 | |
| 1608 | CommandOptions (CommandInterpreter &interpreter) : |
| 1609 | Options (interpreter), |
| 1610 | m_filename (), |
| 1611 | m_line_num (0) |
| 1612 | { |
| 1613 | } |
| 1614 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1615 | ~CommandOptions () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1616 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1617 | Error |
| 1618 | SetOptionValue (uint32_t option_idx, const char *option_arg) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1619 | { |
| 1620 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 1621 | const int short_option = m_getopt_table[option_idx].val; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1622 | |
| 1623 | switch (short_option) |
| 1624 | { |
| 1625 | case 'f': |
| 1626 | m_filename.assign (option_arg); |
| 1627 | break; |
| 1628 | |
| 1629 | case 'l': |
Vince Harron | 5275aaa | 2015-01-15 20:08:35 +0000 | [diff] [blame] | 1630 | m_line_num = StringConvert::ToUInt32 (option_arg, 0); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1631 | break; |
| 1632 | |
| 1633 | default: |
| 1634 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
| 1635 | break; |
| 1636 | } |
| 1637 | |
| 1638 | return error; |
| 1639 | } |
| 1640 | |
| 1641 | void |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1642 | OptionParsingStarting () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1643 | { |
| 1644 | m_filename.clear(); |
| 1645 | m_line_num = 0; |
| 1646 | } |
| 1647 | |
| 1648 | const OptionDefinition* |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1649 | GetDefinitions () override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1650 | { |
| 1651 | return g_option_table; |
| 1652 | } |
| 1653 | |
| 1654 | // Options table: Required for subclasses of Options. |
| 1655 | |
| 1656 | static OptionDefinition g_option_table[]; |
| 1657 | |
| 1658 | // Instance variables to hold the values for command options. |
| 1659 | |
| 1660 | std::string m_filename; |
| 1661 | uint32_t m_line_num; |
| 1662 | |
| 1663 | }; |
| 1664 | |
| 1665 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1666 | bool |
| 1667 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1668 | { |
Jim Ingham | 893c932 | 2014-11-22 01:42:44 +0000 | [diff] [blame] | 1669 | Target *target = GetSelectedOrDummyTarget(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1670 | if (target == NULL) |
| 1671 | { |
| 1672 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 1673 | result.SetStatus (eReturnStatusFailed); |
| 1674 | return false; |
| 1675 | } |
| 1676 | |
| 1677 | // The following are the various types of breakpoints that could be cleared: |
| 1678 | // 1). -f -l (clearing breakpoint by source location) |
| 1679 | |
| 1680 | BreakpointClearType break_type = eClearTypeInvalid; |
| 1681 | |
| 1682 | if (m_options.m_line_num != 0) |
| 1683 | break_type = eClearTypeFileAndLine; |
| 1684 | |
| 1685 | Mutex::Locker locker; |
| 1686 | target->GetBreakpointList().GetListMutex(locker); |
| 1687 | |
| 1688 | BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1689 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1690 | |
| 1691 | // Early return if there's no breakpoint at all. |
| 1692 | if (num_breakpoints == 0) |
| 1693 | { |
| 1694 | result.AppendError ("Breakpoint clear: No breakpoint cleared."); |
| 1695 | result.SetStatus (eReturnStatusFailed); |
| 1696 | return result.Succeeded(); |
| 1697 | } |
| 1698 | |
| 1699 | // Find matching breakpoints and delete them. |
| 1700 | |
| 1701 | // First create a copy of all the IDs. |
| 1702 | std::vector<break_id_t> BreakIDs; |
| 1703 | for (size_t i = 0; i < num_breakpoints; ++i) |
| 1704 | BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID()); |
| 1705 | |
| 1706 | int num_cleared = 0; |
| 1707 | StreamString ss; |
| 1708 | switch (break_type) |
| 1709 | { |
| 1710 | case eClearTypeFileAndLine: // Breakpoint by source position |
| 1711 | { |
| 1712 | const ConstString filename(m_options.m_filename.c_str()); |
| 1713 | BreakpointLocationCollection loc_coll; |
| 1714 | |
| 1715 | for (size_t i = 0; i < num_breakpoints; ++i) |
| 1716 | { |
| 1717 | Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get(); |
| 1718 | |
| 1719 | if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) |
| 1720 | { |
| 1721 | // If the collection size is 0, it's a full match and we can just remove the breakpoint. |
| 1722 | if (loc_coll.GetSize() == 0) |
| 1723 | { |
| 1724 | bp->GetDescription(&ss, lldb::eDescriptionLevelBrief); |
| 1725 | ss.EOL(); |
| 1726 | target->RemoveBreakpointByID (bp->GetID()); |
| 1727 | ++num_cleared; |
| 1728 | } |
| 1729 | } |
| 1730 | } |
| 1731 | } |
| 1732 | break; |
| 1733 | |
| 1734 | default: |
| 1735 | break; |
| 1736 | } |
| 1737 | |
| 1738 | if (num_cleared > 0) |
| 1739 | { |
| 1740 | Stream &output_stream = result.GetOutputStream(); |
| 1741 | output_stream.Printf ("%d breakpoints cleared:\n", num_cleared); |
| 1742 | output_stream << ss.GetData(); |
| 1743 | output_stream.EOL(); |
| 1744 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1745 | } |
| 1746 | else |
| 1747 | { |
| 1748 | result.AppendError ("Breakpoint clear: No breakpoint cleared."); |
| 1749 | result.SetStatus (eReturnStatusFailed); |
| 1750 | } |
| 1751 | |
| 1752 | return result.Succeeded(); |
| 1753 | } |
| 1754 | |
| 1755 | private: |
| 1756 | CommandOptions m_options; |
| 1757 | }; |
| 1758 | |
| 1759 | #pragma mark Clear::CommandOptions |
| 1760 | |
| 1761 | OptionDefinition |
| 1762 | CommandObjectBreakpointClear::CommandOptions::g_option_table[] = |
| 1763 | { |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1764 | { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1765 | "Specify the breakpoint by source location in this particular file."}, |
| 1766 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1767 | { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLineNum, |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1768 | "Specify the breakpoint by source location at this particular line."}, |
| 1769 | |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame] | 1770 | { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1771 | }; |
| 1772 | |
| 1773 | //------------------------------------------------------------------------- |
| 1774 | // CommandObjectBreakpointDelete |
| 1775 | //------------------------------------------------------------------------- |
| 1776 | #pragma mark Delete |
| 1777 | |
| 1778 | class CommandObjectBreakpointDelete : public CommandObjectParsed |
| 1779 | { |
| 1780 | public: |
| 1781 | CommandObjectBreakpointDelete (CommandInterpreter &interpreter) : |
| 1782 | CommandObjectParsed (interpreter, |
| 1783 | "breakpoint delete", |
| 1784 | "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1785 | NULL), |
| 1786 | m_options (interpreter) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1787 | { |
| 1788 | CommandArgumentEntry arg; |
| 1789 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
| 1790 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1791 | m_arguments.push_back (arg); |
| 1792 | } |
| 1793 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1794 | ~CommandObjectBreakpointDelete () override {} |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1795 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1796 | Options * |
| 1797 | GetOptions () override |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1798 | { |
| 1799 | return &m_options; |
| 1800 | } |
| 1801 | |
| 1802 | class CommandOptions : public Options |
| 1803 | { |
| 1804 | public: |
| 1805 | |
| 1806 | CommandOptions (CommandInterpreter &interpreter) : |
| 1807 | Options (interpreter), |
| 1808 | m_use_dummy (false), |
| 1809 | m_force (false) |
| 1810 | { |
| 1811 | } |
| 1812 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1813 | ~CommandOptions () override {} |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1814 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1815 | Error |
| 1816 | SetOptionValue (uint32_t option_idx, const char *option_arg) override |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1817 | { |
| 1818 | Error error; |
| 1819 | const int short_option = m_getopt_table[option_idx].val; |
| 1820 | |
| 1821 | switch (short_option) |
| 1822 | { |
| 1823 | case 'f': |
| 1824 | m_force = true; |
| 1825 | break; |
| 1826 | |
| 1827 | case 'D': |
| 1828 | m_use_dummy = true; |
| 1829 | break; |
| 1830 | |
| 1831 | default: |
| 1832 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
| 1833 | break; |
| 1834 | } |
| 1835 | |
| 1836 | return error; |
| 1837 | } |
| 1838 | |
| 1839 | void |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1840 | OptionParsingStarting () override |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1841 | { |
| 1842 | m_use_dummy = false; |
| 1843 | m_force = false; |
| 1844 | } |
| 1845 | |
| 1846 | const OptionDefinition* |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1847 | GetDefinitions () override |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1848 | { |
| 1849 | return g_option_table; |
| 1850 | } |
| 1851 | |
| 1852 | // Options table: Required for subclasses of Options. |
| 1853 | |
| 1854 | static OptionDefinition g_option_table[]; |
| 1855 | |
| 1856 | // Instance variables to hold the values for command options. |
| 1857 | bool m_use_dummy; |
| 1858 | bool m_force; |
| 1859 | }; |
| 1860 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1861 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1862 | bool |
| 1863 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1864 | { |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1865 | Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); |
| 1866 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1867 | if (target == NULL) |
| 1868 | { |
| 1869 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 1870 | result.SetStatus (eReturnStatusFailed); |
| 1871 | return false; |
| 1872 | } |
| 1873 | |
| 1874 | Mutex::Locker locker; |
| 1875 | target->GetBreakpointList().GetListMutex(locker); |
| 1876 | |
| 1877 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1878 | |
| 1879 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1880 | |
| 1881 | if (num_breakpoints == 0) |
| 1882 | { |
| 1883 | result.AppendError ("No breakpoints exist to be deleted."); |
| 1884 | result.SetStatus (eReturnStatusFailed); |
| 1885 | return false; |
| 1886 | } |
| 1887 | |
| 1888 | if (command.GetArgumentCount() == 0) |
| 1889 | { |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1890 | if (!m_options.m_force && !m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true)) |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1891 | { |
| 1892 | result.AppendMessage("Operation cancelled..."); |
| 1893 | } |
| 1894 | else |
| 1895 | { |
| 1896 | target->RemoveAllBreakpoints (); |
Greg Clayton | 6fea17e | 2014-03-03 19:15:20 +0000 | [diff] [blame] | 1897 | result.AppendMessageWithFormat ("All breakpoints removed. (%" PRIu64 " breakpoint%s)\n", (uint64_t)num_breakpoints, num_breakpoints > 1 ? "s" : ""); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1898 | } |
| 1899 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1900 | } |
| 1901 | else |
| 1902 | { |
| 1903 | // Particular breakpoint selected; disable that breakpoint. |
| 1904 | BreakpointIDList valid_bp_ids; |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1905 | CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs (command, target, result, &valid_bp_ids); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1906 | |
| 1907 | if (result.Succeeded()) |
| 1908 | { |
| 1909 | int delete_count = 0; |
| 1910 | int disable_count = 0; |
| 1911 | const size_t count = valid_bp_ids.GetSize(); |
| 1912 | for (size_t i = 0; i < count; ++i) |
| 1913 | { |
| 1914 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1915 | |
| 1916 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1917 | { |
| 1918 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1919 | { |
| 1920 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1921 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1922 | // It makes no sense to try to delete individual locations, so we disable them instead. |
| 1923 | if (location) |
| 1924 | { |
| 1925 | location->SetEnabled (false); |
| 1926 | ++disable_count; |
| 1927 | } |
| 1928 | } |
| 1929 | else |
| 1930 | { |
| 1931 | target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); |
| 1932 | ++delete_count; |
| 1933 | } |
| 1934 | } |
| 1935 | } |
| 1936 | result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", |
| 1937 | delete_count, disable_count); |
| 1938 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1939 | } |
| 1940 | } |
| 1941 | return result.Succeeded(); |
| 1942 | } |
Jim Ingham | 33df7cd | 2014-12-06 01:28:03 +0000 | [diff] [blame] | 1943 | private: |
| 1944 | CommandOptions m_options; |
| 1945 | }; |
| 1946 | |
| 1947 | OptionDefinition |
| 1948 | CommandObjectBreakpointDelete::CommandOptions::g_option_table[] = |
| 1949 | { |
| 1950 | { LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 1951 | "Delete all breakpoints without querying for confirmation."}, |
| 1952 | |
| 1953 | { LLDB_OPT_SET_1, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 1954 | "Delete Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."}, |
| 1955 | |
| 1956 | { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1957 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1958 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1959 | //------------------------------------------------------------------------- |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1960 | // CommandObjectBreakpointName |
| 1961 | //------------------------------------------------------------------------- |
| 1962 | |
| 1963 | static OptionDefinition |
| 1964 | g_breakpoint_name_options[] = |
| 1965 | { |
| 1966 | { LLDB_OPT_SET_1, false, "name", 'N', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointName, "Specifies a breakpoint name to use."}, |
| 1967 | { LLDB_OPT_SET_2, false, "breakpoint-id", 'B', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBreakpointID, "Specify a breakpoint id to use."}, |
| 1968 | { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, |
| 1969 | "Operate on Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets."}, |
| 1970 | }; |
| 1971 | class BreakpointNameOptionGroup : public OptionGroup |
| 1972 | { |
| 1973 | public: |
| 1974 | BreakpointNameOptionGroup() : |
| 1975 | OptionGroup(), |
| 1976 | m_breakpoint(LLDB_INVALID_BREAK_ID), |
| 1977 | m_use_dummy (false) |
| 1978 | { |
| 1979 | |
| 1980 | } |
| 1981 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1982 | ~BreakpointNameOptionGroup () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1983 | { |
| 1984 | } |
| 1985 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1986 | uint32_t |
| 1987 | GetNumDefinitions () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1988 | { |
| 1989 | return sizeof (g_breakpoint_name_options) / sizeof (OptionDefinition); |
| 1990 | } |
| 1991 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1992 | const OptionDefinition* |
| 1993 | GetDefinitions () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1994 | { |
| 1995 | return g_breakpoint_name_options; |
| 1996 | } |
| 1997 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 1998 | Error |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 1999 | SetOptionValue (CommandInterpreter &interpreter, |
| 2000 | uint32_t option_idx, |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2001 | const char *option_value) override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2002 | { |
| 2003 | Error error; |
| 2004 | const int short_option = g_breakpoint_name_options[option_idx].short_option; |
| 2005 | |
| 2006 | switch (short_option) |
| 2007 | { |
| 2008 | case 'N': |
| 2009 | if (BreakpointID::StringIsBreakpointName(option_value, error) && error.Success()) |
Pavel Labath | c95f7e2 | 2015-02-20 11:14:59 +0000 | [diff] [blame] | 2010 | m_name.SetValueFromString(option_value); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2011 | break; |
| 2012 | |
| 2013 | case 'B': |
Pavel Labath | c95f7e2 | 2015-02-20 11:14:59 +0000 | [diff] [blame] | 2014 | if (m_breakpoint.SetValueFromString(option_value).Fail()) |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2015 | error.SetErrorStringWithFormat ("unrecognized value \"%s\" for breakpoint", option_value); |
| 2016 | break; |
| 2017 | case 'D': |
Pavel Labath | c95f7e2 | 2015-02-20 11:14:59 +0000 | [diff] [blame] | 2018 | if (m_use_dummy.SetValueFromString(option_value).Fail()) |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2019 | error.SetErrorStringWithFormat ("unrecognized value \"%s\" for use-dummy", option_value); |
| 2020 | break; |
| 2021 | |
| 2022 | default: |
| 2023 | error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option); |
| 2024 | break; |
| 2025 | } |
| 2026 | return error; |
| 2027 | } |
| 2028 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2029 | void |
| 2030 | OptionParsingStarting (CommandInterpreter &interpreter) override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2031 | { |
| 2032 | m_name.Clear(); |
| 2033 | m_breakpoint.Clear(); |
| 2034 | m_use_dummy.Clear(); |
| 2035 | m_use_dummy.SetDefaultValue(false); |
| 2036 | } |
| 2037 | |
| 2038 | OptionValueString m_name; |
| 2039 | OptionValueUInt64 m_breakpoint; |
| 2040 | OptionValueBoolean m_use_dummy; |
| 2041 | }; |
| 2042 | |
| 2043 | |
| 2044 | class CommandObjectBreakpointNameAdd : public CommandObjectParsed |
| 2045 | { |
| 2046 | public: |
| 2047 | CommandObjectBreakpointNameAdd (CommandInterpreter &interpreter) : |
| 2048 | CommandObjectParsed (interpreter, |
| 2049 | "add", |
| 2050 | "Add a name to the breakpoints provided.", |
| 2051 | "breakpoint name add <command-options> <breakpoint-id-list>"), |
| 2052 | m_name_options(), |
| 2053 | m_option_group(interpreter) |
| 2054 | { |
| 2055 | // Create the first variant for the first (and only) argument for this command. |
| 2056 | CommandArgumentEntry arg1; |
| 2057 | CommandArgumentData id_arg; |
| 2058 | id_arg.arg_type = eArgTypeBreakpointID; |
| 2059 | id_arg.arg_repetition = eArgRepeatOptional; |
| 2060 | arg1.push_back(id_arg); |
| 2061 | m_arguments.push_back (arg1); |
| 2062 | |
| 2063 | m_option_group.Append (&m_name_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL); |
| 2064 | m_option_group.Finalize(); |
| 2065 | } |
| 2066 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2067 | ~CommandObjectBreakpointNameAdd () override {} |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2068 | |
| 2069 | Options * |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2070 | GetOptions () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2071 | { |
| 2072 | return &m_option_group; |
| 2073 | } |
| 2074 | |
| 2075 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2076 | bool |
| 2077 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2078 | { |
| 2079 | if (!m_name_options.m_name.OptionWasSet()) |
| 2080 | { |
| 2081 | result.SetError("No name option provided."); |
| 2082 | return false; |
| 2083 | } |
| 2084 | |
| 2085 | Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); |
| 2086 | |
| 2087 | if (target == NULL) |
| 2088 | { |
| 2089 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 2090 | result.SetStatus (eReturnStatusFailed); |
| 2091 | return false; |
| 2092 | } |
| 2093 | |
| 2094 | Mutex::Locker locker; |
| 2095 | target->GetBreakpointList().GetListMutex(locker); |
| 2096 | |
| 2097 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 2098 | |
| 2099 | size_t num_breakpoints = breakpoints.GetSize(); |
| 2100 | if (num_breakpoints == 0) |
| 2101 | { |
| 2102 | result.SetError("No breakpoints, cannot add names."); |
| 2103 | result.SetStatus (eReturnStatusFailed); |
| 2104 | return false; |
| 2105 | } |
| 2106 | |
| 2107 | // Particular breakpoint selected; disable that breakpoint. |
| 2108 | BreakpointIDList valid_bp_ids; |
| 2109 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 2110 | |
| 2111 | if (result.Succeeded()) |
| 2112 | { |
| 2113 | if (valid_bp_ids.GetSize() == 0) |
| 2114 | { |
| 2115 | result.SetError("No breakpoints specified, cannot add names."); |
| 2116 | result.SetStatus (eReturnStatusFailed); |
| 2117 | return false; |
| 2118 | } |
| 2119 | size_t num_valid_ids = valid_bp_ids.GetSize(); |
| 2120 | for (size_t index = 0; index < num_valid_ids; index++) |
| 2121 | { |
| 2122 | lldb::break_id_t bp_id = valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID(); |
| 2123 | BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id); |
| 2124 | Error error; // We don't need to check the error here, since the option parser checked it... |
| 2125 | bp_sp->AddName(m_name_options.m_name.GetCurrentValue(), error); |
| 2126 | } |
| 2127 | } |
| 2128 | |
| 2129 | return true; |
| 2130 | } |
| 2131 | |
| 2132 | private: |
| 2133 | BreakpointNameOptionGroup m_name_options; |
| 2134 | OptionGroupOptions m_option_group; |
| 2135 | }; |
| 2136 | |
| 2137 | |
| 2138 | |
| 2139 | class CommandObjectBreakpointNameDelete : public CommandObjectParsed |
| 2140 | { |
| 2141 | public: |
| 2142 | CommandObjectBreakpointNameDelete (CommandInterpreter &interpreter) : |
| 2143 | CommandObjectParsed (interpreter, |
| 2144 | "delete", |
| 2145 | "Delete a name from the breakpoints provided.", |
| 2146 | "breakpoint name delete <command-options> <breakpoint-id-list>"), |
| 2147 | m_name_options(), |
| 2148 | m_option_group(interpreter) |
| 2149 | { |
| 2150 | // Create the first variant for the first (and only) argument for this command. |
| 2151 | CommandArgumentEntry arg1; |
| 2152 | CommandArgumentData id_arg; |
| 2153 | id_arg.arg_type = eArgTypeBreakpointID; |
| 2154 | id_arg.arg_repetition = eArgRepeatOptional; |
| 2155 | arg1.push_back(id_arg); |
| 2156 | m_arguments.push_back (arg1); |
| 2157 | |
| 2158 | m_option_group.Append (&m_name_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL); |
| 2159 | m_option_group.Finalize(); |
| 2160 | } |
| 2161 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2162 | ~CommandObjectBreakpointNameDelete () override {} |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2163 | |
| 2164 | Options * |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2165 | GetOptions () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2166 | { |
| 2167 | return &m_option_group; |
| 2168 | } |
| 2169 | |
| 2170 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2171 | bool |
| 2172 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2173 | { |
| 2174 | if (!m_name_options.m_name.OptionWasSet()) |
| 2175 | { |
| 2176 | result.SetError("No name option provided."); |
| 2177 | return false; |
| 2178 | } |
| 2179 | |
| 2180 | Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); |
| 2181 | |
| 2182 | if (target == NULL) |
| 2183 | { |
| 2184 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 2185 | result.SetStatus (eReturnStatusFailed); |
| 2186 | return false; |
| 2187 | } |
| 2188 | |
| 2189 | Mutex::Locker locker; |
| 2190 | target->GetBreakpointList().GetListMutex(locker); |
| 2191 | |
| 2192 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 2193 | |
| 2194 | size_t num_breakpoints = breakpoints.GetSize(); |
| 2195 | if (num_breakpoints == 0) |
| 2196 | { |
| 2197 | result.SetError("No breakpoints, cannot delete names."); |
| 2198 | result.SetStatus (eReturnStatusFailed); |
| 2199 | return false; |
| 2200 | } |
| 2201 | |
| 2202 | // Particular breakpoint selected; disable that breakpoint. |
| 2203 | BreakpointIDList valid_bp_ids; |
| 2204 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 2205 | |
| 2206 | if (result.Succeeded()) |
| 2207 | { |
| 2208 | if (valid_bp_ids.GetSize() == 0) |
| 2209 | { |
| 2210 | result.SetError("No breakpoints specified, cannot delete names."); |
| 2211 | result.SetStatus (eReturnStatusFailed); |
| 2212 | return false; |
| 2213 | } |
| 2214 | size_t num_valid_ids = valid_bp_ids.GetSize(); |
| 2215 | for (size_t index = 0; index < num_valid_ids; index++) |
| 2216 | { |
| 2217 | lldb::break_id_t bp_id = valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID(); |
| 2218 | BreakpointSP bp_sp = breakpoints.FindBreakpointByID(bp_id); |
| 2219 | bp_sp->RemoveName(m_name_options.m_name.GetCurrentValue()); |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | return true; |
| 2224 | } |
| 2225 | |
| 2226 | private: |
| 2227 | BreakpointNameOptionGroup m_name_options; |
| 2228 | OptionGroupOptions m_option_group; |
| 2229 | }; |
| 2230 | |
| 2231 | class CommandObjectBreakpointNameList : public CommandObjectParsed |
| 2232 | { |
| 2233 | public: |
| 2234 | CommandObjectBreakpointNameList (CommandInterpreter &interpreter) : |
| 2235 | CommandObjectParsed (interpreter, |
| 2236 | "list", |
| 2237 | "List either the names for a breakpoint or the breakpoints for a given name.", |
| 2238 | "breakpoint name list <command-options>"), |
| 2239 | m_name_options(), |
| 2240 | m_option_group(interpreter) |
| 2241 | { |
| 2242 | m_option_group.Append (&m_name_options); |
| 2243 | m_option_group.Finalize(); |
| 2244 | } |
| 2245 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2246 | ~CommandObjectBreakpointNameList () override {} |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2247 | |
| 2248 | Options * |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2249 | GetOptions () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2250 | { |
| 2251 | return &m_option_group; |
| 2252 | } |
| 2253 | |
| 2254 | protected: |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2255 | bool |
| 2256 | DoExecute (Args& command, CommandReturnObject &result) override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2257 | { |
| 2258 | Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); |
| 2259 | |
| 2260 | if (target == NULL) |
| 2261 | { |
| 2262 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
| 2263 | result.SetStatus (eReturnStatusFailed); |
| 2264 | return false; |
| 2265 | } |
| 2266 | |
| 2267 | if (m_name_options.m_name.OptionWasSet()) |
| 2268 | { |
| 2269 | const char *name = m_name_options.m_name.GetCurrentValue(); |
| 2270 | Mutex::Locker locker; |
| 2271 | target->GetBreakpointList().GetListMutex(locker); |
| 2272 | |
| 2273 | BreakpointList &breakpoints = target->GetBreakpointList(); |
| 2274 | for (BreakpointSP bp_sp : breakpoints.Breakpoints()) |
| 2275 | { |
| 2276 | if (bp_sp->MatchesName(name)) |
| 2277 | { |
| 2278 | StreamString s; |
| 2279 | bp_sp->GetDescription(&s, eDescriptionLevelBrief); |
| 2280 | s.EOL(); |
| 2281 | result.AppendMessage(s.GetData()); |
| 2282 | } |
| 2283 | } |
| 2284 | |
| 2285 | } |
| 2286 | else if (m_name_options.m_breakpoint.OptionWasSet()) |
| 2287 | { |
| 2288 | BreakpointSP bp_sp = target->GetBreakpointList().FindBreakpointByID(m_name_options.m_breakpoint.GetCurrentValue()); |
| 2289 | if (bp_sp) |
| 2290 | { |
| 2291 | std::vector<std::string> names; |
| 2292 | bp_sp->GetNames (names); |
| 2293 | result.AppendMessage ("Names:"); |
| 2294 | for (auto name : names) |
| 2295 | result.AppendMessageWithFormat (" %s\n", name.c_str()); |
| 2296 | } |
| 2297 | else |
| 2298 | { |
| 2299 | result.AppendErrorWithFormat ("Could not find breakpoint %" PRId64 ".\n", |
| 2300 | m_name_options.m_breakpoint.GetCurrentValue()); |
| 2301 | result.SetStatus (eReturnStatusFailed); |
| 2302 | return false; |
| 2303 | } |
| 2304 | } |
| 2305 | else |
| 2306 | { |
| 2307 | result.SetError ("Must specify -N or -B option to list."); |
| 2308 | result.SetStatus (eReturnStatusFailed); |
| 2309 | return false; |
| 2310 | } |
| 2311 | return true; |
| 2312 | } |
| 2313 | |
| 2314 | private: |
| 2315 | BreakpointNameOptionGroup m_name_options; |
| 2316 | OptionGroupOptions m_option_group; |
| 2317 | }; |
| 2318 | |
| 2319 | //------------------------------------------------------------------------- |
| 2320 | // CommandObjectMultiwordBreakpoint |
| 2321 | //------------------------------------------------------------------------- |
| 2322 | class CommandObjectBreakpointName : public CommandObjectMultiword |
| 2323 | { |
| 2324 | public: |
| 2325 | CommandObjectBreakpointName (CommandInterpreter &interpreter) : |
| 2326 | CommandObjectMultiword(interpreter, |
| 2327 | "name", |
| 2328 | "A set of commands to manage name tags for breakpoints", |
| 2329 | "breakpoint name <command> [<command-options>]") |
| 2330 | { |
| 2331 | CommandObjectSP add_command_object (new CommandObjectBreakpointNameAdd (interpreter)); |
| 2332 | CommandObjectSP delete_command_object (new CommandObjectBreakpointNameDelete (interpreter)); |
| 2333 | CommandObjectSP list_command_object (new CommandObjectBreakpointNameList (interpreter)); |
| 2334 | |
| 2335 | LoadSubCommand ("add", add_command_object); |
| 2336 | LoadSubCommand ("delete", delete_command_object); |
| 2337 | LoadSubCommand ("list", list_command_object); |
| 2338 | |
| 2339 | } |
| 2340 | |
Bruce Mitchener | 13d21e9 | 2015-10-07 16:56:17 +0000 | [diff] [blame] | 2341 | ~CommandObjectBreakpointName () override |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2342 | { |
| 2343 | } |
| 2344 | |
| 2345 | }; |
| 2346 | |
| 2347 | |
| 2348 | //------------------------------------------------------------------------- |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2349 | // CommandObjectMultiwordBreakpoint |
| 2350 | //------------------------------------------------------------------------- |
Jim Ingham | ae1c4cf | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 2351 | #pragma mark MultiwordBreakpoint |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2352 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 2353 | CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2354 | CommandObjectMultiword (interpreter, |
| 2355 | "breakpoint", |
Jim Ingham | 46fbc60 | 2011-05-26 20:39:01 +0000 | [diff] [blame] | 2356 | "A set of commands for operating on breakpoints. Also see _regexp-break.", |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2357 | "breakpoint <command> [<command-options>]") |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2358 | { |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2359 | CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2360 | CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); |
| 2361 | CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); |
Johnny Chen | b7234e4 | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 2362 | CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter)); |
| 2363 | CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2364 | CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2365 | CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2366 | CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2367 | CommandObjectSP name_command_object (new CommandObjectBreakpointName(interpreter)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2368 | |
Johnny Chen | b7234e4 | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 2369 | list_command_object->SetCommandName ("breakpoint list"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2370 | enable_command_object->SetCommandName("breakpoint enable"); |
| 2371 | disable_command_object->SetCommandName("breakpoint disable"); |
Johnny Chen | b7234e4 | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 2372 | clear_command_object->SetCommandName("breakpoint clear"); |
| 2373 | delete_command_object->SetCommandName("breakpoint delete"); |
Jim Ingham | ae1c4cf | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 2374 | set_command_object->SetCommandName("breakpoint set"); |
Johnny Chen | b7234e4 | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 2375 | command_command_object->SetCommandName ("breakpoint command"); |
| 2376 | modify_command_object->SetCommandName ("breakpoint modify"); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2377 | name_command_object->SetCommandName ("breakpoint name"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2378 | |
Greg Clayton | 23f5950 | 2012-07-17 03:23:13 +0000 | [diff] [blame] | 2379 | LoadSubCommand ("list", list_command_object); |
| 2380 | LoadSubCommand ("enable", enable_command_object); |
| 2381 | LoadSubCommand ("disable", disable_command_object); |
| 2382 | LoadSubCommand ("clear", clear_command_object); |
| 2383 | LoadSubCommand ("delete", delete_command_object); |
| 2384 | LoadSubCommand ("set", set_command_object); |
| 2385 | LoadSubCommand ("command", command_command_object); |
| 2386 | LoadSubCommand ("modify", modify_command_object); |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2387 | LoadSubCommand ("name", name_command_object); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2388 | } |
| 2389 | |
| 2390 | CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () |
| 2391 | { |
| 2392 | } |
| 2393 | |
| 2394 | void |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2395 | CommandObjectMultiwordBreakpoint::VerifyIDs (Args &args, |
| 2396 | Target *target, |
| 2397 | bool allow_locations, |
| 2398 | CommandReturnObject &result, |
| 2399 | BreakpointIDList *valid_ids) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2400 | { |
| 2401 | // args can be strings representing 1). integers (for breakpoint ids) |
| 2402 | // 2). the full breakpoint & location canonical representation |
| 2403 | // 3). the word "to" or a hyphen, representing a range (in which case there |
| 2404 | // had *better* be an entry both before & after of one of the first two types. |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2405 | // 4). A breakpoint name |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 2406 | // If args is empty, we will use the last created breakpoint (if there is one.) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2407 | |
| 2408 | Args temp_args; |
| 2409 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 2410 | if (args.GetArgumentCount() == 0) |
| 2411 | { |
Greg Clayton | 4d122c4 | 2011-09-17 08:33:22 +0000 | [diff] [blame] | 2412 | if (target->GetLastCreatedBreakpoint()) |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 2413 | { |
| 2414 | valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); |
| 2415 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 2416 | } |
| 2417 | else |
| 2418 | { |
| 2419 | result.AppendError("No breakpoint specified and no last created breakpoint."); |
| 2420 | result.SetStatus (eReturnStatusFailed); |
| 2421 | } |
| 2422 | return; |
| 2423 | } |
| 2424 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2425 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 2426 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 2427 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 2428 | |
Jim Ingham | 5e09c8c | 2014-12-16 23:40:14 +0000 | [diff] [blame] | 2429 | BreakpointIDList::FindAndReplaceIDRanges (args, target, allow_locations, result, temp_args); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2430 | |
| 2431 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 2432 | |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 2433 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2434 | |
| 2435 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 2436 | // and put into valid_ids. |
| 2437 | |
| 2438 | if (result.Succeeded()) |
| 2439 | { |
| 2440 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 2441 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 2442 | |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 2443 | const size_t count = valid_ids->GetSize(); |
| 2444 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2445 | { |
| 2446 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 2447 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 2448 | if (breakpoint != NULL) |
| 2449 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 2450 | const size_t num_locations = breakpoint->GetNumLocations(); |
Saleem Abdulrasool | 3985c8c | 2014-04-02 03:51:35 +0000 | [diff] [blame] | 2451 | if (static_cast<size_t>(cur_bp_id.GetLocationID()) > num_locations) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2452 | { |
| 2453 | StreamString id_str; |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 2454 | BreakpointID::GetCanonicalReference (&id_str, |
| 2455 | cur_bp_id.GetBreakpointID(), |
| 2456 | cur_bp_id.GetLocationID()); |
| 2457 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2458 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 2459 | id_str.GetData()); |
| 2460 | result.SetStatus (eReturnStatusFailed); |
| 2461 | } |
| 2462 | } |
| 2463 | else |
| 2464 | { |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 2465 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2466 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 2467 | result.SetStatus (eReturnStatusFailed); |
| 2468 | } |
| 2469 | } |
| 2470 | } |
| 2471 | } |