Add support for "dynamic values" for C++ classes.  This currently only works for "frame var" and for the
expressions that are simple enough to get passed to the "frame var" underpinnings.  The parser code will
have to be changed to also query for the dynamic types & offsets as it is looking up variables.

The behavior of "frame var" is controlled in two ways.  You can pass "-d {true/false} to the frame var
command to get the dynamic or static value of the variables you are printing.

There's also a general setting:

target.prefer-dynamic-value (boolean) = 'true'

which is consulted if you call "frame var" without supplying a value for the -d option.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129623 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index e51c2ec..93c5410 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -343,6 +343,13 @@
 SBValue
 SBFrame::FindVariable (const char *name)
 {
+    bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+    return FindVariable (name, use_dynamic);
+}
+
+SBValue
+SBFrame::FindVariable (const char *name, bool use_dynamic)
+{
     VariableSP var_sp;
     if (m_opaque_sp && name && name[0])
     {
@@ -369,7 +376,7 @@
     SBValue sb_value;
     
     if (var_sp)
-        *sb_value = ValueObjectSP (new ValueObjectVariable (m_opaque_sp.get(), var_sp));
+        *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic));
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     if (log)
@@ -382,6 +389,13 @@
 SBValue
 SBFrame::FindValue (const char *name, ValueType value_type)
 {
+    bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+    return FindValue (name, value_type, use_dynamic);
+}
+
+SBValue
+SBFrame::FindValue (const char *name, ValueType value_type, bool use_dynamic)
+{
     SBValue sb_value;
     if (m_opaque_sp && name && name[0])
     {
@@ -416,7 +430,8 @@
                             variable_sp->GetScope() == value_type &&
                             variable_sp->GetName() == const_name)
                         {
-                            *sb_value = ValueObjectSP (new ValueObjectVariable (m_opaque_sp.get(), variable_sp));
+                            *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(variable_sp, 
+                                                                                                   use_dynamic));
                             break;
                         }
                     }
@@ -564,6 +579,17 @@
                        bool statics,
                        bool in_scope_only)
 {
+    bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+    return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
+}
+
+SBValueList
+SBFrame::GetVariables (bool arguments,
+                       bool locals,
+                       bool statics,
+                       bool in_scope_only,
+                       bool use_dynamic)
+{
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     if (log)
@@ -619,7 +645,7 @@
                             if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get()))
                                 continue;
 
-                            value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp));
+                            value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
                         }
                     }
                 }
@@ -680,6 +706,13 @@
 SBValue
 SBFrame::EvaluateExpression (const char *expr)
 {
+    bool use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue();
+    return EvaluateExpression (expr, use_dynamic);
+}
+
+SBValue
+SBFrame::EvaluateExpression (const char *expr, bool fetch_dynamic_value)
+{
     Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
 
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -696,14 +729,23 @@
         const bool unwind_on_error = true;
         const bool keep_in_memory = false;
 
-        exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, m_opaque_sp.get(), unwind_on_error, keep_in_memory, *expr_result);
+        exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, 
+                                                                                           m_opaque_sp.get(), 
+                                                                                           unwind_on_error, 
+                                                                                           fetch_dynamic_value, 
+                                                                                           keep_in_memory, 
+                                                                                           *expr_result);
     }
     
     if (expr_log)
-        expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", expr_result.GetValue(*this), expr_result.GetSummary(*this));
+        expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", 
+                         expr_result.GetValue(*this), 
+                         expr_result.GetSummary(*this));
     
     if (log)
-        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr, expr_result.get());
+        log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), 
+                     expr, 
+                     expr_result.get());
 
     return expr_result;
 }