diff --git a/lldb/include/lldb/Core/DumpDataExtractor.h b/lldb/include/lldb/Core/DumpDataExtractor.h --- a/lldb/include/lldb/Core/DumpDataExtractor.h +++ b/lldb/include/lldb/Core/DumpDataExtractor.h @@ -91,7 +91,7 @@ DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, - uint32_t item_bit_size, uint32_t item_bit_offset, + uint32_t item_bit_size, int32_t item_bit_offset, ExecutionContextScope *exe_scope = nullptr, bool show_memory_tags = false); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -423,7 +423,7 @@ virtual uint32_t GetBitfieldBitSize() { return 0; } - virtual uint32_t GetBitfieldBitOffset() { return 0; } + virtual int32_t GetBitfieldBitOffset() { return 0; } bool IsBitfield() { return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0); diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -36,7 +36,7 @@ uint32_t GetBitfieldBitSize() override { return m_bitfield_bit_size; } - uint32_t GetBitfieldBitOffset() override { return m_bitfield_bit_offset; } + int32_t GetBitfieldBitOffset() override { return m_bitfield_bit_offset; } lldb::ValueType GetValueType() const override; @@ -66,7 +66,7 @@ uint64_t m_byte_size; int32_t m_byte_offset; uint8_t m_bitfield_bit_size; - uint8_t m_bitfield_bit_offset; + int8_t m_bitfield_bit_offset; bool m_is_base_class; bool m_is_deref_of_parent; llvm::Optional m_can_update_with_invalid_exe_ctx; @@ -76,10 +76,9 @@ friend class ValueObjectConstResultImpl; ValueObjectChild(ValueObject &parent, const CompilerType &compiler_type, - ConstString name, uint64_t byte_size, - int32_t byte_offset, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, bool is_base_class, - bool is_deref_of_parent, + ConstString name, uint64_t byte_size, int32_t byte_offset, + uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, + bool is_base_class, bool is_deref_of_parent, AddressType child_ptr_or_ref_addr_type, uint64_t language_flags); diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -294,7 +294,7 @@ uint32_t GetNumFields() const; CompilerType GetFieldAtIndex(size_t idx, std::string &name, - uint64_t *bit_offset_ptr, + int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const; @@ -303,14 +303,14 @@ uint32_t GetNumVirtualBaseClasses() const; CompilerType GetDirectBaseClassAtIndex(size_t idx, - uint32_t *bit_offset_ptr) const; + int32_t *bit_offset_ptr) const; CompilerType GetVirtualBaseClassAtIndex(size_t idx, - uint32_t *bit_offset_ptr) const; + int32_t *bit_offset_ptr) const; uint32_t GetIndexOfFieldWithName(const char *name, CompilerType *field_compiler_type = nullptr, - uint64_t *bit_offset_ptr = nullptr, + int64_t *bit_offset_ptr = nullptr, uint32_t *bitfield_bit_size_ptr = nullptr, bool *is_bitfield_ptr = nullptr) const; @@ -319,7 +319,7 @@ bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, + int32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const; @@ -379,12 +379,12 @@ void DumpValue(ExecutionContext *exe_ctx, 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, bool show_types, + int32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth); 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, + uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, ExecutionContextScope *exe_scope); void DumpSummary(ExecutionContext *exe_ctx, Stream *s, diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -308,7 +308,7 @@ virtual CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, - uint64_t *bit_offset_ptr, + int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) = 0; @@ -320,18 +320,18 @@ virtual CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - uint32_t *bit_offset_ptr) = 0; + int32_t *bit_offset_ptr) = 0; virtual CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - uint32_t *bit_offset_ptr) = 0; + int32_t *bit_offset_ptr) = 0; virtual CompilerType GetChildCompilerTypeAtIndex( lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, + uint32_t &child_bitfield_bit_size, int32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) = 0; @@ -378,14 +378,14 @@ 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, bool show_types, + int32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) = 0; 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, + int32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) = 0; /// Dump the type to stdout. diff --git a/lldb/include/lldb/Target/ProcessStructReader.h b/lldb/include/lldb/Target/ProcessStructReader.h --- a/lldb/include/lldb/Target/ProcessStructReader.h +++ b/lldb/include/lldb/Target/ProcessStructReader.h @@ -50,7 +50,7 @@ for (size_t idx = 0; idx < struct_type.GetNumFields(); idx++) { std::string name; - uint64_t bit_offset; + int64_t bit_offset; uint32_t bitfield_bit_size; bool is_bitfield; CompilerType field_type = struct_type.GetFieldAtIndex( diff --git a/lldb/include/lldb/Utility/DataExtractor.h b/lldb/include/lldb/Utility/DataExtractor.h --- a/lldb/include/lldb/Utility/DataExtractor.h +++ b/lldb/include/lldb/Utility/DataExtractor.h @@ -546,7 +546,7 @@ /// zero on failure. uint64_t GetMaxU64Bitfield(lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset) const; + int32_t bitfield_bit_offset) const; /// Extract an signed integer of size \a size from \a *offset_ptr, then /// extract and sign-extend the bitfield from this value if \a @@ -584,7 +584,7 @@ /// zero on failure. int64_t GetMaxS64Bitfield(lldb::offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset) const; + int32_t bitfield_bit_offset) const; /// Get the current byte order value. /// diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -412,7 +412,7 @@ SBTypeMember sb_type_member; if (IsValid()) { - uint32_t bit_offset = 0; + int32_t bit_offset = 0; CompilerType base_class_type = m_opaque_sp->GetCompilerType(true).GetDirectBaseClassAtIndex( idx, &bit_offset); @@ -428,7 +428,7 @@ SBTypeMember sb_type_member; if (IsValid()) { - uint32_t bit_offset = 0; + int32_t bit_offset = 0; CompilerType base_class_type = m_opaque_sp->GetCompilerType(true).GetVirtualBaseClassAtIndex( idx, &bit_offset); @@ -468,7 +468,7 @@ if (IsValid()) { CompilerType this_type(m_opaque_sp->GetCompilerType(false)); if (this_type.IsValid()) { - uint64_t bit_offset = 0; + int64_t bit_offset = 0; uint32_t bitfield_bit_size = 0; bool is_bitfield = false; std::string name_sstr; @@ -730,9 +730,9 @@ Stream &strm = description.ref(); if (m_opaque_up) { - const uint32_t bit_offset = m_opaque_up->GetBitOffset(); - const uint32_t byte_offset = bit_offset / 8u; - const uint32_t byte_bit_offset = bit_offset % 8u; + const int32_t bit_offset = m_opaque_up->GetBitOffset(); + const int32_t byte_offset = bit_offset / 8u; + const int32_t byte_bit_offset = bit_offset % 8u; const char *name = m_opaque_up->GetName().GetCString(); if (byte_bit_offset) strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset); diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -342,10 +342,10 @@ const DataExtractor &DE, Stream *s, offset_t start_offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, - uint32_t item_bit_size, // If zero, this is not a bitfield value, if - // non-zero, the value is a bitfield - uint32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the - // shift amount to apply to a bitfield + uint32_t item_bit_size, // If zero, this is not a bitfield value, if + // non-zero, the value is a bitfield + int32_t item_bit_offset, // If "item_bit_size" is non-zero, this is the + // shift amount to apply to a bitfield ExecutionContextScope *exe_scope, bool show_memory_tags) { if (s == nullptr) return start_offset; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -539,7 +539,7 @@ uint32_t child_byte_size = 0; int32_t child_byte_offset = 0; uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; + int32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; bool child_is_deref_of_parent = false; uint64_t language_flags = 0; @@ -2643,7 +2643,7 @@ uint32_t child_byte_size = 0; int32_t child_byte_offset = 0; uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; + int32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; bool child_is_deref_of_parent = false; const bool transparent_pointers = false; diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -27,10 +27,9 @@ using namespace lldb_private; ValueObjectChild::ValueObjectChild( - ValueObject &parent, const CompilerType &compiler_type, - ConstString name, uint64_t byte_size, int32_t byte_offset, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool is_base_class, bool is_deref_of_parent, + ValueObject &parent, const CompilerType &compiler_type, ConstString name, + uint64_t byte_size, int32_t byte_offset, uint32_t bitfield_bit_size, + int32_t bitfield_bit_offset, bool is_base_class, bool is_deref_of_parent, AddressType child_ptr_or_ref_addr_type, uint64_t language_flags) : ValueObject(parent), m_compiler_type(compiler_type), m_byte_size(byte_size), m_byte_offset(byte_offset), diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp --- a/lldb/source/Core/ValueObjectConstResultImpl.cpp +++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp @@ -59,7 +59,7 @@ uint32_t child_byte_size = 0; int32_t child_byte_offset = 0; uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; + int32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; bool child_is_deref_of_parent = false; uint64_t language_flags; diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp @@ -906,7 +906,7 @@ // GetChild output params int32_t child_offs; uint32_t child_bitfield_bit_size; - uint32_t child_bitfield_bit_offset; + int32_t child_bitfield_bit_offset; bool child_is_base_class; bool child_is_deref_of_parent; ValueObject *valobj = nullptr; diff --git a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp --- a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp @@ -584,7 +584,7 @@ uint32_t count; bool is_complex; - uint64_t field_bit_offset = 0; + int64_t field_bit_offset = 0; CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); llvm::Optional field_bit_width = @@ -595,7 +595,7 @@ return false; } - uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset; + int32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset; const uint32_t field_type_flags = field_compiler_type.GetTypeInfo(); if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || diff --git a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp --- a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp @@ -557,7 +557,7 @@ uint32_t count; bool is_complex; - uint64_t field_bit_offset = 0; + int64_t field_bit_offset = 0; CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); llvm::Optional field_bit_width = diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -110,7 +110,7 @@ uint32_t child_byte_size = 0; int32_t child_byte_offset = 0; uint32_t child_bitfield_bit_size = 0; - uint32_t child_bitfield_bit_offset = 0; + int32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; bool child_is_deref_of_parent = false; uint64_t language_flags = 0; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -278,7 +278,7 @@ CompilerType pair_type( __i_->GetCompilerType().GetTypeTemplateArgument(0)); std::string name; - uint64_t bit_offset_ptr; + int64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr; pair_type = pair_type.GetFieldAtIndex( @@ -443,7 +443,7 @@ CompilerType pair_type(node_type.GetTypeTemplateArgument(0)); std::string name; - uint64_t bit_offset_ptr; + int64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -270,7 +270,7 @@ .GetTypeTemplateArgument(1); if (m_element_type) { std::string name; - uint64_t bit_offset_ptr; + int64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr; m_element_type = m_element_type.GetFieldAtIndex( @@ -290,7 +290,7 @@ if (!node) return; CompilerType node_type(node->GetCompilerType()); - uint64_t bit_offset; + int64_t bit_offset; if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) != UINT32_MAX) { m_skip_size = bit_offset / 8u; @@ -310,7 +310,7 @@ uint32_t child_byte_size; int32_t child_byte_offset = 0; uint32_t child_bitfield_bit_size; - uint32_t child_bitfield_bit_offset; + int32_t child_bitfield_bit_offset; bool child_is_base_class; bool child_is_deref_of_parent; uint64_t language_flags; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -770,7 +770,7 @@ uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, + std::string &name, int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) override; @@ -780,11 +780,11 @@ CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - uint32_t *bit_offset_ptr) override; + int32_t *bit_offset_ptr) override; CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - uint32_t *bit_offset_ptr) override; + int32_t *bit_offset_ptr) override; static uint32_t GetNumPointeeChildren(clang::QualType type); @@ -793,7 +793,7 @@ bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, + uint32_t &child_bitfield_bit_size, int32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) override; @@ -958,14 +958,14 @@ void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, 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, + uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) override; 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, + uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override; void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -5651,7 +5651,7 @@ static lldb::opaque_compiler_type_t GetObjCFieldAtIndex(clang::ASTContext *ast, clang::ObjCInterfaceDecl *class_interface_decl, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, + std::string &name, int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) { if (class_interface_decl) { if (idx < (class_interface_decl->ivar_size())) { @@ -5702,7 +5702,7 @@ CompilerType TypeSystemClang::GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, - uint64_t *bit_offset_ptr, + int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) { if (!type) @@ -5876,7 +5876,7 @@ } CompilerType TypeSystemClang::GetDirectBaseClassAtIndex( - lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) { + lldb::opaque_compiler_type_t type, size_t idx, int32_t *bit_offset_ptr) { clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -5971,7 +5971,7 @@ } CompilerType TypeSystemClang::GetVirtualBaseClassAtIndex( - lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) { + lldb::opaque_compiler_type_t type, size_t idx, int32_t *bit_offset_ptr) { clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type)); const clang::Type::TypeClass type_class = qual_type->getTypeClass(); switch (type_class) { @@ -6156,7 +6156,7 @@ bool transparent_pointers, bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, + uint32_t &child_bitfield_bit_size, int32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) { if (!type) @@ -6297,7 +6297,7 @@ bit_offset = record_layout.getFieldOffset(field_idx); if (FieldIsBitfield(*field, child_bitfield_bit_size)) { child_bitfield_bit_offset = bit_offset % child_bit_size; - const uint32_t child_bit_offset = + const int32_t child_bit_offset = bit_offset - child_bitfield_bit_offset; child_byte_offset = child_bit_offset / 8; } else { @@ -8532,7 +8532,7 @@ lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const lldb_private::DataExtractor &data, lldb::offset_t data_byte_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, + uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) { if (!type) return; @@ -8545,8 +8545,8 @@ llvm::cast(qual_type.getTypePtr()); const clang::RecordDecl *record_decl = record_type->getDecl(); assert(record_decl); - uint32_t field_bit_offset = 0; - uint32_t field_byte_offset = 0; + int32_t field_bit_offset = 0; + int32_t field_byte_offset = 0; const clang::ASTRecordLayout &record_layout = getASTContext().getASTRecordLayout(record_decl); uint32_t child_idx = 0; @@ -8645,7 +8645,7 @@ field_bit_offset = record_layout.getFieldOffset(field_idx); field_byte_offset = field_bit_offset / 8; uint32_t field_bitfield_bit_size = 0; - uint32_t field_bitfield_bit_offset = 0; + int32_t field_bitfield_bit_offset = 0; if (FieldIsBitfield(*field, field_bitfield_bit_size)) field_bitfield_bit_offset = field_bit_offset % 8; @@ -8904,7 +8904,7 @@ 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, + size_t byte_size, int32_t bitfield_bit_offset, uint32_t bitfield_bit_size) { const clang::EnumType *enutype = llvm::cast(qual_type.getTypePtr()); @@ -8985,7 +8985,7 @@ bool TypeSystemClang::DumpTypeValue( lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, const lldb_private::DataExtractor &data, lldb::offset_t byte_offset, - size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, + size_t byte_size, uint32_t bitfield_bit_size, int32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) { if (!type) return false; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -541,7 +541,7 @@ } CompilerType CompilerType::GetFieldAtIndex(size_t idx, std::string &name, - uint64_t *bit_offset_ptr, + int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const { if (!IsValid()) @@ -564,7 +564,7 @@ CompilerType CompilerType::GetDirectBaseClassAtIndex(size_t idx, - uint32_t *bit_offset_ptr) const { + int32_t *bit_offset_ptr) const { if (IsValid()) return m_type_system->GetDirectBaseClassAtIndex(m_type, idx, bit_offset_ptr); @@ -573,7 +573,7 @@ CompilerType CompilerType::GetVirtualBaseClassAtIndex(size_t idx, - uint32_t *bit_offset_ptr) const { + int32_t *bit_offset_ptr) const { if (IsValid()) return m_type_system->GetVirtualBaseClassAtIndex(m_type, idx, bit_offset_ptr); @@ -582,7 +582,7 @@ uint32_t CompilerType::GetIndexOfFieldWithName( const char *name, CompilerType *field_compiler_type_ptr, - uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, + int64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const { unsigned count = GetNumFields(); std::string field_name; @@ -604,7 +604,7 @@ bool omit_empty_base_classes, bool ignore_array_bounds, std::string &child_name, uint32_t &child_byte_size, int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, bool &child_is_base_class, + int32_t &child_bitfield_bit_offset, bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const { if (!IsValid()) @@ -726,7 +726,7 @@ lldb::Format format, const DataExtractor &data, lldb::offset_t data_byte_offset, size_t data_byte_size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, bool show_types, + int32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) { if (!IsValid()) return; @@ -740,7 +740,7 @@ const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, + int32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) { if (!IsValid()) return false; diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -572,7 +572,7 @@ uint64_t DataExtractor::GetMaxU64Bitfield(offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset) const { + int32_t bitfield_bit_offset) const { assert(bitfield_bit_size <= 64); uint64_t uval64 = GetMaxU64(offset_ptr, size); @@ -583,8 +583,11 @@ if (m_byte_order == eByteOrderBig) lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size; - if (lsbcount > 0) + if (lsbcount > 0) { uval64 >>= lsbcount; + } else { + uval64 <<= -lsbcount; + } uint64_t bitfield_mask = (bitfield_bit_size == 64 @@ -600,7 +603,7 @@ int64_t DataExtractor::GetMaxS64Bitfield(offset_t *offset_ptr, size_t size, uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset) const { + int32_t bitfield_bit_offset) const { assert(size >= 1 && "GetMaxS64Bitfield size must be >= 1"); assert(size <= 8 && "GetMaxS64Bitfield size must be <= 8"); int64_t sval64 = GetMaxS64(offset_ptr, size); diff --git a/lldb/test/API/commands/expression/expr-bitfield-on-boundary/Makefile b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/Makefile new file mode 100644 --- /dev/null +++ b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +CXXFLAGS_EXTRAS := -gdwarf-2 + +include Makefile.rules diff --git a/lldb/test/API/commands/expression/expr-bitfield-on-boundary/TestExprBitfieldOnBoundary.py b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/TestExprBitfieldOnBoundary.py new file mode 100644 --- /dev/null +++ b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/TestExprBitfieldOnBoundary.py @@ -0,0 +1,12 @@ +"""Test that we are able to print bitfield fields that cross a byte boundary""" + +import lldb +from lldbsuite.test.lldbtest import * + +class BitFieldExprOnBoundaryTestCase(TestBase): + + def test_bitfield_expr_on_boundary(self): + """ Test that we are able to print bitfield fields that cross a byte boundary """ + self.build() + lldbutil.run_to_source_breakpoint(self, '// Break here', lldb.SBFileSpec("main.cpp")) + self.expect_expr("f", result_type="volatile Foo", result_children=[ValueCheck(name='a', value=r"'\x01'"), ValueCheck(name='b', value=r"'\x02'")]) diff --git a/lldb/test/API/commands/expression/expr-bitfield-on-boundary/main.cpp b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/commands/expression/expr-bitfield-on-boundary/main.cpp @@ -0,0 +1,11 @@ +struct __attribute__((packed)) Foo { + unsigned char a : 7; + unsigned char b : 4; +}; + +int main() { + volatile struct Foo f; + f.a = 1; + f.b = 2; + return 0; // Break here +} diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -59,7 +59,7 @@ CompilerType field_type = siginfo_type; uint64_t total_offset = 0; for (auto field_name : llvm::split(path, '.')) { - uint64_t bit_offset; + int64_t bit_offset; ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(), &field_type, &bit_offset), UINT32_MAX);