Example #1
0
bool CornerNode::getValue (const String& strMemberName, String& strValue)
{
    bool bValueSet = false;
    Corner* pObject = dynamic_cast<Corner*>(m_pObject);
    if (strMemberName == L"value")
    {
        ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
        if (pValueObj)
        {
            if (!pValueObj->isNothing())
            {
                strValue = pValueObj->toString();
                bValueSet = true;
            }
        }
    }
    else if (strMemberName == L"StaStart")
    {
        if (pObject->hasValue_StaStart())
        {
            strValue = (DoubleObjectImpl(pObject->getStaStart())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"StaEnd")
    {
        if (pObject->hasValue_StaEnd())
        {
            strValue = (DoubleObjectImpl(pObject->getStaEnd())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"Type")
    {
        if (pObject->hasValue_Type())
        {
            strValue = (EnumCornerTypeImpl(pObject->getType())).toString();
            bValueSet = true;
        }
    }
    return bValueSet;
}
Example #2
0
bool DesignHourNode::getValue (const String& strMemberName, String& strValue)
{
    bool bValueSet = false;
    DesignHour* pObject = dynamic_cast<DesignHour*>(m_pObject);
    if (strMemberName == L"value")
    {
        ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
        if (pValueObj)
        {
            if (!pValueObj->isNothing())
            {
                strValue = pValueObj->toString();
                bValueSet = true;
            }
        }
    }
    else if (strMemberName == L"StaStart")
    {
        if (pObject->hasValue_StaStart())
        {
            strValue = (DoubleObjectImpl(pObject->getStaStart())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"StaEnd")
    {
        if (pObject->hasValue_StaEnd())
        {
            strValue = (DoubleObjectImpl(pObject->getStaEnd())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"Volume")
    {
        if (pObject->hasValue_Volume())
        {
            strValue = (DoubleObjectImpl(pObject->getVolume())).toString();
            bValueSet = true;
        }
    }
    return bValueSet;
}
Example #3
0
bool OffsetValsNode::getValue (const String& strMemberName, String& strValue)
{
    bool bValueSet = false;
    OffsetVals* pObject = dynamic_cast<OffsetVals*>(m_pObject);
    if (strMemberName == L"value")
    {
        ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
        if (pValueObj)
        {
            if (!pValueObj->isNothing())
            {
                strValue = pValueObj->toString();
                bValueSet = true;
            }
        }
    }
    else if (strMemberName == L"OffsetInOut")
    {
        if (pObject->hasValue_OffsetInOut())
        {
            strValue = (DoubleObjectImpl(pObject->getOffsetInOut())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"OffsetLeftRight")
    {
        if (pObject->hasValue_OffsetLeftRight())
        {
            strValue = (DoubleObjectImpl(pObject->getOffsetLeftRight())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"OffsetUpDown")
    {
        if (pObject->hasValue_OffsetUpDown())
        {
            strValue = (DoubleObjectImpl(pObject->getOffsetUpDown())).toString();
            bValueSet = true;
        }
    }
    return bValueSet;
}
Example #4
0
bool NoPassingZoneNode::getValue (const String& strMemberName, String& strValue)
{
    bool bValueSet = false;
    NoPassingZone* pObject = dynamic_cast<NoPassingZone*>(m_pObject);
    if (strMemberName == L"value")
    {
        ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
        if (pValueObj)
        {
            if (!pValueObj->isNothing())
            {
                strValue = pValueObj->toString();
                bValueSet = true;
            }
        }
    }
    else if (strMemberName == L"StaStart")
    {
        if (pObject->hasValue_StaStart())
        {
            strValue = (DoubleObjectImpl(pObject->getStaStart())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"StaEnd")
    {
        if (pObject->hasValue_StaEnd())
        {
            strValue = (DoubleObjectImpl(pObject->getStaEnd())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"SideofRoad")
    {
        if (pObject->hasValue_SideofRoad())
        {
            strValue = (EnumSideofRoadTypeImpl(pObject->getSideofRoad())).toString();
            bValueSet = true;
        }
    }
    return bValueSet;
}
Example #5
0
bool CrossSectSurfNode::getValue (const String& strMemberName, String& strValue)
{
    bool bValueSet = false;
    CrossSectSurf* pObject = dynamic_cast<CrossSectSurf*>(m_pObject);
    if (strMemberName == L"value")
    {
        ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
        if (pValueObj)
        {
            if (!pValueObj->isNothing())
            {
                strValue = pValueObj->toString();
                bValueSet = true;
            }
        }
    }
    else if (strMemberName == L"Name")
    {
        if (pObject->hasValue_Name())
        {
            strValue = (StringObjectImpl(pObject->getName())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"Desc")
    {
        if (pObject->hasValue_Desc())
        {
            strValue = (StringObjectImpl(pObject->getDesc())).toString();
            bValueSet = true;
        }
    }
    else if (strMemberName == L"State")
    {
        if (pObject->hasValue_State())
        {
            strValue = (EnumStateTypeImpl(pObject->getState())).toString();
            bValueSet = true;
        }
    }
    return bValueSet;
}
Example #6
0
bool
AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &valobj)
{
    CompilerType compiler_type(valobj.GetCompilerType());
    bool is_signed;
    // ObjC objects can only be pointers (or numbers that actually represents pointers
    // but haven't been typecast, because reasons..)
    if (!compiler_type.IsIntegerType (is_signed) && !compiler_type.IsPointerType ())
        return false;
    
    // Make the argument list: we pass one arg, the address of our pointer, to the print function.
    Value val;
    
    if (!valobj.ResolveValue(val.GetScalar()))
        return false;
    
    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
    return GetObjectDescription(str, val, exe_ctx.GetBestExecutionContextScope());
                   
}
Example #7
0
bool
AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &valobj)
{
    bool is_signed;
    // ObjC objects can only be pointers, but we extend this to integer types because an expression might just
    // result in an address, and we should try that to see if the address is an ObjC object.
    
    if (!(valobj.IsPointerType() || valobj.IsIntegerType(is_signed)))
        return false;
    
    // Make the argument list: we pass one arg, the address of our pointer, to the print function.
    Value val;
    
    if (!valobj.ResolveValue(val.GetScalar()))
        return false;
    
    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
    return GetObjectDescription(str, val, exe_ctx.GetBestExecutionContextScope());
                   
}
ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter) :
    ValueObject(parent),
    m_synth_sp(filter),
    m_children_byindex(),
    m_name_toindex(),
    m_synthetic_children_count(UINT32_MAX),
    m_parent_type_name(parent.GetTypeName()),
    m_might_have_children(eLazyBoolCalculate),
    m_provides_value(eLazyBoolCalculate)
{
#ifdef FOOBAR
    std::string new_name(parent.GetName().AsCString());
    new_name += "$$__synth__";
    SetName (ConstString(new_name.c_str()));
#else
    SetName(parent.GetName());
#endif
    CopyValueData(m_parent);
    CreateSynthFilter();
}
Example #9
0
	bool decode_value(Buffer& buf, ValueObject& value, bool copyRawValue)
	{
		value.Clear();
		if (!BufferHelper::ReadFixUInt8(buf, value.type))
		{
			return false;
		}
		switch (value.type)
		{
			case EMPTY:
			{
				break;
			}
			case INTEGER:
			{
				if (!BufferHelper::ReadVarInt64(buf, value.v.int_v))
				{
					return false;
				}
				break;
			}
			case DOUBLE:
			{
				if (!BufferHelper::ReadFixDouble(buf, value.v.double_v))
				{
					return false;
				}
				break;
			}
			default:
			{
				uint32_t len;
				if (!BufferHelper::ReadVarUInt32(buf, len)
				        || buf.ReadableBytes() < len)
				{
					return false;
				}

				if (copyRawValue)
				{
					value.v.raw = new Buffer(len);
					buf.Read(value.v.raw, len);
				}
				else
				{
					const char* tmp = buf.GetRawReadBuffer();
					value.v.raw = new Buffer(const_cast<char*>(tmp), 0, len);
					buf.SkipBytes(len);
				}
				break;
			}
		}
		return true;
	}
Example #10
0
bool
lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
    if (const char* description = valobj.GetObjectDescription())
    {
        stream.Printf("%s", description);
        return true;
    }
    else
        return false;
}
Example #11
0
ConstString
FormatManager::GetTypeForCache (ValueObject& valobj,
                                lldb::DynamicValueType use_dynamic)
{
    ValueObjectSP valobj_sp = valobj.GetQualifiedRepresentationIfAvailable(use_dynamic, valobj.IsSynthetic());
    if (valobj_sp && valobj_sp->GetCompilerType().IsValid())
    {
        if (!valobj_sp->GetCompilerType().IsMeaninglessWithoutDynamicResolution())
            return valobj_sp->GetQualifiedTypeName();
    }
    return ConstString();
}
Example #12
0
bool
lldb_private::formatters::swift::NSContiguousString_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
    static ConstString g_StringCoreType("_TtVs11_StringCore");
    lldb::addr_t core_location = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
    if (core_location == LLDB_INVALID_ADDRESS)
        return false;
    ProcessSP process_sp(valobj.GetProcessSP());
    if (!process_sp)
        return false;
    size_t ptr_size = process_sp->GetAddressByteSize();
    core_location += 2*ptr_size;

    Error error;
    
    InferiorSizedWord isw_1(process_sp->ReadPointerFromMemory(core_location, error),*process_sp);
    InferiorSizedWord isw_2(process_sp->ReadPointerFromMemory(core_location+ptr_size, error),*process_sp);
    InferiorSizedWord isw_3(process_sp->ReadPointerFromMemory(core_location+ptr_size+ptr_size, error),*process_sp);
    
    DataBufferSP buffer_sp(new DataBufferHeap(3*ptr_size, 0));
    uint8_t* buffer = buffer_sp->GetBytes();
    
    buffer = isw_1.CopyToBuffer(buffer);
    buffer = isw_2.CopyToBuffer(buffer);
    buffer = isw_3.CopyToBuffer(buffer);

    DataExtractor data(buffer_sp, process_sp->GetByteOrder(), ptr_size);

    SwiftASTContext* lldb_swift_ast = process_sp->GetTarget().GetScratchSwiftASTContext(error);
    if (!lldb_swift_ast)
        return false;
    CompilerType string_core_type = lldb_swift_ast->GetTypeFromMangledTypename(g_StringCoreType.GetCString(), error);
    if (string_core_type.IsValid() == false)
        return false;
    
    ValueObjectSP string_core_sp = ValueObject::CreateValueObjectFromData("stringcore", data, valobj.GetExecutionContextRef(), string_core_type);
    if (string_core_sp)
        return StringCore_SummaryProvider(*string_core_sp, stream, options);
    return false;
}
Example #13
0
bool
lldb_private::formatters::NSError_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
    ProcessSP process_sp(valobj.GetProcessSP());
    if (!process_sp)
        return false;
    
    lldb::addr_t ptr_value = LLDB_INVALID_ADDRESS;
    
    CompilerType valobj_type(valobj.GetCompilerType());
    Flags type_flags(valobj_type.GetTypeInfo());
    if (type_flags.AllClear(eTypeHasValue))
    {
        if (valobj.IsBaseClass() && valobj.GetParent())
            ptr_value = valobj.GetParent()->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
    }
    else
        ptr_value = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);

    if (ptr_value == LLDB_INVALID_ADDRESS)
        return false;
    size_t ptr_size = process_sp->GetAddressByteSize();
    lldb::addr_t code_location = ptr_value + 2 * ptr_size;
    lldb::addr_t domain_location = ptr_value + 3 * ptr_size;
    
    Error error;
    uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location, ptr_size, 0, error);
    if (error.Fail())
        return false;
    
    lldb::addr_t domain_str_value = process_sp->ReadPointerFromMemory(domain_location, error);
    if (error.Fail() || domain_str_value == LLDB_INVALID_ADDRESS)
        return false;
    
    if (!domain_str_value)
    {
        stream.Printf("domain: nil - code: %" PRIu64, code);
        return true;
    }
    
    InferiorSizedWord isw(domain_str_value, *process_sp);
    
    ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData("domain_str", isw.GetAsData(process_sp->GetByteOrder()), valobj.GetExecutionContextRef(), process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeVoid).GetPointerType());
    
    if (!domain_str_sp)
        return false;
    
    StreamString domain_str_summary;
    if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) && !domain_str_summary.Empty())
    {
        stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(), code);
        return true;
    }
    else
    {
        stream.Printf("domain: nil - code: %" PRIu64, code);
        return true;
    }
}
Example #14
0
bool
lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
{
    ProcessSP process_sp = valobj.GetProcessSP();
    if (!process_sp)
        return false;
    
    lldb::addr_t valobj_addr = GetArrayAddressOrPointerValue(valobj);
    if (valobj_addr == 0 || valobj_addr == LLDB_INVALID_ADDRESS)
        return false;
    
    // Get a wchar_t basic type from the current type system
    CompilerType wchar_compiler_type = valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeWChar);
    
    if (!wchar_compiler_type)
        return false;
    
    const uint32_t wchar_size = wchar_compiler_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
    
    StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
    options.SetLocation(valobj_addr);
    options.SetProcessSP(process_sp);
    options.SetStream(&stream);
    options.SetPrefixToken("L");
    
    switch (wchar_size)
    {
        case 8:
            return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF8>(options);
        case 16:
            return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF16>(options);
        case 32:
            return StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::UTF32>(options);
        default:
            stream.Printf("size for wchar_t is not valid");
            return true;
    }
    return true;
}
lldb::ValueObjectSP
ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
{
    UpdateValueIfNeeded();

    ValueObject *valobj;
    if (m_children_byindex.GetValueForKey(idx, valobj) == false)
    {
        if (can_create && m_synth_filter_ap.get() != NULL)
        {
            lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx);
            if (!synth_guy)
                return synth_guy;
            m_children_byindex.SetValueForKey(idx, synth_guy.get());
            return synth_guy;
        }
        else
            return lldb::ValueObjectSP();
    }
    else
        return valobj->GetSP();
}
Example #16
0
ObjCLanguageRuntime::ClassDescriptorSP
ObjCLanguageRuntime::GetClassDescriptor(ValueObject &valobj) {
  ClassDescriptorSP objc_class_sp;
  // if we get an invalid VO (which might still happen when playing around
  // with pointers returned by the expression parser, don't consider this
  // a valid ObjC object)
  if (valobj.GetCompilerType().IsValid()) {
    addr_t isa_pointer = valobj.GetPointerValue();
    if (isa_pointer != LLDB_INVALID_ADDRESS) {
      ExecutionContext exe_ctx(valobj.GetExecutionContextRef());

      Process *process = exe_ctx.GetProcessPtr();
      if (process) {
        Error error;
        ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
        if (isa != LLDB_INVALID_ADDRESS)
          objc_class_sp = GetClassDescriptorFromISA(isa);
      }
    }
  }
  return objc_class_sp;
}
TypeAndOrName
JavaLanguageRuntime::FixUpDynamicType(const TypeAndOrName &type_and_or_name,
                                      ValueObject &static_value) {
  CompilerType static_type(static_value.GetCompilerType());

  TypeAndOrName ret(type_and_or_name);
  if (type_and_or_name.HasType()) {
    CompilerType orig_type = type_and_or_name.GetCompilerType();
    if (static_type.IsReferenceType())
      ret.SetCompilerType(orig_type.GetLValueReferenceType());
  }
  return ret;
}
Example #18
0
bool lldb_private::formatters::LibCxxAtomicSummaryProvider(
    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
    static ConstString g___a_("__a_");

    if (ValueObjectSP child = valobj.GetChildMemberWithName(g___a_, true)) {
        std::string summary;
        if (child->GetSummaryAsCString(summary, options) && summary.size() > 0) {
            stream.Printf("%s", summary.c_str());
            return true;
        }
    }

    return false;
}
Example #19
0
bool
lldb_private::formatters::CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream)
{
    time_t epoch = GetOSXEpoch();
    epoch = epoch + (time_t)valobj.GetValueAsUnsigned(0);
    tm *tm_date = localtime(&epoch);
    if (!tm_date)
        return false;
    std::string buffer(1024,0);
    if (strftime (&buffer[0], 1023, "%Z", tm_date) == 0)
        return false;
    stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year+1900, tm_date->tm_mon+1, tm_date->tm_mday, tm_date->tm_hour, tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
    return true;
}
Example #20
0
lldb::ValueObjectSP
lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
                                                const char* return_type,
                                                const char* selector,
                                                const char* key)
{
    lldb::ValueObjectSP valobj_sp;
    if (!return_type || !*return_type)
        return valobj_sp;
    if (!selector || !*selector)
        return valobj_sp;
    if (!key || !*key)
        return valobj_sp;
    StreamString expr_path_stream;
    valobj.GetExpressionPath(expr_path_stream, false);
    StreamString expr;
    expr.Printf("(%s)[%s %s:%s]",return_type,expr_path_stream.GetData(),selector,key);
    ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
    lldb::ValueObjectSP result_sp;
    Target* target = exe_ctx.GetTargetPtr();
    StackFrame* stack_frame = GetViableFrame(exe_ctx);
    if (!target || !stack_frame)
        return valobj_sp;
    
    EvaluateExpressionOptions options;
    options.SetCoerceToId(false);
    options.SetUnwindOnError(true);
    options.SetKeepInMemory(true);
    options.SetUseDynamic(lldb::eDynamicCanRunTarget);
    
    target->EvaluateExpression(expr.GetData(),
                               stack_frame,
                               valobj_sp,
                               options);
    return valobj_sp;
}
Example #21
0
bool lldb_private::formatters::CXXFunctionPointerSummaryProvider(
    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
    std::string destination;
    StreamString sstr;
    AddressType func_ptr_address_type = eAddressTypeInvalid;
    addr_t func_ptr_address = valobj.GetPointerValue(&func_ptr_address_type);
    if (func_ptr_address != 0 && func_ptr_address != LLDB_INVALID_ADDRESS) {
        switch (func_ptr_address_type) {
        case eAddressTypeInvalid:
        case eAddressTypeFile:
        case eAddressTypeHost:
            break;

        case eAddressTypeLoad: {
            ExecutionContext exe_ctx(valobj.GetExecutionContextRef());

            Address so_addr;
            Target *target = exe_ctx.GetTargetPtr();
            if (target && target->GetSectionLoadList().IsEmpty() == false) {
                if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address,
                        so_addr)) {
                    so_addr.Dump(&sstr, exe_ctx.GetBestExecutionContextScope(),
                                 Address::DumpStyleResolvedDescription,
                                 Address::DumpStyleSectionNameOffset);
                }
            }
        }
        break;
        }
    }
    if (sstr.GetSize() > 0) {
        stream.Printf("(%s)", sstr.GetData());
        return true;
    } else
        return false;
}
Example #22
0
bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {

  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());

  if (!valobj_sp)
    return false;

  ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
  Process *process = exe_ctx.GetProcessPtr();

  if (process == nullptr)
    return false;

  CPPLanguageRuntime *cpp_runtime = process->GetCPPLanguageRuntime();

  if (!cpp_runtime)
    return false;

  CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
      cpp_runtime->FindLibCppStdFunctionCallableInfo(valobj_sp);

  switch (callable_info.callable_case) {
  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
    stream.Printf(" __f_ = %" PRIu64, callable_info.member__f_pointer_value);
    return false;
    break;
  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
    stream.Printf(
        " Lambda in File %s at Line %u",
        callable_info.callable_line_entry.file.GetFilename().GetCString(),
        callable_info.callable_line_entry.line);
    break;
  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
    stream.Printf(
        " Function in File %s at Line %u",
        callable_info.callable_line_entry.file.GetFilename().GetCString(),
        callable_info.callable_line_entry.line);
    break;
  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
    stream.Printf(" Function = %s ",
                  callable_info.callable_symbol.GetName().GetCString());
    break;
  }

  return true;
}
Example #23
0
static bool
SwiftOptional_SummaryProvider_Impl (ValueObject& valobj,
                                    Stream& stream,
                                    const TypeSummaryOptions& options)
{
    static ConstString g_Some("Some");
    static ConstString g_None("None");

    ValueObjectSP non_synth_valobj = valobj.GetNonSyntheticValue();
    if (!non_synth_valobj)
        return false;

    ConstString value(non_synth_valobj->GetValueAsCString());

    if (!value)
        return false;

    if (value == g_None)
    {
        stream.Printf("nil");
        return true;
    }

    ValueObjectSP value_sp(non_synth_valobj->GetChildMemberWithName(g_Some, true));
    if (!value_sp)
        return false;

    value_sp = value_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true);
    if (!value_sp)
        return false;

    const char* value_summary = value_sp->GetSummaryAsCString();

    if (value_summary)
        stream.Printf("%s",value_summary);
    else if (lldb_private::DataVisualization::ShouldPrintAsOneLiner(*value_sp.get()))
    {
        TypeSummaryImpl::Flags oneliner_flags;
        oneliner_flags.SetHideItemNames(false).SetCascades(true).SetDontShowChildren(false).SetDontShowValue(false).SetShowMembersOneLiner(true).SetSkipPointers(false).SetSkipReferences(false);
        StringSummaryFormat oneliner(oneliner_flags, "");
        std::string buffer;
        oneliner.FormatObject(value_sp.get(), buffer, options);
        stream.Printf("%s",buffer.c_str());
    }

    return true;
}
Example #24
0
	int Ardb::GetValueByPattern(const DBID& db, const Slice& pattern,
	        ValueObject& subst, ValueObject& value)
	{
		const char *p, *f;
		const char* spat;
		/* If the pattern is "#" return the substitution object itself in order
		 * to implement the "SORT ... GET #" feature. */
		spat = pattern.data();
		if (spat[0] == '#' && spat[1] == '\0')
		{
			value = subst;
			return 0;
		}

		/* If we can't find '*' in the pattern we return NULL as to GET a
		 * fixed key does not make sense. */
		p = strchr(spat, '*');
		if (!p)
		{
			return -1;
		}

		f = strstr(spat, "->");
		if (NULL != f && (uint32)(f - spat) == (pattern.size() - 2))
		{
			f = NULL;
		}
		std::string vstr;
		subst.ToString(vstr);
		std::string keystr(pattern.data(), pattern.size());
		string_replace(keystr, "*", vstr);
		if (f == NULL)
		{
			KeyObject k(keystr, KV, db);
			return GetValue(k, &value);
		}
		else
		{
			size_t pos = keystr.find("->");
			std::string field = keystr.substr(pos + 2);
			keystr = keystr.substr(0, pos);
			HashKeyObject hk(keystr, field, db);
			return GetValue(hk, &value);
		}
	}
Example #25
0
bool
lldb_private::formatters::swift::DarwinBoolean_SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
{
    static ConstString g__value("_value");
    ValueObjectSP value_child(valobj.GetChildMemberWithName(g__value, true));
    if (!value_child)
        return false;
    auto value = value_child->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
    switch (value)
    {
        case 0:
            stream.Printf("false");
            return true;
        default:
            stream.Printf("true");
            return true;
    }
}
bool
lldb_private::formatters::VectorTypeSummaryProvider (ValueObject& valobj,
                                                     Stream& s,
                                                     const TypeSummaryOptions&)
{
    auto synthetic_children = VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP());
    if (!synthetic_children)
        return false;
    
    synthetic_children->Update();
    
    s.PutChar('(');
    bool first = true;
    
    size_t idx = 0, len = synthetic_children->CalculateNumChildren();
    
    for (;
         idx < len;
         idx++)
    {
        auto child_sp = synthetic_children->GetChildAtIndex(idx);
        if (!child_sp)
            continue;
        child_sp = child_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true);
        
        const char* child_value = child_sp->GetValueAsCString();
        if (child_value && *child_value)
        {
            if (first)
            {
                s.Printf("%s", child_value);
                first = false;
            }
            else
            {
                s.Printf(", %s", child_value);
            }
        }
    }
    
    s.PutChar(')');
    
    return true;
}
Example #27
0
ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass, ValueObject &backend) :
SyntheticChildrenFrontEnd(backend),
m_python_class(pclass),
m_wrapper_sp(),
m_interpreter(NULL)
{
    if (backend == LLDB_INVALID_UID)
        return;
    
    TargetSP target_sp = backend.GetTargetSP();
    
    if (!target_sp)
        return;
    
    m_interpreter = target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
    
    if (m_interpreter != NULL)
        m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(m_python_class.c_str(), backend.GetSP());
}
Example #28
0
// for V1 runtime we just try to return a class name as that is the minimum level of support
// required for the data formatters to work
bool
AppleObjCRuntimeV1::GetDynamicTypeAndAddress (ValueObject &in_value,
                                             lldb::DynamicValueType use_dynamic, 
                                             TypeAndOrName &class_type_or_name, 
                                             Address &address)
{
    class_type_or_name.Clear();
    if (CouldHaveDynamicValue(in_value))
    {
        auto class_descriptor(GetClassDescriptor(in_value));
        if (class_descriptor && class_descriptor->IsValid() && class_descriptor->GetClassName())
        {
            const addr_t object_ptr = in_value.GetPointerValue();
            address.SetRawAddress(object_ptr);
            class_type_or_name.SetName(class_descriptor->GetClassName());
        }
    }
    return class_type_or_name.IsEmpty() == false;
}
Example #29
0
bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
  if (!valobj_sp)
    return false;
  ValueObjectSP ptr_sp(
      valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
  ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
      {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
  ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
      {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));

  if (!ptr_sp)
    return false;

  if (ptr_sp->GetValueAsUnsigned(0) == 0) {
    stream.Printf("nullptr");
    return true;
  } else {
    bool print_pointee = false;
    Status error;
    ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
    if (pointee_sp && error.Success()) {
      if (pointee_sp->DumpPrintableRepresentation(
              stream, ValueObject::eValueObjectRepresentationStyleSummary,
              lldb::eFormatInvalid,
              ValueObject::PrintableRepresentationSpecialCases::eDisable,
              false))
        print_pointee = true;
    }
    if (!print_pointee)
      stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
  }

  if (count_sp)
    stream.Printf(" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));

  if (weakcount_sp)
    stream.Printf(" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));

  return true;
}
Example #30
0
bool
lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
{
    DataExtractor data;
    Error error;
    valobj.GetData(data, error);
    
    if (error.Fail())
        return false;
    
    ReadBufferAndDumpToStreamOptions options(valobj);
    options.SetData(data);
    options.SetStream(&stream);
    options.SetPrefixToken('L');
    options.SetQuote('\'');
    options.SetSourceSize(1);
    options.SetBinaryZeroIsTerminator(false);
    
    return ReadBufferAndDumpToStream<StringElementType::UTF16>(options);
}