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