Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectFrame.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 "CommandObjectFrame.h" |
| 13 | |
| 14 | // C Includes |
| 15 | // C++ Includes |
Johnny Chen | de6bd24 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 16 | #include <string> |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | // Other libraries and framework includes |
| 18 | // Project includes |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Debugger.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Module.h" |
| 21 | #include "lldb/Core/StreamFile.h" |
Johnny Chen | de6bd24 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 22 | #include "lldb/Core/StreamString.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Core/Timer.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 24 | #include "lldb/Core/Value.h" |
| 25 | #include "lldb/Core/ValueObject.h" |
| 26 | #include "lldb/Core/ValueObjectVariable.h" |
Enrico Granata | 5548cb5 | 2013-01-28 23:47:25 +0000 | [diff] [blame] | 27 | #include "lldb/DataFormatters/DataVisualization.h" |
Enrico Granata | 4d93b8c | 2013-09-30 19:11:51 +0000 | [diff] [blame] | 28 | #include "lldb/DataFormatters/ValueObjectPrinter.h" |
Greg Clayton | 7fb56d0 | 2011-02-01 01:31:41 +0000 | [diff] [blame] | 29 | #include "lldb/Host/Host.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 30 | #include "lldb/Interpreter/Args.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 32 | #include "lldb/Interpreter/CommandReturnObject.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 33 | #include "lldb/Interpreter/Options.h" |
Greg Clayton | 1deb796 | 2011-10-25 06:44:01 +0000 | [diff] [blame] | 34 | #include "lldb/Interpreter/OptionGroupFormat.h" |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 35 | #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 36 | #include "lldb/Interpreter/OptionGroupVariable.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 37 | #include "lldb/Symbol/ClangASTType.h" |
| 38 | #include "lldb/Symbol/ClangASTContext.h" |
| 39 | #include "lldb/Symbol/ObjectFile.h" |
| 40 | #include "lldb/Symbol/SymbolContext.h" |
| 41 | #include "lldb/Symbol/Type.h" |
| 42 | #include "lldb/Symbol/Variable.h" |
| 43 | #include "lldb/Symbol/VariableList.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | #include "lldb/Target/Process.h" |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 45 | #include "lldb/Target/StackFrame.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | #include "lldb/Target/Thread.h" |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 47 | #include "lldb/Target/Target.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 48 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | using namespace lldb; |
| 50 | using namespace lldb_private; |
| 51 | |
| 52 | #pragma mark CommandObjectFrameInfo |
| 53 | |
| 54 | //------------------------------------------------------------------------- |
| 55 | // CommandObjectFrameInfo |
| 56 | //------------------------------------------------------------------------- |
| 57 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 58 | class CommandObjectFrameInfo : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | { |
| 60 | public: |
| 61 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 62 | CommandObjectFrameInfo (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 63 | CommandObjectParsed (interpreter, |
| 64 | "frame info", |
| 65 | "List information about the currently selected frame in the current thread.", |
| 66 | "frame info", |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 67 | eFlagRequiresFrame | |
| 68 | eFlagTryTargetAPILock | |
| 69 | eFlagProcessMustBeLaunched | |
| 70 | eFlagProcessMustBePaused ) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 71 | { |
| 72 | } |
| 73 | |
| 74 | ~CommandObjectFrameInfo () |
| 75 | { |
| 76 | } |
| 77 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 78 | protected: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | bool |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 80 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 81 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 82 | m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat (&result.GetOutputStream()); |
| 83 | result.SetStatus (eReturnStatusSuccessFinishResult); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 84 | return result.Succeeded(); |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | #pragma mark CommandObjectFrameSelect |
| 89 | |
| 90 | //------------------------------------------------------------------------- |
| 91 | // CommandObjectFrameSelect |
| 92 | //------------------------------------------------------------------------- |
| 93 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 94 | class CommandObjectFrameSelect : public CommandObjectParsed |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 95 | { |
| 96 | public: |
| 97 | |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 98 | class CommandOptions : public Options |
| 99 | { |
| 100 | public: |
| 101 | |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 102 | CommandOptions (CommandInterpreter &interpreter) : |
Johnny Chen | f16066e | 2011-04-08 22:39:17 +0000 | [diff] [blame] | 103 | Options(interpreter) |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 104 | { |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 105 | OptionParsingStarting (); |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | virtual |
| 109 | ~CommandOptions () |
| 110 | { |
| 111 | } |
| 112 | |
| 113 | virtual Error |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 114 | SetOptionValue (uint32_t option_idx, const char *option_arg) |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 115 | { |
| 116 | Error error; |
| 117 | bool success = false; |
Greg Clayton | 3bcdfc0 | 2012-12-04 00:32:51 +0000 | [diff] [blame] | 118 | const int short_option = m_getopt_table[option_idx].val; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 119 | switch (short_option) |
| 120 | { |
| 121 | case 'r': |
| 122 | relative_frame_offset = Args::StringToSInt32 (option_arg, INT32_MIN, 0, &success); |
| 123 | if (!success) |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 124 | error.SetErrorStringWithFormat ("invalid frame offset argument '%s'", option_arg); |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 125 | break; |
| 126 | |
| 127 | default: |
Greg Clayton | 86edbf4 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 128 | error.SetErrorStringWithFormat ("invalid short option character '%c'", short_option); |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 129 | break; |
| 130 | } |
| 131 | |
| 132 | return error; |
| 133 | } |
| 134 | |
| 135 | void |
Greg Clayton | f6b8b58 | 2011-04-13 00:18:08 +0000 | [diff] [blame] | 136 | OptionParsingStarting () |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 137 | { |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 138 | relative_frame_offset = INT32_MIN; |
| 139 | } |
| 140 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 141 | const OptionDefinition* |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 142 | GetDefinitions () |
| 143 | { |
| 144 | return g_option_table; |
| 145 | } |
| 146 | |
| 147 | // Options table: Required for subclasses of Options. |
| 148 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 149 | static OptionDefinition g_option_table[]; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 150 | int32_t relative_frame_offset; |
| 151 | }; |
| 152 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 153 | CommandObjectFrameSelect (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 154 | CommandObjectParsed (interpreter, |
| 155 | "frame select", |
| 156 | "Select a frame by index from within the current thread and make it the current frame.", |
| 157 | NULL, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 158 | eFlagRequiresThread | |
| 159 | eFlagTryTargetAPILock | |
| 160 | eFlagProcessMustBeLaunched | |
| 161 | eFlagProcessMustBePaused ), |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 162 | m_options (interpreter) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 163 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 164 | CommandArgumentEntry arg; |
| 165 | CommandArgumentData index_arg; |
| 166 | |
| 167 | // Define the first (and only) variant of this arg. |
| 168 | index_arg.arg_type = eArgTypeFrameIndex; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 169 | index_arg.arg_repetition = eArgRepeatOptional; |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 170 | |
| 171 | // There is only one variant this argument could be; put it into the argument entry. |
| 172 | arg.push_back (index_arg); |
| 173 | |
| 174 | // Push the data for the first argument into the m_arguments vector. |
| 175 | m_arguments.push_back (arg); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | ~CommandObjectFrameSelect () |
| 179 | { |
| 180 | } |
| 181 | |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 182 | virtual |
| 183 | Options * |
| 184 | GetOptions () |
| 185 | { |
| 186 | return &m_options; |
| 187 | } |
| 188 | |
| 189 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 190 | protected: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 191 | bool |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 192 | DoExecute (Args& command, CommandReturnObject &result) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 193 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 194 | // No need to check "thread" for validity as eFlagRequiresThread ensures it is valid |
| 195 | Thread *thread = m_exe_ctx.GetThreadPtr(); |
| 196 | |
| 197 | uint32_t frame_idx = UINT32_MAX; |
| 198 | if (m_options.relative_frame_offset != INT32_MIN) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 199 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 200 | // The one and only argument is a signed relative frame index |
| 201 | frame_idx = thread->GetSelectedFrameIndex (); |
| 202 | if (frame_idx == UINT32_MAX) |
| 203 | frame_idx = 0; |
| 204 | |
| 205 | if (m_options.relative_frame_offset < 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | { |
Saleem Abdulrasool | 3985c8c | 2014-04-02 03:51:35 +0000 | [diff] [blame] | 207 | if (static_cast<int32_t>(frame_idx) >= -m_options.relative_frame_offset) |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 208 | frame_idx += m_options.relative_frame_offset; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 209 | else |
| 210 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 211 | if (frame_idx == 0) |
| 212 | { |
| 213 | //If you are already at the bottom of the stack, then just warn and don't reset the frame. |
| 214 | result.AppendError("Already at the bottom of the stack"); |
| 215 | result.SetStatus(eReturnStatusFailed); |
| 216 | return false; |
| 217 | } |
| 218 | else |
| 219 | frame_idx = 0; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 220 | } |
| 221 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 222 | else if (m_options.relative_frame_offset > 0) |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 223 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 224 | // I don't want "up 20" where "20" takes you past the top of the stack to produce |
| 225 | // an error, but rather to just go to the top. So I have to count the stack here... |
| 226 | const uint32_t num_frames = thread->GetStackFrameCount(); |
Saleem Abdulrasool | 3985c8c | 2014-04-02 03:51:35 +0000 | [diff] [blame] | 227 | if (static_cast<int32_t>(num_frames - frame_idx) > m_options.relative_frame_offset) |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 228 | frame_idx += m_options.relative_frame_offset; |
| 229 | else |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 230 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 231 | if (frame_idx == num_frames - 1) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 232 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 233 | //If we are already at the top of the stack, just warn and don't reset the frame. |
| 234 | result.AppendError("Already at the top of the stack"); |
| 235 | result.SetStatus(eReturnStatusFailed); |
| 236 | return false; |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 237 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 238 | else |
| 239 | frame_idx = num_frames - 1; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 240 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 241 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 242 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 243 | else |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 244 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 245 | if (command.GetArgumentCount() == 1) |
| 246 | { |
| 247 | const char *frame_idx_cstr = command.GetArgumentAtIndex(0); |
Jim Ingham | afbb0af | 2013-11-05 18:25:23 +0000 | [diff] [blame] | 248 | bool success = false; |
| 249 | frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success); |
| 250 | if (!success) |
| 251 | { |
| 252 | result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr); |
| 253 | result.SetStatus (eReturnStatusFailed); |
| 254 | return false; |
| 255 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 256 | } |
| 257 | else if (command.GetArgumentCount() == 0) |
| 258 | { |
| 259 | frame_idx = thread->GetSelectedFrameIndex (); |
| 260 | if (frame_idx == UINT32_MAX) |
| 261 | { |
| 262 | frame_idx = 0; |
| 263 | } |
| 264 | } |
| 265 | else |
| 266 | { |
| 267 | result.AppendError ("invalid arguments.\n"); |
| 268 | m_options.GenerateOptionUsage (result.GetErrorStream(), this); |
| 269 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 270 | } |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 271 | |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 272 | bool success = thread->SetSelectedFrameByIndexNoisily (frame_idx, result.GetOutputStream()); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 273 | if (success) |
| 274 | { |
| 275 | m_exe_ctx.SetFrameSP(thread->GetSelectedFrame ()); |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 276 | result.SetStatus (eReturnStatusSuccessFinishResult); |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 277 | } |
Jim Ingham | 93208b8 | 2013-01-31 21:46:01 +0000 | [diff] [blame] | 278 | else |
| 279 | { |
| 280 | result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx); |
| 281 | result.SetStatus (eReturnStatusFailed); |
| 282 | } |
| 283 | |
| 284 | return result.Succeeded(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 285 | } |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 286 | protected: |
| 287 | |
| 288 | CommandOptions m_options; |
| 289 | }; |
| 290 | |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 291 | OptionDefinition |
Greg Clayton | 864174e | 2010-10-10 22:28:11 +0000 | [diff] [blame] | 292 | CommandObjectFrameSelect::CommandOptions::g_option_table[] = |
| 293 | { |
Zachary Turner | d37221d | 2014-07-09 16:31:49 +0000 | [diff] [blame^] | 294 | { LLDB_OPT_SET_1, false, "relative", 'r', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."}, |
| 295 | { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 296 | }; |
| 297 | |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 298 | #pragma mark CommandObjectFrameVariable |
| 299 | //---------------------------------------------------------------------- |
| 300 | // List images with associated information |
| 301 | //---------------------------------------------------------------------- |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 302 | class CommandObjectFrameVariable : public CommandObjectParsed |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 303 | { |
| 304 | public: |
| 305 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 306 | CommandObjectFrameVariable (CommandInterpreter &interpreter) : |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 307 | CommandObjectParsed (interpreter, |
| 308 | "frame variable", |
| 309 | "Show frame variables. All argument and local variables " |
| 310 | "that are in scope will be shown when no arguments are given. " |
| 311 | "If any arguments are specified, they can be names of " |
| 312 | "argument, local, file static and file global variables. " |
| 313 | "Children of aggregate variables can be specified such as " |
| 314 | "'var->child.x'.", |
| 315 | NULL, |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 316 | eFlagRequiresFrame | |
| 317 | eFlagTryTargetAPILock | |
| 318 | eFlagProcessMustBeLaunched | |
Enrico Granata | a6db933 | 2013-02-21 01:29:04 +0000 | [diff] [blame] | 319 | eFlagProcessMustBePaused | |
| 320 | eFlagRequiresProcess), |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 321 | m_option_group (interpreter), |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 322 | m_option_variable(true), // Include the frame specific options by passing "true" |
Greg Clayton | 1deb796 | 2011-10-25 06:44:01 +0000 | [diff] [blame] | 323 | m_option_format (eFormatDefault), |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 324 | m_varobj_options() |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 325 | { |
Caroline Tice | 405fe67 | 2010-10-04 22:28:36 +0000 | [diff] [blame] | 326 | CommandArgumentEntry arg; |
| 327 | CommandArgumentData var_name_arg; |
| 328 | |
| 329 | // Define the first (and only) variant of this arg. |
| 330 | var_name_arg.arg_type = eArgTypeVarName; |
| 331 | var_name_arg.arg_repetition = eArgRepeatStar; |
| 332 | |
| 333 | // There is only one variant this argument could be; put it into the argument entry. |
| 334 | arg.push_back (var_name_arg); |
| 335 | |
| 336 | // Push the data for the first argument into the m_arguments vector. |
| 337 | m_arguments.push_back (arg); |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 338 | |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 339 | m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); |
Greg Clayton | 5009f9d | 2011-10-27 17:55:14 +0000 | [diff] [blame] | 340 | m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1); |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 341 | m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); |
| 342 | m_option_group.Finalize(); |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | virtual |
| 346 | ~CommandObjectFrameVariable () |
| 347 | { |
| 348 | } |
| 349 | |
| 350 | virtual |
| 351 | Options * |
| 352 | GetOptions () |
| 353 | { |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 354 | return &m_option_group; |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 355 | } |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 356 | |
| 357 | |
| 358 | virtual int |
| 359 | HandleArgumentCompletion (Args &input, |
| 360 | int &cursor_index, |
| 361 | int &cursor_char_position, |
| 362 | OptionElementVector &opt_element_vector, |
| 363 | int match_start_point, |
| 364 | int max_return_elements, |
| 365 | bool &word_complete, |
| 366 | StringList &matches) |
| 367 | { |
| 368 | // Arguments are the standard source file completer. |
| 369 | std::string completion_str (input.GetArgumentAtIndex(cursor_index)); |
| 370 | completion_str.erase (cursor_char_position); |
| 371 | |
| 372 | CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, |
| 373 | CommandCompletions::eVariablePathCompletion, |
| 374 | completion_str.c_str(), |
| 375 | match_start_point, |
| 376 | max_return_elements, |
| 377 | NULL, |
| 378 | word_complete, |
| 379 | matches); |
| 380 | return matches.GetSize(); |
| 381 | } |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 382 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 383 | protected: |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 384 | virtual bool |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 385 | DoExecute (Args& command, CommandReturnObject &result) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 386 | { |
Greg Clayton | f9fc609 | 2013-01-09 19:44:40 +0000 | [diff] [blame] | 387 | // No need to check "frame" for validity as eFlagRequiresFrame ensures it is valid |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 388 | StackFrame *frame = m_exe_ctx.GetFramePtr(); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 389 | |
| 390 | Stream &s = result.GetOutputStream(); |
| 391 | |
| 392 | bool get_file_globals = true; |
| 393 | |
| 394 | // Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList |
| 395 | // for the thread. So hold onto a shared pointer to the frame so it stays alive. |
| 396 | |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 397 | VariableList *variable_list = frame->GetVariableList (get_file_globals); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 398 | |
| 399 | VariableSP var_sp; |
| 400 | ValueObjectSP valobj_sp; |
| 401 | |
| 402 | const char *name_cstr = NULL; |
| 403 | size_t idx; |
| 404 | |
Enrico Granata | 061858c | 2012-02-15 02:34:21 +0000 | [diff] [blame] | 405 | TypeSummaryImplSP summary_format_sp; |
Enrico Granata | 17b1174 | 2012-08-09 22:02:51 +0000 | [diff] [blame] | 406 | if (!m_option_variable.summary.IsCurrentValueEmpty()) |
| 407 | DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.GetCurrentValue()), summary_format_sp); |
| 408 | else if (!m_option_variable.summary_string.IsCurrentValueEmpty()) |
| 409 | summary_format_sp.reset(new StringSummaryFormat(TypeSummaryImpl::Flags(),m_option_variable.summary_string.GetCurrentValue())); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 410 | |
Enrico Granata | 4d93b8c | 2013-09-30 19:11:51 +0000 | [diff] [blame] | 411 | DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(eLanguageRuntimeDescriptionDisplayVerbosityFull,eFormatDefault,summary_format_sp)); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 412 | |
| 413 | if (variable_list) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 414 | { |
Greg Clayton | 1deb796 | 2011-10-25 06:44:01 +0000 | [diff] [blame] | 415 | const Format format = m_option_format.GetFormat(); |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 416 | options.SetFormat(format); |
Greg Clayton | 1deb796 | 2011-10-25 06:44:01 +0000 | [diff] [blame] | 417 | |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 418 | if (command.GetArgumentCount() > 0) |
| 419 | { |
| 420 | VariableList regex_var_list; |
| 421 | |
| 422 | // If we have any args to the variable command, we will make |
| 423 | // variable objects from them... |
| 424 | for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) |
| 425 | { |
| 426 | if (m_option_variable.use_regex) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 427 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 428 | const size_t regex_start_index = regex_var_list.GetSize(); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 429 | RegularExpression regex (name_cstr); |
| 430 | if (regex.Compile(name_cstr)) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 431 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 432 | size_t num_matches = 0; |
| 433 | const size_t num_new_regex_vars = variable_list->AppendVariablesIfUnique(regex, |
| 434 | regex_var_list, |
| 435 | num_matches); |
| 436 | if (num_new_regex_vars > 0) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 437 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 438 | for (size_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize(); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 439 | regex_idx < end_index; |
| 440 | ++regex_idx) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 441 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 442 | var_sp = regex_var_list.GetVariableAtIndex (regex_idx); |
| 443 | if (var_sp) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 444 | { |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 445 | valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 446 | if (valobj_sp) |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 447 | { |
Greg Clayton | 6efba4f | 2012-01-26 21:08:30 +0000 | [diff] [blame] | 448 | // if (format != eFormatDefault) |
| 449 | // valobj_sp->SetFormat (format); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 450 | |
| 451 | if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile()) |
| 452 | { |
| 453 | bool show_fullpaths = false; |
| 454 | bool show_module = true; |
| 455 | if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module)) |
| 456 | s.PutCString (": "); |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 457 | } |
Enrico Granata | 4d93b8c | 2013-09-30 19:11:51 +0000 | [diff] [blame] | 458 | valobj_sp->Dump(result.GetOutputStream(),options); |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | } |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 462 | } |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 463 | else if (num_matches == 0) |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 464 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 465 | result.GetErrorStream().Printf ("error: no variables matched the regular expression '%s'.\n", name_cstr); |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 466 | } |
| 467 | } |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 468 | else |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 469 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 470 | char regex_error[1024]; |
| 471 | if (regex.GetErrorAsCString(regex_error, sizeof(regex_error))) |
| 472 | result.GetErrorStream().Printf ("error: %s\n", regex_error); |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 473 | else |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 474 | result.GetErrorStream().Printf ("error: unkown regex error when compiling '%s'\n", name_cstr); |
| 475 | } |
| 476 | } |
| 477 | else // No regex, either exact variable names or variable expressions. |
| 478 | { |
| 479 | Error error; |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 480 | uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | |
| 481 | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess; |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 482 | lldb::VariableSP var_sp; |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 483 | valobj_sp = frame->GetValueForVariableExpressionPath (name_cstr, |
| 484 | m_varobj_options.use_dynamic, |
| 485 | expr_path_options, |
| 486 | var_sp, |
| 487 | error); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 488 | if (valobj_sp) |
| 489 | { |
Greg Clayton | 6efba4f | 2012-01-26 21:08:30 +0000 | [diff] [blame] | 490 | // if (format != eFormatDefault) |
| 491 | // valobj_sp->SetFormat (format); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 492 | if (m_option_variable.show_decl && var_sp && var_sp->GetDeclaration ().GetFile()) |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 493 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 494 | var_sp->GetDeclaration ().DumpStopContext (&s, false); |
| 495 | s.PutCString (": "); |
Greg Clayton | 4674702 | 2010-10-10 23:55:27 +0000 | [diff] [blame] | 496 | } |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 497 | |
| 498 | options.SetFormat(format); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 499 | |
| 500 | Stream &output_stream = result.GetOutputStream(); |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 501 | options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL); |
Enrico Granata | 4d93b8c | 2013-09-30 19:11:51 +0000 | [diff] [blame] | 502 | valobj_sp->Dump(output_stream,options); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 503 | } |
| 504 | else |
| 505 | { |
| 506 | const char *error_cstr = error.AsCString(NULL); |
| 507 | if (error_cstr) |
| 508 | result.GetErrorStream().Printf("error: %s\n", error_cstr); |
| 509 | else |
| 510 | result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n", name_cstr); |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 511 | } |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 512 | } |
| 513 | } |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 514 | } |
| 515 | else // No command arg specified. Use variable_list, instead. |
| 516 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 517 | const size_t num_variables = variable_list->GetSize(); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 518 | if (num_variables > 0) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 519 | { |
Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 520 | for (size_t i=0; i<num_variables; i++) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 521 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 522 | var_sp = variable_list->GetVariableAtIndex(i); |
| 523 | bool dump_variable = true; |
| 524 | switch (var_sp->GetScope()) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 525 | { |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 526 | case eValueTypeVariableGlobal: |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 527 | dump_variable = m_option_variable.show_globals; |
| 528 | if (dump_variable && m_option_variable.show_scope) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 529 | s.PutCString("GLOBAL: "); |
| 530 | break; |
| 531 | |
| 532 | case eValueTypeVariableStatic: |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 533 | dump_variable = m_option_variable.show_globals; |
| 534 | if (dump_variable && m_option_variable.show_scope) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 535 | s.PutCString("STATIC: "); |
| 536 | break; |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 537 | |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 538 | case eValueTypeVariableArgument: |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 539 | dump_variable = m_option_variable.show_args; |
| 540 | if (dump_variable && m_option_variable.show_scope) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 541 | s.PutCString(" ARG: "); |
| 542 | break; |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 543 | |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 544 | case eValueTypeVariableLocal: |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 545 | dump_variable = m_option_variable.show_locals; |
| 546 | if (dump_variable && m_option_variable.show_scope) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 547 | s.PutCString(" LOCAL: "); |
| 548 | break; |
| 549 | |
| 550 | default: |
| 551 | break; |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 552 | } |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 553 | |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 554 | if (dump_variable) |
| 555 | { |
| 556 | // Use the variable object code to make sure we are |
| 557 | // using the same APIs as the the public API will be |
| 558 | // using... |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 559 | valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, |
| 560 | m_varobj_options.use_dynamic); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 561 | if (valobj_sp) |
| 562 | { |
Greg Clayton | 6efba4f | 2012-01-26 21:08:30 +0000 | [diff] [blame] | 563 | // if (format != eFormatDefault) |
| 564 | // valobj_sp->SetFormat (format); |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 565 | |
| 566 | // When dumping all variables, don't print any variables |
| 567 | // that are not in scope to avoid extra unneeded output |
| 568 | if (valobj_sp->IsInScope ()) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 569 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 570 | if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile()) |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 571 | { |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 572 | var_sp->GetDeclaration ().DumpStopContext (&s, false); |
| 573 | s.PutCString (": "); |
Greg Clayton | 6f00abd | 2010-09-14 03:16:58 +0000 | [diff] [blame] | 574 | } |
Enrico Granata | 0c489f5 | 2012-03-01 04:24:26 +0000 | [diff] [blame] | 575 | |
| 576 | options.SetFormat(format); |
| 577 | options.SetRootValueObjectName(name_cstr); |
Enrico Granata | 4d93b8c | 2013-09-30 19:11:51 +0000 | [diff] [blame] | 578 | valobj_sp->Dump(result.GetOutputStream(),options); |
Greg Clayton | 9df87c1 | 2010-09-13 03:44:33 +0000 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | } |
| 582 | } |
| 583 | } |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 584 | } |
Johnny Chen | 1e49e5e | 2011-09-12 23:58:53 +0000 | [diff] [blame] | 585 | result.SetStatus (eReturnStatusSuccessFinishResult); |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 586 | } |
Enrico Granata | 61a80ba | 2011-08-12 16:42:31 +0000 | [diff] [blame] | 587 | |
| 588 | if (m_interpreter.TruncationWarningNecessary()) |
| 589 | { |
| 590 | result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(), |
| 591 | m_cmd_name.c_str()); |
| 592 | m_interpreter.TruncationWarningGiven(); |
| 593 | } |
| 594 | |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 595 | return result.Succeeded(); |
| 596 | } |
| 597 | protected: |
| 598 | |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 599 | OptionGroupOptions m_option_group; |
Greg Clayton | 715c236 | 2011-07-07 04:38:25 +0000 | [diff] [blame] | 600 | OptionGroupVariable m_option_variable; |
Greg Clayton | 1deb796 | 2011-10-25 06:44:01 +0000 | [diff] [blame] | 601 | OptionGroupFormat m_option_format; |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 602 | OptionGroupValueObjectDisplay m_varobj_options; |
Jim Ingham | 6d56d2c | 2010-09-02 00:18:39 +0000 | [diff] [blame] | 603 | }; |
| 604 | |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 605 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 606 | #pragma mark CommandObjectMultiwordFrame |
| 607 | |
| 608 | //------------------------------------------------------------------------- |
| 609 | // CommandObjectMultiwordFrame |
| 610 | //------------------------------------------------------------------------- |
| 611 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 612 | CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 613 | CommandObjectMultiword (interpreter, |
| 614 | "frame", |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 615 | "A set of commands for operating on the current thread's frames.", |
| 616 | "frame <subcommand> [<subcommand-options>]") |
| 617 | { |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 618 | LoadSubCommand ("info", CommandObjectSP (new CommandObjectFrameInfo (interpreter))); |
| 619 | LoadSubCommand ("select", CommandObjectSP (new CommandObjectFrameSelect (interpreter))); |
| 620 | LoadSubCommand ("variable", CommandObjectSP (new CommandObjectFrameVariable (interpreter))); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () |
| 624 | { |
| 625 | } |
| 626 | |