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