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