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