Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "CommandObjectBreakpoint.h" |
| 11 | #include "CommandObjectBreakpointCommand.h" |
| 12 | |
| 13 | // C Includes |
| 14 | // C++ Includes |
| 15 | // Other libraries and framework includes |
| 16 | // Project includes |
| 17 | #include "lldb/Breakpoint/Breakpoint.h" |
| 18 | #include "lldb/Breakpoint/BreakpointIDList.h" |
| 19 | #include "lldb/Breakpoint/BreakpointLocation.h" |
Jim Ingham | 84cdc15 | 2010-06-15 19:49:27 +0000 | [diff] [blame] | 20 | #include "lldb/Interpreter/Options.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #include "lldb/Core/RegularExpression.h" |
| 22 | #include "lldb/Core/StreamString.h" |
| 23 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 24 | #include "lldb/Interpreter/CommandReturnObject.h" |
| 25 | #include "lldb/Target/Target.h" |
| 26 | #include "lldb/Interpreter/CommandCompletions.h" |
| 27 | #include "lldb/Target/StackFrame.h" |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 28 | #include "lldb/Target/Thread.h" |
| 29 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 31 | #include <vector> |
| 32 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | using namespace lldb; |
| 34 | using namespace lldb_private; |
| 35 | |
| 36 | static void |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 37 | AddBreakpointDescription (Stream *s, Breakpoint *bp, lldb::DescriptionLevel level) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | { |
| 39 | s->IndentMore(); |
| 40 | bp->GetDescription (s, level, true); |
| 41 | s->IndentLess(); |
| 42 | s->EOL(); |
| 43 | } |
| 44 | |
| 45 | //------------------------------------------------------------------------- |
| 46 | // CommandObjectBreakpointSet::CommandOptions |
| 47 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 48 | #pragma mark Set::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 50 | CommandObjectBreakpointSet::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 51 | Options (interpreter), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 137 | CommandObjectBreakpointSet::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 236 | CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 262 | "breakpoint set <cmd-options>"), |
| 263 | m_options (interpreter) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | { |
| 265 | } |
| 266 | |
| 267 | CommandObjectBreakpointSet::~CommandObjectBreakpointSet () |
| 268 | { |
| 269 | } |
| 270 | |
| 271 | Options * |
| 272 | CommandObjectBreakpointSet::GetOptions () |
| 273 | { |
| 274 | return &m_options; |
| 275 | } |
| 276 | |
| 277 | bool |
| 278 | CommandObjectBreakpointSet::Execute |
| 279 | ( |
| 280 | Args& command, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 281 | CommandReturnObject &result |
| 282 | ) |
| 283 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 284 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 285 | if (target == NULL) |
| 286 | { |
Greg Clayton | e1f50b9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 287 | result.AppendError ("Invalid target. Must set target before setting breakpoints (see 'target create' command)."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 288 | result.SetStatus (eReturnStatusFailed); |
| 289 | return false; |
| 290 | } |
| 291 | |
| 292 | // The following are the various types of breakpoints that could be set: |
| 293 | // 1). -f -l -p [-s -g] (setting breakpoint by source location) |
| 294 | // 2). -a [-s -g] (setting breakpoint by address) |
| 295 | // 3). -n [-s -g] (setting breakpoint by function name) |
| 296 | // 4). -r [-s -g] (setting breakpoint by function name regular expression) |
| 297 | |
| 298 | BreakpointSetType break_type = eSetTypeInvalid; |
| 299 | |
| 300 | if (m_options.m_line_num != 0) |
| 301 | break_type = eSetTypeFileAndLine; |
| 302 | else if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) |
| 303 | break_type = eSetTypeAddress; |
| 304 | else if (!m_options.m_func_name.empty()) |
| 305 | break_type = eSetTypeFunctionName; |
| 306 | else if (!m_options.m_func_regexp.empty()) |
| 307 | break_type = eSetTypeFunctionRegexp; |
| 308 | |
| 309 | ModuleSP module_sp = target->GetExecutableModule(); |
| 310 | Breakpoint *bp = NULL; |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 311 | FileSpec module_spec; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | bool use_module = false; |
| 313 | int num_modules = m_options.m_modules.size(); |
| 314 | |
| 315 | if ((num_modules > 0) && (break_type != eSetTypeAddress)) |
| 316 | use_module = true; |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 317 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 318 | switch (break_type) |
| 319 | { |
| 320 | case eSetTypeFileAndLine: // Breakpoint by source position |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 321 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 322 | FileSpec file; |
| 323 | if (m_options.m_filename.empty()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 324 | { |
Greg Clayton | b72d0f0 | 2011-04-12 05:54:46 +0000 | [diff] [blame] | 325 | StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 326 | if (cur_frame == NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 327 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 328 | 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] | 329 | result.SetStatus (eReturnStatusFailed); |
| 330 | break; |
| 331 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 332 | else if (!cur_frame->HasDebugInformation()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 333 | { |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 334 | result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); |
| 335 | result.SetStatus (eReturnStatusFailed); |
| 336 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 337 | } |
| 338 | else |
| 339 | { |
Greg Clayton | 52c8b6e | 2011-04-19 04:19:37 +0000 | [diff] [blame] | 340 | const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); |
| 341 | if (sc.line_entry.file) |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 342 | { |
Greg Clayton | 52c8b6e | 2011-04-19 04:19:37 +0000 | [diff] [blame] | 343 | file = sc.line_entry.file; |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 344 | } |
| 345 | else |
| 346 | { |
| 347 | result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); |
| 348 | result.SetStatus (eReturnStatusFailed); |
| 349 | break; |
| 350 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 351 | } |
| 352 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 353 | else |
| 354 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 355 | file.SetFile(m_options.m_filename.c_str(), false); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | if (use_module) |
| 359 | { |
| 360 | for (int i = 0; i < num_modules; ++i) |
| 361 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 362 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 363 | bp = target->CreateBreakpoint (&module_spec, |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 364 | file, |
| 365 | m_options.m_line_num, |
Greg Clayton | 2dfe4c6 | 2010-11-02 03:02:38 +0000 | [diff] [blame] | 366 | m_options.m_check_inlines).get(); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 367 | if (bp) |
| 368 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 369 | Stream &output_stream = result.GetOutputStream(); |
| 370 | result.AppendMessage ("Breakpoint created: "); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 371 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 372 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame] | 373 | if (bp->GetNumLocations() == 0) |
| 374 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 375 | " locations.\n"); |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 376 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 377 | } |
| 378 | else |
| 379 | { |
| 380 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 381 | m_options.m_modules[i].c_str()); |
| 382 | result.SetStatus (eReturnStatusFailed); |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | else |
| 387 | bp = target->CreateBreakpoint (NULL, |
| 388 | file, |
| 389 | m_options.m_line_num, |
Greg Clayton | 2dfe4c6 | 2010-11-02 03:02:38 +0000 | [diff] [blame] | 390 | m_options.m_check_inlines).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 391 | } |
Greg Clayton | 887aa28 | 2010-10-11 01:05:37 +0000 | [diff] [blame] | 392 | break; |
| 393 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 394 | case eSetTypeAddress: // Breakpoint by address |
| 395 | bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); |
| 396 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 397 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 398 | case eSetTypeFunctionName: // Breakpoint by function name |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 399 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 400 | uint32_t name_type_mask = m_options.m_func_name_type_mask; |
| 401 | |
| 402 | if (name_type_mask == 0) |
Greg Clayton | 48fbdf7 | 2010-10-12 04:29:14 +0000 | [diff] [blame] | 403 | name_type_mask = eFunctionNameTypeAuto; |
| 404 | |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 405 | if (use_module) |
| 406 | { |
| 407 | for (int i = 0; i < num_modules; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 408 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 409 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 410 | bp = target->CreateBreakpoint (&module_spec, |
| 411 | m_options.m_func_name.c_str(), |
| 412 | name_type_mask, |
| 413 | Breakpoint::Exact).get(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 414 | if (bp) |
| 415 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 416 | Stream &output_stream = result.GetOutputStream(); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 417 | output_stream.Printf ("Breakpoint created: "); |
| 418 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 419 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame] | 420 | if (bp->GetNumLocations() == 0) |
| 421 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 422 | " locations.\n"); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 423 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 428 | m_options.m_modules[i].c_str()); |
| 429 | result.SetStatus (eReturnStatusFailed); |
| 430 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | } |
| 432 | } |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 433 | else |
| 434 | 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] | 435 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 436 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 437 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 438 | case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name |
| 439 | { |
| 440 | RegularExpression regexp(m_options.m_func_regexp.c_str()); |
| 441 | if (use_module) |
| 442 | { |
| 443 | for (int i = 0; i < num_modules; ++i) |
| 444 | { |
Greg Clayton | 537a7a8 | 2010-10-20 20:54:39 +0000 | [diff] [blame] | 445 | module_spec.SetFile(m_options.m_modules[i].c_str(), false); |
| 446 | bp = target->CreateBreakpoint (&module_spec, regexp).get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 447 | if (bp) |
| 448 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 449 | Stream &output_stream = result.GetOutputStream(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 450 | output_stream.Printf ("Breakpoint created: "); |
| 451 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 452 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame] | 453 | if (bp->GetNumLocations() == 0) |
| 454 | output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" |
| 455 | " locations.\n"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 456 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 457 | } |
| 458 | else |
| 459 | { |
| 460 | result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", |
| 461 | m_options.m_modules[i].c_str()); |
| 462 | result.SetStatus (eReturnStatusFailed); |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | else |
| 467 | bp = target->CreateBreakpoint (NULL, regexp).get(); |
| 468 | } |
| 469 | break; |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 470 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 471 | default: |
| 472 | break; |
| 473 | } |
| 474 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 475 | // Now set the various options that were passed in: |
| 476 | if (bp) |
| 477 | { |
| 478 | if (m_options.m_thread_id != LLDB_INVALID_THREAD_ID) |
| 479 | bp->SetThreadID (m_options.m_thread_id); |
| 480 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 481 | if (m_options.m_thread_index != UINT32_MAX) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 482 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 483 | |
| 484 | if (!m_options.m_thread_name.empty()) |
| 485 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 486 | |
| 487 | if (!m_options.m_queue_name.empty()) |
| 488 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 489 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 490 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 491 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
| 492 | } |
| 493 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 494 | if (bp && !use_module) |
| 495 | { |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 496 | Stream &output_stream = result.GetOutputStream(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 497 | output_stream.Printf ("Breakpoint created: "); |
| 498 | bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); |
| 499 | output_stream.EOL(); |
Caroline Tice | cf2f305 | 2010-10-28 16:28:56 +0000 | [diff] [blame] | 500 | if (bp->GetNumLocations() == 0) |
| 501 | 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] | 502 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 503 | } |
| 504 | else if (!bp) |
| 505 | { |
| 506 | result.AppendError ("Breakpoint creation failed: No breakpoint created."); |
| 507 | result.SetStatus (eReturnStatusFailed); |
| 508 | } |
| 509 | |
| 510 | return result.Succeeded(); |
| 511 | } |
| 512 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 513 | //------------------------------------------------------------------------- |
| 514 | // CommandObjectMultiwordBreakpoint |
| 515 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 516 | #pragma mark MultiwordBreakpoint |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 517 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 518 | CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 519 | CommandObjectMultiword (interpreter, |
| 520 | "breakpoint", |
| 521 | "A set of commands for operating on breakpoints. Also see regexp-break.", |
| 522 | "breakpoint <command> [<command-options>]") |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 523 | { |
| 524 | bool status; |
| 525 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 526 | CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 527 | CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); |
| 528 | CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 529 | CommandObjectSP clear_command_object (new CommandObjectBreakpointClear (interpreter)); |
| 530 | CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 531 | CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 532 | CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 533 | CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 534 | |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 535 | list_command_object->SetCommandName ("breakpoint list"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 536 | enable_command_object->SetCommandName("breakpoint enable"); |
| 537 | disable_command_object->SetCommandName("breakpoint disable"); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 538 | clear_command_object->SetCommandName("breakpoint clear"); |
| 539 | delete_command_object->SetCommandName("breakpoint delete"); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 540 | set_command_object->SetCommandName("breakpoint set"); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 541 | command_command_object->SetCommandName ("breakpoint command"); |
| 542 | modify_command_object->SetCommandName ("breakpoint modify"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 543 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 544 | status = LoadSubCommand ("list", list_command_object); |
| 545 | status = LoadSubCommand ("enable", enable_command_object); |
| 546 | status = LoadSubCommand ("disable", disable_command_object); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 547 | status = LoadSubCommand ("clear", clear_command_object); |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 548 | status = LoadSubCommand ("delete", delete_command_object); |
| 549 | status = LoadSubCommand ("set", set_command_object); |
| 550 | status = LoadSubCommand ("command", command_command_object); |
| 551 | status = LoadSubCommand ("modify", modify_command_object); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () |
| 555 | { |
| 556 | } |
| 557 | |
| 558 | void |
| 559 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (Args &args, Target *target, CommandReturnObject &result, |
| 560 | BreakpointIDList *valid_ids) |
| 561 | { |
| 562 | // args can be strings representing 1). integers (for breakpoint ids) |
| 563 | // 2). the full breakpoint & location canonical representation |
| 564 | // 3). the word "to" or a hyphen, representing a range (in which case there |
| 565 | // 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] | 566 | // 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] | 567 | |
| 568 | Args temp_args; |
| 569 | |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 570 | if (args.GetArgumentCount() == 0) |
| 571 | { |
| 572 | if (target->GetLastCreatedBreakpoint() != NULL) |
| 573 | { |
| 574 | valid_ids->AddBreakpointID (BreakpointID(target->GetLastCreatedBreakpoint()->GetID(), LLDB_INVALID_BREAK_ID)); |
| 575 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 576 | } |
| 577 | else |
| 578 | { |
| 579 | result.AppendError("No breakpoint specified and no last created breakpoint."); |
| 580 | result.SetStatus (eReturnStatusFailed); |
| 581 | } |
| 582 | return; |
| 583 | } |
| 584 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 585 | // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff directly from the old ARGS to |
| 586 | // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead generate a list of strings for |
| 587 | // all the breakpoint ids in the range, and shove all of those breakpoint id strings into TEMP_ARGS. |
| 588 | |
| 589 | BreakpointIDList::FindAndReplaceIDRanges (args, target, result, temp_args); |
| 590 | |
| 591 | // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual BreakpointIDList: |
| 592 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 593 | valid_ids->InsertStringArray (temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 594 | |
| 595 | // At this point, all of the breakpoint ids that the user passed in have been converted to breakpoint IDs |
| 596 | // and put into valid_ids. |
| 597 | |
| 598 | if (result.Succeeded()) |
| 599 | { |
| 600 | // Now that we've converted everything from args into a list of breakpoint ids, go through our tentative list |
| 601 | // of breakpoint id's and verify that they correspond to valid/currently set breakpoints. |
| 602 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 603 | const size_t count = valid_ids->GetSize(); |
| 604 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 605 | { |
| 606 | BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex (i); |
| 607 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 608 | if (breakpoint != NULL) |
| 609 | { |
| 610 | int num_locations = breakpoint->GetNumLocations(); |
| 611 | if (cur_bp_id.GetLocationID() > num_locations) |
| 612 | { |
| 613 | StreamString id_str; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 614 | BreakpointID::GetCanonicalReference (&id_str, |
| 615 | cur_bp_id.GetBreakpointID(), |
| 616 | cur_bp_id.GetLocationID()); |
| 617 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 618 | result.AppendErrorWithFormat ("'%s' is not a currently valid breakpoint/location id.\n", |
| 619 | id_str.GetData()); |
| 620 | result.SetStatus (eReturnStatusFailed); |
| 621 | } |
| 622 | } |
| 623 | else |
| 624 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 625 | i = valid_ids->GetSize() + 1; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 626 | result.AppendErrorWithFormat ("'%d' is not a currently valid breakpoint id.\n", cur_bp_id.GetBreakpointID()); |
| 627 | result.SetStatus (eReturnStatusFailed); |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | //------------------------------------------------------------------------- |
| 634 | // CommandObjectBreakpointList::Options |
| 635 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 636 | #pragma mark List::CommandOptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 637 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 638 | CommandObjectBreakpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 639 | Options (interpreter), |
Caroline Tice | 41950cc | 2011-02-04 22:59:41 +0000 | [diff] [blame] | 640 | m_level (lldb::eDescriptionLevelBrief) // Breakpoint List defaults to brief descriptions |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 641 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | CommandObjectBreakpointList::CommandOptions::~CommandOptions () |
| 645 | { |
| 646 | } |
| 647 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 648 | OptionDefinition |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 649 | CommandObjectBreakpointList::CommandOptions::g_option_table[] = |
| 650 | { |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 651 | { LLDB_OPT_SET_ALL, false, "internal", 'i', no_argument, NULL, 0, eArgTypeNone, |
Jim Ingham | 34e9a98 | 2010-06-15 18:47:14 +0000 | [diff] [blame] | 652 | "Show debugger internal breakpoints" }, |
| 653 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 654 | { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 655 | "Give a brief description of the breakpoint (no location info)."}, |
| 656 | |
| 657 | // FIXME: We need to add an "internal" command, and then add this sort of thing to it. |
| 658 | // 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] | 659 | { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 660 | "Give a full description of the breakpoint and its locations."}, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 661 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 662 | { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 663 | "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 664 | |
Caroline Tice | 4d6675c | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 665 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 666 | }; |
| 667 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 668 | const OptionDefinition* |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 669 | CommandObjectBreakpointList::CommandOptions::GetDefinitions () |
| 670 | { |
| 671 | return g_option_table; |
| 672 | } |
| 673 | |
| 674 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 675 | CommandObjectBreakpointList::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 676 | { |
| 677 | Error error; |
| 678 | char short_option = (char) m_getopt_table[option_idx].val; |
| 679 | |
| 680 | switch (short_option) |
| 681 | { |
| 682 | case 'b': |
| 683 | m_level = lldb::eDescriptionLevelBrief; |
| 684 | break; |
| 685 | case 'f': |
| 686 | m_level = lldb::eDescriptionLevelFull; |
| 687 | break; |
| 688 | case 'v': |
| 689 | m_level = lldb::eDescriptionLevelVerbose; |
| 690 | break; |
| 691 | case 'i': |
| 692 | m_internal = true; |
| 693 | break; |
| 694 | default: |
| 695 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 696 | break; |
| 697 | } |
| 698 | |
| 699 | return error; |
| 700 | } |
| 701 | |
| 702 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 703 | CommandObjectBreakpointList::CommandOptions::OptionParsingStarting () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 704 | { |
Jim Ingham | dc25905 | 2011-05-17 01:21:41 +0000 | [diff] [blame] | 705 | m_level = lldb::eDescriptionLevelFull; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 706 | m_internal = false; |
| 707 | } |
| 708 | |
| 709 | //------------------------------------------------------------------------- |
| 710 | // CommandObjectBreakpointList |
| 711 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 712 | #pragma mark List |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 713 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 714 | CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : |
| 715 | CommandObject (interpreter, |
| 716 | "breakpoint list", |
| 717 | "List some or all breakpoints at configurable levels of detail.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 718 | NULL), |
| 719 | m_options (interpreter) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 720 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 721 | CommandArgumentEntry arg; |
| 722 | CommandArgumentData bp_id_arg; |
| 723 | |
| 724 | // Define the first (and only) variant of this arg. |
| 725 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 726 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 727 | |
| 728 | // There is only one variant this argument could be; put it into the argument entry. |
| 729 | arg.push_back (bp_id_arg); |
| 730 | |
| 731 | // Push the data for the first argument into the m_arguments vector. |
| 732 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | CommandObjectBreakpointList::~CommandObjectBreakpointList () |
| 736 | { |
| 737 | } |
| 738 | |
| 739 | Options * |
| 740 | CommandObjectBreakpointList::GetOptions () |
| 741 | { |
| 742 | return &m_options; |
| 743 | } |
| 744 | |
| 745 | bool |
| 746 | CommandObjectBreakpointList::Execute |
| 747 | ( |
| 748 | Args& args, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 749 | CommandReturnObject &result |
| 750 | ) |
| 751 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 752 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 753 | if (target == NULL) |
| 754 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 755 | result.AppendError ("Invalid target. No current target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 756 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 757 | return true; |
| 758 | } |
| 759 | |
| 760 | const BreakpointList &breakpoints = target->GetBreakpointList(m_options.m_internal); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 761 | Mutex::Locker locker; |
| 762 | target->GetBreakpointList(m_options.m_internal).GetListMutex(locker); |
| 763 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 764 | size_t num_breakpoints = breakpoints.GetSize(); |
| 765 | |
| 766 | if (num_breakpoints == 0) |
| 767 | { |
| 768 | result.AppendMessage ("No breakpoints currently set."); |
| 769 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 770 | return true; |
| 771 | } |
| 772 | |
Jim Ingham | 2e8cb8a | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 773 | Stream &output_stream = result.GetOutputStream(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 774 | |
| 775 | if (args.GetArgumentCount() == 0) |
| 776 | { |
| 777 | // No breakpoint selected; show info about all currently set breakpoints. |
| 778 | result.AppendMessage ("Current breakpoints:"); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 779 | for (size_t i = 0; i < num_breakpoints; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 780 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 781 | Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 782 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 783 | } |
| 784 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 785 | } |
| 786 | else |
| 787 | { |
| 788 | // Particular breakpoints selected; show info about that breakpoint. |
| 789 | BreakpointIDList valid_bp_ids; |
| 790 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 791 | |
| 792 | if (result.Succeeded()) |
| 793 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 794 | for (size_t i = 0; i < valid_bp_ids.GetSize(); ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 795 | { |
| 796 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 797 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 798 | AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 799 | } |
| 800 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 801 | } |
| 802 | else |
| 803 | { |
| 804 | result.AppendError ("Invalid breakpoint id."); |
| 805 | result.SetStatus (eReturnStatusFailed); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | return result.Succeeded(); |
| 810 | } |
| 811 | |
| 812 | //------------------------------------------------------------------------- |
| 813 | // CommandObjectBreakpointEnable |
| 814 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 815 | #pragma mark Enable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 816 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 817 | CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : |
| 818 | CommandObject (interpreter, |
| 819 | "enable", |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 820 | "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", |
| 821 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 822 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 823 | CommandArgumentEntry arg; |
| 824 | CommandArgumentData bp_id_arg; |
| 825 | CommandArgumentData bp_id_range_arg; |
| 826 | |
| 827 | // Create the first variant for the first (and only) argument for this command. |
| 828 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 829 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 830 | |
| 831 | // Create the second variant for the first (and only) argument for this command. |
| 832 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 833 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 834 | |
| 835 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 836 | // Push both variants into the entry for the first argument for this command. |
| 837 | arg.push_back (bp_id_arg); |
| 838 | arg.push_back (bp_id_range_arg); |
| 839 | |
| 840 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 841 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | |
| 845 | CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () |
| 846 | { |
| 847 | } |
| 848 | |
| 849 | |
| 850 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 851 | CommandObjectBreakpointEnable::Execute |
| 852 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 853 | Args& args, |
| 854 | CommandReturnObject &result |
| 855 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 856 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 857 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 858 | if (target == NULL) |
| 859 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 860 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 861 | result.SetStatus (eReturnStatusFailed); |
| 862 | return false; |
| 863 | } |
| 864 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 865 | Mutex::Locker locker; |
| 866 | target->GetBreakpointList().GetListMutex(locker); |
| 867 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 868 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 869 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 870 | size_t num_breakpoints = breakpoints.GetSize(); |
| 871 | |
| 872 | if (num_breakpoints == 0) |
| 873 | { |
| 874 | result.AppendError ("No breakpoints exist to be enabled."); |
| 875 | result.SetStatus (eReturnStatusFailed); |
| 876 | return false; |
| 877 | } |
| 878 | |
| 879 | if (args.GetArgumentCount() == 0) |
| 880 | { |
| 881 | // No breakpoint selected; enable all currently set breakpoints. |
| 882 | target->EnableAllBreakpoints (); |
| 883 | result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints); |
| 884 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | // Particular breakpoint selected; enable that breakpoint. |
| 889 | BreakpointIDList valid_bp_ids; |
| 890 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 891 | |
| 892 | if (result.Succeeded()) |
| 893 | { |
| 894 | int enable_count = 0; |
| 895 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 896 | const size_t count = valid_bp_ids.GetSize(); |
| 897 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 898 | { |
| 899 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 900 | |
| 901 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 902 | { |
| 903 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 904 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 905 | { |
| 906 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 907 | if (location) |
| 908 | { |
| 909 | location->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 910 | ++loc_count; |
| 911 | } |
| 912 | } |
| 913 | else |
| 914 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 915 | breakpoint->SetEnabled (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 916 | ++enable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 917 | } |
| 918 | } |
| 919 | } |
| 920 | result.AppendMessageWithFormat ("%d breakpoints enabled.\n", enable_count + loc_count); |
| 921 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | return result.Succeeded(); |
| 926 | } |
| 927 | |
| 928 | //------------------------------------------------------------------------- |
| 929 | // CommandObjectBreakpointDisable |
| 930 | //------------------------------------------------------------------------- |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 931 | #pragma mark Disable |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 932 | |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 933 | CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : |
| 934 | CommandObject (interpreter, |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 935 | "breakpoint disable", |
Caroline Tice | abb507a | 2010-09-08 21:06:11 +0000 | [diff] [blame] | 936 | "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] | 937 | NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 938 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 939 | CommandArgumentEntry arg; |
| 940 | CommandArgumentData bp_id_arg; |
| 941 | CommandArgumentData bp_id_range_arg; |
| 942 | |
| 943 | // Create the first variant for the first (and only) argument for this command. |
| 944 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 945 | bp_id_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 946 | |
| 947 | // Create the second variant for the first (and only) argument for this command. |
| 948 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 949 | bp_id_range_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 950 | |
| 951 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 952 | // Push both variants into the entry for the first argument for this command. |
| 953 | arg.push_back (bp_id_arg); |
| 954 | arg.push_back (bp_id_range_arg); |
| 955 | |
| 956 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 957 | m_arguments.push_back (arg); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () |
| 961 | { |
| 962 | } |
| 963 | |
| 964 | bool |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 965 | CommandObjectBreakpointDisable::Execute |
| 966 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 967 | Args& args, |
| 968 | CommandReturnObject &result |
| 969 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 970 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 971 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 972 | if (target == NULL) |
| 973 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 974 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 975 | result.SetStatus (eReturnStatusFailed); |
| 976 | return false; |
| 977 | } |
| 978 | |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 979 | Mutex::Locker locker; |
| 980 | target->GetBreakpointList().GetListMutex(locker); |
| 981 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 982 | const BreakpointList &breakpoints = target->GetBreakpointList(); |
| 983 | size_t num_breakpoints = breakpoints.GetSize(); |
| 984 | |
| 985 | if (num_breakpoints == 0) |
| 986 | { |
| 987 | result.AppendError ("No breakpoints exist to be disabled."); |
| 988 | result.SetStatus (eReturnStatusFailed); |
| 989 | return false; |
| 990 | } |
| 991 | |
| 992 | if (args.GetArgumentCount() == 0) |
| 993 | { |
| 994 | // No breakpoint selected; disable all currently set breakpoints. |
| 995 | target->DisableAllBreakpoints (); |
| 996 | result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints); |
| 997 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 998 | } |
| 999 | else |
| 1000 | { |
| 1001 | // Particular breakpoint selected; disable that breakpoint. |
| 1002 | BreakpointIDList valid_bp_ids; |
| 1003 | |
| 1004 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (args, target, result, &valid_bp_ids); |
| 1005 | |
| 1006 | if (result.Succeeded()) |
| 1007 | { |
| 1008 | int disable_count = 0; |
| 1009 | int loc_count = 0; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1010 | const size_t count = valid_bp_ids.GetSize(); |
| 1011 | for (size_t i = 0; i < count; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1012 | { |
| 1013 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1014 | |
| 1015 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1016 | { |
| 1017 | Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1018 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1019 | { |
| 1020 | BreakpointLocation *location = breakpoint->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1021 | if (location) |
| 1022 | { |
| 1023 | location->SetEnabled (false); |
| 1024 | ++loc_count; |
| 1025 | } |
| 1026 | } |
| 1027 | else |
| 1028 | { |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1029 | breakpoint->SetEnabled (false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1030 | ++disable_count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | result.AppendMessageWithFormat ("%d breakpoints disabled.\n", disable_count + loc_count); |
| 1035 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | return result.Succeeded(); |
| 1040 | } |
| 1041 | |
| 1042 | //------------------------------------------------------------------------- |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1043 | // CommandObjectBreakpointClear::CommandOptions |
| 1044 | //------------------------------------------------------------------------- |
| 1045 | #pragma mark Clear::CommandOptions |
| 1046 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1047 | CommandObjectBreakpointClear::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 1048 | Options (interpreter), |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1049 | m_filename (), |
| 1050 | m_line_num (0) |
| 1051 | { |
| 1052 | } |
| 1053 | |
| 1054 | CommandObjectBreakpointClear::CommandOptions::~CommandOptions () |
| 1055 | { |
| 1056 | } |
| 1057 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1058 | OptionDefinition |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1059 | CommandObjectBreakpointClear::CommandOptions::g_option_table[] = |
| 1060 | { |
| 1061 | { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
| 1062 | "Specify the breakpoint by source location in this particular file."}, |
| 1063 | |
| 1064 | { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, |
| 1065 | "Specify the breakpoint by source location at this particular line."}, |
| 1066 | |
| 1067 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
| 1068 | }; |
| 1069 | |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1070 | const OptionDefinition* |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1071 | CommandObjectBreakpointClear::CommandOptions::GetDefinitions () |
| 1072 | { |
| 1073 | return g_option_table; |
| 1074 | } |
| 1075 | |
| 1076 | Error |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1077 | CommandObjectBreakpointClear::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1078 | { |
| 1079 | Error error; |
| 1080 | char short_option = (char) m_getopt_table[option_idx].val; |
| 1081 | |
| 1082 | switch (short_option) |
| 1083 | { |
| 1084 | case 'f': |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1085 | m_filename.assign (option_arg); |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1086 | break; |
| 1087 | |
| 1088 | case 'l': |
| 1089 | m_line_num = Args::StringToUInt32 (option_arg, 0); |
| 1090 | break; |
| 1091 | |
| 1092 | default: |
| 1093 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 1094 | break; |
| 1095 | } |
| 1096 | |
| 1097 | return error; |
| 1098 | } |
| 1099 | |
| 1100 | void |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1101 | CommandObjectBreakpointClear::CommandOptions::OptionParsingStarting () |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1102 | { |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 1103 | m_filename.clear(); |
| 1104 | m_line_num = 0; |
| 1105 | } |
| 1106 | |
| 1107 | //------------------------------------------------------------------------- |
| 1108 | // CommandObjectBreakpointClear |
| 1109 | //------------------------------------------------------------------------- |
| 1110 | #pragma mark Clear |
| 1111 | |
| 1112 | CommandObjectBreakpointClear::CommandObjectBreakpointClear (CommandInterpreter &interpreter) : |
| 1113 | CommandObject (interpreter, |
| 1114 | "breakpoint clear", |
| 1115 | "Clears a breakpoint or set of breakpoints in the executable.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1116 | "breakpoint clear <cmd-options>"), |
| 1117 | m_options (interpreter) |
Johnny Chen | a62ad7c | 2010-10-28 17:27:46 +0000 | [diff] [blame] | 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 | |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1351 | CommandObjectBreakpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : |
| 1352 | Options (interpreter), |
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 |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1394 | CommandObjectBreakpointModify::CommandOptions::SetOptionValue (uint32_t 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 |
Greg Clayton | 143fcc3 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 1480 | CommandObjectBreakpointModify::CommandOptions::OptionParsingStarting () |
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.", |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 1507 | NULL), |
| 1508 | m_options (interpreter) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1509 | { |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1510 | CommandArgumentEntry arg; |
| 1511 | CommandArgumentData bp_id_arg; |
| 1512 | CommandArgumentData bp_id_range_arg; |
| 1513 | |
| 1514 | // Create the first variant for the first (and only) argument for this command. |
| 1515 | bp_id_arg.arg_type = eArgTypeBreakpointID; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1516 | bp_id_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1517 | |
| 1518 | // Create the second variant for the first (and only) argument for this command. |
| 1519 | bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; |
Caroline Tice | 43b014a | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1520 | bp_id_range_arg.arg_repetition = eArgRepeatPlain; |
Caroline Tice | fb35511 | 2010-10-01 17:46:38 +0000 | [diff] [blame] | 1521 | |
| 1522 | // The first (and only) argument for this command could be either a bp_id or a bp_id_range. |
| 1523 | // Push both variants into the entry for the first argument for this command. |
| 1524 | arg.push_back (bp_id_arg); |
| 1525 | arg.push_back (bp_id_range_arg); |
| 1526 | |
| 1527 | // Add the entry for the first argument for this command to the object's arguments vector. |
| 1528 | m_arguments.push_back (arg); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1529 | } |
| 1530 | |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1531 | CommandObjectBreakpointModify::~CommandObjectBreakpointModify () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1532 | { |
| 1533 | } |
| 1534 | |
| 1535 | Options * |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1536 | CommandObjectBreakpointModify::GetOptions () |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1537 | { |
| 1538 | return &m_options; |
| 1539 | } |
| 1540 | |
| 1541 | bool |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1542 | CommandObjectBreakpointModify::Execute |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1543 | ( |
| 1544 | Args& command, |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1545 | CommandReturnObject &result |
| 1546 | ) |
| 1547 | { |
Greg Clayton | 238c0a1 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1548 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1549 | if (target == NULL) |
| 1550 | { |
Caroline Tice | 17dce1c | 2010-09-29 19:42:33 +0000 | [diff] [blame] | 1551 | result.AppendError ("Invalid target. No existing target or breakpoints."); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1552 | result.SetStatus (eReturnStatusFailed); |
| 1553 | return false; |
| 1554 | } |
| 1555 | |
| 1556 | Mutex::Locker locker; |
| 1557 | target->GetBreakpointList().GetListMutex(locker); |
| 1558 | |
| 1559 | BreakpointIDList valid_bp_ids; |
| 1560 | |
| 1561 | CommandObjectMultiwordBreakpoint::VerifyBreakpointIDs (command, target, result, &valid_bp_ids); |
| 1562 | |
| 1563 | if (result.Succeeded()) |
| 1564 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1565 | const size_t count = valid_bp_ids.GetSize(); |
| 1566 | for (size_t i = 0; i < count; ++i) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1567 | { |
| 1568 | BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); |
| 1569 | |
| 1570 | if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) |
| 1571 | { |
| 1572 | Breakpoint *bp = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); |
| 1573 | if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) |
| 1574 | { |
| 1575 | BreakpointLocation *location = bp->FindLocationByID (cur_bp_id.GetLocationID()).get(); |
| 1576 | if (location) |
| 1577 | { |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1578 | if (m_options.m_thread_id_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1579 | location->SetThreadID (m_options.m_thread_id); |
| 1580 | |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1581 | if (m_options.m_thread_index_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1582 | location->GetLocationOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1583 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1584 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1585 | location->GetLocationOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1586 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1587 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1588 | location->GetLocationOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1589 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1590 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1591 | location->GetLocationOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1592 | |
| 1593 | if (m_options.m_enable_passed) |
| 1594 | location->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1595 | |
| 1596 | if (m_options.m_condition_passed) |
| 1597 | location->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1598 | } |
| 1599 | } |
| 1600 | else |
| 1601 | { |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1602 | if (m_options.m_thread_id_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1603 | bp->SetThreadID (m_options.m_thread_id); |
| 1604 | |
Jim Ingham | 9a7b291 | 2010-12-03 23:04:19 +0000 | [diff] [blame] | 1605 | if (m_options.m_thread_index_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1606 | bp->GetOptions()->GetThreadSpec()->SetIndex(m_options.m_thread_index); |
| 1607 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1608 | if (m_options.m_name_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1609 | bp->GetOptions()->GetThreadSpec()->SetName(m_options.m_thread_name.c_str()); |
| 1610 | |
Jim Ingham | d457122 | 2010-06-19 04:35:20 +0000 | [diff] [blame] | 1611 | if (m_options.m_queue_passed) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1612 | bp->GetOptions()->GetThreadSpec()->SetQueueName(m_options.m_queue_name.c_str()); |
| 1613 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1614 | if (m_options.m_ignore_count != 0) |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1615 | bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); |
Jim Ingham | 10622a2 | 2010-06-18 00:58:52 +0000 | [diff] [blame] | 1616 | |
| 1617 | if (m_options.m_enable_passed) |
| 1618 | bp->SetEnabled (m_options.m_enable_value); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 1619 | |
| 1620 | if (m_options.m_condition_passed) |
| 1621 | bp->SetCondition (m_options.m_condition.c_str()); |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 1622 | } |
| 1623 | } |
| 1624 | } |
| 1625 | } |
| 1626 | |
| 1627 | return result.Succeeded(); |
| 1628 | } |
| 1629 | |
| 1630 | |