DumpValueObjectOptions OptionGroupValueObjectDisplay::GetAsDumpOptions (LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity, lldb::Format format, lldb::TypeSummaryImplSP summary_sp) { DumpValueObjectOptions options; options.SetMaximumPointerDepth(ptr_depth); if (use_objc) options.SetShowSummary(false); else options.SetOmitSummaryDepth(no_summary_depth); options.SetMaximumDepth(max_depth) .SetShowTypes(show_types) .SetShowLocation(show_location) .SetUseObjectiveC(use_objc) .SetUseDynamicType(use_dynamic) .SetUseSyntheticValue(use_synth) .SetFlatOutput(flat_output) .SetIgnoreCap(ignore_cap) .SetFormat(format) .SetSummary(summary_sp); if (lang_descr_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact) options.SetHideRootType(use_objc) .SetHideName(use_objc) .SetHideValue(use_objc); if (be_raw) options.SetRawDisplay(true); return options; }
bool SwiftREPL::PrintOneVariable (Debugger &debugger, StreamFileSP &output_sp, ValueObjectSP &valobj_sp, ExpressionVariable *var) { bool is_computed = false; if (var) { if (lldb::ValueObjectSP valobj_sp = var->GetValueObject()) { Flags valobj_type_flags(valobj_sp->GetCompilerType().GetTypeInfo()); const bool is_swift(valobj_type_flags.AllSet(eTypeIsSwift)); if ((var->GetName().AsCString("anonymous")[0] != '$') && is_swift) { is_computed = llvm::cast<SwiftExpressionVariable>(var)->GetIsComputed(); } else { return false; } } else { return false; } } const bool colorize_out = output_sp->GetFile().GetIsTerminalWithColors(); bool handled = false; Format format = m_format_options.GetFormat(); bool treat_as_void = (format == eFormatVoid); // if we are asked to suppress void, check if this is the empty tuple type, and if so suppress it if (!treat_as_void && !debugger.GetNotifyVoid()) { const CompilerType &expr_type(valobj_sp->GetCompilerType()); Flags expr_type_flags(expr_type.GetTypeInfo()); if (expr_type_flags.AllSet(eTypeIsSwift | eTypeIsTuple)) { treat_as_void = (expr_type.GetNumFields() == 0); } } if (!treat_as_void) { if (format != eFormatDefault) valobj_sp->SetFormat (format); DumpValueObjectOptions options; options.SetUseDynamicType(lldb::eDynamicCanRunTarget); options.SetMaximumPointerDepth( {DumpValueObjectOptions::PointerDepth::Mode::Formatters,1} ); options.SetUseSyntheticValue(true); options.SetRevealEmptyAggregates(false); options.SetHidePointerValue(true); options.SetVariableFormatDisplayLanguage(lldb::eLanguageTypeSwift); options.SetDeclPrintingHelper ([] (ConstString type_name, ConstString var_name, const DumpValueObjectOptions &options, Stream &stream) -> bool { if (!type_name || !var_name) return false; std::string type_name_str(type_name ? type_name.GetCString() : ""); for(auto iter = type_name_str.find(" *"); iter != std::string::npos; iter = type_name_str.find(" *")) { type_name_str.erase(iter, 2); } if (!type_name_str.empty()) { stream.Printf("%s: %s =", var_name.GetCString(), type_name_str.c_str()); return true; } return false; }); if (is_computed) { StringSummaryFormat::Flags flags; flags.SetDontShowChildren(true); flags.SetDontShowValue(true); flags.SetHideItemNames(true); flags.SetShowMembersOneLiner(false); flags.SetSkipPointers(false); flags.SetSkipReferences(false); options.SetHideValue(true); options.SetShowSummary(true); options.SetSummary(lldb::TypeSummaryImplSP(new StringSummaryFormat(flags,"<computed property>"))); } if (colorize_out) { const char *color = isThrownError(valobj_sp) ? ANSI_ESCAPE1(ANSI_FG_COLOR_RED) : ANSI_ESCAPE1(ANSI_FG_COLOR_CYAN); fprintf(output_sp->GetFile().GetStream(), "%s", color); } valobj_sp->Dump(*output_sp, options); if (colorize_out) fprintf(output_sp->GetFile().GetStream(), ANSI_ESCAPE1(ANSI_CTRL_NORMAL)); handled = true; } return handled; }