summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupVariable.h63
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj6
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp130
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp89
-rw-r--r--lldb/source/Interpreter/OptionGroupVariable.cpp109
-rw-r--r--lldb/test/lang/cpp/class_static/TestStaticVariables.py6
6 files changed, 274 insertions, 129 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionGroupVariable.h b/lldb/include/lldb/Interpreter/OptionGroupVariable.h
new file mode 100644
index 00000000000..e7dac2afc3e
--- /dev/null
+++ b/lldb/include/lldb/Interpreter/OptionGroupVariable.h
@@ -0,0 +1,63 @@
+//===-- OptionGroupVariable.h -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_OptionGroupVariable_h_
+#define liblldb_OptionGroupVariable_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/Options.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// OptionGroupVariable
+//-------------------------------------------------------------------------
+
+ class OptionGroupVariable : public OptionGroup
+ {
+ public:
+
+ OptionGroupVariable (bool show_frame_options);
+
+ virtual
+ ~OptionGroupVariable ();
+
+ virtual uint32_t
+ GetNumDefinitions ();
+
+ virtual const OptionDefinition*
+ GetDefinitions ();
+
+ virtual Error
+ SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg);
+
+ virtual void
+ OptionParsingStarting (CommandInterpreter &interpreter);
+
+ bool include_frame_options:1,
+ show_args:1, // Frame option only (include_frame_options == true)
+ show_locals:1, // Frame option only (include_frame_options == true)
+ show_globals:1, // Frame option only (include_frame_options == true)
+ use_regex:1,
+ show_scope:1,
+ show_decl:1;
+ lldb::Format format;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable);
+ };
+
+} // namespace lldb_private
+
+#endif // liblldb_OptionGroupVariable_h_
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index 2b8fa20739e..76f7018d645 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -380,6 +380,7 @@
26DE20631161904200A093E2 /* SBLineEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20621161904200A093E2 /* SBLineEntry.cpp */; };
26DE20651161904E00A093E2 /* SBSymbol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26DE20641161904E00A093E2 /* SBSymbol.cpp */; };
26ECA04313665FED008D1F18 /* ARM_DWARF_Registers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */; };
+ 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */; };
26F5C27710F3D9E4009D5894 /* Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27310F3D9E4009D5894 /* Driver.cpp */; };
26F5C27810F3D9E4009D5894 /* IOChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F5C27510F3D9E4009D5894 /* IOChannel.cpp */; };
26F5C32510F3DF23009D5894 /* libpython.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32410F3DF23009D5894 /* libpython.dylib */; };
@@ -1048,6 +1049,8 @@
26E6902E129C6BD500DDECD9 /* ClangExternalASTSourceCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExternalASTSourceCallbacks.h; path = include/lldb/Symbol/ClangExternalASTSourceCallbacks.h; sourceTree = "<group>"; };
26E69030129C6BEF00DDECD9 /* ClangExternalASTSourceCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExternalASTSourceCallbacks.cpp; path = source/Symbol/ClangExternalASTSourceCallbacks.cpp; sourceTree = "<group>"; };
26ECA04213665FED008D1F18 /* ARM_DWARF_Registers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ARM_DWARF_Registers.cpp; path = source/Utility/ARM_DWARF_Registers.cpp; sourceTree = "<group>"; };
+ 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupVariable.cpp; path = source/Interpreter/OptionGroupVariable.cpp; sourceTree = "<group>"; };
+ 26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupVariable.h; path = include/lldb/Interpreter/OptionGroupVariable.h; sourceTree = "<group>"; };
26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; };
26F5C27210F3D9E4009D5894 /* lldb-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "lldb-Info.plist"; path = "tools/driver/lldb-Info.plist"; sourceTree = "<group>"; };
26F5C27310F3D9E4009D5894 /* Driver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Driver.cpp; path = tools/driver/Driver.cpp; sourceTree = "<group>"; };
@@ -2263,6 +2266,8 @@
260E07C5136FA69E00CF21D3 /* OptionGroupUUID.cpp */,
267C0128136880C7006E963E /* OptionGroupValueObjectDisplay.h */,
267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */,
+ 26ED3D6F13C5638A0017D45E /* OptionGroupVariable.h */,
+ 26ED3D6C13C563810017D45E /* OptionGroupVariable.cpp */,
26BC7DE510F1B7F900F91463 /* ScriptInterpreter.h */,
9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */,
9A2771FB1135A35C00E6ADB6 /* ScriptInterpreterNone.h */,
@@ -3245,6 +3250,7 @@
9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */,
49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */,
9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */,
+ 26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 33e735ac81d..d184e0038d4 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -26,6 +26,7 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
+#include "lldb/Interpreter/OptionGroupVariable.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -378,7 +379,7 @@ public:
NULL,
eFlagProcessMustBeLaunched | eFlagProcessMustBePaused),
m_option_group (interpreter),
- m_frame_var_options(),
+ m_option_variable(true), // Include the frame specific options by passing "true"
m_varobj_options()
{
CommandArgumentEntry arg;
@@ -394,7 +395,7 @@ public:
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back (arg);
- m_option_group.Append (&m_frame_var_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
}
@@ -438,73 +439,8 @@ public:
const char *name_cstr = NULL;
size_t idx;
- if (!m_frame_var_options.globals.empty())
- {
- uint32_t fail_count = 0;
- if (exe_ctx.target)
- {
- const size_t num_globals = m_frame_var_options.globals.size();
- for (idx = 0; idx < num_globals; ++idx)
- {
- VariableList global_var_list;
- const uint32_t num_matching_globals
- = exe_ctx.target->GetImages().FindGlobalVariables (m_frame_var_options.globals[idx],
- true,
- UINT32_MAX,
- global_var_list);
-
- if (num_matching_globals == 0)
- {
- ++fail_count;
- result.GetErrorStream().Printf ("error: can't find global variable '%s'\n",
- m_frame_var_options.globals[idx].AsCString());
- }
- else
- {
- for (uint32_t global_idx=0; global_idx<num_matching_globals; ++global_idx)
- {
- var_sp = global_var_list.GetVariableAtIndex(global_idx);
- if (var_sp)
- {
- valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp,
- m_varobj_options.use_dynamic);
- if (!valobj_sp)
- valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp,
- m_varobj_options.use_dynamic);
-
- if (valobj_sp)
- {
- if (m_frame_var_options.format != eFormatDefault)
- valobj_sp->SetFormat (m_frame_var_options.format);
- if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile())
- {
- var_sp->GetDeclaration ().DumpStopContext (&s, false);
- s.PutCString (": ");
- }
-
- ValueObject::DumpValueObject (result.GetOutputStream(),
- valobj_sp.get(),
- name_cstr,
- m_varobj_options.ptr_depth,
- 0,
- m_varobj_options.max_depth,
- m_varobj_options.show_types,
- m_varobj_options.show_location,
- m_varobj_options.use_objc,
- m_varobj_options.use_dynamic,
- false,
- m_varobj_options.flat_output);
- }
- }
- }
- }
- }
- }
- if (fail_count)
- result.SetStatus (eReturnStatusFailed);
- }
- else if (variable_list)
+ if (variable_list)
{
if (command.GetArgumentCount() > 0)
{
@@ -516,7 +452,7 @@ public:
{
uint32_t ptr_depth = m_varobj_options.ptr_depth;
- if (m_frame_var_options.use_regex)
+ if (m_option_variable.use_regex)
{
const uint32_t regex_start_index = regex_var_list.GetSize();
RegularExpression regex (name_cstr);
@@ -538,10 +474,10 @@ public:
valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic);
if (valobj_sp)
{
- if (m_frame_var_options.format != eFormatDefault)
- valobj_sp->SetFormat (m_frame_var_options.format);
+ if (m_option_variable.format != eFormatDefault)
+ valobj_sp->SetFormat (m_option_variable.format);
- if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile())
+ if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
s.PutCString (": ");
@@ -589,9 +525,9 @@ public:
error);
if (valobj_sp)
{
- if (m_frame_var_options.format != eFormatDefault)
- valobj_sp->SetFormat (m_frame_var_options.format);
- if (m_frame_var_options.show_decl && var_sp && var_sp->GetDeclaration ().GetFile())
+ if (m_option_variable.format != eFormatDefault)
+ valobj_sp->SetFormat (m_option_variable.format);
+ if (m_option_variable.show_decl && var_sp && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
s.PutCString (": ");
@@ -635,26 +571,26 @@ public:
switch (var_sp->GetScope())
{
case eValueTypeVariableGlobal:
- dump_variable = m_frame_var_options.show_globals;
- if (dump_variable && m_frame_var_options.show_scope)
+ dump_variable = m_option_variable.show_globals;
+ if (dump_variable && m_option_variable.show_scope)
s.PutCString("GLOBAL: ");
break;
case eValueTypeVariableStatic:
- dump_variable = m_frame_var_options.show_globals;
- if (dump_variable && m_frame_var_options.show_scope)
+ dump_variable = m_option_variable.show_globals;
+ if (dump_variable && m_option_variable.show_scope)
s.PutCString("STATIC: ");
break;
case eValueTypeVariableArgument:
- dump_variable = m_frame_var_options.show_args;
- if (dump_variable && m_frame_var_options.show_scope)
+ dump_variable = m_option_variable.show_args;
+ if (dump_variable && m_option_variable.show_scope)
s.PutCString(" ARG: ");
break;
case eValueTypeVariableLocal:
- dump_variable = m_frame_var_options.show_locals;
- if (dump_variable && m_frame_var_options.show_scope)
+ dump_variable = m_option_variable.show_locals;
+ if (dump_variable && m_option_variable.show_scope)
s.PutCString(" LOCAL: ");
break;
@@ -672,14 +608,14 @@ public:
m_varobj_options.use_dynamic);
if (valobj_sp)
{
- if (m_frame_var_options.format != eFormatDefault)
- valobj_sp->SetFormat (m_frame_var_options.format);
+ if (m_option_variable.format != eFormatDefault)
+ valobj_sp->SetFormat (m_option_variable.format);
// When dumping all variables, don't print any variables
// that are not in scope to avoid extra unneeded output
if (valobj_sp->IsInScope ())
{
- if (m_frame_var_options.show_decl && var_sp->GetDeclaration ().GetFile())
+ if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
{
var_sp->GetDeclaration ().DumpStopContext (&s, false);
s.PutCString (": ");
@@ -710,30 +646,10 @@ public:
protected:
OptionGroupOptions m_option_group;
- OptionGroupFrameVariable m_frame_var_options;
+ OptionGroupVariable m_option_variable;
OptionGroupValueObjectDisplay m_varobj_options;
};
-OptionDefinition
-CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table[] =
-{
-{ LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."},
-{ LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
-{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."},
-{ LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
-{ LLDB_OPT_SET_1, false, "find-global", 'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."},
-{ LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."},
-{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
-{ LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."},
-{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
-};
-
-uint32_t
-CommandObjectFrameVariable::OptionGroupFrameVariable::GetNumDefinitions ()
-{
- return sizeof(CommandObjectFrameVariable::OptionGroupFrameVariable::g_option_table)/sizeof(OptionDefinition);
-}
-
#pragma mark CommandObjectMultiwordFrame
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 7b000a96a9d..2cce53e6816 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -27,7 +27,7 @@
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionGroupArchitecture.h"
#include "lldb/Interpreter/OptionGroupFile.h"
-#include "lldb/Interpreter/OptionGroupFormat.h"
+#include "lldb/Interpreter/OptionGroupVariable.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Interpreter/OptionGroupUInt64.h"
#include "lldb/Interpreter/OptionGroupUUID.h"
@@ -417,13 +417,13 @@ public:
NULL,
0),
m_option_group (interpreter),
- m_format_options (eFormatDefault, 0, false),
+ m_option_variable (false), // Don't include frame options
m_option_compile_units (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypePath, "A basename or fullpath to a file that contains global variables. This option can be specified multiple times."),
m_option_shared_libraries (LLDB_OPT_SET_1, false, "shlib",'s', 0, eArgTypePath, "A basename or fullpath to a shared library to use in the search for global variables. This option can be specified multiple times."),
m_varobj_options()
{
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
- m_option_group.Append (&m_format_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+ m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_option_compile_units, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_option_shared_libraries, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Finalize();
@@ -447,19 +447,39 @@ public:
for (size_t idx = 0; idx < argc; ++idx)
{
VariableList global_var_list;
- const char *global_var_name = args.GetArgumentAtIndex(idx);
- const uint32_t matches = exe_ctx.target->GetImages().FindGlobalVariables (global_var_name,
- true,
- UINT32_MAX,
- global_var_list);
+ const char *arg = args.GetArgumentAtIndex(idx);
+ uint32_t matches = 0;
+ if (m_option_variable.use_regex)
+ {
+ RegularExpression regex(arg);
+ if (!regex.IsValid ())
+ {
+ result.GetErrorStream().Printf ("error: invalid regular expression: '%s'\n", arg);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ matches = exe_ctx.target->GetImages().FindGlobalVariables (regex,
+ true,
+ UINT32_MAX,
+ global_var_list);
+ }
+ else
+ {
+ matches = exe_ctx.target->GetImages().FindGlobalVariables (arg,
+ true,
+ UINT32_MAX,
+ global_var_list);
+ }
if (matches == 0)
{
- result.GetErrorStream().Printf ("error: can't find global variable '%s'\n",
- global_var_name);
+ result.GetErrorStream().Printf ("error: can't find global variable '%s'\n", arg);
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
else
{
+ Stream &s = result.GetOutputStream();
for (uint32_t global_idx=0; global_idx<matches; ++global_idx)
{
VariableSP var_sp (global_var_list.GetVariableAtIndex(global_idx));
@@ -469,19 +489,48 @@ public:
if (valobj_sp)
{
- const Format format = m_format_options.GetFormat ();
+ if (m_option_variable.format != eFormatDefault)
+ valobj_sp->SetFormat (m_option_variable.format);
+
+ switch (var_sp->GetScope())
+ {
+ case eValueTypeVariableGlobal:
+ if (m_option_variable.show_scope)
+ s.PutCString("GLOBAL: ");
+ break;
+
+ case eValueTypeVariableStatic:
+ if (m_option_variable.show_scope)
+ s.PutCString("STATIC: ");
+ break;
+
+ case eValueTypeVariableArgument:
+ if (m_option_variable.show_scope)
+ s.PutCString(" ARG: ");
+ break;
+
+ case eValueTypeVariableLocal:
+ if (m_option_variable.show_scope)
+ s.PutCString(" LOCAL: ");
+ break;
+
+ default:
+ break;
+ }
+
+ if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
+ {
+ var_sp->GetDeclaration ().DumpStopContext (&s, false);
+ s.PutCString (": ");
+ }
+
+ const Format format = m_option_variable.format;
if (format != eFormatDefault)
valobj_sp->SetFormat (format);
-// if (m_format_options.show_decl && var_sp->GetDeclaration ().GetFile())
-// {
-// var_sp->GetDeclaration ().DumpStopContext (&s, false);
-// s.PutCString (": ");
-// }
-
- ValueObject::DumpValueObject (result.GetOutputStream(),
+ ValueObject::DumpValueObject (s,
valobj_sp.get(),
- global_var_name,
+ var_sp->GetName().GetCString(),
m_varobj_options.ptr_depth,
0,
m_varobj_options.max_depth,
@@ -520,7 +569,7 @@ public:
protected:
OptionGroupOptions m_option_group;
- OptionGroupFormat m_format_options;
+ OptionGroupVariable m_option_variable;
OptionGroupFileList m_option_compile_units;
OptionGroupFileList m_option_shared_libraries;
OptionGroupValueObjectDisplay m_varobj_options;
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
new file mode 100644
index 00000000000..e553e1bea47
--- /dev/null
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -0,0 +1,109 @@
+//===-- OptionGroupVariable.cpp -----------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Interpreter/OptionGroupVariable.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Target.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static OptionDefinition
+g_option_table[] =
+{
+ { LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."},
+ { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."},
+ { LLDB_OPT_SET_1, false, "show-globals", 'g', no_argument, NULL, 0, eArgTypeNone, "Show the current frame source file global and static variables."},
+ { LLDB_OPT_SET_1, false, "show-declaration",'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."},
+ { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the variable output should use."},
+ { LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The <variable-name> argument for name lookups are regular expressions."},
+ { LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}
+};
+
+
+OptionGroupVariable::OptionGroupVariable (bool show_frame_options) :
+ OptionGroup(),
+ include_frame_options (show_frame_options)
+{
+}
+
+OptionGroupVariable::~OptionGroupVariable ()
+{
+}
+
+Error
+OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter,
+ uint32_t option_idx,
+ const char *option_arg)
+{
+ Error error;
+ if (!include_frame_options)
+ option_idx += 3;
+ char short_option = (char) g_option_table[option_idx].short_option;
+ switch (short_option)
+ {
+ case 'r': use_regex = true; break;
+ case 'a': show_args = false; break;
+ case 'l': show_locals = false; break;
+ case 'g': show_globals = true; break;
+ case 'c': show_decl = true; break;
+ case 'f': error = Args::StringToFormat(option_arg, format, NULL); break;
+ case 's':
+ show_scope = true;
+ break;
+
+ default:
+ error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option);
+ break;
+ }
+
+ return error;
+}
+
+void
+OptionGroupVariable::OptionParsingStarting (CommandInterpreter &interpreter)
+{
+ show_args = true; // Frame option only
+ show_locals = true; // Frame option only
+ show_globals = false; // Frame option only
+ show_decl = false;
+ format = lldb::eFormatDefault;
+ use_regex = false;
+ show_scope = false;
+}
+
+
+const OptionDefinition*
+OptionGroupVariable::GetDefinitions ()
+{
+ // Show the "--no-args", "--no-locals" and "--show-globals"
+ // options if we are showing frame specific options
+ if (include_frame_options)
+ return g_option_table;
+
+ // Skip the "--no-args", "--no-locals" and "--show-globals"
+ // options if we are not showing frame specific options (globals only)
+ return &g_option_table[3];
+}
+
+uint32_t
+OptionGroupVariable::GetNumDefinitions ()
+{
+ if (include_frame_options)
+ return 7;
+ else
+ return 4;
+}
+
+
diff --git a/lldb/test/lang/cpp/class_static/TestStaticVariables.py b/lldb/test/lang/cpp/class_static/TestStaticVariables.py
index 18415b16595..9e08fc2faf7 100644
--- a/lldb/test/lang/cpp/class_static/TestStaticVariables.py
+++ b/lldb/test/lang/cpp/class_static/TestStaticVariables.py
@@ -60,9 +60,11 @@ class StaticVariableTestCase(TestBase):
# On Mac OS X, gcc 4.2 emits the wrong debug info for A::g_points.
slist = ['(PointType [2]) g_points', 'A::g_points']
+# global variables are no longer displayed with the "frame variable" command.
+# add tests for the "target variable" command soon
# 'frame variable -G' finds and displays global variable(s) by name.
- self.expect('frame variable -G g_points', VARIABLES_DISPLAYED_CORRECTLY,
- substrs = slist)
+ # self.expect('frame variable -G g_points', VARIABLES_DISPLAYED_CORRECTLY,
+ # substrs = slist)
# A::g_points is an array of two elements.
if sys.platform.startswith("darwin") and self.getCompiler() in ['clang', 'llvm-gcc']:
OpenPOWER on IntegriCloud