diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 | 
| commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
| tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Core/ValueObject.cpp | |
| parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) | |
Diffstat (limited to 'source/Core/ValueObject.cpp')
| -rw-r--r-- | source/Core/ValueObject.cpp | 153 | 
1 files changed, 63 insertions, 90 deletions
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp index 244ea2936fb4..95e944b22b87 100644 --- a/source/Core/ValueObject.cpp +++ b/source/Core/ValueObject.cpp @@ -9,9 +9,8 @@  #include "lldb/Core/ValueObject.h" -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h"  #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" // for Scalar  #include "lldb/Core/ValueObjectCast.h"  #include "lldb/Core/ValueObjectChild.h"  #include "lldb/Core/ValueObjectConstResult.h" @@ -19,51 +18,52 @@  #include "lldb/Core/ValueObjectMemory.h"  #include "lldb/Core/ValueObjectSyntheticFilter.h"  #include "lldb/DataFormatters/DataVisualization.h" -#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... -#include "lldb/DataFormatters/FormatManager.h" // for FormatManager +#include "lldb/DataFormatters/DumpValueObjectOptions.h" +#include "lldb/DataFormatters/FormatManager.h"  #include "lldb/DataFormatters/StringPrinter.h" -#include "lldb/DataFormatters/TypeFormat.h"    // for TypeFormatImpl_F... -#include "lldb/DataFormatters/TypeSummary.h"   // for TypeSummaryOptions -#include "lldb/DataFormatters/TypeValidator.h" // for TypeValidatorImp... +#include "lldb/DataFormatters/TypeFormat.h" +#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/DataFormatters/TypeValidator.h"  #include "lldb/DataFormatters/ValueObjectPrinter.h" -#include "lldb/Expression/ExpressionVariable.h" // for ExpressionVariable +#include "lldb/Expression/ExpressionVariable.h"  #include "lldb/Symbol/ClangASTContext.h"  #include "lldb/Symbol/CompileUnit.h"  #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/Declaration.h"   // for Declaration -#include "lldb/Symbol/SymbolContext.h" // for SymbolContext +#include "lldb/Symbol/Declaration.h" +#include "lldb/Symbol/SymbolContext.h"  #include "lldb/Symbol/Type.h"  #include "lldb/Target/ExecutionContext.h"  #include "lldb/Target/Language.h"  #include "lldb/Target/LanguageRuntime.h"  #include "lldb/Target/ObjCLanguageRuntime.h"  #include "lldb/Target/Process.h" -#include "lldb/Target/StackFrame.h" // for StackFrame +#include "lldb/Target/StackFrame.h"  #include "lldb/Target/Target.h"  #include "lldb/Target/Thread.h" -#include "lldb/Target/ThreadList.h"  // for ThreadList -#include "lldb/Utility/DataBuffer.h" // for DataBuffer +#include "lldb/Target/ThreadList.h" +#include "lldb/Utility/DataBuffer.h"  #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/Flags.h" // for Flags +#include "lldb/Utility/Flags.h"  #include "lldb/Utility/Log.h" -#include "lldb/Utility/Logging.h"    // for GetLogIfAllCateg... -#include "lldb/Utility/SharingPtr.h" // for SharingPtr -#include "lldb/Utility/Stream.h"     // for Stream +#include "lldb/Utility/Logging.h" +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/SharingPtr.h" +#include "lldb/Utility/Stream.h"  #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-private-types.h" // for RegisterInfo +#include "lldb/lldb-private-types.h" -#include "llvm/Support/Compiler.h" // for LLVM_FALLTHROUGH +#include "llvm/Support/Compiler.h" -#include <algorithm> // for min -#include <cstdint>   // for uint32_t, uint64_t -#include <cstdlib>   // for size_t, NULL -#include <memory>    // for shared_ptr, oper... -#include <tuple>     // for tie, tuple +#include <algorithm> +#include <cstdint> +#include <cstdlib> +#include <memory> +#include <tuple> -#include <assert.h>   // for assert -#include <inttypes.h> // for PRIu64, PRIx64 -#include <stdio.h>    // for snprintf -#include <string.h>   // for memcpy, memcmp +#include <assert.h> +#include <inttypes.h> +#include <stdio.h> +#include <string.h>  namespace lldb_private {  class ExecutionContextScope; @@ -214,7 +214,7 @@ bool ValueObject::UpdateValueIfNeeded(bool update_format) {        if (first_update)          SetValueDidChange(false); -      else if (!m_value_did_change && success == false) { +      else if (!m_value_did_change && !success) {          // The value wasn't gotten successfully, so we mark this as changed if          // the value used to be valid and now isn't          SetValueDidChange(value_was_valid); @@ -442,10 +442,7 @@ bool ValueObject::IsLogicalTrue(Status &error) {    }    bool ret; -  if (scalar_value.ULongLong(1) == 0) -    ret = false; -  else -    ret = true; +  ret = scalar_value.ULongLong(1) != 0;    error.Clear();    return ret;  } @@ -639,7 +636,7 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,    bool child_is_deref_of_parent = false;    uint64_t language_flags = 0; -  const bool transparent_pointers = synthetic_array_member == false; +  const bool transparent_pointers = !synthetic_array_member;    CompilerType child_compiler_type;    ExecutionContext exe_ctx(GetExecutionContextRef()); @@ -662,8 +659,6 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,          child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,          child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,          language_flags); -    // if (valobj) -    //    valobj->SetAddressTypeOfChildren(eAddressTypeInvalid);    }    return valobj; @@ -761,10 +756,13 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,    ExecutionContext exe_ctx(GetExecutionContextRef()); -  const uint64_t item_type_size = pointee_or_element_compiler_type.GetByteSize( -      exe_ctx.GetBestExecutionContextScope()); -  const uint64_t bytes = item_count * item_type_size; -  const uint64_t offset = item_idx * item_type_size; +  llvm::Optional<uint64_t> item_type_size = +      pointee_or_element_compiler_type.GetByteSize( +          exe_ctx.GetBestExecutionContextScope()); +  if (!item_type_size) +    return 0; +  const uint64_t bytes = item_count * *item_type_size; +  const uint64_t offset = item_idx * *item_type_size;    if (item_idx == 0 && item_count == 1) // simply a deref    { @@ -827,10 +825,10 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,        }      } break;      case eAddressTypeHost: { -      const uint64_t max_bytes = +      auto max_bytes =            GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope()); -      if (max_bytes > offset) { -        size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes); +      if (max_bytes && *max_bytes > offset) { +        size_t bytes_read = std::min<uint64_t>(*max_bytes - offset, bytes);          addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);          if (addr == 0 || addr == LLDB_INVALID_ADDRESS)            break; @@ -1823,14 +1821,16 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset(      return synthetic_child_sp;    if (!can_create) -    return ValueObjectSP(); +    return {};    ExecutionContext exe_ctx(GetExecutionContextRef()); - -  ValueObjectChild *synthetic_child = new ValueObjectChild( -      *this, type, name_const_str, -      type.GetByteSize(exe_ctx.GetBestExecutionContextScope()), offset, 0, 0, -      false, false, eAddressTypeInvalid, 0); +  llvm::Optional<uint64_t> size = +      type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); +  if (!size) +    return {}; +  ValueObjectChild *synthetic_child = +      new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0, +                           false, false, eAddressTypeInvalid, 0);    if (synthetic_child) {      AddSyntheticChild(name_const_str, synthetic_child);      synthetic_child_sp = synthetic_child->GetSP(); @@ -1861,16 +1861,18 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset,      return synthetic_child_sp;    if (!can_create) -    return ValueObjectSP(); +    return {};    const bool is_base_class = true;    ExecutionContext exe_ctx(GetExecutionContextRef()); - -  ValueObjectChild *synthetic_child = new ValueObjectChild( -      *this, type, name_const_str, -      type.GetByteSize(exe_ctx.GetBestExecutionContextScope()), offset, 0, 0, -      is_base_class, false, eAddressTypeInvalid, 0); +  llvm::Optional<uint64_t> size = +      type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); +  if (!size) +    return {}; +  ValueObjectChild *synthetic_child = +      new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0, +                           is_base_class, false, eAddressTypeInvalid, 0);    if (synthetic_child) {      AddSyntheticChild(name_const_str, synthetic_child);      synthetic_child_sp = synthetic_child->GetSP(); @@ -1923,11 +1925,11 @@ ValueObject::GetSyntheticExpressionPathChild(const char *expression,  }  void ValueObject::CalculateSyntheticValue(bool use_synthetic) { -  if (use_synthetic == false) +  if (!use_synthetic)      return;    TargetSP target_sp(GetTargetSP()); -  if (target_sp && target_sp->GetEnableSyntheticValue() == false) { +  if (target_sp && !target_sp->GetEnableSyntheticValue()) {      m_synthetic_value = NULL;      return;    } @@ -1978,7 +1980,7 @@ ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); }  lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); }  ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) { -  if (use_synthetic == false) +  if (!use_synthetic)      return ValueObjectSP();    CalculateSyntheticValue(use_synthetic); @@ -1997,10 +1999,7 @@ bool ValueObject::HasSyntheticValue() {    CalculateSyntheticValue(true); -  if (m_synthetic_value) -    return true; -  else -    return false; +  return m_synthetic_value != nullptr;  }  bool ValueObject::GetBaseClassPath(Stream &s) { @@ -2806,31 +2805,6 @@ ValueObjectSP ValueObject::GetQualifiedRepresentationIfAvailable(    return result_sp;  } -lldb::addr_t ValueObject::GetCPPVTableAddress(AddressType &address_type) { -  CompilerType pointee_type; -  CompilerType this_type(GetCompilerType()); -  uint32_t type_info = this_type.GetTypeInfo(&pointee_type); -  if (type_info) { -    bool ptr_or_ref = false; -    if (type_info & (eTypeIsPointer | eTypeIsReference)) { -      ptr_or_ref = true; -      type_info = pointee_type.GetTypeInfo(); -    } - -    const uint32_t cpp_class = eTypeIsClass | eTypeIsCPlusPlus; -    if ((type_info & cpp_class) == cpp_class) { -      if (ptr_or_ref) { -        address_type = GetAddressTypeOfChildren(); -        return GetValueAsUnsigned(LLDB_INVALID_ADDRESS); -      } else -        return GetAddressOf(false, &address_type); -    } -  } - -  address_type = eAddressTypeInvalid; -  return LLDB_INVALID_ADDRESS; -} -  ValueObjectSP ValueObject::Dereference(Status &error) {    if (m_deref_valobj)      return m_deref_valobj->GetSP(); @@ -3222,7 +3196,7 @@ ValueObject *  ValueObject::FollowParentChain(std::function<bool(ValueObject *)> f) {    ValueObject *vo = this;    while (vo) { -    if (f(vo) == false) +    if (!f(vo))        break;      vo = vo->m_parent;    } @@ -3291,8 +3265,7 @@ bool ValueObject::CanProvideValue() {    // board debugging scenarios have no notion of types, but still manage to    // have raw numeric values for things like registers. sigh.    const CompilerType &type(GetCompilerType()); -  return (false == type.IsValid()) || -         (0 != (type.GetTypeInfo() & eTypeHasValue)); +  return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));  }  bool ValueObject::IsChecksumEmpty() { return m_value_checksum.empty(); }  | 
