Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "CommandObjectBreakpoint.h" |
| 11 | #include "CommandObjectBreakpointCommand.h" |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | // Other libraries and framework includes |
| 16 | // Project includes |
| 17 | #include "lldb/Breakpoint/Breakpoint.h" |
| 18 | #include "lldb/Breakpoint/BreakpointIDList.h" |
| 19 | #include "lldb/Breakpoint/BreakpointLocation.h" |
Jim Ingham | 84cdc15 | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 20 | #include "lldb/Interpreter/Options.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #include "lldb/Core/RegularExpression.h" |
| 22 | #include "lldb/Core/StreamString.h" |
| 23 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 24 | #include "lldb/Interpreter/CommandReturnObject.h" |
| 25 | #include "lldb/Target/Target.h" |
| 26 | #include "lldb/Interpreter/CommandCompletions.h" |
| 27 | #include "lldb/Target/StackFrame.h" |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 28 | #include "lldb/Target/Thread.h" |
| 29 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 31 | #include <vector> |
| 32 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | using namespace lldb; |
| 34 | using namespace lldb_private; |
| 35 | |
| 36 | static void |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 37 | AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | { |
| 39 | s->IndentMore(); |
| 40 | bp->GetDescription (s, level, true); |
| 41 | s->IndentLess(); |
| 42 | s->EOL(); |
| 43 | } |
| 44 | |
| 45 | //------------------------------------------------------------------------- |
| 46 | // CommandObjectBreakpointSet::CommandOptions |
| 47 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 48 | #pragma mark Set::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 50 | CommandObjectBreakpointSet::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 51 | Options (interpreter), |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 52 | m_filenames (), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | m_line_num (0), |
| 54 | m_column (0), |
Greg Clayton | 2dfe4c6 | 2010-11-02 03:02:38 +0000 | [diff] [blame] | 55 | m_check_inlines (true), |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 56 | m_func_names (), |
| 57 | m_func_name_type_mask (eFunctionNameTypeNone), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 58 | m_func_regexp (), |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 59 | m_source_text_regexp(), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | m_modules (), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 61 | m_load_addr(), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 62 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 63 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 64 | m_thread_index (UINT32_MAX), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 65 | m_thread_name(), |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 66 | m_queue_name(), |
| 67 | m_catch_bp (false), |
| 68 | m_throw_bp (false), |
| 69 | m_language (eLanguageTypeUnknown) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | CommandObjectBreakpointSet::CommandOptions::~CommandOptions () |
| 74 | { |
| 75 | } |
| 76 | |
Johnny Chen | 8d03c6f | 2012-05-08 00:43:20 +0000 | [diff] [blame] | 77 | // If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to |
| 78 | // update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately. |
Johnny Chen | 6f4a115 | 2012-05-07 23:23:41 +0000 | [diff] [blame] | 79 | #define LLDB_OPT_FILE ( LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2 ) |
| 80 | #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 81 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 82 | OptionDefinition |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 83 | CommandObjectBreakpointSet::CommandOptions::g_option_table[] = |
| 84 | { |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 85 | { LLDB_OPT_NOT_10, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, eArgTypeShlibName, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 86 | "Set the breakpoint only in this shared library. " |
| 87 | "Can repeat this option multiple times to specify multiple shared libraries."}, |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 88 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 89 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, |
| 90 | "Set the number of times this breakpoint is skipped before stopping." }, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 91 | |
Bill Wendling | ff7df6d | 2012-04-03 04:13:41 +0000 | [diff] [blame] | 92 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 93 | "The breakpoint stops only for the thread whose index matches this argument."}, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 94 | |
Bill Wendling | ff7df6d | 2012-04-03 04:13:41 +0000 | [diff] [blame] | 95 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 96 | "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 97 | |
Bill Wendling | ff7df6d | 2012-04-03 04:13:41 +0000 | [diff] [blame] | 98 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 99 | "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 100 | |
Bill Wendling | ff7df6d | 2012-04-03 04:13:41 +0000 | [diff] [blame] | 101 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 102 | "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 103 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 104 | { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
| 105 | "Specifies the source file in which to set this breakpoint."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 106 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 107 | { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 108 | "Specifies the line number on which to set this breakpoint."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 109 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 110 | // Comment out this option for the moment, as we don't actually use it, but will in the future. |
| 111 | // This way users won't see it, but the infrastructure is left in place. |
| 112 | // { 0, false, "column", 'c', required_argument, NULL, "<column>", |
| 113 | // "Set the breakpoint by source location at this particular column."}, |
| 114 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 115 | { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 116 | "Set the breakpoint by address, at the specified address."}, |
| 117 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 118 | { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 119 | "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple snames" }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 120 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 121 | { LLDB_OPT_SET_4, true, "fullname", 'F', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 122 | "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and " |
| 123 | "for Objective C this means a full function prototype with class and selector. " |
| 124 | "Can be repeated multiple times to make one breakpoint for multiple names." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 125 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 126 | { LLDB_OPT_SET_5, true, "selector", 'S', required_argument, NULL, 0, eArgTypeSelector, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 127 | "Set the breakpoint by ObjC selector name. Can be repeated multiple times to make one breakpoint for multiple Selectors." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 128 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 129 | { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, eArgTypeMethod, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 130 | "Set the breakpoint by C++ method names. Can be repeated multiple times to make one breakpoint for multiple methods." }, |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 131 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 132 | { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, eArgTypeRegularExpression, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 133 | "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, |
| 134 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 135 | { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, |
Jim Ingham | ee033f2 | 2012-05-03 20:30:08 +0000 | [diff] [blame] | 136 | "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored). " |
| 137 | "Can be repeated multiple times to make one breakpoint for multiple symbols." }, |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 138 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 139 | { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression, |
| 140 | "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." }, |
| 141 | |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 142 | { LLDB_OPT_SET_10, true, "language-exception", 'E', required_argument, NULL, 0, eArgTypeLanguage, |
| 143 | "Set the breakpoint on exceptions thrown by the specified language (without options, on throw but not catch.)" }, |
| 144 | |
| 145 | { LLDB_OPT_SET_10, false, "on-throw", 'w', required_argument, NULL, 0, eArgTypeBoolean, |
| 146 | "Set the breakpoint on exception throW." }, |
| 147 | |
| 148 | { LLDB_OPT_SET_10, false, "on-catch", 'h', required_argument, NULL, 0, eArgTypeBoolean, |
| 149 | "Set the breakpoint on exception catcH." }, |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 150 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 151 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | }; |
| 153 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 154 | const OptionDefinition* |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 155 | CommandObjectBreakpointSet::CommandOptions::GetDefinitions () |
| 156 | { |
| 157 | return g_option_table; |
| 158 | } |
| 159 | |
| 160 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 161 | CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 162 | { |
| 163 | Error error; |
| 164 | char short_option = (char) m_getopt_table[option_idx].val; |
| 165 | |
| 166 | switch (short_option) |
| 167 | { |
| 168 | case 'a': |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 169 | m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 170 | if (m_load_addr == LLDB_INVALID_ADDRESS) |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 171 | m_load_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 172 | |
| 173 | if (m_load_addr == LLDB_INVALID_ADDRESS) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 174 | error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 175 | break; |
| 176 | |
| 177 | case 'c': |
| 178 | m_column = Args::StringToUInt32 (option_arg, 0); |
| 179 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 181 | case 'f': |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 182 | m_filenames.AppendIfUnique (FileSpec(option_arg, false)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 183 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 184 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 185 | case 'l': |
| 186 | m_line_num = Args::StringToUInt32 (option_arg, 0); |
| 187 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 188 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 189 | case 'b': |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 190 | m_func_names.push_back (option_arg); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 191 | m_func_name_type_mask |= eFunctionNameTypeBase; |
| 192 | break; |
| 193 | |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 194 | case 'n': |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 195 | m_func_names.push_back (option_arg); |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 196 | m_func_name_type_mask |= eFunctionNameTypeAuto; |
| 197 | break; |
| 198 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 199 | case 'F': |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 200 | m_func_names.push_back (option_arg); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 201 | m_func_name_type_mask |= eFunctionNameTypeFull; |
| 202 | break; |
| 203 | |
| 204 | case 'S': |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 205 | m_func_names.push_back (option_arg); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 206 | m_func_name_type_mask |= eFunctionNameTypeSelector; |
| 207 | break; |
| 208 | |
Jim Ingham | d9e2b76 | 2010-08-26 23:56:11 +0000 | [diff] [blame] | 209 | case 'M': |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 210 | m_func_names.push_back (option_arg); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 211 | m_func_name_type_mask |= eFunctionNameTypeMethod; |
| 212 | break; |
| 213 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 214 | case 'p': |
| 215 | m_source_text_regexp.assign (option_arg); |
| 216 | break; |
| 217 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 218 | case 'r': |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 219 | m_func_regexp.assign (option_arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 220 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 221 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 222 | case 's': |
| 223 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 224 | m_modules.AppendIfUnique (FileSpec (option_arg, false)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 225 | break; |
| 226 | } |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 227 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 228 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 229 | m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 230 | if (m_ignore_count == UINT32_MAX) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 231 | error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 232 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 233 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 234 | case 't' : |
| 235 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 236 | m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 237 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 238 | error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 239 | } |
| 240 | break; |
| 241 | case 'T': |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 242 | m_thread_name.assign (option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 243 | break; |
| 244 | case 'q': |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 245 | m_queue_name.assign (option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 246 | break; |
| 247 | case 'x': |
| 248 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 249 | m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 250 | if (m_thread_id == UINT32_MAX) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 251 | error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 252 | |
| 253 | } |
| 254 | break; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 255 | case 'E': |
| 256 | { |
| 257 | LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg); |
| 258 | |
| 259 | switch (language) |
| 260 | { |
| 261 | case eLanguageTypeC89: |
| 262 | case eLanguageTypeC: |
| 263 | case eLanguageTypeC99: |
| 264 | m_language = eLanguageTypeC; |
| 265 | break; |
| 266 | case eLanguageTypeC_plus_plus: |
| 267 | m_language = eLanguageTypeC_plus_plus; |
| 268 | break; |
| 269 | case eLanguageTypeObjC: |
| 270 | m_language = eLanguageTypeObjC; |
| 271 | break; |
| 272 | case eLanguageTypeObjC_plus_plus: |
| 273 | error.SetErrorStringWithFormat ("Set exception breakpoints separately for c++ and objective-c"); |
| 274 | break; |
| 275 | case eLanguageTypeUnknown: |
| 276 | error.SetErrorStringWithFormat ("Unknown language type: '%s' for exception breakpoint", option_arg); |
| 277 | break; |
| 278 | default: |
| 279 | error.SetErrorStringWithFormat ("Unsupported language type: '%s' for exception breakpoint", option_arg); |
| 280 | } |
| 281 | } |
| 282 | break; |
| 283 | case 'w': |
| 284 | { |
| 285 | bool success; |
| 286 | m_throw_bp = Args::StringToBoolean (option_arg, true, &success); |
| 287 | if (!success) |
| 288 | error.SetErrorStringWithFormat ("Invalid boolean value for on-throw option: '%s'", option_arg); |
| 289 | } |
| 290 | break; |
| 291 | case 'h': |
| 292 | { |
| 293 | bool success; |
| 294 | m_catch_bp = Args::StringToBoolean (option_arg, true, &success); |
| 295 | if (!success) |
| 296 | error.SetErrorStringWithFormat ("Invalid boolean value for on-catch option: '%s'", option_arg); |
| 297 | } |
| 298 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 299 | default: |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 300 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 301 | break; |
| 302 | } |
| 303 | |
| 304 | return error; |
| 305 | } |
| 306 | |
| 307 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 308 | CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 309 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 310 | m_filenames.Clear(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 311 | m_line_num = 0; |
| 312 | m_column = 0; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 313 | m_func_names.clear(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 314 | m_func_name_type_mask = 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 315 | m_func_regexp.clear(); |
| 316 | m_load_addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 317 | m_modules.Clear(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 318 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 319 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 320 | m_thread_index = UINT32_MAX; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 321 | m_thread_name.clear(); |
| 322 | m_queue_name.clear(); |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 323 | m_language = eLanguageTypeUnknown; |
| 324 | m_catch_bp = false; |
| 325 | m_throw_bp = true; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | //------------------------------------------------------------------------- |
| 329 | // CommandObjectBreakpointSet |
| 330 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 331 | #pragma mark Set |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 332 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 333 | CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) : |
| 334 | CommandObject (interpreter, |
| 335 | "breakpoint set", |
| 336 | "Sets a breakpoint or set of breakpoints in the executable.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 337 | "breakpoint set <cmd-options>"), |
| 338 | m_options (interpreter) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 339 | { |
| 340 | } |
| 341 | |
| 342 | CommandObjectBreakpointSet::~CommandObjectBreakpointSet () |
| 343 | { |
| 344 | } |
| 345 | |
| 346 | Options * |
| 347 | CommandObjectBreakpointSet::GetOptions () |
| 348 | { |
| 349 | return &m_options; |
| 350 | } |
| 351 | |
| 352 | bool |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 353 | CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 354 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 355 | uint32_t default_line; |
| 356 | // First use the Source Manager's default file. |
| 357 | // Then use the current stack frame's file. |
| 358 | if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 359 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 360 | StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr(); |
| 361 | if (cur_frame == NULL) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 362 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 363 | result.AppendError ("No selected frame to use to find the default file."); |
| 364 | result.SetStatus (eReturnStatusFailed); |
| 365 | return false; |
| 366 | } |
| 367 | else if (!cur_frame->HasDebugInformation()) |
| 368 | { |
| 369 | result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info."); |
| 370 | result.SetStatus (eReturnStatusFailed); |
| 371 | return false; |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); |
| 376 | if (sc.line_entry.file) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 377 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 378 | file = sc.line_entry.file; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 379 | } |
| 380 | else |
| 381 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 382 | result.AppendError ("Can't find the file for the selected frame to use as the default file."); |
| 383 | result.SetStatus (eReturnStatusFailed); |
| 384 | return false; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | } |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 388 | return true; |
| 389 | } |
| 390 | |
| 391 | bool |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 392 | CommandObjectBreakpointSet::Execute |
| 393 | ( |
| 394 | Args& command, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 395 | CommandReturnObject &result |
| 396 | ) |
| 397 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 398 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 399 | if (target == NULL) |
| 400 | { |
Greg Clayton | e1f50b9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 401 | result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command)."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 402 | result.SetStatus (eReturnStatusFailed); |
| 403 | return false; |
| 404 | } |
| 405 | |
| 406 | // The following are the various types of breakpoints that could be set: |
| 407 | // 1). -f -l -p [-s -g] (setting breakpoint by source location) |
| 408 | // 2). -a [-s -g] (setting breakpoint by address) |
| 409 | // 3). -n [-s -g] (setting breakpoint by function name) |
| 410 | // 4). -r [-s -g] (setting breakpoint by function name regular expression) |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 411 | // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text) |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 412 | // 6). -E [-w -h] (setting a breakpoint for exceptions for a given language.) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 413 | |
| 414 | BreakpointSetType break_type = eSetTypeInvalid; |
| 415 | |
| 416 | if (m_options.m_line_num != 0) |
| 417 | break_type = eSetTypeFileAndLine; |
| 418 | else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) |
| 419 | break_type = eSetTypeAddress; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 420 | else if (!m_options.m_func_names.empty()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 421 | break_type = eSetTypeFunctionName; |
| 422 | else if (!m_options.m_func_regexp.empty()) |
| 423 | break_type = eSetTypeFunctionRegexp; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 424 | else if (!m_options.m_source_text_regexp.empty()) |
| 425 | break_type = eSetTypeSourceRegexp; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 426 | else if (m_options.m_language != eLanguageTypeUnknown) |
| 427 | break_type = eSetTypeException; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 428 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | Breakpoint *bp = NULL; |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 430 | FileSpec module_spec; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | bool use_module = false; |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 432 | int num_modules = m_options.m_modules.GetSize(); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 433 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 434 | if ((num_modules > 0) && (break_type != eSetTypeAddress)) |
| 435 | use_module = true; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 436 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 437 | switch (break_type) |
| 438 | { |
| 439 | case eSetTypeFileAndLine: // Breakpoint by source position |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 440 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 441 | FileSpec file; |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 442 | uint32_t num_files = m_options.m_filenames.GetSize(); |
| 443 | if (num_files == 0) |
| 444 | { |
| 445 | if (!GetDefaultFile (target, file, result)) |
| 446 | { |
| 447 | result.AppendError("No file supplied and no default file available."); |
| 448 | result.SetStatus (eReturnStatusFailed); |
| 449 | return false; |
| 450 | } |
| 451 | } |
| 452 | else if (num_files > 1) |
| 453 | { |
| 454 | result.AppendError("Only one file at a time is allowed for file and line breakpoints."); |
| 455 | result.SetStatus (eReturnStatusFailed); |
| 456 | return false; |
| 457 | } |
| 458 | else |
| 459 | file = m_options.m_filenames.GetFileSpecAtIndex(0); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 460 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 461 | bp = target->CreateBreakpoint (&(m_options.m_modules), |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 462 | file, |
| 463 | m_options.m_line_num, |
| 464 | m_options.m_check_inlines).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 465 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 466 | break; |
| 467 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 468 | case eSetTypeAddress: // Breakpoint by address |
| 469 | bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); |
| 470 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 471 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 472 | case eSetTypeFunctionName: // Breakpoint by function name |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 473 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 474 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 475 | |
| 476 | if (name_type_mask == 0) |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 477 | name_type_mask = eFunctionNameTypeAuto; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 478 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 479 | bp = target->CreateBreakpoint (&(m_options.m_modules), |
| 480 | &(m_options.m_filenames), |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 481 | m_options.m_func_names, |
| 482 | name_type_mask, |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 483 | Breakpoint::Exact).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 485 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 486 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 487 | case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name |
| 488 | { |
| 489 | RegularExpression regexp(m_options.m_func_regexp.c_str()); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 490 | if (!regexp.IsValid()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 491 | { |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 492 | char err_str[1024]; |
| 493 | regexp.GetErrorAsCString(err_str, sizeof(err_str)); |
| 494 | result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"", |
| 495 | err_str); |
| 496 | result.SetStatus (eReturnStatusFailed); |
| 497 | return false; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 498 | } |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 499 | |
| 500 | bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 501 | } |
| 502 | break; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 503 | case eSetTypeSourceRegexp: // Breakpoint by regexp on source text. |
| 504 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 505 | int num_files = m_options.m_filenames.GetSize(); |
| 506 | |
| 507 | if (num_files == 0) |
| 508 | { |
| 509 | FileSpec file; |
| 510 | if (!GetDefaultFile (target, file, result)) |
| 511 | { |
| 512 | result.AppendError ("No files provided and could not find default file."); |
| 513 | result.SetStatus (eReturnStatusFailed); |
| 514 | return false; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | m_options.m_filenames.Append (file); |
| 519 | } |
| 520 | } |
| 521 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 522 | RegularExpression regexp(m_options.m_source_text_regexp.c_str()); |
| 523 | if (!regexp.IsValid()) |
| 524 | { |
| 525 | char err_str[1024]; |
| 526 | regexp.GetErrorAsCString(err_str, sizeof(err_str)); |
| 527 | result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"", |
| 528 | err_str); |
| 529 | result.SetStatus (eReturnStatusFailed); |
| 530 | return false; |
| 531 | } |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 532 | bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get(); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 533 | } |
| 534 | break; |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 535 | case eSetTypeException: |
| 536 | { |
| 537 | bp = target->CreateExceptionBreakpoint (m_options.m_language, m_options.m_catch_bp, m_options.m_throw_bp).get(); |
| 538 | } |
| 539 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 540 | default: |
| 541 | break; |
| 542 | } |
| 543 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 544 | // Now set the various options that were passed in: |
| 545 | if (bp) |
| 546 | { |
| 547 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 548 | bp->SetThreadID (m_options.m_thread_id); |
| 549 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 550 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 551 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 552 | |
| 553 | if (!m_options.m_thread_name.empty()) |
| 554 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 555 | |
| 556 | if (!m_options.m_queue_name.empty()) |
| 557 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 558 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 559 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 560 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
| 561 | } |
| 562 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 563 | if (bp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 564 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 565 | Stream &output_stream = result.GetOutputStream(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 566 | output_stream.Printf ("Breakpoint created: "); |
| 567 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 568 | output_stream.EOL(); |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 569 | // Don't print out this warning for exception breakpoints. They can get set before the target |
| 570 | // is set, but we won't know how to actually set the breakpoint till we run. |
| 571 | if (bp->GetNumLocations() == 0 && break_type != eSetTypeException) |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame] | 572 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual locations.\n"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 573 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 574 | } |
| 575 | else if (!bp) |
| 576 | { |
| 577 | result.AppendError ("Breakpoint creation failed: No breakpoint created."); |
| 578 | result.SetStatus (eReturnStatusFailed); |
| 579 | } |
| 580 | |
| 581 | return result.Succeeded(); |
| 582 | } |
| 583 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 584 | //------------------------------------------------------------------------- |
| 585 | // CommandObjectMultiwordBreakpoint |
| 586 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 587 | #pragma mark MultiwordBreakpoint |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 588 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 589 | CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 590 | CommandObjectMultiword (interpreter, |
| 591 | "breakpoint", |
Jim Ingham | 7224aab | 2011-05-26 20:39:01 +0000 | [diff] [blame] | 592 | "A set of commands for operating on breakpoints. Also see _regexp-break.", |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 593 | "breakpoint <command> [<command-options>]") |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 594 | { |
| 595 | bool status; |
| 596 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 597 | CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 598 | CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); |
| 599 | CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 600 | CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter)); |
| 601 | CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 602 | CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 603 | CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 604 | CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 605 | |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 606 | list_command_object->SetCommandName ("breakpoint list"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 607 | enable_command_object->SetCommandName("breakpoint enable"); |
| 608 | disable_command_object->SetCommandName("breakpoint disable"); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 609 | clear_command_object->SetCommandName("breakpoint clear"); |
| 610 | delete_command_object->SetCommandName("breakpoint delete"); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 611 | set_command_object->SetCommandName("breakpoint set"); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 612 | command_command_object->SetCommandName ("breakpoint command"); |
| 613 | modify_command_object->SetCommandName ("breakpoint modify"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 614 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 615 | status = LoadSubCommand ("list", list_command_object); |
| 616 | status = LoadSubCommand ("enable", enable_command_object); |
| 617 | status = LoadSubCommand ("disable", disable_command_object); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 618 | status = LoadSubCommand ("clear", clear_command_object); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 619 | status = LoadSubCommand ("delete", delete_command_object); |
| 620 | status = LoadSubCommand ("set", set_command_object); |
| 621 | status = LoadSubCommand ("command", command_command_object); |
| 622 | status = LoadSubCommand ("modify", modify_command_object); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () |
| 626 | { |
| 627 | } |
| 628 | |
| 629 | void |
| 630 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result, |
| 631 | BreakpointIDList *valid_ids) |
| 632 | { |
| 633 | // args can be strings representing 1). integers (for breakpoint ids) |
| 634 | // 2). the full breakpoint & location canonical representation |
| 635 | // 3). the word "to" or a hyphen, representing a range (in which case there |
| 636 | // had *better* be an entry both before & after of one of the first two types. |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 637 | // If args is empty, we will use the last created breakpoint (if there is one.) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 638 | |
| 639 | Args temp_args; |
| 640 | |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 641 | if (args.GetArgumentCount() == 0) |
| 642 | { |
Greg Clayton | 987c7eb | 2011-09-17 08:33:22 +0000 | [diff] [blame] | 643 | if (target->GetLastCreatedBreakpoint()) |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 644 | { |
| 645 | valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); |
| 646 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 647 | } |
| 648 | else |
| 649 | { |
| 650 | result.AppendError("No breakpoint specified and no last created breakpoint."); |
| 651 | result.SetStatus (eReturnStatusFailed); |
| 652 | } |
| 653 | return; |
| 654 | } |
| 655 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 656 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 657 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 658 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 659 | |
| 660 | BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); |
| 661 | |
| 662 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 663 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 664 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 665 | |
| 666 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 667 | // and put into valid_ids. |
| 668 | |
| 669 | if (result.Succeeded()) |
| 670 | { |
| 671 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 672 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 673 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 674 | const size_t count = valid_ids->GetSize(); |
| 675 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 676 | { |
| 677 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 678 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 679 | if (breakpoint != NULL) |
| 680 | { |
| 681 | int num_locations = breakpoint->GetNumLocations(); |
| 682 | if (cur_bp_id.GetLocationID() > num_locations) |
| 683 | { |
| 684 | StreamString id_str; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 685 | BreakpointID::GetCanonicalReference (&id_str, |
| 686 | cur_bp_id.GetBreakpointID(), |
| 687 | cur_bp_id.GetLocationID()); |
| 688 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 689 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 690 | id_str.GetData()); |
| 691 | result.SetStatus (eReturnStatusFailed); |
| 692 | } |
| 693 | } |
| 694 | else |
| 695 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 696 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 697 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 698 | result.SetStatus (eReturnStatusFailed); |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | //------------------------------------------------------------------------- |
| 705 | // CommandObjectBreakpointList::Options |
| 706 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 707 | #pragma mark List::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 708 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 709 | CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 710 | Options (interpreter), |
Caroline Tice | 41950cc | 2011-02-04 22:59:41 +0000 | [diff] [blame] | 711 | m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 712 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | CommandObjectBreakpointList::CommandOptions::~CommandOptions () |
| 716 | { |
| 717 | } |
| 718 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 719 | OptionDefinition |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 720 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 721 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 722 | { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 723 | "Show debugger internal breakpoints" }, |
| 724 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 725 | { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 726 | "Give a brief description of the breakpoint (no location info)."}, |
| 727 | |
| 728 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 729 | // But I need to see it for now, and don't want to wait. |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 730 | { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 731 | "Give a full description of the breakpoint and its locations."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 732 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 733 | { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 734 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 735 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 736 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 737 | }; |
| 738 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 739 | const OptionDefinition* |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 740 | CommandObjectBreakpointList::CommandOptions::GetDefinitions () |
| 741 | { |
| 742 | return g_option_table; |
| 743 | } |
| 744 | |
| 745 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 746 | CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 747 | { |
| 748 | Error error; |
| 749 | char short_option = (char) m_getopt_table[option_idx].val; |
| 750 | |
| 751 | switch (short_option) |
| 752 | { |
| 753 | case 'b': |
| 754 | m_level = lldb::eDescriptionLevelBrief; |
| 755 | break; |
| 756 | case 'f': |
| 757 | m_level = lldb::eDescriptionLevelFull; |
| 758 | break; |
| 759 | case 'v': |
| 760 | m_level = lldb::eDescriptionLevelVerbose; |
| 761 | break; |
| 762 | case 'i': |
| 763 | m_internal = true; |
| 764 | break; |
| 765 | default: |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 766 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 767 | break; |
| 768 | } |
| 769 | |
| 770 | return error; |
| 771 | } |
| 772 | |
| 773 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 774 | CommandObjectBreakpointList::CommandOptions::OptionParsingStarting () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 775 | { |
Jim Ingham | dc25905 | 2011-05-17 01:21:41 +0000 | [diff] [blame] | 776 | m_level = lldb::eDescriptionLevelFull; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 777 | m_internal = false; |
| 778 | } |
| 779 | |
| 780 | //------------------------------------------------------------------------- |
| 781 | // CommandObjectBreakpointList |
| 782 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 783 | #pragma mark List |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 784 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 785 | CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 786 | CommandObject (interpreter, |
| 787 | "breakpoint list", |
| 788 | "List some or all breakpoints at configurable levels of detail.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 789 | NULL), |
| 790 | m_options (interpreter) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 791 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 792 | CommandArgumentEntry arg; |
| 793 | CommandArgumentData bp_id_arg; |
| 794 | |
| 795 | // Define the first (and only) variant of this arg. |
| 796 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 797 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 798 | |
| 799 | // There is only one variant this argument could be; put it into the argument entry. |
| 800 | arg.push_back (bp_id_arg); |
| 801 | |
| 802 | // Push the data for the first argument into the m_arguments vector. |
| 803 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | CommandObjectBreakpointList::~CommandObjectBreakpointList () |
| 807 | { |
| 808 | } |
| 809 | |
| 810 | Options * |
| 811 | CommandObjectBreakpointList::GetOptions () |
| 812 | { |
| 813 | return &m_options; |
| 814 | } |
| 815 | |
| 816 | bool |
| 817 | CommandObjectBreakpointList::Execute |
| 818 | ( |
| 819 | Args& args, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 820 | CommandReturnObject &result |
| 821 | ) |
| 822 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 823 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 824 | if (target == NULL) |
| 825 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 826 | result.AppendError ("Invalid target. No current target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 827 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 828 | return true; |
| 829 | } |
| 830 | |
| 831 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 832 | Mutex::Locker locker; |
| 833 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 834 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 835 | size_t num_breakpoints = breakpoints.GetSize(); |
| 836 | |
| 837 | if (num_breakpoints == 0) |
| 838 | { |
| 839 | result.AppendMessage ("No breakpoints currently set."); |
| 840 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 841 | return true; |
| 842 | } |
| 843 | |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 844 | Stream &output_stream = result.GetOutputStream(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 845 | |
| 846 | if (args.GetArgumentCount() == 0) |
| 847 | { |
| 848 | // No breakpoint selected; show info about all currently set breakpoints. |
| 849 | result.AppendMessage ("Current breakpoints:"); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 850 | for (size_t i = 0; i < num_breakpoints; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 851 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 852 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 853 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 854 | } |
| 855 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 856 | } |
| 857 | else |
| 858 | { |
| 859 | // Particular breakpoints selected; show info about that breakpoint. |
| 860 | BreakpointIDList valid_bp_ids; |
| 861 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 862 | |
| 863 | if (result.Succeeded()) |
| 864 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 865 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 866 | { |
| 867 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 868 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 869 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 870 | } |
| 871 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 872 | } |
| 873 | else |
| 874 | { |
| 875 | result.AppendError ("Invalid breakpoint id."); |
| 876 | result.SetStatus (eReturnStatusFailed); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | return result.Succeeded(); |
| 881 | } |
| 882 | |
| 883 | //------------------------------------------------------------------------- |
| 884 | // CommandObjectBreakpointEnable |
| 885 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 886 | #pragma mark Enable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 887 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 888 | CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 889 | CommandObject (interpreter, |
| 890 | "enable", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 891 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 892 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 893 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 894 | CommandArgumentEntry arg; |
Johnny Chen | cacedfb | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 895 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 896 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 897 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | |
| 901 | CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () |
| 902 | { |
| 903 | } |
| 904 | |
| 905 | |
| 906 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 907 | CommandObjectBreakpointEnable::Execute |
| 908 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 909 | Args& args, |
| 910 | CommandReturnObject &result |
| 911 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 912 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 913 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 914 | if (target == NULL) |
| 915 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 916 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 917 | result.SetStatus (eReturnStatusFailed); |
| 918 | return false; |
| 919 | } |
| 920 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 921 | Mutex::Locker locker; |
| 922 | target->GetBreakpointList().GetListMutex(locker); |
| 923 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 924 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 925 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 926 | size_t num_breakpoints = breakpoints.GetSize(); |
| 927 | |
| 928 | if (num_breakpoints == 0) |
| 929 | { |
| 930 | result.AppendError ("No breakpoints exist to be enabled."); |
| 931 | result.SetStatus (eReturnStatusFailed); |
| 932 | return false; |
| 933 | } |
| 934 | |
| 935 | if (args.GetArgumentCount() == 0) |
| 936 | { |
| 937 | // No breakpoint selected; enable all currently set breakpoints. |
| 938 | target->EnableAllBreakpoints (); |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 939 | result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 940 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 941 | } |
| 942 | else |
| 943 | { |
| 944 | // Particular breakpoint selected; enable that breakpoint. |
| 945 | BreakpointIDList valid_bp_ids; |
| 946 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 947 | |
| 948 | if (result.Succeeded()) |
| 949 | { |
| 950 | int enable_count = 0; |
| 951 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 952 | const size_t count = valid_bp_ids.GetSize(); |
| 953 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 954 | { |
| 955 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 956 | |
| 957 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 958 | { |
| 959 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 960 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 961 | { |
| 962 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 963 | if (location) |
| 964 | { |
| 965 | location->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 966 | ++loc_count; |
| 967 | } |
| 968 | } |
| 969 | else |
| 970 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 971 | breakpoint->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 972 | ++enable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 973 | } |
| 974 | } |
| 975 | } |
| 976 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 977 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | return result.Succeeded(); |
| 982 | } |
| 983 | |
| 984 | //------------------------------------------------------------------------- |
| 985 | // CommandObjectBreakpointDisable |
| 986 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 987 | #pragma mark Disable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 988 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 989 | CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 990 | CommandObject (interpreter, |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 991 | "breakpoint disable", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 992 | "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 993 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 994 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 995 | CommandArgumentEntry arg; |
Johnny Chen | cacedfb | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 996 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 997 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 998 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () |
| 1002 | { |
| 1003 | } |
| 1004 | |
| 1005 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1006 | CommandObjectBreakpointDisable::Execute |
| 1007 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1008 | Args& args, |
| 1009 | CommandReturnObject &result |
| 1010 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1011 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1012 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1013 | if (target == NULL) |
| 1014 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1015 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1016 | result.SetStatus (eReturnStatusFailed); |
| 1017 | return false; |
| 1018 | } |
| 1019 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1020 | Mutex::Locker locker; |
| 1021 | target->GetBreakpointList().GetListMutex(locker); |
| 1022 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1023 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1024 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1025 | |
| 1026 | if (num_breakpoints == 0) |
| 1027 | { |
| 1028 | result.AppendError ("No breakpoints exist to be disabled."); |
| 1029 | result.SetStatus (eReturnStatusFailed); |
| 1030 | return false; |
| 1031 | } |
| 1032 | |
| 1033 | if (args.GetArgumentCount() == 0) |
| 1034 | { |
| 1035 | // No breakpoint selected; disable all currently set breakpoints. |
| 1036 | target->DisableAllBreakpoints (); |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 1037 | result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1038 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1039 | } |
| 1040 | else |
| 1041 | { |
| 1042 | // Particular breakpoint selected; disable that breakpoint. |
| 1043 | BreakpointIDList valid_bp_ids; |
| 1044 | |
| 1045 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1046 | |
| 1047 | if (result.Succeeded()) |
| 1048 | { |
| 1049 | int disable_count = 0; |
| 1050 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1051 | const size_t count = valid_bp_ids.GetSize(); |
| 1052 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1053 | { |
| 1054 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1055 | |
| 1056 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1057 | { |
| 1058 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1059 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1060 | { |
| 1061 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1062 | if (location) |
| 1063 | { |
| 1064 | location->SetEnabled (false); |
| 1065 | ++loc_count; |
| 1066 | } |
| 1067 | } |
| 1068 | else |
| 1069 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1070 | breakpoint->SetEnabled (false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1071 | ++disable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1072 | } |
| 1073 | } |
| 1074 | } |
| 1075 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1076 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | return result.Succeeded(); |
| 1081 | } |
| 1082 | |
| 1083 | //------------------------------------------------------------------------- |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1084 | // CommandObjectBreakpointClear::CommandOptions |
| 1085 | //------------------------------------------------------------------------- |
| 1086 | #pragma mark Clear::CommandOptions |
| 1087 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1088 | CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 1089 | Options (interpreter), |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1090 | m_filename (), |
| 1091 | m_line_num (0) |
| 1092 | { |
| 1093 | } |
| 1094 | |
| 1095 | CommandObjectBreakpointClear::CommandOptions::~CommandOptions () |
| 1096 | { |
| 1097 | } |
| 1098 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1099 | OptionDefinition |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1100 | CommandObjectBreakpointClear::CommandOptions::g_option_table[] = |
| 1101 | { |
| 1102 | { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
| 1103 | "Specify the breakpoint by source location in this particular file."}, |
| 1104 | |
| 1105 | { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, |
| 1106 | "Specify the breakpoint by source location at this particular line."}, |
| 1107 | |
| 1108 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
| 1109 | }; |
| 1110 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1111 | const OptionDefinition* |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1112 | CommandObjectBreakpointClear::CommandOptions::GetDefinitions () |
| 1113 | { |
| 1114 | return g_option_table; |
| 1115 | } |
| 1116 | |
| 1117 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1118 | CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1119 | { |
| 1120 | Error error; |
| 1121 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1122 | |
| 1123 | switch (short_option) |
| 1124 | { |
| 1125 | case 'f': |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1126 | m_filename.assign (option_arg); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1127 | break; |
| 1128 | |
| 1129 | case 'l': |
| 1130 | m_line_num = Args::StringToUInt32 (option_arg, 0); |
| 1131 | break; |
| 1132 | |
| 1133 | default: |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1134 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1135 | break; |
| 1136 | } |
| 1137 | |
| 1138 | return error; |
| 1139 | } |
| 1140 | |
| 1141 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1142 | CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting () |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1143 | { |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1144 | m_filename.clear(); |
| 1145 | m_line_num = 0; |
| 1146 | } |
| 1147 | |
| 1148 | //------------------------------------------------------------------------- |
| 1149 | // CommandObjectBreakpointClear |
| 1150 | //------------------------------------------------------------------------- |
| 1151 | #pragma mark Clear |
| 1152 | |
| 1153 | CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) : |
| 1154 | CommandObject (interpreter, |
| 1155 | "breakpoint clear", |
| 1156 | "Clears a breakpoint or set of breakpoints in the executable.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1157 | "breakpoint clear <cmd-options>"), |
| 1158 | m_options (interpreter) |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1159 | { |
| 1160 | } |
| 1161 | |
| 1162 | CommandObjectBreakpointClear::~CommandObjectBreakpointClear () |
| 1163 | { |
| 1164 | } |
| 1165 | |
| 1166 | Options * |
| 1167 | CommandObjectBreakpointClear::GetOptions () |
| 1168 | { |
| 1169 | return &m_options; |
| 1170 | } |
| 1171 | |
| 1172 | bool |
| 1173 | CommandObjectBreakpointClear::Execute |
| 1174 | ( |
| 1175 | Args& command, |
| 1176 | CommandReturnObject &result |
| 1177 | ) |
| 1178 | { |
| 1179 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
| 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 | // The following are the various types of breakpoints that could be cleared: |
| 1188 | // 1). -f -l (clearing breakpoint by source location) |
| 1189 | |
| 1190 | BreakpointClearType break_type = eClearTypeInvalid; |
| 1191 | |
| 1192 | if (m_options.m_line_num != 0) |
| 1193 | break_type = eClearTypeFileAndLine; |
| 1194 | |
| 1195 | Mutex::Locker locker; |
| 1196 | target->GetBreakpointList().GetListMutex(locker); |
| 1197 | |
| 1198 | BreakpointList &breakpoints = target->GetBreakpointList(); |
| 1199 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1200 | |
| 1201 | // Early return if there's no breakpoint at all. |
| 1202 | if (num_breakpoints == 0) |
| 1203 | { |
| 1204 | result.AppendError ("Breakpoint clear: No breakpoint cleared."); |
| 1205 | result.SetStatus (eReturnStatusFailed); |
| 1206 | return result.Succeeded(); |
| 1207 | } |
| 1208 | |
| 1209 | // Find matching breakpoints and delete them. |
| 1210 | |
| 1211 | // First create a copy of all the IDs. |
| 1212 | std::vector<break_id_t> BreakIDs; |
| 1213 | for (size_t i = 0; i < num_breakpoints; ++i) |
| 1214 | BreakIDs.push_back(breakpoints.GetBreakpointAtIndex(i).get()->GetID()); |
| 1215 | |
| 1216 | int num_cleared = 0; |
| 1217 | StreamString ss; |
| 1218 | switch (break_type) |
| 1219 | { |
| 1220 | case eClearTypeFileAndLine: // Breakpoint by source position |
| 1221 | { |
| 1222 | const ConstString filename(m_options.m_filename.c_str()); |
| 1223 | BreakpointLocationCollection loc_coll; |
| 1224 | |
| 1225 | for (size_t i = 0; i < num_breakpoints; ++i) |
| 1226 | { |
| 1227 | Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get(); |
| 1228 | |
| 1229 | if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) |
| 1230 | { |
| 1231 | // If the collection size is 0, it's a full match and we can just remove the breakpoint. |
| 1232 | if (loc_coll.GetSize() == 0) |
| 1233 | { |
| 1234 | bp->GetDescription(&ss, lldb::eDescriptionLevelBrief); |
| 1235 | ss.EOL(); |
| 1236 | target->RemoveBreakpointByID (bp->GetID()); |
| 1237 | ++num_cleared; |
| 1238 | } |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | break; |
| 1243 | |
| 1244 | default: |
| 1245 | break; |
| 1246 | } |
| 1247 | |
| 1248 | if (num_cleared > 0) |
| 1249 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 1250 | Stream &output_stream = result.GetOutputStream(); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1251 | output_stream.Printf ("%d breakpoints cleared:\n", num_cleared); |
| 1252 | output_stream << ss.GetData(); |
| 1253 | output_stream.EOL(); |
| 1254 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1255 | } |
| 1256 | else |
| 1257 | { |
| 1258 | result.AppendError ("Breakpoint clear: No breakpoint cleared."); |
| 1259 | result.SetStatus (eReturnStatusFailed); |
| 1260 | } |
| 1261 | |
| 1262 | return result.Succeeded(); |
| 1263 | } |
| 1264 | |
| 1265 | //------------------------------------------------------------------------- |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1266 | // CommandObjectBreakpointDelete |
| 1267 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1268 | #pragma mark Delete |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1269 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1270 | CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : |
| 1271 | CommandObject (interpreter, |
| 1272 | "breakpoint delete", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 1273 | "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1274 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1275 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1276 | CommandArgumentEntry arg; |
Johnny Chen | cacedfb | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 1277 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1278 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1279 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | |
| 1283 | CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () |
| 1284 | { |
| 1285 | } |
| 1286 | |
| 1287 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1288 | CommandObjectBreakpointDelete::Execute |
| 1289 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1290 | Args& args, |
| 1291 | CommandReturnObject &result |
| 1292 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1293 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1294 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1295 | if (target == NULL) |
| 1296 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1297 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1298 | result.SetStatus (eReturnStatusFailed); |
| 1299 | return false; |
| 1300 | } |
| 1301 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1302 | Mutex::Locker locker; |
| 1303 | target->GetBreakpointList().GetListMutex(locker); |
| 1304 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1305 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1306 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1307 | size_t num_breakpoints = breakpoints.GetSize(); |
| 1308 | |
| 1309 | if (num_breakpoints == 0) |
| 1310 | { |
| 1311 | result.AppendError ("No breakpoints exist to be deleted."); |
| 1312 | result.SetStatus (eReturnStatusFailed); |
| 1313 | return false; |
| 1314 | } |
| 1315 | |
| 1316 | if (args.GetArgumentCount() == 0) |
| 1317 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1318 | if (!m_interpreter.Confirm ("About to delete all breakpoints, do you want to do that?", true)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1319 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1320 | result.AppendMessage("Operation cancelled..."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1321 | } |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1322 | else |
| 1323 | { |
| 1324 | target->RemoveAllBreakpoints (); |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 1325 | result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1326 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1327 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1328 | } |
| 1329 | else |
| 1330 | { |
| 1331 | // Particular breakpoint selected; disable that breakpoint. |
| 1332 | BreakpointIDList valid_bp_ids; |
| 1333 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1334 | |
| 1335 | if (result.Succeeded()) |
| 1336 | { |
| 1337 | int delete_count = 0; |
| 1338 | int disable_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1339 | const size_t count = valid_bp_ids.GetSize(); |
| 1340 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1341 | { |
| 1342 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1343 | |
| 1344 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1345 | { |
| 1346 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1347 | { |
| 1348 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1349 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1350 | // It makes no sense to try to delete individual locations, so we disable them instead. |
| 1351 | if (location) |
| 1352 | { |
| 1353 | location->SetEnabled (false); |
| 1354 | ++disable_count; |
| 1355 | } |
| 1356 | } |
| 1357 | else |
| 1358 | { |
| 1359 | target->RemoveBreakpointByID (cur_bp_id.GetBreakpointID()); |
| 1360 | ++delete_count; |
| 1361 | } |
| 1362 | } |
| 1363 | } |
| 1364 | result.AppendMessageWithFormat ("%d breakpoints deleted; %d breakpoint locations disabled.\n", |
| 1365 | delete_count, disable_count); |
| 1366 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1367 | } |
| 1368 | } |
| 1369 | return result.Succeeded(); |
| 1370 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1371 | |
| 1372 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1373 | // CommandObjectBreakpointModify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1374 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1375 | #pragma mark Modify::CommandOptions |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1376 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1377 | CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 1378 | Options (interpreter), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1379 | m_ignore_count (0), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1380 | m_thread_id(LLDB_INVALID_THREAD_ID), |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1381 | m_thread_id_passed(false), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1382 | m_thread_index (UINT32_MAX), |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1383 | m_thread_index_passed(false), |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1384 | m_thread_name(), |
| 1385 | m_queue_name(), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1386 | m_condition (), |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1387 | m_enable_passed (false), |
| 1388 | m_enable_value (false), |
| 1389 | m_name_passed (false), |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1390 | m_queue_passed (false), |
| 1391 | m_condition_passed (false) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1392 | { |
| 1393 | } |
| 1394 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1395 | CommandObjectBreakpointModify::CommandOptions::~CommandOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1396 | { |
| 1397 | } |
| 1398 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1399 | OptionDefinition |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1400 | CommandObjectBreakpointModify::CommandOptions::g_option_table[] = |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1401 | { |
Bill Wendling | ff7df6d | 2012-04-03 04:13:41 +0000 | [diff] [blame] | 1402 | { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, eArgTypeCount, "Set the number of times this breakpoint is skipped before stopping." }, |
| 1403 | { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, 0, eArgTypeThreadIndex, "The breakpoint stops only for the thread whose indeX matches this argument."}, |
| 1404 | { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, 0, eArgTypeThreadID, "The breakpoint stops only for the thread whose TID matches this argument."}, |
| 1405 | { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, 0, eArgTypeThreadName, "The breakpoint stops only for the thread whose thread name matches this argument."}, |
| 1406 | { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, 0, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, |
| 1407 | { LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, 0, eArgTypeExpression, "The breakpoint stops only if this condition expression evaluates to true."}, |
| 1408 | { LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, 0, eArgTypeNone, "Enable the breakpoint."}, |
| 1409 | { LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, 0, eArgTypeNone, "Disable the breakpoint."}, |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1410 | { 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1411 | }; |
| 1412 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1413 | const OptionDefinition* |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1414 | CommandObjectBreakpointModify::CommandOptions::GetDefinitions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1415 | { |
| 1416 | return g_option_table; |
| 1417 | } |
| 1418 | |
| 1419 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1420 | CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1421 | { |
| 1422 | Error error; |
| 1423 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1424 | |
| 1425 | switch (short_option) |
| 1426 | { |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1427 | case 'c': |
| 1428 | if (option_arg != NULL) |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1429 | m_condition.assign (option_arg); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1430 | else |
| 1431 | m_condition.clear(); |
| 1432 | m_condition_passed = true; |
| 1433 | break; |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1434 | case 'd': |
| 1435 | m_enable_passed = true; |
| 1436 | m_enable_value = false; |
| 1437 | break; |
| 1438 | case 'e': |
| 1439 | m_enable_passed = true; |
| 1440 | m_enable_value = true; |
| 1441 | break; |
Greg Clayton | fe424a9 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 1442 | case 'i': |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1443 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 1444 | m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1445 | if (m_ignore_count == UINT32_MAX) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1446 | error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1447 | } |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1448 | break; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1449 | case 't' : |
| 1450 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 1451 | if (option_arg[0] == '\0') |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1452 | { |
| 1453 | m_thread_id = LLDB_INVALID_THREAD_ID; |
| 1454 | m_thread_id_passed = true; |
| 1455 | } |
| 1456 | else |
| 1457 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 1458 | m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0); |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1459 | if (m_thread_id == LLDB_INVALID_THREAD_ID) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1460 | error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg); |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1461 | else |
| 1462 | m_thread_id_passed = true; |
| 1463 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1464 | } |
| 1465 | break; |
| 1466 | case 'T': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1467 | if (option_arg != NULL) |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1468 | m_thread_name.assign (option_arg); |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1469 | else |
| 1470 | m_thread_name.clear(); |
| 1471 | m_name_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1472 | break; |
| 1473 | case 'q': |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1474 | if (option_arg != NULL) |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1475 | m_queue_name.assign (option_arg); |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1476 | else |
| 1477 | m_queue_name.clear(); |
| 1478 | m_queue_passed = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1479 | break; |
| 1480 | case 'x': |
| 1481 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 1482 | if (option_arg[0] == '\n') |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1483 | { |
| 1484 | m_thread_index = UINT32_MAX; |
| 1485 | m_thread_index_passed = true; |
| 1486 | } |
| 1487 | else |
| 1488 | { |
Jim Ingham | 7a4c8ea | 2011-03-22 01:53:33 +0000 | [diff] [blame] | 1489 | m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0); |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1490 | if (m_thread_id == UINT32_MAX) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1491 | error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg); |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1492 | else |
| 1493 | m_thread_index_passed = true; |
| 1494 | } |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1495 | } |
| 1496 | break; |
| 1497 | default: |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1498 | error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1499 | break; |
| 1500 | } |
| 1501 | |
| 1502 | return error; |
| 1503 | } |
| 1504 | |
| 1505 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1506 | CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1507 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1508 | m_ignore_count = 0; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1509 | m_thread_id = LLDB_INVALID_THREAD_ID; |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1510 | m_thread_id_passed = false; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1511 | m_thread_index = UINT32_MAX; |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1512 | m_thread_index_passed = false; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1513 | m_thread_name.clear(); |
| 1514 | m_queue_name.clear(); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1515 | m_condition.clear(); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1516 | m_enable_passed = false; |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1517 | m_queue_passed = false; |
| 1518 | m_name_passed = false; |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1519 | m_condition_passed = false; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1520 | } |
| 1521 | |
| 1522 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1523 | // CommandObjectBreakpointModify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1524 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1525 | #pragma mark Modify |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1526 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1527 | CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : |
| 1528 | CommandObject (interpreter, |
| 1529 | "breakpoint modify", |
Jim Ingham | 19ac0bd | 2010-12-03 22:37:19 +0000 | [diff] [blame] | 1530 | "Modify the options on a breakpoint or set of breakpoints in the executable. " |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1531 | "If no breakpoint is specified, acts on the last created breakpoint. " |
| 1532 | "With the exception of -e, -d and -i, passing an empty argument clears the modification.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1533 | NULL), |
| 1534 | m_options (interpreter) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1535 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1536 | CommandArgumentEntry arg; |
Johnny Chen | cacedfb | 2011-09-22 22:34:09 +0000 | [diff] [blame] | 1537 | CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1538 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1539 | m_arguments.push_back (arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1540 | } |
| 1541 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1542 | CommandObjectBreakpointModify::~CommandObjectBreakpointModify () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1543 | { |
| 1544 | } |
| 1545 | |
| 1546 | Options * |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1547 | CommandObjectBreakpointModify::GetOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1548 | { |
| 1549 | return &m_options; |
| 1550 | } |
| 1551 | |
| 1552 | bool |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1553 | CommandObjectBreakpointModify::Execute |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1554 | ( |
| 1555 | Args& command, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1556 | CommandReturnObject &result |
| 1557 | ) |
| 1558 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1559 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1560 | if (target == NULL) |
| 1561 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1562 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1563 | result.SetStatus (eReturnStatusFailed); |
| 1564 | return false; |
| 1565 | } |
| 1566 | |
| 1567 | Mutex::Locker locker; |
| 1568 | target->GetBreakpointList().GetListMutex(locker); |
| 1569 | |
| 1570 | BreakpointIDList valid_bp_ids; |
| 1571 | |
| 1572 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 1573 | |
| 1574 | if (result.Succeeded()) |
| 1575 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1576 | const size_t count = valid_bp_ids.GetSize(); |
| 1577 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1578 | { |
| 1579 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1580 | |
| 1581 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1582 | { |
| 1583 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1584 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1585 | { |
| 1586 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1587 | if (location) |
| 1588 | { |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1589 | if (m_options.m_thread_id_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1590 | location->SetThreadID (m_options.m_thread_id); |
| 1591 | |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1592 | if (m_options.m_thread_index_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1593 | location->SetThreadIndex(m_options.m_thread_index); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1594 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1595 | if (m_options.m_name_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1596 | location->SetThreadName(m_options.m_thread_name.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1597 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1598 | if (m_options.m_queue_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1599 | location->SetQueueName(m_options.m_queue_name.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1600 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1601 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1602 | location->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1603 | |
| 1604 | if (m_options.m_enable_passed) |
| 1605 | location->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1606 | |
| 1607 | if (m_options.m_condition_passed) |
| 1608 | location->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1609 | } |
| 1610 | } |
| 1611 | else |
| 1612 | { |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1613 | if (m_options.m_thread_id_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1614 | bp->SetThreadID (m_options.m_thread_id); |
| 1615 | |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1616 | if (m_options.m_thread_index_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1617 | bp->SetThreadIndex(m_options.m_thread_index); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1618 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1619 | if (m_options.m_name_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1620 | bp->SetThreadName(m_options.m_thread_name.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1621 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1622 | if (m_options.m_queue_passed) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1623 | bp->SetQueueName(m_options.m_queue_name.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1624 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1625 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 1626 | bp->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1627 | |
| 1628 | if (m_options.m_enable_passed) |
| 1629 | bp->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1630 | |
| 1631 | if (m_options.m_condition_passed) |
| 1632 | bp->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1633 | } |
| 1634 | } |
| 1635 | } |
| 1636 | } |
| 1637 | |
| 1638 | return result.Succeeded(); |
| 1639 | } |
| 1640 | |
| 1641 | |