Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectThread.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 | |
Daniel Malea | 93a6430 | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "CommandObjectThread.h" |
| 13 | |
| 14 | // C Includes |
| 15 | // C++ Includes |
| 16 | // Other libraries and framework includes |
| 17 | // Project includes |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 18 | #include "lldb/lldb-private.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | #include "lldb/Core/State.h" |
| 20 | #include "lldb/Core/SourceManager.h" |
Greg Clayton | 7fb56d0 | 2011-02-01 01:31:41 +0000 | [diff] [blame] | 21 | #include "lldb/Host/Host.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 23 | #include "lldb/Interpreter/CommandReturnObject.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 24 | #include "lldb/Interpreter/Options.h" |
| 25 | #include "lldb/Symbol/CompileUnit.h" |
| 26 | #include "lldb/Symbol/Function.h" |
| 27 | #include "lldb/Symbol/LineTable.h" |
| 28 | #include "lldb/Symbol/LineEntry.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | #include "lldb/Target/Process.h" |
| 30 | #include "lldb/Target/RegisterContext.h" |
| 31 | #include "lldb/Target/Target.h" |
| 32 | #include "lldb/Target/Thread.h" |
| 33 | #include "lldb/Target/ThreadPlan.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 34 | #include "lldb/Target/ThreadPlanStepInstruction.h" |
| 35 | #include "lldb/Target/ThreadPlanStepOut.h" |
| 36 | #include "lldb/Target/ThreadPlanStepRange.h" |
| 37 | #include "lldb/Target/ThreadPlanStepInRange.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 38 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | |
| 40 | using namespace lldb; |
| 41 | using namespace lldb_private; |
| 42 | |
| 43 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | //------------------------------------------------------------------------- |
| 45 | // CommandObjectThreadBacktrace |
| 46 | //------------------------------------------------------------------------- |
| 47 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 48 | class CommandObjectThreadBacktrace : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | { |
| 50 | public: |
| 51 | |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 52 | class CommandOptions : public Options |
| 53 | { |
| 54 | public: |
| 55 | |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 56 | CommandOptions (CommandInterpreter &interpreter) : |
| 57 | Options(interpreter) |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 58 | { |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 59 | // Keep default values of all options in one place: OptionParsingStarting () |
| 60 | OptionParsingStarting (); |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | virtual |
| 64 | ~CommandOptions () |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | virtual Error |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 69 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 70 | { |
| 71 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 72 | const int short_option = m_getopt_table[option_idx].val; |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 73 | |
| 74 | switch (short_option) |
| 75 | { |
| 76 | case 'c': |
| 77 | { |
| 78 | bool success; |
| 79 | int32_t input_count = Args::StringToSInt32 (option_arg, -1, 0, &success); |
| 80 | if (!success) |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 81 | error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option); |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 82 | if (input_count < -1) |
| 83 | m_count = UINT32_MAX; |
| 84 | else |
| 85 | m_count = input_count; |
| 86 | } |
| 87 | break; |
| 88 | case 's': |
| 89 | { |
| 90 | bool success; |
| 91 | m_start = Args::StringToUInt32 (option_arg, 0, 0, &success); |
| 92 | if (!success) |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 93 | error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option); |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 94 | } |
| 95 | break; |
| 96 | default: |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 97 | error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 98 | break; |
| 99 | |
| 100 | } |
| 101 | return error; |
| 102 | } |
| 103 | |
| 104 | void |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 105 | OptionParsingStarting () |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 106 | { |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 107 | m_count = UINT32_MAX; |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 108 | m_start = 0; |
| 109 | } |
| 110 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 111 | const OptionDefinition* |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 112 | GetDefinitions () |
| 113 | { |
| 114 | return g_option_table; |
| 115 | } |
| 116 | |
| 117 | // Options table: Required for subclasses of Options. |
| 118 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 119 | static OptionDefinition g_option_table[]; |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 120 | |
| 121 | // Instance variables to hold the values for command options. |
| 122 | uint32_t m_count; |
| 123 | uint32_t m_start; |
| 124 | }; |
| 125 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 126 | CommandObjectThreadBacktrace (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 127 | CommandObjectParsed (interpreter, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 128 | "thread backtrace", |
| 129 | "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", |
| 130 | NULL, |
| 131 | eFlagRequiresProcess | |
| 132 | eFlagRequiresThread | |
| 133 | eFlagTryTargetAPILock | |
| 134 | eFlagProcessMustBeLaunched | |
| 135 | eFlagProcessMustBePaused ), |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 136 | m_options(interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 137 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 138 | CommandArgumentEntry arg; |
| 139 | CommandArgumentData thread_idx_arg; |
| 140 | |
| 141 | // Define the first (and only) variant of this arg. |
| 142 | thread_idx_arg.arg_type = eArgTypeThreadIndex; |
| 143 | thread_idx_arg.arg_repetition = eArgRepeatStar; |
| 144 | |
| 145 | // There is only one variant this argument could be; put it into the argument entry. |
| 146 | arg.push_back (thread_idx_arg); |
| 147 | |
| 148 | // Push the data for the first argument into the m_arguments vector. |
| 149 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | ~CommandObjectThreadBacktrace() |
| 153 | { |
| 154 | } |
| 155 | |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 156 | virtual Options * |
| 157 | GetOptions () |
| 158 | { |
| 159 | return &m_options; |
| 160 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 161 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 162 | protected: |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 163 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 164 | DoExecute (Args& command, CommandReturnObject &result) |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 165 | { |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 166 | result.SetStatus (eReturnStatusSuccessFinishResult); |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 167 | Stream &strm = result.GetOutputStream(); |
| 168 | |
| 169 | // Don't show source context when doing backtraces. |
| 170 | const uint32_t num_frames_with_source = 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 171 | if (command.GetArgumentCount() == 0) |
| 172 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 173 | Thread *thread = m_exe_ctx.GetThreadPtr(); |
| 174 | // Thread::GetStatus() returns the number of frames shown. |
| 175 | if (thread->GetStatus (strm, |
| 176 | m_options.m_start, |
| 177 | m_options.m_count, |
| 178 | num_frames_with_source)) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 179 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 180 | result.SetStatus (eReturnStatusSuccessFinishResult); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 181 | } |
| 182 | } |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 183 | else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) |
| 184 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 185 | Process *process = m_exe_ctx.GetProcessPtr(); |
Jim Ingham | 41f2b94 | 2012-09-10 20:50:15 +0000 | [diff] [blame] | 186 | Mutex::Locker locker (process->GetThreadList().GetMutex()); |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 187 | uint32_t num_threads = process->GetThreadList().GetSize(); |
| 188 | for (uint32_t i = 0; i < num_threads; i++) |
| 189 | { |
| 190 | ThreadSP thread_sp = process->GetThreadList().GetThreadAtIndex(i); |
Johnny Chen | f2ddc71 | 2011-06-01 23:19:52 +0000 | [diff] [blame] | 191 | if (!thread_sp->GetStatus (strm, |
| 192 | m_options.m_start, |
| 193 | m_options.m_count, |
| 194 | num_frames_with_source)) |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 195 | { |
Greg Clayton | 1346f7e | 2010-09-03 22:45:01 +0000 | [diff] [blame] | 196 | result.AppendErrorWithFormat ("error displaying backtrace for thread: \"0x%4.4x\"\n", i); |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 197 | result.SetStatus (eReturnStatusFailed); |
| 198 | return false; |
| 199 | } |
Jim Ingham | 5c4df7a | 2011-07-26 02:39:59 +0000 | [diff] [blame] | 200 | |
| 201 | if (i < num_threads - 1) |
| 202 | result.AppendMessage(""); |
| 203 | |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 204 | } |
| 205 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | else |
| 207 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 208 | const size_t num_args = command.GetArgumentCount(); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 209 | Process *process = m_exe_ctx.GetProcessPtr(); |
Jim Ingham | 41f2b94 | 2012-09-10 20:50:15 +0000 | [diff] [blame] | 210 | Mutex::Locker locker (process->GetThreadList().GetMutex()); |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 211 | std::vector<ThreadSP> thread_sps; |
| 212 | |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 213 | for (size_t i = 0; i < num_args; i++) |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 214 | { |
| 215 | bool success; |
| 216 | |
| 217 | uint32_t thread_idx = Args::StringToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success); |
| 218 | if (!success) |
| 219 | { |
| 220 | result.AppendErrorWithFormat ("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i)); |
| 221 | result.SetStatus (eReturnStatusFailed); |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | thread_sps.push_back(process->GetThreadList().FindThreadByIndexID(thread_idx)); |
| 226 | |
| 227 | if (!thread_sps[i]) |
| 228 | { |
| 229 | result.AppendErrorWithFormat ("no thread with index: \"%s\"\n", command.GetArgumentAtIndex(i)); |
| 230 | result.SetStatus (eReturnStatusFailed); |
| 231 | return false; |
| 232 | } |
| 233 | |
| 234 | } |
| 235 | |
| 236 | for (uint32_t i = 0; i < num_args; i++) |
| 237 | { |
Greg Clayton | 7260f62 | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 238 | if (!thread_sps[i]->GetStatus (strm, |
| 239 | m_options.m_start, |
| 240 | m_options.m_count, |
| 241 | num_frames_with_source)) |
Jim Ingham | 09b263e | 2010-08-27 00:58:05 +0000 | [diff] [blame] | 242 | { |
| 243 | result.AppendErrorWithFormat ("error displaying backtrace for thread: \"%s\"\n", command.GetArgumentAtIndex(i)); |
| 244 | result.SetStatus (eReturnStatusFailed); |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | if (i < num_args - 1) |
| 249 | result.AppendMessage(""); |
| 250 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 251 | } |
| 252 | return result.Succeeded(); |
| 253 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 254 | |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 255 | CommandOptions m_options; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 258 | OptionDefinition |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 259 | CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = |
| 260 | { |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 261 | { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, |
| 262 | { LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"}, |
Caroline Tice | deaab22 | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 263 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Jim Ingham | e2e0b45 | 2010-08-26 23:36:03 +0000 | [diff] [blame] | 264 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 265 | |
Greg Clayton | 69b518f | 2010-07-07 17:07:17 +0000 | [diff] [blame] | 266 | enum StepScope |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 267 | { |
| 268 | eStepScopeSource, |
| 269 | eStepScopeInstruction |
| 270 | }; |
| 271 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 272 | class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 273 | { |
| 274 | public: |
| 275 | |
| 276 | class CommandOptions : public Options |
| 277 | { |
| 278 | public: |
| 279 | |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 280 | CommandOptions (CommandInterpreter &interpreter) : |
| 281 | Options (interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 282 | { |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 283 | // Keep default values of all options in one place: OptionParsingStarting () |
| 284 | OptionParsingStarting (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | virtual |
| 288 | ~CommandOptions () |
| 289 | { |
| 290 | } |
| 291 | |
| 292 | virtual Error |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 293 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 294 | { |
| 295 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 296 | const int short_option = m_getopt_table[option_idx].val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 297 | |
| 298 | switch (short_option) |
| 299 | { |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 300 | case 'a': |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 301 | { |
| 302 | bool success; |
| 303 | m_avoid_no_debug = Args::StringToBoolean (option_arg, true, &success); |
| 304 | if (!success) |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 305 | error.SetErrorStringWithFormat("invalid boolean value for option '%c'", short_option); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 306 | } |
| 307 | break; |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 308 | |
| 309 | case 'm': |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 310 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 311 | OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; |
Greg Clayton | cf0e4f0 | 2011-10-07 18:58:12 +0000 | [diff] [blame] | 312 | m_run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 313 | } |
| 314 | break; |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 315 | |
| 316 | case 'r': |
Jim Ingham | a56c800 | 2010-07-10 02:27:39 +0000 | [diff] [blame] | 317 | { |
| 318 | m_avoid_regexp.clear(); |
| 319 | m_avoid_regexp.assign(option_arg); |
| 320 | } |
| 321 | break; |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 322 | |
Jim Ingham | c627682 | 2012-12-12 19:58:40 +0000 | [diff] [blame] | 323 | case 't': |
| 324 | { |
| 325 | m_step_in_target.clear(); |
| 326 | m_step_in_target.assign(option_arg); |
| 327 | |
| 328 | } |
| 329 | break; |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 330 | default: |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 331 | error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); |
Greg Clayton | 8087ca2 | 2010-10-08 04:20:14 +0000 | [diff] [blame] | 332 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 333 | |
| 334 | } |
| 335 | return error; |
| 336 | } |
| 337 | |
| 338 | void |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 339 | OptionParsingStarting () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 340 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 341 | m_avoid_no_debug = true; |
| 342 | m_run_mode = eOnlyDuringStepping; |
Jim Ingham | a56c800 | 2010-07-10 02:27:39 +0000 | [diff] [blame] | 343 | m_avoid_regexp.clear(); |
Jim Ingham | c627682 | 2012-12-12 19:58:40 +0000 | [diff] [blame] | 344 | m_step_in_target.clear(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 345 | } |
| 346 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 347 | const OptionDefinition* |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 348 | GetDefinitions () |
| 349 | { |
| 350 | return g_option_table; |
| 351 | } |
| 352 | |
| 353 | // Options table: Required for subclasses of Options. |
| 354 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 355 | static OptionDefinition g_option_table[]; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 356 | |
| 357 | // Instance variables to hold the values for command options. |
| 358 | bool m_avoid_no_debug; |
| 359 | RunMode m_run_mode; |
Jim Ingham | a56c800 | 2010-07-10 02:27:39 +0000 | [diff] [blame] | 360 | std::string m_avoid_regexp; |
Jim Ingham | c627682 | 2012-12-12 19:58:40 +0000 | [diff] [blame] | 361 | std::string m_step_in_target; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 362 | }; |
| 363 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 364 | CommandObjectThreadStepWithTypeAndScope (CommandInterpreter &interpreter, |
| 365 | const char *name, |
| 366 | const char *help, |
| 367 | const char *syntax, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 368 | StepType step_type, |
| 369 | StepScope step_scope) : |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 370 | CommandObjectParsed (interpreter, name, help, syntax, |
| 371 | eFlagRequiresProcess | |
| 372 | eFlagRequiresThread | |
| 373 | eFlagTryTargetAPILock | |
| 374 | eFlagProcessMustBeLaunched | |
| 375 | eFlagProcessMustBePaused ), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 376 | m_step_type (step_type), |
| 377 | m_step_scope (step_scope), |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 378 | m_options (interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 379 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 380 | CommandArgumentEntry arg; |
| 381 | CommandArgumentData thread_id_arg; |
| 382 | |
| 383 | // Define the first (and only) variant of this arg. |
| 384 | thread_id_arg.arg_type = eArgTypeThreadID; |
| 385 | thread_id_arg.arg_repetition = eArgRepeatOptional; |
| 386 | |
| 387 | // There is only one variant this argument could be; put it into the argument entry. |
| 388 | arg.push_back (thread_id_arg); |
| 389 | |
| 390 | // Push the data for the first argument into the m_arguments vector. |
| 391 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | virtual |
| 395 | ~CommandObjectThreadStepWithTypeAndScope () |
| 396 | { |
| 397 | } |
| 398 | |
| 399 | virtual |
| 400 | Options * |
| 401 | GetOptions () |
| 402 | { |
| 403 | return &m_options; |
| 404 | } |
| 405 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 406 | protected: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 407 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 408 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 409 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 410 | Process *process = m_exe_ctx.GetProcessPtr(); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 411 | bool synchronous_execution = m_interpreter.GetSynchronous(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 412 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 413 | const uint32_t num_threads = process->GetThreadList().GetSize(); |
| 414 | Thread *thread = NULL; |
| 415 | |
| 416 | if (command.GetArgumentCount() == 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 417 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 418 | thread = process->GetThreadList().GetSelectedThread().get(); |
| 419 | if (thread == NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 420 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 421 | result.AppendError ("no selected thread in process"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 422 | result.SetStatus (eReturnStatusFailed); |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 423 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 424 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 425 | } |
| 426 | else |
| 427 | { |
| 428 | const char *thread_idx_cstr = command.GetArgumentAtIndex(0); |
| 429 | uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32); |
| 430 | if (step_thread_idx == LLDB_INVALID_INDEX32) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 431 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 432 | result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr); |
| 433 | result.SetStatus (eReturnStatusFailed); |
| 434 | return false; |
| 435 | } |
| 436 | thread = process->GetThreadList().FindThreadByIndexID(step_thread_idx).get(); |
| 437 | if (thread == NULL) |
| 438 | { |
| 439 | result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", |
| 440 | step_thread_idx, num_threads); |
| 441 | result.SetStatus (eReturnStatusFailed); |
| 442 | return false; |
| 443 | } |
| 444 | } |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 445 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 446 | const bool abort_other_plans = false; |
| 447 | const lldb::RunMode stop_other_threads = m_options.m_run_mode; |
| 448 | |
| 449 | // This is a bit unfortunate, but not all the commands in this command object support |
| 450 | // only while stepping, so I use the bool for them. |
| 451 | bool bool_stop_other_threads; |
| 452 | if (m_options.m_run_mode == eAllThreads) |
| 453 | bool_stop_other_threads = false; |
| 454 | else if (m_options.m_run_mode == eOnlyDuringStepping) |
| 455 | { |
| 456 | if (m_step_type == eStepTypeOut) |
| 457 | bool_stop_other_threads = false; |
| 458 | else |
| 459 | bool_stop_other_threads = true; |
| 460 | } |
| 461 | else |
| 462 | bool_stop_other_threads = true; |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 463 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 464 | ThreadPlanSP new_plan_sp; |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 465 | |
| 466 | if (m_step_type == eStepTypeInto) |
| 467 | { |
| 468 | StackFrame *frame = thread->GetStackFrameAtIndex(0).get(); |
| 469 | |
| 470 | if (frame->HasDebugInformation ()) |
| 471 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 472 | new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 473 | frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, |
| 474 | frame->GetSymbolContext(eSymbolContextEverything), |
| 475 | m_options.m_step_in_target.c_str(), |
| 476 | stop_other_threads, |
| 477 | m_options.m_avoid_no_debug); |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 478 | if (new_plan_sp && !m_options.m_avoid_regexp.empty()) |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 479 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 480 | ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (new_plan_sp.get()); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 481 | step_in_range_plan->SetAvoidRegexp(m_options.m_avoid_regexp.c_str()); |
Jim Ingham | 29412d1 | 2012-05-16 00:37:40 +0000 | [diff] [blame] | 482 | } |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 483 | } |
| 484 | else |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 485 | new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 486 | |
| 487 | } |
| 488 | else if (m_step_type == eStepTypeOver) |
| 489 | { |
| 490 | StackFrame *frame = thread->GetStackFrameAtIndex(0).get(); |
| 491 | |
| 492 | if (frame->HasDebugInformation()) |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 493 | new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 494 | frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, |
| 495 | frame->GetSymbolContext(eSymbolContextEverything), |
| 496 | stop_other_threads); |
| 497 | else |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 498 | new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (true, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 499 | abort_other_plans, |
| 500 | bool_stop_other_threads); |
| 501 | |
| 502 | } |
| 503 | else if (m_step_type == eStepTypeTrace) |
| 504 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 505 | new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, bool_stop_other_threads); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 506 | } |
| 507 | else if (m_step_type == eStepTypeTraceOver) |
| 508 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 509 | new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, bool_stop_other_threads); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 510 | } |
| 511 | else if (m_step_type == eStepTypeOut) |
| 512 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 513 | new_plan_sp = thread->QueueThreadPlanForStepOut (abort_other_plans, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 514 | NULL, |
| 515 | false, |
| 516 | bool_stop_other_threads, |
| 517 | eVoteYes, |
| 518 | eVoteNoOpinion, |
| 519 | thread->GetSelectedFrameIndex()); |
| 520 | } |
| 521 | else |
| 522 | { |
| 523 | result.AppendError ("step type is not supported"); |
| 524 | result.SetStatus (eReturnStatusFailed); |
| 525 | return false; |
| 526 | } |
| 527 | |
| 528 | // If we got a new plan, then set it to be a master plan (User level Plans should be master plans |
| 529 | // so that they can be interruptible). Then resume the process. |
| 530 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 531 | if (new_plan_sp) |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 532 | { |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 533 | new_plan_sp->SetIsMasterPlan (true); |
| 534 | new_plan_sp->SetOkayToDiscard (false); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 535 | |
| 536 | process->GetThreadList().SetSelectedThreadByID (thread->GetID()); |
| 537 | process->Resume (); |
| 538 | |
| 539 | |
| 540 | if (synchronous_execution) |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 541 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 542 | StateType state = process->WaitForProcessToStop (NULL); |
| 543 | |
| 544 | //EventSP event_sp; |
| 545 | //StateType state = process->WaitForStateChangedEvents (NULL, event_sp); |
| 546 | //while (! StateIsStoppedState (state)) |
| 547 | // { |
| 548 | // state = process->WaitForStateChangedEvents (NULL, event_sp); |
| 549 | // } |
| 550 | process->GetThreadList().SetSelectedThreadByID (thread->GetID()); |
| 551 | result.SetDidChangeProcessState (true); |
| 552 | result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state)); |
| 553 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 554 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 555 | else |
| 556 | { |
| 557 | result.SetStatus (eReturnStatusSuccessContinuingNoResult); |
| 558 | } |
| 559 | } |
| 560 | else |
| 561 | { |
| 562 | result.AppendError ("Couldn't find thread plan to implement step type."); |
| 563 | result.SetStatus (eReturnStatusFailed); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 564 | } |
| 565 | return result.Succeeded(); |
| 566 | } |
| 567 | |
| 568 | protected: |
| 569 | StepType m_step_type; |
| 570 | StepScope m_step_scope; |
| 571 | CommandOptions m_options; |
| 572 | }; |
| 573 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 574 | static OptionEnumValueElement |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 575 | g_tri_running_mode[] = |
| 576 | { |
Greg Clayton | ed8a705 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 577 | { eOnlyThisThread, "this-thread", "Run only this thread"}, |
| 578 | { eAllThreads, "all-threads", "Run all threads"}, |
| 579 | { eOnlyDuringStepping, "while-stepping", "Run only this thread while stepping"}, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 580 | { 0, NULL, NULL } |
| 581 | }; |
| 582 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 583 | static OptionEnumValueElement |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 584 | g_duo_running_mode[] = |
| 585 | { |
Greg Clayton | ed8a705 | 2010-09-18 03:37:20 +0000 | [diff] [blame] | 586 | { eOnlyThisThread, "this-thread", "Run only this thread"}, |
| 587 | { eAllThreads, "all-threads", "Run all threads"}, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 588 | { 0, NULL, NULL } |
| 589 | }; |
| 590 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 591 | OptionDefinition |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 592 | CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = |
| 593 | { |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 594 | { LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', OptionParser::eRequiredArgument, NULL, 0, eArgTypeBoolean, "A boolean value that sets whether step-in will step over functions with no debug information."}, |
| 595 | { LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, g_tri_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread."}, |
| 596 | { LLDB_OPT_SET_1, false, "step-over-regexp",'r', OptionParser::eRequiredArgument, NULL, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in."}, |
| 597 | { LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into."}, |
Caroline Tice | deaab22 | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 598 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 599 | }; |
| 600 | |
| 601 | |
| 602 | //------------------------------------------------------------------------- |
| 603 | // CommandObjectThreadContinue |
| 604 | //------------------------------------------------------------------------- |
| 605 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 606 | class CommandObjectThreadContinue : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 607 | { |
| 608 | public: |
| 609 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 610 | CommandObjectThreadContinue (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 611 | CommandObjectParsed (interpreter, |
| 612 | "thread continue", |
| 613 | "Continue execution of one or more threads in an active process.", |
| 614 | NULL, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 615 | eFlagRequiresThread | |
| 616 | eFlagTryTargetAPILock | |
| 617 | eFlagProcessMustBeLaunched | |
| 618 | eFlagProcessMustBePaused) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 619 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 620 | CommandArgumentEntry arg; |
| 621 | CommandArgumentData thread_idx_arg; |
| 622 | |
| 623 | // Define the first (and only) variant of this arg. |
| 624 | thread_idx_arg.arg_type = eArgTypeThreadIndex; |
| 625 | thread_idx_arg.arg_repetition = eArgRepeatPlus; |
| 626 | |
| 627 | // There is only one variant this argument could be; put it into the argument entry. |
| 628 | arg.push_back (thread_idx_arg); |
| 629 | |
| 630 | // Push the data for the first argument into the m_arguments vector. |
| 631 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | |
| 635 | virtual |
| 636 | ~CommandObjectThreadContinue () |
| 637 | { |
| 638 | } |
| 639 | |
| 640 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 641 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | { |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 643 | bool synchronous_execution = m_interpreter.GetSynchronous (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 644 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 645 | if (!m_interpreter.GetDebugger().GetSelectedTarget().get()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 646 | { |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 647 | result.AppendError ("invalid target, create a debug target using the 'target create' command"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 648 | result.SetStatus (eReturnStatusFailed); |
| 649 | return false; |
| 650 | } |
| 651 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 652 | Process *process = m_exe_ctx.GetProcessPtr(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 653 | if (process == NULL) |
| 654 | { |
| 655 | result.AppendError ("no process exists. Cannot continue"); |
| 656 | result.SetStatus (eReturnStatusFailed); |
| 657 | return false; |
| 658 | } |
| 659 | |
| 660 | StateType state = process->GetState(); |
| 661 | if ((state == eStateCrashed) || (state == eStateStopped) || (state == eStateSuspended)) |
| 662 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 663 | const size_t argc = command.GetArgumentCount(); |
| 664 | if (argc > 0) |
| 665 | { |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 666 | // These two lines appear at the beginning of both blocks in |
| 667 | // this if..else, but that is because we need to release the |
| 668 | // lock before calling process->Resume below. |
| 669 | Mutex::Locker locker (process->GetThreadList().GetMutex()); |
| 670 | const uint32_t num_threads = process->GetThreadList().GetSize(); |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 671 | std::vector<Thread *> resume_threads; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 672 | for (uint32_t i=0; i<argc; ++i) |
| 673 | { |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 674 | bool success; |
| 675 | const int base = 0; |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 676 | uint32_t thread_idx = Args::StringToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success); |
| 677 | if (success) |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 678 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 679 | Thread *thread = process->GetThreadList().FindThreadByIndexID(thread_idx).get(); |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 680 | |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 681 | if (thread) |
| 682 | { |
| 683 | resume_threads.push_back(thread); |
| 684 | } |
| 685 | else |
| 686 | { |
| 687 | result.AppendErrorWithFormat("invalid thread index %u.\n", thread_idx); |
| 688 | result.SetStatus (eReturnStatusFailed); |
| 689 | return false; |
| 690 | } |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 691 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 692 | else |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 693 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 694 | result.AppendErrorWithFormat ("invalid thread index argument: \"%s\".\n", command.GetArgumentAtIndex(i)); |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 695 | result.SetStatus (eReturnStatusFailed); |
| 696 | return false; |
| 697 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 698 | } |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 699 | |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 700 | if (resume_threads.empty()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 701 | { |
| 702 | result.AppendError ("no valid thread indexes were specified"); |
| 703 | result.SetStatus (eReturnStatusFailed); |
| 704 | return false; |
| 705 | } |
| 706 | else |
| 707 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 708 | if (resume_threads.size() == 1) |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 709 | result.AppendMessageWithFormat ("Resuming thread: "); |
| 710 | else |
| 711 | result.AppendMessageWithFormat ("Resuming threads: "); |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 712 | |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 713 | for (uint32_t idx=0; idx<num_threads; ++idx) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 714 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 715 | Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get(); |
| 716 | std::vector<Thread *>::iterator this_thread_pos = find(resume_threads.begin(), resume_threads.end(), thread); |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 717 | |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 718 | if (this_thread_pos != resume_threads.end()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 719 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 720 | resume_threads.erase(this_thread_pos); |
| 721 | if (resume_threads.size() > 0) |
Jim Ingham | ce76c62 | 2012-05-31 20:48:41 +0000 | [diff] [blame] | 722 | result.AppendMessageWithFormat ("%u, ", thread->GetIndexID()); |
| 723 | else |
| 724 | result.AppendMessageWithFormat ("%u ", thread->GetIndexID()); |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 725 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 726 | thread->SetResumeState (eStateRunning); |
| 727 | } |
| 728 | else |
| 729 | { |
| 730 | thread->SetResumeState (eStateSuspended); |
| 731 | } |
| 732 | } |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 733 | result.AppendMessageWithFormat ("in process %" PRIu64 "\n", process->GetID()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | else |
| 737 | { |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 738 | // These two lines appear at the beginning of both blocks in |
| 739 | // this if..else, but that is because we need to release the |
| 740 | // lock before calling process->Resume below. |
| 741 | Mutex::Locker locker (process->GetThreadList().GetMutex()); |
| 742 | const uint32_t num_threads = process->GetThreadList().GetSize(); |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 743 | Thread *current_thread = process->GetThreadList().GetSelectedThread().get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 744 | if (current_thread == NULL) |
| 745 | { |
| 746 | result.AppendError ("the process doesn't have a current thread"); |
| 747 | result.SetStatus (eReturnStatusFailed); |
| 748 | return false; |
| 749 | } |
| 750 | // Set the actions that the threads should each take when resuming |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 751 | for (uint32_t idx=0; idx<num_threads; ++idx) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 752 | { |
Greg Clayton | c8a0ce0 | 2012-07-03 20:54:16 +0000 | [diff] [blame] | 753 | Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 754 | if (thread == current_thread) |
| 755 | { |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 756 | result.AppendMessageWithFormat ("Resuming thread 0x%4.4" PRIx64 " in process %" PRIu64 "\n", thread->GetID(), process->GetID()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 757 | thread->SetResumeState (eStateRunning); |
| 758 | } |
| 759 | else |
| 760 | { |
| 761 | thread->SetResumeState (eStateSuspended); |
| 762 | } |
| 763 | } |
| 764 | } |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 765 | |
| 766 | // We should not be holding the thread list lock when we do this. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 767 | Error error (process->Resume()); |
| 768 | if (error.Success()) |
| 769 | { |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 770 | result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 771 | if (synchronous_execution) |
| 772 | { |
Greg Clayton | b132097 | 2010-07-14 00:18:15 +0000 | [diff] [blame] | 773 | state = process->WaitForProcessToStop (NULL); |
Andrew Kaylor | 9063bf4 | 2013-09-12 19:15:05 +0000 | [diff] [blame^] | 774 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 775 | result.SetDidChangeProcessState (true); |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 776 | result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 777 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 778 | } |
| 779 | else |
| 780 | { |
| 781 | result.SetStatus (eReturnStatusSuccessContinuingNoResult); |
| 782 | } |
| 783 | } |
| 784 | else |
| 785 | { |
| 786 | result.AppendErrorWithFormat("Failed to resume process: %s\n", error.AsCString()); |
| 787 | result.SetStatus (eReturnStatusFailed); |
| 788 | } |
| 789 | } |
| 790 | else |
| 791 | { |
| 792 | result.AppendErrorWithFormat ("Process cannot be continued from its current state (%s).\n", |
| 793 | StateAsCString(state)); |
| 794 | result.SetStatus (eReturnStatusFailed); |
| 795 | } |
| 796 | |
| 797 | return result.Succeeded(); |
| 798 | } |
| 799 | |
| 800 | }; |
| 801 | |
| 802 | //------------------------------------------------------------------------- |
| 803 | // CommandObjectThreadUntil |
| 804 | //------------------------------------------------------------------------- |
| 805 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 806 | class CommandObjectThreadUntil : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 807 | { |
| 808 | public: |
| 809 | |
| 810 | class CommandOptions : public Options |
| 811 | { |
| 812 | public: |
| 813 | uint32_t m_thread_idx; |
| 814 | uint32_t m_frame_idx; |
| 815 | |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 816 | CommandOptions (CommandInterpreter &interpreter) : |
| 817 | Options (interpreter), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 818 | m_thread_idx(LLDB_INVALID_THREAD_ID), |
| 819 | m_frame_idx(LLDB_INVALID_FRAME_ID) |
| 820 | { |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 821 | // Keep default values of all options in one place: OptionParsingStarting () |
| 822 | OptionParsingStarting (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | virtual |
| 826 | ~CommandOptions () |
| 827 | { |
| 828 | } |
| 829 | |
| 830 | virtual Error |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 831 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 832 | { |
| 833 | Error error; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 834 | const int short_option = m_getopt_table[option_idx].val; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 835 | |
| 836 | switch (short_option) |
| 837 | { |
| 838 | case 't': |
| 839 | { |
Greg Clayton | b132097 | 2010-07-14 00:18:15 +0000 | [diff] [blame] | 840 | m_thread_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_INDEX32); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 841 | if (m_thread_idx == LLDB_INVALID_INDEX32) |
| 842 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 843 | error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 844 | } |
| 845 | } |
| 846 | break; |
| 847 | case 'f': |
| 848 | { |
| 849 | m_frame_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_FRAME_ID); |
| 850 | if (m_frame_idx == LLDB_INVALID_FRAME_ID) |
| 851 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 852 | error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 853 | } |
| 854 | } |
| 855 | break; |
| 856 | case 'm': |
| 857 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 858 | OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; |
Greg Clayton | cf0e4f0 | 2011-10-07 18:58:12 +0000 | [diff] [blame] | 859 | lldb::RunMode run_mode = (lldb::RunMode) Args::StringToOptionEnum(option_arg, enum_values, eOnlyDuringStepping, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 860 | |
Greg Clayton | cf0e4f0 | 2011-10-07 18:58:12 +0000 | [diff] [blame] | 861 | if (error.Success()) |
| 862 | { |
| 863 | if (run_mode == eAllThreads) |
| 864 | m_stop_others = false; |
| 865 | else |
| 866 | m_stop_others = true; |
| 867 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 868 | } |
| 869 | break; |
| 870 | default: |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 871 | error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 872 | break; |
| 873 | |
| 874 | } |
| 875 | return error; |
| 876 | } |
| 877 | |
| 878 | void |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 879 | OptionParsingStarting () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 880 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 881 | m_thread_idx = LLDB_INVALID_THREAD_ID; |
| 882 | m_frame_idx = 0; |
| 883 | m_stop_others = false; |
| 884 | } |
| 885 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 886 | const OptionDefinition* |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 887 | GetDefinitions () |
| 888 | { |
| 889 | return g_option_table; |
| 890 | } |
| 891 | |
| 892 | uint32_t m_step_thread_idx; |
| 893 | bool m_stop_others; |
| 894 | |
| 895 | // Options table: Required for subclasses of Options. |
| 896 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 897 | static OptionDefinition g_option_table[]; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 898 | |
| 899 | // Instance variables to hold the values for command options. |
| 900 | }; |
| 901 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 902 | CommandObjectThreadUntil (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 903 | CommandObjectParsed (interpreter, |
| 904 | "thread until", |
| 905 | "Run the current or specified thread until it reaches a given line number or leaves the current function.", |
| 906 | NULL, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 907 | eFlagRequiresThread | |
| 908 | eFlagTryTargetAPILock | |
| 909 | eFlagProcessMustBeLaunched | |
| 910 | eFlagProcessMustBePaused ), |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 911 | m_options (interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 912 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 913 | CommandArgumentEntry arg; |
| 914 | CommandArgumentData line_num_arg; |
| 915 | |
| 916 | // Define the first (and only) variant of this arg. |
| 917 | line_num_arg.arg_type = eArgTypeLineNum; |
| 918 | line_num_arg.arg_repetition = eArgRepeatPlain; |
| 919 | |
| 920 | // There is only one variant this argument could be; put it into the argument entry. |
| 921 | arg.push_back (line_num_arg); |
| 922 | |
| 923 | // Push the data for the first argument into the m_arguments vector. |
| 924 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | |
| 928 | virtual |
| 929 | ~CommandObjectThreadUntil () |
| 930 | { |
| 931 | } |
| 932 | |
| 933 | virtual |
| 934 | Options * |
| 935 | GetOptions () |
| 936 | { |
| 937 | return &m_options; |
| 938 | } |
| 939 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 940 | protected: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 941 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 942 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 943 | { |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 944 | bool synchronous_execution = m_interpreter.GetSynchronous (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 945 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 946 | Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 947 | if (target == NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 948 | { |
Greg Clayton | effe5c9 | 2011-05-03 22:09:39 +0000 | [diff] [blame] | 949 | result.AppendError ("invalid target, create a debug target using the 'target create' command"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 950 | result.SetStatus (eReturnStatusFailed); |
| 951 | return false; |
| 952 | } |
| 953 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 954 | Process *process = m_exe_ctx.GetProcessPtr(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 955 | if (process == NULL) |
| 956 | { |
| 957 | result.AppendError ("need a valid process to step"); |
| 958 | result.SetStatus (eReturnStatusFailed); |
| 959 | |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | Thread *thread = NULL; |
| 964 | uint32_t line_number; |
| 965 | |
| 966 | if (command.GetArgumentCount() != 1) |
| 967 | { |
| 968 | result.AppendErrorWithFormat ("No line number provided:\n%s", GetSyntax()); |
| 969 | result.SetStatus (eReturnStatusFailed); |
| 970 | return false; |
| 971 | } |
| 972 | |
| 973 | line_number = Args::StringToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX); |
| 974 | if (line_number == UINT32_MAX) |
| 975 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 976 | result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 977 | result.SetStatus (eReturnStatusFailed); |
| 978 | return false; |
| 979 | } |
| 980 | |
| 981 | if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID) |
| 982 | { |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 983 | thread = process->GetThreadList().GetSelectedThread().get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 984 | } |
| 985 | else |
| 986 | { |
Greg Clayton | 76927ee | 2012-05-31 00:29:20 +0000 | [diff] [blame] | 987 | thread = process->GetThreadList().FindThreadByIndexID(m_options.m_thread_idx).get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | if (thread == NULL) |
| 991 | { |
| 992 | const uint32_t num_threads = process->GetThreadList().GetSize(); |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 993 | result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", |
| 994 | m_options.m_thread_idx, |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 995 | num_threads); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 996 | result.SetStatus (eReturnStatusFailed); |
| 997 | return false; |
| 998 | } |
| 999 | |
Jim Ingham | 7ba6e99 | 2012-05-11 23:47:32 +0000 | [diff] [blame] | 1000 | const bool abort_other_plans = false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1001 | |
| 1002 | StackFrame *frame = thread->GetStackFrameAtIndex(m_options.m_frame_idx).get(); |
| 1003 | if (frame == NULL) |
| 1004 | { |
| 1005 | |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1006 | result.AppendErrorWithFormat ("Frame index %u is out of range for thread %u.\n", |
| 1007 | m_options.m_frame_idx, |
| 1008 | m_options.m_thread_idx); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1009 | result.SetStatus (eReturnStatusFailed); |
| 1010 | return false; |
| 1011 | } |
| 1012 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 1013 | ThreadPlanSP new_plan_sp; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1014 | |
| 1015 | if (frame->HasDebugInformation ()) |
| 1016 | { |
| 1017 | // Finally we got here... Translate the given line number to a bunch of addresses: |
| 1018 | SymbolContext sc(frame->GetSymbolContext (eSymbolContextCompUnit)); |
| 1019 | LineTable *line_table = NULL; |
| 1020 | if (sc.comp_unit) |
| 1021 | line_table = sc.comp_unit->GetLineTable(); |
| 1022 | |
| 1023 | if (line_table == NULL) |
| 1024 | { |
| 1025 | result.AppendErrorWithFormat ("Failed to resolve the line table for frame %u of thread index %u.\n", |
| 1026 | m_options.m_frame_idx, m_options.m_thread_idx); |
| 1027 | result.SetStatus (eReturnStatusFailed); |
| 1028 | return false; |
| 1029 | } |
| 1030 | |
| 1031 | LineEntry function_start; |
| 1032 | uint32_t index_ptr = 0, end_ptr; |
| 1033 | std::vector<addr_t> address_list; |
| 1034 | |
| 1035 | // Find the beginning & end index of the |
| 1036 | AddressRange fun_addr_range = sc.function->GetAddressRange(); |
| 1037 | Address fun_start_addr = fun_addr_range.GetBaseAddress(); |
| 1038 | line_table->FindLineEntryByAddress (fun_start_addr, function_start, &index_ptr); |
| 1039 | |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1040 | Address fun_end_addr(fun_start_addr.GetSection(), |
| 1041 | fun_start_addr.GetOffset() + fun_addr_range.GetByteSize()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1042 | line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr); |
| 1043 | |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1044 | bool all_in_function = true; |
| 1045 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1046 | while (index_ptr <= end_ptr) |
| 1047 | { |
| 1048 | LineEntry line_entry; |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 1049 | const bool exact = false; |
| 1050 | index_ptr = sc.comp_unit->FindLineEntry(index_ptr, line_number, sc.comp_unit, exact, &line_entry); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1051 | if (index_ptr == UINT32_MAX) |
| 1052 | break; |
| 1053 | |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 1054 | addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1055 | if (address != LLDB_INVALID_ADDRESS) |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1056 | { |
| 1057 | if (fun_addr_range.ContainsLoadAddress (address, target)) |
| 1058 | address_list.push_back (address); |
| 1059 | else |
| 1060 | all_in_function = false; |
| 1061 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1062 | index_ptr++; |
| 1063 | } |
| 1064 | |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1065 | if (address_list.size() == 0) |
| 1066 | { |
| 1067 | if (all_in_function) |
| 1068 | result.AppendErrorWithFormat ("No line entries matching until target.\n"); |
| 1069 | else |
| 1070 | result.AppendErrorWithFormat ("Until target outside of the current function.\n"); |
| 1071 | |
| 1072 | result.SetStatus (eReturnStatusFailed); |
| 1073 | return false; |
| 1074 | } |
| 1075 | |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 1076 | new_plan_sp = thread->QueueThreadPlanForStepUntil (abort_other_plans, |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1077 | &address_list.front(), |
| 1078 | address_list.size(), |
| 1079 | m_options.m_stop_others, |
Jim Ingham | f76ab67 | 2012-09-14 20:48:14 +0000 | [diff] [blame] | 1080 | m_options.m_frame_idx); |
Jim Ingham | 64e7ead | 2012-05-03 21:19:36 +0000 | [diff] [blame] | 1081 | // User level plans should be master plans so they can be interrupted (e.g. by hitting a breakpoint) |
| 1082 | // and other plans executed by the user (stepping around the breakpoint) and then a "continue" |
| 1083 | // will resume the original plan. |
Jim Ingham | 4d56e9c | 2013-07-18 21:48:26 +0000 | [diff] [blame] | 1084 | new_plan_sp->SetIsMasterPlan (true); |
| 1085 | new_plan_sp->SetOkayToDiscard(false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1086 | } |
| 1087 | else |
| 1088 | { |
Jim Ingham | 9b70ddb | 2011-05-08 00:56:32 +0000 | [diff] [blame] | 1089 | result.AppendErrorWithFormat ("Frame index %u of thread %u has no debug information.\n", |
| 1090 | m_options.m_frame_idx, |
| 1091 | m_options.m_thread_idx); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1092 | result.SetStatus (eReturnStatusFailed); |
| 1093 | return false; |
| 1094 | |
| 1095 | } |
| 1096 | |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 1097 | process->GetThreadList().SetSelectedThreadByID (m_options.m_thread_idx); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1098 | Error error (process->Resume ()); |
| 1099 | if (error.Success()) |
| 1100 | { |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1101 | result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1102 | if (synchronous_execution) |
| 1103 | { |
| 1104 | StateType state = process->WaitForProcessToStop (NULL); |
| 1105 | |
| 1106 | result.SetDidChangeProcessState (true); |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 1107 | result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1108 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 1109 | } |
| 1110 | else |
| 1111 | { |
| 1112 | result.SetStatus (eReturnStatusSuccessContinuingNoResult); |
| 1113 | } |
| 1114 | } |
| 1115 | else |
| 1116 | { |
| 1117 | result.AppendErrorWithFormat("Failed to resume process: %s.\n", error.AsCString()); |
| 1118 | result.SetStatus (eReturnStatusFailed); |
| 1119 | } |
| 1120 | |
| 1121 | } |
| 1122 | return result.Succeeded(); |
| 1123 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1124 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1125 | CommandOptions m_options; |
| 1126 | |
| 1127 | }; |
| 1128 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1129 | OptionDefinition |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1130 | CommandObjectThreadUntil::CommandOptions::g_option_table[] = |
| 1131 | { |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 1132 | { LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"}, |
| 1133 | { LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, |
| 1134 | { LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, g_duo_running_mode, 0, eArgTypeRunMode,"Determine how to run other threads while stepping this one"}, |
Caroline Tice | deaab22 | 2010-10-01 19:59:14 +0000 | [diff] [blame] | 1135 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1136 | }; |
| 1137 | |
| 1138 | |
| 1139 | //------------------------------------------------------------------------- |
| 1140 | // CommandObjectThreadSelect |
| 1141 | //------------------------------------------------------------------------- |
| 1142 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1143 | class CommandObjectThreadSelect : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1144 | { |
| 1145 | public: |
| 1146 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1147 | CommandObjectThreadSelect (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1148 | CommandObjectParsed (interpreter, |
| 1149 | "thread select", |
| 1150 | "Select a thread as the currently active thread.", |
| 1151 | NULL, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1152 | eFlagRequiresProcess | |
| 1153 | eFlagTryTargetAPILock | |
| 1154 | eFlagProcessMustBeLaunched | |
| 1155 | eFlagProcessMustBePaused ) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1156 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1157 | CommandArgumentEntry arg; |
| 1158 | CommandArgumentData thread_idx_arg; |
| 1159 | |
| 1160 | // Define the first (and only) variant of this arg. |
| 1161 | thread_idx_arg.arg_type = eArgTypeThreadIndex; |
| 1162 | thread_idx_arg.arg_repetition = eArgRepeatPlain; |
| 1163 | |
| 1164 | // There is only one variant this argument could be; put it into the argument entry. |
| 1165 | arg.push_back (thread_idx_arg); |
| 1166 | |
| 1167 | // Push the data for the first argument into the m_arguments vector. |
| 1168 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
| 1171 | |
| 1172 | virtual |
| 1173 | ~CommandObjectThreadSelect () |
| 1174 | { |
| 1175 | } |
| 1176 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1177 | protected: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1178 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1179 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1180 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1181 | Process *process = m_exe_ctx.GetProcessPtr(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1182 | if (process == NULL) |
| 1183 | { |
| 1184 | result.AppendError ("no process"); |
| 1185 | result.SetStatus (eReturnStatusFailed); |
| 1186 | return false; |
| 1187 | } |
| 1188 | else if (command.GetArgumentCount() != 1) |
| 1189 | { |
Jason Molenda | fd54b36 | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 1190 | result.AppendErrorWithFormat("'%s' takes exactly one thread index argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1191 | result.SetStatus (eReturnStatusFailed); |
| 1192 | return false; |
| 1193 | } |
| 1194 | |
| 1195 | uint32_t index_id = Args::StringToUInt32(command.GetArgumentAtIndex(0), 0, 0); |
| 1196 | |
| 1197 | Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get(); |
| 1198 | if (new_thread == NULL) |
| 1199 | { |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1200 | result.AppendErrorWithFormat ("invalid thread #%s.\n", command.GetArgumentAtIndex(0)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1201 | result.SetStatus (eReturnStatusFailed); |
| 1202 | return false; |
| 1203 | } |
| 1204 | |
Jim Ingham | c3faa19 | 2012-12-11 02:31:48 +0000 | [diff] [blame] | 1205 | process->GetThreadList().SetSelectedThreadByID(new_thread->GetID(), true); |
Johnny Chen | c13ee52 | 2010-09-14 00:53:53 +0000 | [diff] [blame] | 1206 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1207 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1208 | return result.Succeeded(); |
| 1209 | } |
| 1210 | |
| 1211 | }; |
| 1212 | |
| 1213 | |
| 1214 | //------------------------------------------------------------------------- |
| 1215 | // CommandObjectThreadList |
| 1216 | //------------------------------------------------------------------------- |
| 1217 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1218 | class CommandObjectThreadList : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1219 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1220 | public: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1221 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1222 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1223 | CommandObjectThreadList (CommandInterpreter &interpreter): |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1224 | CommandObjectParsed (interpreter, |
| 1225 | "thread list", |
| 1226 | "Show a summary of all current threads in a process.", |
| 1227 | "thread list", |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1228 | eFlagRequiresProcess | |
| 1229 | eFlagTryTargetAPILock | |
| 1230 | eFlagProcessMustBeLaunched | |
| 1231 | eFlagProcessMustBePaused ) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1232 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1233 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1234 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1235 | ~CommandObjectThreadList() |
| 1236 | { |
| 1237 | } |
| 1238 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1239 | protected: |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1240 | bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1241 | DoExecute (Args& command, CommandReturnObject &result) |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1242 | { |
Jim Ingham | 85e8b81 | 2011-02-19 02:53:09 +0000 | [diff] [blame] | 1243 | Stream &strm = result.GetOutputStream(); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1244 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1245 | Process *process = m_exe_ctx.GetProcessPtr(); |
| 1246 | const bool only_threads_with_stop_reason = false; |
| 1247 | const uint32_t start_frame = 0; |
| 1248 | const uint32_t num_frames = 0; |
| 1249 | const uint32_t num_frames_with_source = 0; |
| 1250 | process->GetStatus(strm); |
| 1251 | process->GetThreadStatus (strm, |
| 1252 | only_threads_with_stop_reason, |
| 1253 | start_frame, |
| 1254 | num_frames, |
| 1255 | num_frames_with_source); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1256 | return result.Succeeded(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1257 | } |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1258 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1259 | |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1260 | //------------------------------------------------------------------------- |
| 1261 | // CommandObjectThreadReturn |
| 1262 | //------------------------------------------------------------------------- |
| 1263 | |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1264 | class CommandObjectThreadReturn : public CommandObjectRaw |
| 1265 | { |
| 1266 | public: |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1267 | class CommandOptions : public Options |
| 1268 | { |
| 1269 | public: |
| 1270 | |
| 1271 | CommandOptions (CommandInterpreter &interpreter) : |
| 1272 | Options (interpreter), |
| 1273 | m_from_expression (false) |
| 1274 | { |
| 1275 | // Keep default values of all options in one place: OptionParsingStarting () |
| 1276 | OptionParsingStarting (); |
| 1277 | } |
| 1278 | |
| 1279 | virtual |
| 1280 | ~CommandOptions () |
| 1281 | { |
| 1282 | } |
| 1283 | |
| 1284 | virtual Error |
| 1285 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
| 1286 | { |
| 1287 | Error error; |
| 1288 | const int short_option = m_getopt_table[option_idx].val; |
| 1289 | |
| 1290 | switch (short_option) |
| 1291 | { |
| 1292 | case 'x': |
| 1293 | { |
| 1294 | bool success; |
| 1295 | bool tmp_value = Args::StringToBoolean (option_arg, false, &success); |
| 1296 | if (success) |
| 1297 | m_from_expression = tmp_value; |
| 1298 | else |
| 1299 | { |
| 1300 | error.SetErrorStringWithFormat ("invalid boolean value '%s' for 'x' option", option_arg); |
| 1301 | } |
| 1302 | } |
| 1303 | break; |
| 1304 | default: |
| 1305 | error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); |
| 1306 | break; |
| 1307 | |
| 1308 | } |
| 1309 | return error; |
| 1310 | } |
| 1311 | |
| 1312 | void |
| 1313 | OptionParsingStarting () |
| 1314 | { |
| 1315 | m_from_expression = false; |
| 1316 | } |
| 1317 | |
| 1318 | const OptionDefinition* |
| 1319 | GetDefinitions () |
| 1320 | { |
| 1321 | return g_option_table; |
| 1322 | } |
| 1323 | |
| 1324 | bool m_from_expression; |
| 1325 | |
| 1326 | // Options table: Required for subclasses of Options. |
| 1327 | |
| 1328 | static OptionDefinition g_option_table[]; |
| 1329 | |
| 1330 | // Instance variables to hold the values for command options. |
| 1331 | }; |
| 1332 | |
| 1333 | virtual |
| 1334 | Options * |
| 1335 | GetOptions () |
| 1336 | { |
| 1337 | return &m_options; |
| 1338 | } |
| 1339 | |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1340 | CommandObjectThreadReturn (CommandInterpreter &interpreter) : |
| 1341 | CommandObjectRaw (interpreter, |
| 1342 | "thread return", |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1343 | "Return from the currently selected frame, short-circuiting execution of the frames below it, with an optional return value," |
| 1344 | " or with the -x option from the innermost function evaluation.", |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1345 | "thread return", |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1346 | eFlagRequiresFrame | |
| 1347 | eFlagTryTargetAPILock | |
| 1348 | eFlagProcessMustBeLaunched | |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1349 | eFlagProcessMustBePaused ), |
| 1350 | m_options (interpreter) |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1351 | { |
| 1352 | CommandArgumentEntry arg; |
| 1353 | CommandArgumentData expression_arg; |
| 1354 | |
| 1355 | // Define the first (and only) variant of this arg. |
| 1356 | expression_arg.arg_type = eArgTypeExpression; |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1357 | expression_arg.arg_repetition = eArgRepeatOptional; |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1358 | |
| 1359 | // There is only one variant this argument could be; put it into the argument entry. |
| 1360 | arg.push_back (expression_arg); |
| 1361 | |
| 1362 | // Push the data for the first argument into the m_arguments vector. |
| 1363 | m_arguments.push_back (arg); |
| 1364 | |
| 1365 | |
| 1366 | } |
| 1367 | |
| 1368 | ~CommandObjectThreadReturn() |
| 1369 | { |
| 1370 | } |
| 1371 | |
| 1372 | protected: |
| 1373 | |
| 1374 | bool DoExecute |
| 1375 | ( |
| 1376 | const char *command, |
| 1377 | CommandReturnObject &result |
| 1378 | ) |
| 1379 | { |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1380 | // I am going to handle this by hand, because I don't want you to have to say: |
| 1381 | // "thread return -- -5". |
| 1382 | if (command[0] == '-' && command[1] == 'x') |
| 1383 | { |
| 1384 | if (command && command[2] != '\0') |
| 1385 | result.AppendWarning("Return values ignored when returning from user called expressions"); |
| 1386 | |
| 1387 | Thread *thread = m_exe_ctx.GetThreadPtr(); |
| 1388 | Error error; |
| 1389 | error = thread->UnwindInnermostExpression(); |
| 1390 | if (!error.Success()) |
| 1391 | { |
| 1392 | result.AppendErrorWithFormat ("Unwinding expression failed - %s.", error.AsCString()); |
| 1393 | result.SetStatus (eReturnStatusFailed); |
| 1394 | } |
| 1395 | else |
| 1396 | { |
| 1397 | bool success = thread->SetSelectedFrameByIndexNoisily (0, result.GetOutputStream()); |
| 1398 | if (success) |
| 1399 | { |
| 1400 | m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ()); |
| 1401 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 1402 | } |
| 1403 | else |
| 1404 | { |
| 1405 | result.AppendErrorWithFormat ("Could not select 0th frame after unwinding expression."); |
| 1406 | result.SetStatus (eReturnStatusFailed); |
| 1407 | } |
| 1408 | } |
| 1409 | return result.Succeeded(); |
| 1410 | } |
| 1411 | |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1412 | ValueObjectSP return_valobj_sp; |
| 1413 | |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1414 | StackFrameSP frame_sp = m_exe_ctx.GetFrameSP(); |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1415 | uint32_t frame_idx = frame_sp->GetFrameIndex(); |
| 1416 | |
| 1417 | if (frame_sp->IsInlined()) |
| 1418 | { |
| 1419 | result.AppendError("Don't know how to return from inlined frames."); |
| 1420 | result.SetStatus (eReturnStatusFailed); |
| 1421 | return false; |
| 1422 | } |
| 1423 | |
| 1424 | if (command && command[0] != '\0') |
| 1425 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1426 | Target *target = m_exe_ctx.GetTargetPtr(); |
Jim Ingham | 35e1bda | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1427 | EvaluateExpressionOptions options; |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1428 | |
| 1429 | options.SetUnwindOnError(true); |
| 1430 | options.SetUseDynamic(eNoDynamicValues); |
| 1431 | |
| 1432 | ExecutionResults exe_results = eExecutionSetupError; |
| 1433 | exe_results = target->EvaluateExpression (command, |
| 1434 | frame_sp.get(), |
| 1435 | return_valobj_sp, |
| 1436 | options); |
| 1437 | if (exe_results != eExecutionCompleted) |
| 1438 | { |
| 1439 | if (return_valobj_sp) |
| 1440 | result.AppendErrorWithFormat("Error evaluating result expression: %s", return_valobj_sp->GetError().AsCString()); |
| 1441 | else |
| 1442 | result.AppendErrorWithFormat("Unknown error evaluating result expression."); |
| 1443 | result.SetStatus (eReturnStatusFailed); |
| 1444 | return false; |
| 1445 | |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | Error error; |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 1450 | ThreadSP thread_sp = m_exe_ctx.GetThreadSP(); |
Jim Ingham | 4f465cf | 2012-10-10 18:32:14 +0000 | [diff] [blame] | 1451 | const bool broadcast = true; |
| 1452 | error = thread_sp->ReturnFromFrame (frame_sp, return_valobj_sp, broadcast); |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1453 | if (!error.Success()) |
| 1454 | { |
| 1455 | result.AppendErrorWithFormat("Error returning from frame %d of thread %d: %s.", frame_idx, thread_sp->GetIndexID(), error.AsCString()); |
| 1456 | result.SetStatus (eReturnStatusFailed); |
| 1457 | return false; |
| 1458 | } |
| 1459 | |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1460 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 1461 | return true; |
| 1462 | } |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1463 | |
| 1464 | CommandOptions m_options; |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1465 | |
| 1466 | }; |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1467 | OptionDefinition |
| 1468 | CommandObjectThreadReturn::CommandOptions::g_option_table[] = |
| 1469 | { |
Virgile Bello | e2607b5 | 2013-09-05 16:42:23 +0000 | [diff] [blame] | 1470 | { LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Return from the innermost expression evaluation."}, |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 1471 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
| 1472 | }; |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1473 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1474 | //------------------------------------------------------------------------- |
Richard Mitton | f86248d | 2013-09-12 02:20:34 +0000 | [diff] [blame] | 1475 | // CommandObjectThreadJump |
| 1476 | //------------------------------------------------------------------------- |
| 1477 | |
| 1478 | class CommandObjectThreadJump : public CommandObjectParsed |
| 1479 | { |
| 1480 | public: |
| 1481 | class CommandOptions : public Options |
| 1482 | { |
| 1483 | public: |
| 1484 | |
| 1485 | CommandOptions (CommandInterpreter &interpreter) : |
| 1486 | Options (interpreter) |
| 1487 | { |
| 1488 | OptionParsingStarting (); |
| 1489 | } |
| 1490 | |
| 1491 | void |
| 1492 | OptionParsingStarting () |
| 1493 | { |
| 1494 | m_filenames.Clear(); |
| 1495 | m_line_num = 0; |
| 1496 | m_line_offset = 0; |
| 1497 | m_load_addr = LLDB_INVALID_ADDRESS; |
| 1498 | m_force = false; |
| 1499 | } |
| 1500 | |
| 1501 | virtual |
| 1502 | ~CommandOptions () |
| 1503 | { |
| 1504 | } |
| 1505 | |
| 1506 | virtual Error |
| 1507 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
| 1508 | { |
| 1509 | bool success; |
| 1510 | const int short_option = m_getopt_table[option_idx].val; |
| 1511 | Error error; |
| 1512 | |
| 1513 | switch (short_option) |
| 1514 | { |
| 1515 | case 'f': |
| 1516 | m_filenames.AppendIfUnique (FileSpec(option_arg, false)); |
| 1517 | if (m_filenames.GetSize() > 1) |
| 1518 | return Error("only one source file expected."); |
| 1519 | break; |
| 1520 | case 'l': |
| 1521 | m_line_num = Args::StringToUInt32 (option_arg, 0, 0, &success); |
| 1522 | if (!success || m_line_num == 0) |
| 1523 | return Error("invalid line number: '%s'.", option_arg); |
| 1524 | break; |
| 1525 | case 'b': |
| 1526 | m_line_offset = Args::StringToSInt32 (option_arg, 0, 0, &success); |
| 1527 | if (!success) |
| 1528 | return Error("invalid line offset: '%s'.", option_arg); |
| 1529 | break; |
| 1530 | case 'a': |
| 1531 | { |
| 1532 | ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); |
| 1533 | m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); |
| 1534 | } |
| 1535 | break; |
| 1536 | case 'r': |
| 1537 | m_force = true; |
| 1538 | break; |
| 1539 | |
| 1540 | default: |
| 1541 | return Error("invalid short option character '%c'", short_option); |
| 1542 | |
| 1543 | } |
| 1544 | return error; |
| 1545 | } |
| 1546 | |
| 1547 | const OptionDefinition* |
| 1548 | GetDefinitions () |
| 1549 | { |
| 1550 | return g_option_table; |
| 1551 | } |
| 1552 | |
| 1553 | FileSpecList m_filenames; |
| 1554 | uint32_t m_line_num; |
| 1555 | int32_t m_line_offset; |
| 1556 | lldb::addr_t m_load_addr; |
| 1557 | bool m_force; |
| 1558 | |
| 1559 | static OptionDefinition g_option_table[]; |
| 1560 | }; |
| 1561 | |
| 1562 | virtual |
| 1563 | Options * |
| 1564 | GetOptions () |
| 1565 | { |
| 1566 | return &m_options; |
| 1567 | } |
| 1568 | |
| 1569 | CommandObjectThreadJump (CommandInterpreter &interpreter) : |
| 1570 | CommandObjectParsed (interpreter, |
| 1571 | "thread jump", |
| 1572 | "Sets the program counter to a new address.", |
| 1573 | "thread jump", |
| 1574 | eFlagRequiresFrame | |
| 1575 | eFlagTryTargetAPILock | |
| 1576 | eFlagProcessMustBeLaunched | |
| 1577 | eFlagProcessMustBePaused ), |
| 1578 | m_options (interpreter) |
| 1579 | { |
| 1580 | } |
| 1581 | |
| 1582 | ~CommandObjectThreadJump() |
| 1583 | { |
| 1584 | } |
| 1585 | |
| 1586 | protected: |
| 1587 | |
| 1588 | bool DoExecute (Args& args, CommandReturnObject &result) |
| 1589 | { |
| 1590 | RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); |
| 1591 | StackFrame *frame = m_exe_ctx.GetFramePtr(); |
| 1592 | Thread *thread = m_exe_ctx.GetThreadPtr(); |
| 1593 | Target *target = m_exe_ctx.GetTargetPtr(); |
| 1594 | const SymbolContext &sym_ctx = frame->GetSymbolContext (eSymbolContextLineEntry); |
| 1595 | |
| 1596 | if (m_options.m_load_addr != LLDB_INVALID_ADDRESS) |
| 1597 | { |
| 1598 | // Use this address directly. |
| 1599 | Address dest = Address(m_options.m_load_addr); |
| 1600 | |
| 1601 | lldb::addr_t callAddr = dest.GetCallableLoadAddress (target); |
| 1602 | if (callAddr == LLDB_INVALID_ADDRESS) |
| 1603 | { |
| 1604 | result.AppendErrorWithFormat ("Invalid destination address."); |
| 1605 | result.SetStatus (eReturnStatusFailed); |
| 1606 | return false; |
| 1607 | } |
| 1608 | |
| 1609 | if (!reg_ctx->SetPC (callAddr)) |
| 1610 | { |
| 1611 | result.AppendErrorWithFormat ("Error changing PC value for thread %d.", thread->GetIndexID()); |
| 1612 | result.SetStatus (eReturnStatusFailed); |
| 1613 | return false; |
| 1614 | } |
| 1615 | } |
| 1616 | else |
| 1617 | { |
| 1618 | // Pick either the absolute line, or work out a relative one. |
| 1619 | int32_t line = (int32_t)m_options.m_line_num; |
| 1620 | if (line == 0) |
| 1621 | line = sym_ctx.line_entry.line + m_options.m_line_offset; |
| 1622 | |
| 1623 | // Try the current file, but override if asked. |
| 1624 | FileSpec file = sym_ctx.line_entry.file; |
| 1625 | if (m_options.m_filenames.GetSize() == 1) |
| 1626 | file = m_options.m_filenames.GetFileSpecAtIndex(0); |
| 1627 | |
| 1628 | if (!file) |
| 1629 | { |
| 1630 | result.AppendErrorWithFormat ("No source file available for the current location."); |
| 1631 | result.SetStatus (eReturnStatusFailed); |
| 1632 | return false; |
| 1633 | } |
| 1634 | |
| 1635 | std::string warnings; |
| 1636 | Error err = thread->JumpToLine (file, line, m_options.m_force, &warnings); |
| 1637 | |
| 1638 | if (err.Fail()) |
| 1639 | { |
| 1640 | result.SetError (err); |
| 1641 | return false; |
| 1642 | } |
| 1643 | |
| 1644 | if (!warnings.empty()) |
| 1645 | result.AppendWarning (warnings.c_str()); |
| 1646 | } |
| 1647 | |
| 1648 | result.SetStatus (eReturnStatusSuccessFinishResult); |
| 1649 | return true; |
| 1650 | } |
| 1651 | |
| 1652 | CommandOptions m_options; |
| 1653 | }; |
| 1654 | OptionDefinition |
| 1655 | CommandObjectThreadJump::CommandOptions::g_option_table[] = |
| 1656 | { |
| 1657 | { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, |
| 1658 | "Specifies the source file to jump to."}, |
| 1659 | |
| 1660 | { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, NULL, 0, eArgTypeLineNum, |
| 1661 | "Specifies the line number to jump to."}, |
| 1662 | |
| 1663 | { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, NULL, 0, eArgTypeOffset, |
| 1664 | "Jumps by a relative line offset from the current line."}, |
| 1665 | |
| 1666 | { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, NULL, 0, eArgTypeAddressOrExpression, |
| 1667 | "Jumps to a specific address."}, |
| 1668 | |
| 1669 | { LLDB_OPT_SET_1| |
| 1670 | LLDB_OPT_SET_2| |
| 1671 | LLDB_OPT_SET_3, false, "force",'r', OptionParser::eNoArgument, NULL, 0, eArgTypeNone,"Allows the PC to leave the current function."}, |
| 1672 | |
| 1673 | { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } |
| 1674 | }; |
| 1675 | |
| 1676 | //------------------------------------------------------------------------- |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1677 | // CommandObjectMultiwordThread |
| 1678 | //------------------------------------------------------------------------- |
| 1679 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1680 | CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1681 | CommandObjectMultiword (interpreter, |
| 1682 | "thread", |
Caroline Tice | 3f4c09c | 2010-09-07 22:38:08 +0000 | [diff] [blame] | 1683 | "A set of commands for operating on one or more threads within a running process.", |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1684 | "thread <subcommand> [<subcommand-options>]") |
| 1685 | { |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1686 | LoadSubCommand ("backtrace", CommandObjectSP (new CommandObjectThreadBacktrace (interpreter))); |
| 1687 | LoadSubCommand ("continue", CommandObjectSP (new CommandObjectThreadContinue (interpreter))); |
| 1688 | LoadSubCommand ("list", CommandObjectSP (new CommandObjectThreadList (interpreter))); |
Jim Ingham | cb640dd | 2012-09-14 02:14:15 +0000 | [diff] [blame] | 1689 | LoadSubCommand ("return", CommandObjectSP (new CommandObjectThreadReturn (interpreter))); |
Richard Mitton | f86248d | 2013-09-12 02:20:34 +0000 | [diff] [blame] | 1690 | LoadSubCommand ("jump", CommandObjectSP (new CommandObjectThreadJump (interpreter))); |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1691 | LoadSubCommand ("select", CommandObjectSP (new CommandObjectThreadSelect (interpreter))); |
| 1692 | LoadSubCommand ("until", CommandObjectSP (new CommandObjectThreadUntil (interpreter))); |
| 1693 | LoadSubCommand ("step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( |
| 1694 | interpreter, |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1695 | "thread step-in", |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1696 | "Source level single step in specified thread (current thread, if none specified).", |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1697 | NULL, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1698 | eStepTypeInto, |
| 1699 | eStepScopeSource))); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1700 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1701 | LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( |
| 1702 | interpreter, |
| 1703 | "thread step-out", |
Jim Ingham | 73ca05a | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 1704 | "Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).", |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1705 | NULL, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1706 | eStepTypeOut, |
| 1707 | eStepScopeSource))); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1708 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1709 | LoadSubCommand ("step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( |
| 1710 | interpreter, |
| 1711 | "thread step-over", |
| 1712 | "Source level single step in specified thread (current thread, if none specified), stepping over calls.", |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1713 | NULL, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1714 | eStepTypeOver, |
| 1715 | eStepScopeSource))); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1716 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1717 | LoadSubCommand ("step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( |
| 1718 | interpreter, |
| 1719 | "thread step-inst", |
| 1720 | "Single step one instruction in specified thread (current thread, if none specified).", |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1721 | NULL, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1722 | eStepTypeTrace, |
| 1723 | eStepScopeInstruction))); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 1724 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1725 | LoadSubCommand ("step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( |
| 1726 | interpreter, |
| 1727 | "thread step-inst-over", |
| 1728 | "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 1729 | NULL, |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 1730 | eStepTypeTraceOver, |
| 1731 | eStepScopeInstruction))); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | CommandObjectMultiwordThread::~CommandObjectMultiwordThread () |
| 1735 | { |
| 1736 | } |
| 1737 | |
| 1738 | |