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