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