[Lldb-commits] [lldb] r137622 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Target/ObjCLanguageRuntime.h include/lldb/lldb-enumerations.h source/API/SBValue.cpp source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectTarget.cpp
Enrico Granata
granata.enrico at gmail.com
Mon Aug 15 11:01:31 PDT 2011
Author: enrico
Date: Mon Aug 15 13:01:31 2011
New Revision: 137622
URL: http://llvm.org/viewvc/llvm-project?rev=137622&view=rev
Log:
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
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Aug 15 13:01:31 2011
@@ -201,6 +201,139 @@
}
};
+
+ 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 @@
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,10 +749,91 @@
{
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,
const char *root_valobj_name,
uint32_t ptr_depth,
uint32_t curr_depth,
Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Mon Aug 15 13:01:31 2011
@@ -154,7 +154,9 @@
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);
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Aug 15 13:01:31 2011
@@ -326,8 +326,8 @@
typedef enum SyntheticValueType
{
- eNoSyntheticFilter = 0,
- eUseSyntheticFilter = 1
+ eNoSyntheticFilter = false,
+ eUseSyntheticFilter = true
} SyntheticValueType;
typedef enum AccessType
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Mon Aug 15 13:01:31 2011
@@ -925,7 +925,7 @@
{
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 @@
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");
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Aug 15 13:01:31 2011
@@ -442,7 +442,23 @@
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 @@
// 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 @@
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 @@
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 @@
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);
}
}
}
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137622&r1=137621&r2=137622&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Aug 15 13:01:31 2011
@@ -553,6 +553,19 @@
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 @@
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);
}
More information about the lldb-commits
mailing list