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