diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-10-05 00:00:42 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-10-05 00:00:42 +0000 |
| commit | 1d3afba3a3625da15c03cddd88844167e11c440a (patch) | |
| tree | 5dbe98282aa04515ce59c43f5bbc5e33ae584e97 /lldb/source/Core/ValueObject.cpp | |
| parent | 668523a1b86333ff63a0e1d8da413e685fc10adc (diff) | |
| download | bcm5719-llvm-1d3afba3a3625da15c03cddd88844167e11c440a.tar.gz bcm5719-llvm-1d3afba3a3625da15c03cddd88844167e11c440a.zip | |
Added a new ValueObject type that will be used to freeze dry expression
results. The clang opaque type for the expression result will be added to the
Target's ASTContext, and the bytes will be stored in a DataBuffer inside
the new object. The class is named: ValueObjectConstResult
Now after an expression is evaluated, we can get a ValueObjectSP back that
contains a ValueObjectConstResult object.
Relocated the value object dumping code into a static function within
the ValueObject class instead of being in the CommandObjectFrame.cpp file
which is what contained the code to dump variables ("frame variables").
llvm-svn: 115578
Diffstat (limited to 'lldb/source/Core/ValueObject.cpp')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ae53a838af5..4b7f0d70807 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -851,3 +851,127 @@ ValueObject::SetDynamicValue () return true; } + + +void +ValueObject::DumpValueObject +( + Stream &s, + ExecutionContextScope *exe_scope, + ValueObject *valobj, + const char *root_valobj_name, + uint32_t ptr_depth, + uint32_t curr_depth, + uint32_t max_depth, + bool show_types, + bool show_location, + bool use_objc, + bool scope_already_checked +) +{ + if (valobj) + { + //const char *loc_cstr = valobj->GetLocationAsCString(); + if (show_location) + { + s.Printf("%s: ", valobj->GetLocationAsCString(exe_scope)); + } + + s.Indent(); + + if (show_types) + s.Printf("(%s) ", valobj->GetTypeName().AsCString()); + + const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString(""); + s.Printf ("%s = ", name_cstr); + + if (!scope_already_checked && !valobj->IsInScope(exe_scope->CalculateStackFrame())) + { + s.PutCString("error: out of scope"); + return; + } + + const char *val_cstr = valobj->GetValueAsCString(exe_scope); + const char *err_cstr = valobj->GetError().AsCString(); + + if (err_cstr) + { + s.Printf ("error: %s", err_cstr); + } + else + { + const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope); + + const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType()); + + if (val_cstr) + s.PutCString(val_cstr); + + if (sum_cstr) + s.Printf(" %s", sum_cstr); + + if (use_objc) + { + const char *object_desc = valobj->GetObjectDescription(exe_scope); + if (object_desc) + s.Printf("\n%s\n", object_desc); + else + s.Printf ("No description available.\n"); + return; + } + + + if (curr_depth < max_depth) + { + if (is_aggregate) + s.PutChar('{'); + + bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType()); + + if (is_ptr_or_ref && ptr_depth == 0) + return; + + const uint32_t num_children = valobj->GetNumChildren(); + if (num_children) + { + s.IndentMore(); + for (uint32_t idx=0; idx<num_children; ++idx) + { + ValueObjectSP child_sp(valobj->GetChildAtIndex(idx, true)); + if (child_sp.get()) + { + s.EOL(); + DumpValueObject (s, + exe_scope, + child_sp.get(), + NULL, + is_ptr_or_ref ? ptr_depth - 1 : ptr_depth, + curr_depth + 1, + max_depth, + show_types, + show_location, + false, + true); + if (idx + 1 < num_children) + s.PutChar(','); + } + } + s.IndentLess(); + } + if (is_aggregate) + { + s.EOL(); + s.Indent("}"); + } + } + else + { + if (is_aggregate) + { + s.PutCString("{...}"); + } + } + } + } +} + |

