diff options
author | emaste <emaste@FreeBSD.org> | 2014-02-18 16:23:10 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-02-18 16:23:10 +0000 |
commit | 6beac4fcf9e5327f07c0fefd527180124438096a (patch) | |
tree | 95cb16075f0af1b3a05b9b84eb18dda8e6c903e9 /source/Core/ValueObject.cpp | |
parent | f087960a1097db2a1ef14a88963f8785df239aaa (diff) | |
download | FreeBSD-src-6beac4fcf9e5327f07c0fefd527180124438096a.zip FreeBSD-src-6beac4fcf9e5327f07c0fefd527180124438096a.tar.gz |
Import lldb as of SVN r201577 (git 2bdc2f6)
(A number of files not required for the FreeBSD build have been removed.)
Sponsored by: DARPA, AFRL
Diffstat (limited to 'source/Core/ValueObject.cpp')
-rw-r--r-- | source/Core/ValueObject.cpp | 115 |
1 files changed, 30 insertions, 85 deletions
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp index d39d21a..10e5ab4 100644 --- a/source/Core/ValueObject.cpp +++ b/source/Core/ValueObject.cpp @@ -50,6 +50,7 @@ #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -977,14 +978,14 @@ ValueObject::GetPointeeData (DataExtractor& data, ValueObjectSP pointee_sp = Dereference(error); if (error.Fail() || pointee_sp.get() == NULL) return 0; - return pointee_sp->GetDataExtractor().Copy(data); + return pointee_sp->GetData(data); } else { ValueObjectSP child_sp = GetChildAtIndex(0, true); if (child_sp.get() == NULL) return 0; - return child_sp->GetDataExtractor().Copy(data); + return child_sp->GetData(data); } return true; } @@ -1388,99 +1389,33 @@ ValueObject::GetObjectDescription () } bool -ValueObject::GetValueAsCString (lldb::Format format, +ValueObject::GetValueAsCString (const lldb_private::TypeFormatImpl& format, std::string& destination) { - if (GetClangType().IsAggregateType () == false && UpdateValueIfNeeded(false)) - { - const Value::ContextType context_type = m_value.GetContextType(); - - if (context_type == Value::eContextTypeRegisterInfo) - { - const RegisterInfo *reg_info = m_value.GetRegisterInfo(); - if (reg_info) - { - ExecutionContext exe_ctx (GetExecutionContextRef()); - - StreamString reg_sstr; - m_data.Dump (®_sstr, - 0, - format, - reg_info->byte_size, - 1, - UINT32_MAX, - LLDB_INVALID_ADDRESS, - 0, - 0, - exe_ctx.GetBestExecutionContextScope()); - destination.swap(reg_sstr.GetString()); - } - } - else - { - ClangASTType clang_type = GetClangType (); - if (clang_type) - { - // put custom bytes to display in this DataExtractor to override the default value logic - lldb_private::DataExtractor special_format_data; - if (format == eFormatCString) - { - Flags type_flags(clang_type.GetTypeInfo(NULL)); - if (type_flags.Test(ClangASTType::eTypeIsPointer) && !type_flags.Test(ClangASTType::eTypeIsObjC)) - { - // if we are dumping a pointer as a c-string, get the pointee data as a string - TargetSP target_sp(GetTargetSP()); - if (target_sp) - { - size_t max_len = target_sp->GetMaximumSizeOfStringSummary(); - Error error; - DataBufferSP buffer_sp(new DataBufferHeap(max_len+1,0)); - Address address(GetPointerValue()); - if (target_sp->ReadCStringFromMemory(address, (char*)buffer_sp->GetBytes(), max_len, error) && error.Success()) - special_format_data.SetData(buffer_sp); - } - } - } - - StreamString sstr; - ExecutionContext exe_ctx (GetExecutionContextRef()); - clang_type.DumpTypeValue (&sstr, // The stream to use for display - format, // Format to display this type with - special_format_data.GetByteSize() ? - special_format_data: m_data, // Data to extract from - 0, // Byte offset into "m_data" - GetByteSize(), // Byte size of item in "m_data" - GetBitfieldBitSize(), // Bitfield bit size - GetBitfieldBitOffset(), // Bitfield bit offset - exe_ctx.GetBestExecutionContextScope()); - // Don't set the m_error to anything here otherwise - // we won't be able to re-format as anything else. The - // code for ClangASTType::DumpTypeValue() should always - // return something, even if that something contains - // an error messsage. "m_error" is used to detect errors - // when reading the valid object, not for formatting errors. - if (sstr.GetString().empty()) - destination.clear(); - else - destination.swap(sstr.GetString()); - } - } - return !destination.empty(); - } + if (UpdateValueIfNeeded(false)) + return format.FormatObject(this,destination); else return false; } +bool +ValueObject::GetValueAsCString (lldb::Format format, + std::string& destination) +{ + return GetValueAsCString(TypeFormatImpl_Format(format),destination); +} + const char * ValueObject::GetValueAsCString () { if (UpdateValueIfNeeded(true)) { + lldb::TypeFormatImplSP format_sp; lldb::Format my_format = GetFormat(); if (my_format == lldb::eFormatDefault) { if (m_type_format_sp) - my_format = m_type_format_sp->GetFormat(); + format_sp = m_type_format_sp; else { if (m_is_bitfield_for_scalar) @@ -1503,7 +1438,9 @@ ValueObject::GetValueAsCString () if (my_format != m_last_format || m_value_str.empty()) { m_last_format = my_format; - if (GetValueAsCString(my_format, m_value_str)) + if (!format_sp) + format_sp.reset(new TypeFormatImpl_Format(my_format)); + if (GetValueAsCString(*format_sp.get(), m_value_str)) { if (!m_value_did_change && m_old_value_valid) { @@ -1609,7 +1546,8 @@ bool ValueObject::DumpPrintableRepresentation(Stream& s, ValueObjectRepresentationStyle val_obj_display, Format custom_format, - PrintableRepresentationSpecialCases special) + PrintableRepresentationSpecialCases special, + bool do_dump_error) { Flags flags(GetTypeInfo()); @@ -1808,7 +1746,12 @@ ValueObject::DumpPrintableRepresentation(Stream& s, else { if (m_error.Fail()) - s.Printf("<%s>", m_error.AsCString()); + { + if (do_dump_error) + s.Printf("<%s>", m_error.AsCString()); + else + return false; + } else if (val_obj_display == eValueObjectRepresentationStyleSummary) s.PutCString("<no summary available>"); else if (val_obj_display == eValueObjectRepresentationStyleValue) @@ -3515,7 +3458,8 @@ ValueObject::CreateConstantValue (const ConstString &name) if (!valobj_sp) { - valobj_sp = ValueObjectConstResult::Create (NULL, m_error); + ExecutionContext exe_ctx (GetExecutionContextRef()); + valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), m_error); } return valobj_sp; } @@ -3769,7 +3713,8 @@ ValueObject::EvaluationPoint::SyncWithProcessState() { // Start with the target, if it is NULL, then we're obviously not going to get any further: - ExecutionContext exe_ctx(m_exe_ctx_ref.Lock()); + const bool thread_and_frame_only_if_stopped = true; + ExecutionContext exe_ctx(m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped)); if (exe_ctx.GetTargetPtr() == NULL) return false; |