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