summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-07-07 04:38:25 +0000
committerGreg Clayton <gclayton@apple.com>2011-07-07 04:38:25 +0000
commit715c236577e8fb0b05a55e21999ac03b5f3cb208 (patch)
tree8584defaf0e8b96b0ba2eed9828515400cc4c07a /lldb/source/Commands
parent5a00499e873277a7bb842dcab7f99baf09fc4595 (diff)
downloadbcm5719-llvm-715c236577e8fb0b05a55e21999ac03b5f3cb208.tar.gz
bcm5719-llvm-715c236577e8fb0b05a55e21999ac03b5f3cb208.zip
Centralize the variable display prefs into a new option
group class: OptionGroupVariable. It gets initialized with a boolean that indicates if the frame specific options are included so that this can be used in both the "frame variable" and "target variable" commands. Removed the global functionality from the "frame variable" command. Users should switch to using the "target variable" command. llvm-svn: 134594
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp130
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp89
2 files changed, 92 insertions, 127 deletions
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;
OpenPOWER on IntegriCloud