Refactoring of ValueObject::DumpValueObject and 'frame variable', 'target variable' commands to use an Options object instead of passing an ever-increasing number of arguments to the DumpValueObject() method, with the ultimate aim of making that call private implementation

llvm-svn: 137622
This commit is contained in:
Enrico Granata 2011-08-15 18:01:31 +00:00
parent dfd6ec3ce1
commit 379447a7f2
6 changed files with 259 additions and 73 deletions

View File

@ -201,6 +201,139 @@ public:
}
};
struct DumpValueObjectOptions
{
uint32_t m_ptr_depth;
uint32_t m_max_depth;
bool m_show_types;
bool m_show_location;
bool m_use_objc;
lldb::DynamicValueType m_use_dynamic;
lldb::SyntheticValueType m_use_synthetic;
bool m_scope_already_checked;
bool m_flat_output;
uint32_t m_omit_summary_depth;
bool m_ignore_cap;
DumpValueObjectOptions() :
m_ptr_depth(0),
m_max_depth(UINT32_MAX),
m_show_types(false),
m_show_location(false),
m_use_objc(false),
m_use_dynamic(lldb::eNoDynamicValues),
m_use_synthetic(lldb::eUseSyntheticFilter),
m_scope_already_checked(false),
m_flat_output(false),
m_omit_summary_depth(0),
m_ignore_cap(false)
{}
static const DumpValueObjectOptions
DefaultOptions()
{
static DumpValueObjectOptions g_default_options;
return g_default_options;
}
DumpValueObjectOptions&
SetPointerDepth(uint32_t depth = 0)
{
m_ptr_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetMaximumDepth(uint32_t depth = 0)
{
m_max_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetShowTypes(bool show = false)
{
m_show_types = show;
return *this;
}
DumpValueObjectOptions&
SetShowLocation(bool show = false)
{
m_show_location = show;
return *this;
}
DumpValueObjectOptions&
SetUseObjectiveC(bool use = false)
{
m_use_objc = use;
return *this;
}
DumpValueObjectOptions&
SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues)
{
m_use_dynamic = dyn;
return *this;
}
DumpValueObjectOptions&
SetUseSyntheticValue(lldb::SyntheticValueType syn = lldb::eUseSyntheticFilter)
{
m_use_synthetic = syn;
return *this;
}
DumpValueObjectOptions&
SetScopeChecked(bool check = true)
{
m_scope_already_checked = check;
return *this;
}
DumpValueObjectOptions&
SetFlatOutput(bool flat = false)
{
m_flat_output = flat;
return *this;
}
DumpValueObjectOptions&
SetOmitSummaryDepth(uint32_t depth = 0)
{
m_omit_summary_depth = depth;
return *this;
}
DumpValueObjectOptions&
SetIgnoreCap(bool ignore = false)
{
m_ignore_cap = ignore;
return *this;
}
DumpValueObjectOptions&
SetRawDisplay(bool raw = false)
{
if (raw)
{
SetUseSyntheticValue(lldb::eNoSyntheticFilter);
SetOmitSummaryDepth(UINT32_MAX);
SetIgnoreCap(true);
}
else
{
SetUseSyntheticValue(lldb::eUseSyntheticFilter);
SetOmitSummaryDepth(0);
SetIgnoreCap(false);
}
return *this;
}
};
class EvaluationPoint
{
@ -601,8 +734,8 @@ public:
CastPointerType (const char *name,
lldb::TypeSP &type_sp);
// The backing bits of this value object were updated, clear any value
// values, summaries or descriptions so we refetch them.
// The backing bits of this value object were updated, clear any
// descriptive string, so we know we have to refetch them
virtual void
ValueUpdated ()
{
@ -616,7 +749,88 @@ public:
{
return false;
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj)
{
if (!valobj)
return;
ValueObject::DumpValueObject(s,
valobj,
DumpValueObjectOptions::DefaultOptions());
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj,
const char *root_valobj_name)
{
if (!valobj)
return;
ValueObject::DumpValueObject(s,
valobj,
root_valobj_name,
DumpValueObjectOptions::DefaultOptions());
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj,
const DumpValueObjectOptions& options)
{
if (!valobj)
return;
ValueObject::DumpValueObject(s,
valobj,
valobj->GetName().AsCString(),
options.m_ptr_depth,
0,
options.m_max_depth,
options.m_show_types,
options.m_show_location,
options.m_use_objc,
options.m_use_dynamic,
options.m_use_synthetic,
options.m_scope_already_checked,
options.m_flat_output,
options.m_omit_summary_depth,
options.m_ignore_cap);
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj,
const char *root_valobj_name,
const DumpValueObjectOptions& options)
{
if (!valobj)
return;
ValueObject::DumpValueObject(s,
valobj,
root_valobj_name,
options.m_ptr_depth,
0,
options.m_max_depth,
options.m_show_types,
options.m_show_location,
options.m_use_objc,
options.m_use_dynamic,
options.m_use_synthetic,
options.m_scope_already_checked,
options.m_flat_output,
options.m_omit_summary_depth,
options.m_ignore_cap);
}
static void
DumpValueObject (Stream &s,
ValueObject *valobj,

View File

@ -154,7 +154,9 @@ private:
typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
MsgImplMap m_impl_cache;
protected:
typedef std::map<lldb::addr_t,TypeAndOrName> ClassNameMap;
typedef ClassNameMap::iterator ClassNameIterator;
ClassNameMap m_class_name_cache;
DISALLOW_COPY_AND_ASSIGN (ObjCLanguageRuntime);

View File

@ -326,8 +326,8 @@ namespace lldb {
typedef enum SyntheticValueType
{
eNoSyntheticFilter = 0,
eUseSyntheticFilter = 1
eNoSyntheticFilter = false,
eUseSyntheticFilter = true
} SyntheticValueType;
typedef enum AccessType

View File

@ -925,7 +925,7 @@ SBValue::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
uint32_t ptr_depth = 0;
/*uint32_t ptr_depth = 0;
uint32_t curr_depth = 0;
uint32_t max_depth = UINT32_MAX;
bool show_types = false;
@ -936,21 +936,9 @@ SBValue::GetDescription (SBStream &description)
bool flat_output = false;
bool use_synthetic = true;
uint32_t no_summary_depth = 0;
bool ignore_cap = false;
bool ignore_cap = false;*/
ValueObject::DumpValueObject (description.ref(),
m_opaque_sp.get(),
m_opaque_sp->GetName().GetCString(),
ptr_depth,
curr_depth,
max_depth,
show_types, show_location,
use_objc,
use_dynamic,
use_synthetic,
scope_already_checked,
flat_output,
no_summary_depth,
ignore_cap);
m_opaque_sp.get());
}
else
description.Printf ("No value");

View File

@ -442,7 +442,23 @@ public:
SummaryFormatSP summary_format_sp;
if (!m_option_variable.summary.empty())
Debugger::Formatting::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp);
ValueObject::DumpValueObjectOptions options;
options.SetPointerDepth(m_varobj_options.ptr_depth)
.SetMaximumDepth(m_varobj_options.max_depth)
.SetShowTypes(m_varobj_options.show_types)
.SetShowLocation(m_varobj_options.show_location)
.SetUseObjectiveC(m_varobj_options.use_objc)
.SetUseDynamicType(m_varobj_options.use_dynamic)
.SetUseSyntheticValue((lldb::SyntheticValueType)m_varobj_options.use_synth)
.SetFlatOutput(m_varobj_options.flat_output)
.SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
.SetIgnoreCap(m_varobj_options.ignore_cap);
if (m_varobj_options.be_raw)
options.SetRawDisplay(true);
if (variable_list)
{
if (command.GetArgumentCount() > 0)
@ -453,8 +469,6 @@ public:
// variable objects from them...
for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx)
{
uint32_t ptr_depth = m_varobj_options.ptr_depth;
if (m_option_variable.use_regex)
{
const uint32_t regex_start_index = regex_var_list.GetSize();
@ -490,20 +504,8 @@ public:
if (summary_format_sp)
valobj_sp->SetCustomSummaryFormat(summary_format_sp);
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
var_sp->GetName().AsCString(),
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,
m_varobj_options.be_raw ? false : m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth,
m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap);
valobj_sp.get(),
options);
}
}
}
@ -545,19 +547,8 @@ public:
valobj_sp->SetCustomSummaryFormat(summary_format_sp);
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
valobj_sp->GetParent() ? name_cstr : NULL,
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,
m_varobj_options.be_raw ? false : m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth,
m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap);
valobj_sp->GetParent() ? name_cstr : NULL,
options);
}
else
{
@ -638,19 +629,8 @@ public:
valobj_sp->SetCustomSummaryFormat(summary_format_sp);
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,
m_varobj_options.be_raw ? false : m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth,
m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap);
name_cstr,
options);
}
}
}

View File

@ -553,6 +553,19 @@ public:
void
DumpValueObject (Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)
{
ValueObject::DumpValueObjectOptions options;
options.SetPointerDepth(m_varobj_options.ptr_depth)
.SetMaximumDepth(m_varobj_options.max_depth)
.SetShowTypes(m_varobj_options.show_types)
.SetShowLocation(m_varobj_options.show_location)
.SetUseObjectiveC(m_varobj_options.use_objc)
.SetUseDynamicType(m_varobj_options.use_dynamic)
.SetUseSyntheticValue((lldb::SyntheticValueType)m_varobj_options.use_synth)
.SetFlatOutput(m_varobj_options.flat_output)
.SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
.SetIgnoreCap(m_varobj_options.ignore_cap);
if (m_option_variable.format != eFormatDefault)
valobj_sp->SetFormat (m_option_variable.format);
@ -597,18 +610,7 @@ public:
ValueObject::DumpValueObject (s,
valobj_sp.get(),
root_name,
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,
m_varobj_options.be_raw ? false : m_varobj_options.use_synth,
false,
m_varobj_options.flat_output,
m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth,
m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap);
options);
}