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