teemperor created this revision. teemperor added a reviewer: labath. teemperor added a project: Upstreaming LLDB's downstream patches. Herald added subscribers: lldb-commits, JDevlieghere, abidh. Herald added a project: LLDB. teemperor retitled this revision from "[lldb] Pass a ValueObject to DumpTypeValue instead of bitfield size/offset pair" to "[lldb][NFC] Pass a ValueObject to DumpTypeValue instead of bitfield size/offset pair".
This makes calling DumpTypeValue less tricky as it's not possible to mix up the size/offset parameters. Also allows us to drop downstream swift patches that try to pass even more ValueObject members as separate parameters to this function. Repository: rLLDB LLDB https://reviews.llvm.org/D70294 Files: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Symbol/CompilerType.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/DataFormatters/TypeFormat.cpp lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/CompilerType.cpp
Index: lldb/source/Symbol/CompilerType.cpp =================================================================== --- lldb/source/Symbol/CompilerType.cpp +++ lldb/source/Symbol/CompilerType.cpp @@ -734,14 +734,12 @@ bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, + ValueObject &value_object, ExecutionContextScope *exe_scope) { if (!IsValid()) return false; return m_type_system->DumpTypeValue(m_type, s, format, data, byte_offset, - byte_size, bitfield_bit_size, - bitfield_bit_offset, exe_scope); + byte_size, value_object, exe_scope); } void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s, Index: lldb/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/source/Symbol/ClangASTContext.cpp +++ lldb/source/Symbol/ClangASTContext.cpp @@ -9390,15 +9390,15 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s, const DataExtractor &data, lldb::offset_t byte_offset, - size_t byte_size, uint32_t bitfield_bit_offset, - uint32_t bitfield_bit_size) { + size_t byte_size, ValueObject &value_object) { const clang::EnumType *enutype = llvm::cast<clang::EnumType>(qual_type.getTypePtr()); const clang::EnumDecl *enum_decl = enutype->getDecl(); assert(enum_decl); lldb::offset_t offset = byte_offset; const uint64_t enum_svalue = data.GetMaxS64Bitfield( - &offset, byte_size, bitfield_bit_size, bitfield_bit_offset); + &offset, byte_size, value_object.GetBitfieldBitSize(), + value_object.GetBitfieldBitOffset()); bool can_be_bitfield = true; uint64_t covered_bits = 0; int num_enumerators = 0; @@ -9468,11 +9468,12 @@ return true; } -bool ClangASTContext::DumpTypeValue( - lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, - const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope) { +bool ClangASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, + Stream *s, lldb::Format format, + const DataExtractor &data, + lldb::offset_t byte_offset, + size_t byte_size, ValueObject &value_object, + ExecutionContextScope *exe_scope) { if (!type) return false; if (IsAggregateType(type)) { @@ -9484,8 +9485,8 @@ if (type_class == clang::Type::Elaborated) { qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType(); - return DumpTypeValue(qual_type.getAsOpaquePtr(), s, format, data, byte_offset, byte_size, - bitfield_bit_size, bitfield_bit_offset, exe_scope); + return DumpTypeValue(qual_type.getAsOpaquePtr(), s, format, data, + byte_offset, byte_size, value_object, exe_scope); } switch (type_class) { @@ -9507,11 +9508,7 @@ data, // Data buffer containing all bytes for this type byte_offset, // Offset into "data" where to grab value from typedef_byte_size, // Size of this type in bytes - bitfield_bit_size, // Size in bits of a bitfield value, if zero don't - // treat as a bitfield - bitfield_bit_offset, // Offset in bits of a bitfield value if - // bitfield_bit_size != 0 - exe_scope); + value_object, exe_scope); } break; case clang::Type::Enum: @@ -9520,7 +9517,8 @@ if ((format == eFormatEnum || format == eFormatDefault) && GetCompleteType(type)) return DumpEnumValue(qual_type, s, data, byte_offset, byte_size, - bitfield_bit_offset, bitfield_bit_size); + value_object.GetBitfieldBitOffset(), + value_object.GetBitfieldBitSize()); // format was not enum, just fall through and dump the value as // requested.... LLVM_FALLTHROUGH; @@ -9580,10 +9578,10 @@ byte_size = 4; break; } - return DumpDataExtractor(data, s, byte_offset, format, byte_size, - item_count, UINT32_MAX, LLDB_INVALID_ADDRESS, - bitfield_bit_size, bitfield_bit_offset, - exe_scope); + return DumpDataExtractor( + data, s, byte_offset, format, byte_size, item_count, UINT32_MAX, + LLDB_INVALID_ADDRESS, value_object.GetBitfieldBitSize(), + value_object.GetBitfieldBitOffset(), exe_scope); } break; } Index: lldb/source/DataFormatters/TypeFormat.cpp =================================================================== --- lldb/source/DataFormatters/TypeFormat.cpp +++ lldb/source/DataFormatters/TypeFormat.cpp @@ -100,14 +100,12 @@ return false; StreamString sstr; compiler_type.DumpTypeValue( - &sstr, // The stream to use for display - GetFormat(), // Format to display this type with - data, // Data to extract from - 0, // Byte offset into "m_data" - *size, // Byte size of item in "m_data" - valobj->GetBitfieldBitSize(), // Bitfield bit size - valobj->GetBitfieldBitOffset(), // Bitfield bit offset - exe_scope); + &sstr, // The stream to use for display + GetFormat(), // Format to display this type with + data, // Data to extract from + 0, // Byte offset into "m_data" + *size, // Byte size of item in "m_data" + *valobj, exe_scope); // Given that we do not want to set the ValueObject's m_error for a // formatting error (or else we wouldn't be able to reformat until a // next update), an empty string is treated as a "false" return from @@ -187,8 +185,10 @@ return false; ExecutionContext exe_ctx(valobj->GetExecutionContextRef()); StreamString sstr; + assert(valobj->GetBitfieldBitSize() == 0); + assert(valobj->GetBitfieldBitOffset() == 0); valobj_enum_type.DumpTypeValue(&sstr, lldb::eFormatEnum, data, 0, - data.GetByteSize(), 0, 0, + data.GetByteSize(), *valobj, exe_ctx.GetBestExecutionContextScope()); if (!sstr.GetString().empty()) dest = sstr.GetString(); Index: lldb/include/lldb/Symbol/TypeSystem.h =================================================================== --- lldb/include/lldb/Symbol/TypeSystem.h +++ lldb/include/lldb/Symbol/TypeSystem.h @@ -378,8 +378,7 @@ virtual bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, + ValueObject &value_object, ExecutionContextScope *exe_scope) = 0; virtual void Index: lldb/include/lldb/Symbol/CompilerType.h =================================================================== --- lldb/include/lldb/Symbol/CompilerType.h +++ lldb/include/lldb/Symbol/CompilerType.h @@ -343,7 +343,7 @@ bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, + ValueObject &value_object, ExecutionContextScope *exe_scope); void DumpSummary(ExecutionContext *exe_ctx, Stream *s, Index: lldb/include/lldb/Symbol/ClangASTContext.h =================================================================== --- lldb/include/lldb/Symbol/ClangASTContext.h +++ lldb/include/lldb/Symbol/ClangASTContext.h @@ -904,7 +904,7 @@ bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, + ValueObject &value_object, ExecutionContextScope *exe_scope) override; void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits