예제 #1
0
파일: SBValue.cpp 프로젝트: markpeek/lldb
lldb::SBValue
SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType type)
{
    lldb::SBValue result;
    if (m_opaque_sp && type.IsValid() && type.GetPointerType().IsValid())
    {
        SBType real_type(type.GetPointerType());
        
        lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
        
        ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (m_opaque_sp->GetExecutionContextScope(),
                                                                           real_type.m_opaque_sp->GetASTContext(),
                                                                           real_type.m_opaque_sp->GetOpaqueQualType(),
                                                                           ConstString(name),
                                                                           buffer,
                                                                           lldb::endian::InlHostByteOrder(), 
                                                                           GetTarget().GetProcess().GetAddressByteSize()));
        
        ValueObjectSP result_valobj_sp;
        
        ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
        if (ptr_result_valobj_sp)
        {
            Error err;
            result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
            if (result_valobj_sp)
                result_valobj_sp->SetName(ConstString(name));
        }
        result = SBValue(result_valobj_sp);
    }
    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
    if (log)
    {
        if (result.IsValid())
            log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString());
        else
            log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get());
    }
    return result;
}