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