Index: lldb/include/lldb/Core/DataExtractor.h =================================================================== --- lldb/include/lldb/Core/DataExtractor.h +++ lldb/include/lldb/Core/DataExtractor.h @@ -43,8 +43,6 @@ //------------------------------------------------------------------ /// @typedef DataExtractor::Type /// @brief Type enumerations used in the dump routines. - /// @see DataExtractor::Dump() - /// @see DataExtractor::DumpRawHexBytes() //------------------------------------------------------------------ typedef enum { TypeUInt8, ///< Format output as unsigned 8 bit integers @@ -57,12 +55,6 @@ TypeSLEB128 ///< Format output as SLEB128 numbers } Type; - static void DumpHexBytes(Stream *s, const void *src, size_t src_len, - uint32_t bytes_per_line, - lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS - // to not show address at - // start of line - //------------------------------------------------------------------ /// Default constructor. /// @@ -172,7 +164,7 @@ /// reference count on the data will be decremented, and if zero, /// the data will be freed. //------------------------------------------------------------------ - ~DataExtractor(); + virtual ~DataExtractor(); //------------------------------------------------------------------ /// Clears the object state. @@ -225,73 +217,6 @@ const char *type_format = nullptr) const; //------------------------------------------------------------------ - /// Dumps \a item_count objects into the stream \a s. - /// - /// Dumps \a item_count objects using \a item_format, each of which - /// are \a item_byte_size bytes long starting at offset \a offset - /// bytes into the contained data, into the stream \a s. \a - /// num_per_line objects will be dumped on each line before a new - /// line will be output. If \a base_addr is a valid address, then - /// each new line of output will be preceded by the address value - /// plus appropriate offset, and a colon and space. Bitfield values - /// can be dumped by calling this function multiple times with the - /// same start offset, format and size, yet differing \a - /// item_bit_size and \a item_bit_offset values. - /// - /// @param[in] s - /// The stream to dump the output to. This value can not be nullptr. - /// - /// @param[in] offset - /// The offset into the data at which to start dumping. - /// - /// @param[in] item_format - /// The format to use when dumping each item. - /// - /// @param[in] item_byte_size - /// The byte size of each item. - /// - /// @param[in] item_count - /// The number of items to dump. - /// - /// @param[in] num_per_line - /// The number of items to display on each line. - /// - /// @param[in] base_addr - /// The base address that gets added to the offset displayed on - /// each line if the value is valid. Is \a base_addr is - /// LLDB_INVALID_ADDRESS then no address values will be prepended - /// to any lines. - /// - /// @param[in] item_bit_size - /// If the value to display is a bitfield, this value should - /// be the number of bits that the bitfield item has within the - /// item's byte size value. This function will need to be called - /// multiple times with identical \a offset and \a item_byte_size - /// values in order to display multiple bitfield values that - /// exist within the same integer value. If the items being - /// displayed are not bitfields, this value should be zero. - /// - /// @param[in] item_bit_offset - /// If the value to display is a bitfield, this value should - /// be the offset in bits, or shift right amount, that the - /// bitfield item occupies within the item's byte size value. - /// This function will need to be called multiple times with - /// identical \a offset and \a item_byte_size values in order - /// to display multiple bitfield values that exist within the - /// same integer value. If the items being displayed are not - /// bitfields, this value should be zero. - /// - /// @return - /// The offset at which dumping ended. - //------------------------------------------------------------------ - lldb::offset_t Dump(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, - ExecutionContextScope *exe_scope = nullptr) const; - - //------------------------------------------------------------------ /// Dump a UUID value at \a offset. /// /// Dump a UUID starting at \a offset bytes into this object's data. @@ -573,38 +498,6 @@ long double GetLongDouble(lldb::offset_t *offset_ptr) const; //------------------------------------------------------------------ - /// Extract a GNU encoded pointer value from \a *offset_ptr. - /// - /// @param[in,out] offset_ptr - /// A pointer to an offset within the data that will be advanced - /// by the appropriate number of bytes if the value is extracted - /// correctly. If the offset is out of bounds or there are not - /// enough bytes to extract this value, the offset will be left - /// unmodified. - /// - /// @param[in] eh_ptr_enc - /// The GNU pointer encoding type. - /// - /// @param[in] pc_rel_addr - /// The PC relative address to use when the encoding is - /// \c DW_GNU_EH_PE_pcrel. - /// - /// @param[in] text_addr - /// The text (code) relative address to use when the encoding is - /// \c DW_GNU_EH_PE_textrel. - /// - /// @param[in] data_addr - /// The data relative address to use when the encoding is - /// \c DW_GNU_EH_PE_datarel. - /// - /// @return - /// The extracted GNU encoded pointer value. - //------------------------------------------------------------------ - uint64_t GetGNUEHPointer(lldb::offset_t *offset_ptr, uint32_t eh_ptr_enc, - lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, - lldb::addr_t data_addr); - - //------------------------------------------------------------------ /// Extract an integer of size \a byte_size from \a *offset_ptr. /// /// Extract a single integer value and update the offset pointed to Index: lldb/include/lldb/Core/DataExtractorEx.h =================================================================== --- /dev/null +++ lldb/include/lldb/Core/DataExtractorEx.h @@ -0,0 +1,144 @@ +//===-- DataExtractorEx.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_CORE_DATAEXTRACTOREX_H +#define LLDB_CORE_DATAEXTRACTOREX_H + +// Project includes +#include "lldb/Core/DataExtractor.h" + +namespace lldb_private { + class ExecutionContextScope; + class Stream; + + class DataExtractorEx : public DataExtractor { + public: + DataExtractorEx(); + + DataExtractorEx(const void *data, lldb::offset_t data_length, + lldb::ByteOrder byte_order, uint32_t addr_size, + uint32_t target_byte_size = 1); + + DataExtractorEx(const lldb::DataBufferSP &data_sp, lldb::ByteOrder byte_order, + uint32_t addr_size, uint32_t target_byte_size = 1); + + DataExtractorEx(const DataExtractor &data, lldb::offset_t offset, + lldb::offset_t length, uint32_t target_byte_size = 1); + + DataExtractorEx(const DataExtractorEx &rhs); + const DataExtractorEx &operator=(const DataExtractorEx &rhs); + ~DataExtractorEx(); + + //------------------------------------------------------------------ + /// Extract a GNU encoded pointer value from \a *offset_ptr. + /// + /// @param[in,out] offset_ptr + /// A pointer to an offset within the data that will be advanced + /// by the appropriate number of bytes if the value is extracted + /// correctly. If the offset is out of bounds or there are not + /// enough bytes to extract this value, the offset will be left + /// unmodified. + /// + /// @param[in] eh_ptr_enc + /// The GNU pointer encoding type. + /// + /// @param[in] pc_rel_addr + /// The PC relative address to use when the encoding is + /// \c DW_GNU_EH_PE_pcrel. + /// + /// @param[in] text_addr + /// The text (code) relative address to use when the encoding is + /// \c DW_GNU_EH_PE_textrel. + /// + /// @param[in] data_addr + /// The data relative address to use when the encoding is + /// \c DW_GNU_EH_PE_datarel. + /// + /// @return + /// The extracted GNU encoded pointer value. + //------------------------------------------------------------------ + uint64_t GetGNUEHPointer(lldb::offset_t *offset_ptr, uint32_t eh_ptr_enc, + lldb::addr_t pc_rel_addr, lldb::addr_t text_addr, + lldb::addr_t data_addr); + + //------------------------------------------------------------------ + /// Dumps \a item_count objects into the stream \a s. + /// + /// Dumps \a item_count objects using \a item_format, each of which + /// are \a item_byte_size bytes long starting at offset \a offset + /// bytes into the contained data, into the stream \a s. \a + /// num_per_line objects will be dumped on each line before a new + /// line will be output. If \a base_addr is a valid address, then + /// each new line of output will be preceded by the address value + /// plus appropriate offset, and a colon and space. Bitfield values + /// can be dumped by calling this function multiple times with the + /// same start offset, format and size, yet differing \a + /// item_bit_size and \a item_bit_offset values. + /// + /// @param[in] s + /// The stream to dump the output to. This value can not be nullptr. + /// + /// @param[in] offset + /// The offset into the data at which to start dumping. + /// + /// @param[in] item_format + /// The format to use when dumping each item. + /// + /// @param[in] item_byte_size + /// The byte size of each item. + /// + /// @param[in] item_count + /// The number of items to dump. + /// + /// @param[in] num_per_line + /// The number of items to display on each line. + /// + /// @param[in] base_addr + /// The base address that gets added to the offset displayed on + /// each line if the value is valid. Is \a base_addr is + /// LLDB_INVALID_ADDRESS then no address values will be prepended + /// to any lines. + /// + /// @param[in] item_bit_size + /// If the value to display is a bitfield, this value should + /// be the number of bits that the bitfield item has within the + /// item's byte size value. This function will need to be called + /// multiple times with identical \a offset and \a item_byte_size + /// values in order to display multiple bitfield values that + /// exist within the same integer value. If the items being + /// displayed are not bitfields, this value should be zero. + /// + /// @param[in] item_bit_offset + /// If the value to display is a bitfield, this value should + /// be the offset in bits, or shift right amount, that the + /// bitfield item occupies within the item's byte size value. + /// This function will need to be called multiple times with + /// identical \a offset and \a item_byte_size values in order + /// to display multiple bitfield values that exist within the + /// same integer value. If the items being displayed are not + /// bitfields, this value should be zero. + /// + /// @return + /// The offset at which dumping ended. + //------------------------------------------------------------------ + lldb::offset_t Dump(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, + ExecutionContextScope *exe_scope = nullptr) const; + + static void DumpHexBytes(Stream *s, const void *src, size_t src_len, + uint32_t bytes_per_line, + lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at + // start of line + }; +} + +#endif Index: lldb/include/lldb/Symbol/ClangASTContext.h =================================================================== --- lldb/include/lldb/Symbol/ClangASTContext.h +++ lldb/include/lldb/Symbol/ClangASTContext.h @@ -42,6 +42,7 @@ namespace lldb_private { class Declaration; +class DataExtractorEx; class ClangASTContext : public TypeSystem { public: @@ -894,14 +895,14 @@ // Dumping types //---------------------------------------------------------------------- void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, + Stream *s, lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override; Index: lldb/include/lldb/Symbol/CompilerType.h =================================================================== --- lldb/include/lldb/Symbol/CompilerType.h +++ lldb/include/lldb/Symbol/CompilerType.h @@ -23,6 +23,9 @@ namespace lldb_private { + class DataExtractor; + class DataExtractorEx; + //---------------------------------------------------------------------- // A class that can carry around a clang ASTContext and a opaque clang // QualType. A clang::QualType can be easily reconstructed from an @@ -385,18 +388,18 @@ // Dumping types //---------------------------------------------------------------------- void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, - const DataExtractor &data, lldb::offset_t data_offset, + const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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, + bool DumpTypeValue(Stream *s, lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope); void DumpSummary(ExecutionContext *exe_ctx, Stream *s, - const DataExtractor &data, lldb::offset_t data_offset, + const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size); void DumpTypeDescription() const; // Dump to stdout Index: lldb/include/lldb/Symbol/DWARFCallFrameInfo.h =================================================================== --- lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -14,7 +14,7 @@ #include #include "lldb/Core/AddressRange.h" -#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Utility/Flags.h" #include "lldb/Core/RangeMap.h" @@ -139,7 +139,7 @@ Flags m_flags; cie_map_t m_cie_map; - DataExtractor m_cfi_data; + DataExtractorEx m_cfi_data; bool m_cfi_data_initialized; // only copy the section into the DE once FDEEntryMap m_fde_index; Index: lldb/include/lldb/Symbol/GoASTContext.h =================================================================== --- lldb/include/lldb/Symbol/GoASTContext.h +++ lldb/include/lldb/Symbol/GoASTContext.h @@ -325,14 +325,14 @@ // Dumping types //---------------------------------------------------------------------- void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, + Stream *s, lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override; Index: lldb/include/lldb/Symbol/JavaASTContext.h =================================================================== --- lldb/include/lldb/Symbol/JavaASTContext.h +++ lldb/include/lldb/Symbol/JavaASTContext.h @@ -23,6 +23,8 @@ namespace lldb_private { + class DataExtractorEx; + class JavaASTContext : public TypeSystem { public: class JavaType; @@ -248,14 +250,14 @@ size_t dst_size) override; void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, + Stream *s, lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override; Index: lldb/include/lldb/Symbol/OCamlASTContext.h =================================================================== --- lldb/include/lldb/Symbol/OCamlASTContext.h +++ lldb/include/lldb/Symbol/OCamlASTContext.h @@ -238,14 +238,14 @@ } void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, + Stream *s, lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) override; Index: lldb/include/lldb/Symbol/Type.h =================================================================== --- lldb/include/lldb/Symbol/Type.h +++ lldb/include/lldb/Symbol/Type.h @@ -23,6 +23,7 @@ #include namespace lldb_private { + class DataExtractorEx; //---------------------------------------------------------------------- // CompilerContext allows an array of these items to be passed to @@ -150,7 +151,7 @@ ConstString GetQualifiedName(); void DumpValue(ExecutionContext *exe_ctx, Stream *s, - const DataExtractor &data, uint32_t data_offset, + const DataExtractorEx &data, uint32_t data_offset, bool show_type, bool show_summary, bool verbose, lldb::Format format = lldb::eFormatDefault); Index: lldb/include/lldb/Symbol/TypeSystem.h =================================================================== --- lldb/include/lldb/Symbol/TypeSystem.h +++ lldb/include/lldb/Symbol/TypeSystem.h @@ -33,6 +33,8 @@ namespace lldb_private { + class DataExtractorEx; + //---------------------------------------------------------------------- // Interface for representing the Type Systems in different languages. //---------------------------------------------------------------------- @@ -361,14 +363,14 @@ virtual void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, - lldb::Format format, const DataExtractor &data, + lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_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::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, Index: lldb/source/API/SBData.cpp =================================================================== --- lldb/source/API/SBData.cpp +++ lldb/source/API/SBData.cpp @@ -15,6 +15,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" @@ -347,7 +348,8 @@ Stream &strm = description.ref(); if (m_opaque_sp) { - m_opaque_sp->Dump(&strm, 0, lldb::eFormatBytesWithASCII, 1, + auto Ex = std::static_pointer_cast(m_opaque_sp); + Ex->Dump(&strm, 0, lldb::eFormatBytesWithASCII, 1, m_opaque_sp->GetByteSize(), 16, base_addr, 0, 0); } else strm.PutCString("No value"); @@ -381,7 +383,7 @@ lldb::ByteOrder endian, uint8_t addr_size) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (!m_opaque_sp.get()) - m_opaque_sp.reset(new DataExtractor(buf, size, endian, addr_size)); + m_opaque_sp.reset(new DataExtractorEx(buf, size, endian, addr_size)); else { m_opaque_sp->SetData(buf, size, endian); @@ -531,7 +533,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); @@ -561,7 +563,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); @@ -593,7 +595,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); @@ -625,7 +627,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); @@ -657,7 +659,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); @@ -689,7 +691,7 @@ if (!m_opaque_sp.get()) m_opaque_sp.reset( - new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize())); + new DataExtractorEx(buffer_sp, GetByteOrder(), GetAddressByteSize())); else m_opaque_sp->SetData(buffer_sp); Index: lldb/source/Commands/CommandObjectMemory.cpp =================================================================== --- lldb/source/Commands/CommandObjectMemory.cpp +++ lldb/source/Commands/CommandObjectMemory.cpp @@ -18,7 +18,7 @@ #include "CommandObjectMemory.h" #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" @@ -831,7 +831,7 @@ } result.SetStatus(eReturnStatusSuccessFinishResult); - DataExtractor data(data_sp, target->GetArchitecture().GetByteOrder(), + DataExtractorEx data(data_sp, target->GetArchitecture().GetByteOrder(), target->GetArchitecture().GetAddressByteSize(), target->GetArchitecture().GetDataByteSize()); @@ -1128,7 +1128,7 @@ found_location + m_memory_options.m_offset.GetCurrentValue(), dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), error); if (!error.Fail()) { - DataExtractor data(dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), + DataExtractorEx data(dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), process->GetByteOrder(), process->GetAddressByteSize()); data.Dump(&result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1, Index: lldb/source/Core/Address.cpp =================================================================== --- lldb/source/Core/Address.cpp +++ lldb/source/Core/Address.cpp @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/Block.h" @@ -141,7 +142,7 @@ ByteOrder byte_order = eByteOrderInvalid; uint32_t addr_size = 0; if (GetByteOrderAndAddressSize(exe_scope, address, byte_order, addr_size)) { - DataExtractor data(&buf.front(), buf.size(), byte_order, addr_size); + DataExtractorEx data(&buf.front(), buf.size(), byte_order, addr_size); data.Dump(strm, 0, // Start offset in "data" @@ -168,7 +169,7 @@ buf[k_buf_len] = '\0'; // NULL terminate // Byte order and address size don't matter for C string dumping.. - DataExtractor data(buf, sizeof(buf), endian::InlHostByteOrder(), 4); + DataExtractorEx data(buf, sizeof(buf), endian::InlHostByteOrder(), 4); size_t total_len = 0; size_t bytes_read; Address curr_address(address); Index: lldb/source/Core/CMakeLists.txt =================================================================== --- lldb/source/Core/CMakeLists.txt +++ lldb/source/Core/CMakeLists.txt @@ -13,6 +13,7 @@ DataBufferLLVM.cpp DataEncoder.cpp DataExtractor.cpp + DataExtractorEx.cpp Debugger.cpp Disassembler.cpp DynamicLoader.cpp Index: lldb/source/Core/DataExtractor.cpp =================================================================== --- lldb/source/Core/DataExtractor.cpp +++ lldb/source/Core/DataExtractor.cpp @@ -9,35 +9,22 @@ // C Includes // C++ Includes -#include #include #include #include -#include #include // Other libraries and framework includes -#include "llvm/ADT/APFloat.h" -#include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/MD5.h" #include "llvm/Support/MathExtras.h" -#include "clang/AST/ASTContext.h" - // Project includes #include "lldb/Core/DataBuffer.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Core/Disassembler.h" #include "lldb/Core/UUID.h" -#include "lldb/Core/dwarf.h" -#include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ExecutionContextScope.h" -#include "lldb/Target/SectionLoadList.h" -#include "lldb/Target/Target.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" @@ -111,8 +98,6 @@ return llvm::ByteSwap_64(value); } -#define NON_PRINTABLE_CHAR '.' - DataExtractor::DataExtractor() : m_start(nullptr), m_end(nullptr), m_byte_order(endian::InlHostByteOrder()), m_addr_size(sizeof(void *)), @@ -785,129 +770,6 @@ return GetMaxU64(offset_ptr, m_addr_size); } -//---------------------------------------------------------------------- -// GetDwarfEHPtr -// -// Used for calls when the value type is specified by a DWARF EH Frame -// pointer encoding. -//---------------------------------------------------------------------- - -uint64_t DataExtractor::GetGNUEHPointer( - offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, - lldb::addr_t text_addr, - lldb::addr_t data_addr) //, BSDRelocs *data_relocs) const -{ - if (eh_ptr_enc == DW_EH_PE_omit) - return ULLONG_MAX; // Value isn't in the buffer... - - uint64_t baseAddress = 0; - uint64_t addressValue = 0; - const uint32_t addr_size = GetAddressByteSize(); -#ifdef LLDB_CONFIGURATION_DEBUG - assert(addr_size == 4 || addr_size == 8); -#endif - - bool signExtendValue = false; - // Decode the base part or adjust our offset - switch (eh_ptr_enc & 0x70) { - case DW_EH_PE_pcrel: - signExtendValue = true; - baseAddress = *offset_ptr; - if (pc_rel_addr != LLDB_INVALID_ADDRESS) - baseAddress += pc_rel_addr; - // else - // Log::GlobalWarning ("PC relative pointer encoding found with - // invalid pc relative address."); - break; - - case DW_EH_PE_textrel: - signExtendValue = true; - if (text_addr != LLDB_INVALID_ADDRESS) - baseAddress = text_addr; - // else - // Log::GlobalWarning ("text relative pointer encoding being - // decoded with invalid text section address, setting base address - // to zero."); - break; - - case DW_EH_PE_datarel: - signExtendValue = true; - if (data_addr != LLDB_INVALID_ADDRESS) - baseAddress = data_addr; - // else - // Log::GlobalWarning ("data relative pointer encoding being - // decoded with invalid data section address, setting base address - // to zero."); - break; - - case DW_EH_PE_funcrel: - signExtendValue = true; - break; - - case DW_EH_PE_aligned: { - // SetPointerSize should be called prior to extracting these so the - // pointer size is cached - assert(addr_size != 0); - if (addr_size) { - // Align to a address size boundary first - uint32_t alignOffset = *offset_ptr % addr_size; - if (alignOffset) - offset_ptr += addr_size - alignOffset; - } - } break; - - default: - break; - } - - // Decode the value part - switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING) { - case DW_EH_PE_absptr: { - addressValue = GetAddress(offset_ptr); - // if (data_relocs) - // addressValue = data_relocs->Relocate(*offset_ptr - - // addr_size, *this, addressValue); - } break; - case DW_EH_PE_uleb128: - addressValue = GetULEB128(offset_ptr); - break; - case DW_EH_PE_udata2: - addressValue = GetU16(offset_ptr); - break; - case DW_EH_PE_udata4: - addressValue = GetU32(offset_ptr); - break; - case DW_EH_PE_udata8: - addressValue = GetU64(offset_ptr); - break; - case DW_EH_PE_sleb128: - addressValue = GetSLEB128(offset_ptr); - break; - case DW_EH_PE_sdata2: - addressValue = (int16_t)GetU16(offset_ptr); - break; - case DW_EH_PE_sdata4: - addressValue = (int32_t)GetU32(offset_ptr); - break; - case DW_EH_PE_sdata8: - addressValue = (int64_t)GetU64(offset_ptr); - break; - default: - // Unhandled encoding type - assert(eh_ptr_enc); - break; - } - - // Since we promote everything to 64 bit, we may need to sign extend - if (signExtendValue && addr_size < sizeof(baseAddress)) { - uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull); - if (sign_bit & addressValue) { - uint64_t mask = ~sign_bit + 1; - addressValue |= mask; - } - } - return baseAddress + addressValue; -} size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length, ByteOrder dst_byte_order, void *dst) const { @@ -1199,759 +1061,6 @@ return bytes_consumed; } -static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr, - lldb::offset_t byte_size, llvm::APInt &result) { - llvm::SmallVector uint64_array; - lldb::offset_t bytes_left = byte_size; - uint64_t u64; - const lldb::ByteOrder byte_order = data.GetByteOrder(); - if (byte_order == lldb::eByteOrderLittle) { - while (bytes_left > 0) { - if (bytes_left >= 8) { - u64 = data.GetU64(offset_ptr); - bytes_left -= 8; - } else { - u64 = data.GetMaxU64(offset_ptr, (uint32_t)bytes_left); - bytes_left = 0; - } - uint64_array.push_back(u64); - } - result = llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); - return true; - } else if (byte_order == lldb::eByteOrderBig) { - lldb::offset_t be_offset = *offset_ptr + byte_size; - lldb::offset_t temp_offset; - while (bytes_left > 0) { - if (bytes_left >= 8) { - be_offset -= 8; - temp_offset = be_offset; - u64 = data.GetU64(&temp_offset); - bytes_left -= 8; - } else { - be_offset -= bytes_left; - temp_offset = be_offset; - u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left); - bytes_left = 0; - } - uint64_array.push_back(u64); - } - *offset_ptr += byte_size; - result = llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); - return true; - } - return false; -} - -static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data, - lldb::offset_t offset, lldb::offset_t byte_size, - bool is_signed, unsigned radix) { - llvm::APInt apint; - if (GetAPInt(data, &offset, byte_size, apint)) { - std::string apint_str(apint.toString(radix, is_signed)); - switch (radix) { - case 2: - s->Write("0b", 2); - break; - case 8: - s->Write("0", 1); - break; - case 10: - break; - } - s->Write(apint_str.c_str(), apint_str.size()); - } - return offset; -} - -static float half2float(uint16_t half) { - union { - float f; - uint32_t u; - } u; - int32_t v = (int16_t)half; - - if (0 == (v & 0x7c00)) { - u.u = v & 0x80007FFFU; - return u.f * ldexpf(1, 125); - } - - v <<= 13; - u.u = v | 0x70000000U; - return u.f * ldexpf(1, -112); -} - -lldb::offset_t DataExtractor::Dump( - 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 - ExecutionContextScope *exe_scope) const { - if (s == nullptr) - return start_offset; - - if (item_format == eFormatPointer) { - if (item_byte_size != 4 && item_byte_size != 8) - item_byte_size = s->GetAddressByteSize(); - } - - offset_t offset = start_offset; - - if (item_format == eFormatInstruction) { - TargetSP target_sp; - if (exe_scope) - target_sp = exe_scope->CalculateTarget(); - if (target_sp) { - DisassemblerSP disassembler_sp(Disassembler::FindPlugin( - target_sp->GetArchitecture(), nullptr, nullptr)); - if (disassembler_sp) { - lldb::addr_t addr = base_addr + start_offset; - lldb_private::Address so_addr; - bool data_from_file = true; - if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) { - data_from_file = false; - } else { - if (target_sp->GetSectionLoadList().IsEmpty() || - !target_sp->GetImages().ResolveFileAddress(addr, so_addr)) - so_addr.SetRawAddress(addr); - } - - size_t bytes_consumed = disassembler_sp->DecodeInstructions( - so_addr, *this, start_offset, item_count, false, data_from_file); - - if (bytes_consumed) { - offset += bytes_consumed; - const bool show_address = base_addr != LLDB_INVALID_ADDRESS; - const bool show_bytes = true; - ExecutionContext exe_ctx; - exe_scope->CalculateExecutionContext(exe_ctx); - disassembler_sp->GetInstructionList().Dump(s, show_address, - show_bytes, &exe_ctx); - } - } - } else - s->Printf("invalid target"); - - return offset; - } - - if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) && - item_byte_size > 8) - item_format = eFormatHex; - - lldb::offset_t line_start_offset = start_offset; - for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count) { - if ((count % num_per_line) == 0) { - if (count > 0) { - if (item_format == eFormatBytesWithASCII && - offset > line_start_offset) { - s->Printf("%*s", - static_cast( - (num_per_line - (offset - line_start_offset)) * 3 + 2), - ""); - Dump(s, line_start_offset, eFormatCharPrintable, 1, - offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, - 0); - } - s->EOL(); - } - if (base_addr != LLDB_INVALID_ADDRESS) - s->Printf("0x%8.8" PRIx64 ": ", - (uint64_t)(base_addr + - (offset - start_offset) / m_target_byte_size)); - - line_start_offset = offset; - } else if (item_format != eFormatChar && - item_format != eFormatCharPrintable && - item_format != eFormatCharArray && count > 0) { - s->PutChar(' '); - } - - switch (item_format) { - case eFormatBoolean: - if (item_byte_size <= 8) - s->Printf("%s", GetMaxU64Bitfield(&offset, item_byte_size, - item_bit_size, item_bit_offset) - ? "true" - : "false"); - else { - s->Printf("error: unsupported byte size (%" PRIu64 - ") for boolean format", - (uint64_t)item_byte_size); - return offset; - } - break; - - case eFormatBinary: - if (item_byte_size <= 8) { - uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, - item_bit_size, item_bit_offset); - // Avoid std::bitset<64>::to_string() since it is missing in - // earlier C++ libraries - std::string binary_value(64, '0'); - std::bitset<64> bits(uval64); - for (uint32_t i = 0; i < 64; ++i) - if (bits[i]) - binary_value[64 - 1 - i] = '1'; - if (item_bit_size > 0) - s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size); - else if (item_byte_size > 0 && item_byte_size <= 8) - s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8); - } else { - const bool is_signed = false; - const unsigned radix = 2; - offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); - } - break; - - case eFormatBytes: - case eFormatBytesWithASCII: - for (uint32_t i = 0; i < item_byte_size; ++i) { - s->Printf("%2.2x", GetU8(&offset)); - } - - // Put an extra space between the groups of bytes if more than one - // is being dumped in a group (item_byte_size is more than 1). - if (item_byte_size > 1) - s->PutChar(' '); - break; - - case eFormatChar: - case eFormatCharPrintable: - case eFormatCharArray: { - // If we are only printing one character surround it with single - // quotes - if (item_count == 1 && item_format == eFormatChar) - s->PutChar('\''); - - const uint64_t ch = GetMaxU64Bitfield(&offset, item_byte_size, - item_bit_size, item_bit_offset); - if (isprint(ch)) - s->Printf("%c", (char)ch); - else if (item_format != eFormatCharPrintable) { - switch (ch) { - case '\033': - s->Printf("\\e"); - break; - case '\a': - s->Printf("\\a"); - break; - case '\b': - s->Printf("\\b"); - break; - case '\f': - s->Printf("\\f"); - break; - case '\n': - s->Printf("\\n"); - break; - case '\r': - s->Printf("\\r"); - break; - case '\t': - s->Printf("\\t"); - break; - case '\v': - s->Printf("\\v"); - break; - case '\0': - s->Printf("\\0"); - break; - default: - if (item_byte_size == 1) - s->Printf("\\x%2.2x", (uint8_t)ch); - else - s->Printf("%" PRIu64, ch); - break; - } - } else { - s->PutChar(NON_PRINTABLE_CHAR); - } - - // If we are only printing one character surround it with single quotes - if (item_count == 1 && item_format == eFormatChar) - s->PutChar('\''); - } break; - - case eFormatEnum: // Print enum value as a signed integer when we don't get - // the enum type - case eFormatDecimal: - if (item_byte_size <= 8) - s->Printf("%" PRId64, - GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset)); - else { - const bool is_signed = true; - const unsigned radix = 10; - offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); - } - break; - - case eFormatUnsigned: - if (item_byte_size <= 8) - s->Printf("%" PRIu64, - GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset)); - else { - const bool is_signed = false; - const unsigned radix = 10; - offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); - } - break; - - case eFormatOctal: - if (item_byte_size <= 8) - s->Printf("0%" PRIo64, - GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset)); - else { - const bool is_signed = false; - const unsigned radix = 8; - offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); - } - break; - - case eFormatOSType: { - uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, - item_bit_size, item_bit_offset); - s->PutChar('\''); - for (uint32_t i = 0; i < item_byte_size; ++i) { - uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8)); - if (isprint(ch)) - s->Printf("%c", ch); - else { - switch (ch) { - case '\033': - s->Printf("\\e"); - break; - case '\a': - s->Printf("\\a"); - break; - case '\b': - s->Printf("\\b"); - break; - case '\f': - s->Printf("\\f"); - break; - case '\n': - s->Printf("\\n"); - break; - case '\r': - s->Printf("\\r"); - break; - case '\t': - s->Printf("\\t"); - break; - case '\v': - s->Printf("\\v"); - break; - case '\0': - s->Printf("\\0"); - break; - default: - s->Printf("\\x%2.2x", ch); - break; - } - } - } - s->PutChar('\''); - } break; - - case eFormatCString: { - const char *cstr = GetCStr(&offset); - - if (!cstr) { - s->Printf("NULL"); - offset = LLDB_INVALID_OFFSET; - } else { - s->PutChar('\"'); - - while (const char c = *cstr) { - if (isprint(c)) { - s->PutChar(c); - } else { - switch (c) { - case '\033': - s->Printf("\\e"); - break; - case '\a': - s->Printf("\\a"); - break; - case '\b': - s->Printf("\\b"); - break; - case '\f': - s->Printf("\\f"); - break; - case '\n': - s->Printf("\\n"); - break; - case '\r': - s->Printf("\\r"); - break; - case '\t': - s->Printf("\\t"); - break; - case '\v': - s->Printf("\\v"); - break; - default: - s->Printf("\\x%2.2x", c); - break; - } - } - - ++cstr; - } - - s->PutChar('\"'); - } - } break; - - case eFormatPointer: - s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset), - sizeof(addr_t)); - break; - - case eFormatComplexInteger: { - size_t complex_int_byte_size = item_byte_size / 2; - - if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) { - s->Printf("%" PRIu64, - GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); - s->Printf(" + %" PRIu64 "i", - GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); - } else { - s->Printf("error: unsupported byte size (%" PRIu64 - ") for complex integer format", - (uint64_t)item_byte_size); - return offset; - } - } break; - - case eFormatComplex: - if (sizeof(float) * 2 == item_byte_size) { - float f32_1 = GetFloat(&offset); - float f32_2 = GetFloat(&offset); - - s->Printf("%g + %gi", f32_1, f32_2); - break; - } else if (sizeof(double) * 2 == item_byte_size) { - double d64_1 = GetDouble(&offset); - double d64_2 = GetDouble(&offset); - - s->Printf("%lg + %lgi", d64_1, d64_2); - break; - } else if (sizeof(long double) * 2 == item_byte_size) { - long double ld64_1 = GetLongDouble(&offset); - long double ld64_2 = GetLongDouble(&offset); - s->Printf("%Lg + %Lgi", ld64_1, ld64_2); - break; - } else { - s->Printf("error: unsupported byte size (%" PRIu64 - ") for complex float format", - (uint64_t)item_byte_size); - return offset; - } - break; - - default: - case eFormatDefault: - case eFormatHex: - case eFormatHexUppercase: { - bool wantsuppercase = (item_format == eFormatHexUppercase); - switch (item_byte_size) { - case 1: - case 2: - case 4: - case 8: - s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, - (int)(2 * item_byte_size), (int)(2 * item_byte_size), - GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset)); - break; - default: { - assert(item_bit_size == 0 && item_bit_offset == 0); - const uint8_t *bytes = - (const uint8_t *)GetData(&offset, item_byte_size); - if (bytes) { - s->PutCString("0x"); - uint32_t idx; - if (m_byte_order == eByteOrderBig) { - for (idx = 0; idx < item_byte_size; ++idx) - s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]); - } else { - for (idx = 0; idx < item_byte_size; ++idx) - s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", - bytes[item_byte_size - 1 - idx]); - } - } - } break; - } - } break; - - case eFormatFloat: { - TargetSP target_sp; - bool used_apfloat = false; - if (exe_scope) - target_sp = exe_scope->CalculateTarget(); - if (target_sp) { - ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); - if (clang_ast) { - clang::ASTContext *ast = clang_ast->getASTContext(); - if (ast) { - llvm::SmallVector sv; - // Show full precision when printing float values - const unsigned format_precision = 0; - const unsigned format_max_padding = 100; - size_t item_bit_size = item_byte_size * 8; - - if (item_bit_size == ast->getTypeSize(ast->FloatTy)) { - llvm::APInt apint(item_bit_size, - this->GetMaxU64(&offset, item_byte_size)); - llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy), - apint); - apfloat.toString(sv, format_precision, format_max_padding); - } else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) { - llvm::APInt apint; - if (GetAPInt(*this, &offset, item_byte_size, apint)) { - llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy), - apint); - apfloat.toString(sv, format_precision, format_max_padding); - } - } else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) { - const auto &semantics = - ast->getFloatTypeSemantics(ast->LongDoubleTy); - const auto byte_size = - (llvm::APFloat::getSizeInBits(semantics) + 7) / 8; - - llvm::APInt apint; - if (GetAPInt(*this, &offset, byte_size, apint)) { - llvm::APFloat apfloat(semantics, apint); - apfloat.toString(sv, format_precision, format_max_padding); - } - } else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) { - llvm::APInt apint(item_bit_size, this->GetU16(&offset)); - llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy), - apint); - apfloat.toString(sv, format_precision, format_max_padding); - } - - if (!sv.empty()) { - s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data()); - used_apfloat = true; - } - } - } - } - - if (!used_apfloat) { - std::ostringstream ss; - if (item_byte_size == sizeof(float) || item_byte_size == 2) { - float f; - if (item_byte_size == 2) { - uint16_t half = this->GetU16(&offset); - f = half2float(half); - } else { - f = GetFloat(&offset); - } - ss.precision(std::numeric_limits::digits10); - ss << f; - } else if (item_byte_size == sizeof(double)) { - ss.precision(std::numeric_limits::digits10); - ss << GetDouble(&offset); - } else if (item_byte_size == sizeof(long double) || - item_byte_size == 10) { - ss.precision(std::numeric_limits::digits10); - ss << GetLongDouble(&offset); - } else { - s->Printf("error: unsupported byte size (%" PRIu64 - ") for float format", - (uint64_t)item_byte_size); - return offset; - } - ss.flush(); - s->Printf("%s", ss.str().c_str()); - } - } break; - - case eFormatUnicode16: - s->Printf("U+%4.4x", GetU16(&offset)); - break; - - case eFormatUnicode32: - s->Printf("U+0x%8.8x", GetU32(&offset)); - break; - - case eFormatAddressInfo: { - addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, - item_bit_offset); - s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size), - (int)(2 * item_byte_size), addr); - if (exe_scope) { - TargetSP target_sp(exe_scope->CalculateTarget()); - lldb_private::Address so_addr; - if (target_sp) { - if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, - so_addr)) { - s->PutChar(' '); - so_addr.Dump(s, exe_scope, Address::DumpStyleResolvedDescription, - Address::DumpStyleModuleWithFileAddress); - } else { - so_addr.SetOffset(addr); - so_addr.Dump(s, exe_scope, - Address::DumpStyleResolvedPointerDescription); - } - } - } - } break; - - case eFormatHexFloat: - if (sizeof(float) == item_byte_size) { - char float_cstr[256]; - llvm::APFloat ap_float(GetFloat(&offset)); - ap_float.convertToHexString(float_cstr, 0, false, - llvm::APFloat::rmNearestTiesToEven); - s->Printf("%s", float_cstr); - break; - } else if (sizeof(double) == item_byte_size) { - char float_cstr[256]; - llvm::APFloat ap_float(GetDouble(&offset)); - ap_float.convertToHexString(float_cstr, 0, false, - llvm::APFloat::rmNearestTiesToEven); - s->Printf("%s", float_cstr); - break; - } else { - s->Printf("error: unsupported byte size (%" PRIu64 - ") for hex float format", - (uint64_t)item_byte_size); - return offset; - } - break; - - // please keep the single-item formats below in sync with - // FormatManager::GetSingleItemFormat - // if you fail to do so, users will start getting different outputs - // depending on internal - // implementation details they should not care about || - case eFormatVectorOfChar: // || - s->PutChar('{'); // \/ - offset = Dump(s, offset, eFormatCharArray, 1, item_byte_size, - item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfSInt8: - s->PutChar('{'); - offset = Dump(s, offset, eFormatDecimal, 1, item_byte_size, - item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfUInt8: - s->PutChar('{'); - offset = Dump(s, offset, eFormatHex, 1, item_byte_size, item_byte_size, - LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfSInt16: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatDecimal, sizeof(uint16_t), - item_byte_size / sizeof(uint16_t), - item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfUInt16: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatHex, sizeof(uint16_t), - item_byte_size / sizeof(uint16_t), - item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfSInt32: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatDecimal, sizeof(uint32_t), - item_byte_size / sizeof(uint32_t), - item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfUInt32: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatHex, sizeof(uint32_t), - item_byte_size / sizeof(uint32_t), - item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfSInt64: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatDecimal, sizeof(uint64_t), - item_byte_size / sizeof(uint64_t), - item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfUInt64: - s->PutChar('{'); - offset = - Dump(s, offset, eFormatHex, sizeof(uint64_t), - item_byte_size / sizeof(uint64_t), - item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfFloat16: - s->PutChar('{'); - offset = Dump(s, offset, eFormatFloat, 2, item_byte_size / 2, - item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfFloat32: - s->PutChar('{'); - offset = Dump(s, offset, eFormatFloat, 4, item_byte_size / 4, - item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfFloat64: - s->PutChar('{'); - offset = Dump(s, offset, eFormatFloat, 8, item_byte_size / 8, - item_byte_size / 8, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - - case eFormatVectorOfUInt128: - s->PutChar('{'); - offset = Dump(s, offset, eFormatHex, 16, item_byte_size / 16, - item_byte_size / 16, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('}'); - break; - } - } - - if (item_format == eFormatBytesWithASCII && offset > line_start_offset) { - s->Printf("%*s", static_cast( - (num_per_line - (offset - line_start_offset)) * 3 + 2), - ""); - Dump(s, line_start_offset, eFormatCharPrintable, 1, - offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, 0); - } - return offset; // Return the offset at which we ended up -} - //---------------------------------------------------------------------- // Dumps bytes from this object's data to the stream "s" starting // "start_offset" bytes into this data, and ending with the byte @@ -2043,19 +1152,6 @@ } } -void DataExtractor::DumpHexBytes(Stream *s, const void *src, size_t src_len, - uint32_t bytes_per_line, addr_t base_addr) { - DataExtractor data(src, src_len, eByteOrderLittle, 4); - data.Dump(s, - 0, // Offset into "src" - eFormatBytes, // Dump as hex bytes - 1, // Size of each item is 1 for single bytes - src_len, // Number of bytes - bytes_per_line, // Num bytes per line - base_addr, // Base address - 0, 0); // Bitfield info -} - size_t DataExtractor::Copy(DataExtractor &dest_data) const { if (m_data_sp) { // we can pass along the SP to the data Index: lldb/source/Core/DataExtractorEx.cpp =================================================================== --- /dev/null +++ lldb/source/Core/DataExtractorEx.cpp @@ -0,0 +1,967 @@ +//===-- DataExtractorEx.cpp -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/DataExtractorEx.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/dwarf.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/ExecutionContextScope.h" +#include "lldb/Target/SectionLoadList.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/Stream.h" + +#include +#include + +using namespace lldb_private; +using namespace lldb; + +#define NON_PRINTABLE_CHAR '.' + +static float half2float(uint16_t half) { + union { + float f; + uint32_t u; + } u; + int32_t v = (int16_t)half; + + if (0 == (v & 0x7c00)) { + u.u = v & 0x80007FFFU; + return u.f * ldexpf(1, 125); + } + + v <<= 13; + u.u = v | 0x70000000U; + return u.f * ldexpf(1, -112); +} + +static bool GetAPInt(const DataExtractorEx &data, lldb::offset_t *offset_ptr, + lldb::offset_t byte_size, llvm::APInt &result) { + llvm::SmallVector uint64_array; + lldb::offset_t bytes_left = byte_size; + uint64_t u64; + const lldb::ByteOrder byte_order = data.GetByteOrder(); + if (byte_order == lldb::eByteOrderLittle) { + while (bytes_left > 0) { + if (bytes_left >= 8) { + u64 = data.GetU64(offset_ptr); + bytes_left -= 8; + } + else { + u64 = data.GetMaxU64(offset_ptr, (uint32_t)bytes_left); + bytes_left = 0; + } + uint64_array.push_back(u64); + } + result = llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); + return true; + } + else if (byte_order == lldb::eByteOrderBig) { + lldb::offset_t be_offset = *offset_ptr + byte_size; + lldb::offset_t temp_offset; + while (bytes_left > 0) { + if (bytes_left >= 8) { + be_offset -= 8; + temp_offset = be_offset; + u64 = data.GetU64(&temp_offset); + bytes_left -= 8; + } + else { + be_offset -= bytes_left; + temp_offset = be_offset; + u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left); + bytes_left = 0; + } + uint64_array.push_back(u64); + } + *offset_ptr += byte_size; + result = llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); + return true; + } + return false; +} + +static lldb::offset_t DumpAPInt(Stream *s, const DataExtractorEx &data, + lldb::offset_t offset, lldb::offset_t byte_size, + bool is_signed, unsigned radix) { + llvm::APInt apint; + if (GetAPInt(data, &offset, byte_size, apint)) { + std::string apint_str(apint.toString(radix, is_signed)); + switch (radix) { + case 2: + s->Write("0b", 2); + break; + case 8: + s->Write("0", 1); + break; + case 10: + break; + } + s->Write(apint_str.c_str(), apint_str.size()); + } + return offset; +} + +DataExtractorEx::DataExtractorEx() { + +} + +DataExtractorEx::DataExtractorEx(const void *Data, offset_t Length, + ByteOrder BO, uint32_t AddrSize, uint32_t TargetByteSize) : DataExtractor(Data, Length, BO, AddrSize, TargetByteSize) { + +} + +DataExtractorEx::DataExtractorEx(const lldb::DataBufferSP &Data, ByteOrder BO, + uint32_t AddrSize, uint32_t TargetByteSize) : DataExtractor(Data, BO, AddrSize, TargetByteSize) { + +} + +DataExtractorEx::DataExtractorEx(const DataExtractor &Extractor, offset_t Offset, + offset_t Length, uint32_t TargetByteSize) : DataExtractor(Extractor, Offset, Length, TargetByteSize) { + +} + +DataExtractorEx::DataExtractorEx(const DataExtractorEx &rhs) : DataExtractor(rhs) { + +} + +DataExtractorEx::~DataExtractorEx() { + +} + +//---------------------------------------------------------------------- +// GetDwarfEHPtr +// +// Used for calls when the value type is specified by a DWARF EH Frame +// pointer encoding. +//---------------------------------------------------------------------- +uint64_t DataExtractorEx::GetGNUEHPointer( + offset_t *offset_ptr, uint32_t eh_ptr_enc, lldb::addr_t pc_rel_addr, + lldb::addr_t text_addr, + lldb::addr_t data_addr) //, BSDRelocs *data_relocs) const +{ + if (eh_ptr_enc == DW_EH_PE_omit) + return ULLONG_MAX; // Value isn't in the buffer... + + uint64_t baseAddress = 0; + uint64_t addressValue = 0; + const uint32_t addr_size = GetAddressByteSize(); +#ifdef LLDB_CONFIGURATION_DEBUG + assert(addr_size == 4 || addr_size == 8); +#endif + + bool signExtendValue = false; + // Decode the base part or adjust our offset + switch (eh_ptr_enc & 0x70) { + case DW_EH_PE_pcrel: + signExtendValue = true; + baseAddress = *offset_ptr; + if (pc_rel_addr != LLDB_INVALID_ADDRESS) + baseAddress += pc_rel_addr; + // else + // Log::GlobalWarning ("PC relative pointer encoding found with + // invalid pc relative address."); + break; + + case DW_EH_PE_textrel: + signExtendValue = true; + if (text_addr != LLDB_INVALID_ADDRESS) + baseAddress = text_addr; + // else + // Log::GlobalWarning ("text relative pointer encoding being + // decoded with invalid text section address, setting base address + // to zero."); + break; + + case DW_EH_PE_datarel: + signExtendValue = true; + if (data_addr != LLDB_INVALID_ADDRESS) + baseAddress = data_addr; + // else + // Log::GlobalWarning ("data relative pointer encoding being + // decoded with invalid data section address, setting base address + // to zero."); + break; + + case DW_EH_PE_funcrel: + signExtendValue = true; + break; + + case DW_EH_PE_aligned: { + // SetPointerSize should be called prior to extracting these so the + // pointer size is cached + assert(addr_size != 0); + if (addr_size) { + // Align to a address size boundary first + uint32_t alignOffset = *offset_ptr % addr_size; + if (alignOffset) + offset_ptr += addr_size - alignOffset; + } + } break; + + default: + break; + } + + // Decode the value part + switch (eh_ptr_enc & DW_EH_PE_MASK_ENCODING) { + case DW_EH_PE_absptr: { + addressValue = GetAddress(offset_ptr); + // if (data_relocs) + // addressValue = data_relocs->Relocate(*offset_ptr - + // addr_size, *this, addressValue); + } break; + case DW_EH_PE_uleb128: + addressValue = GetULEB128(offset_ptr); + break; + case DW_EH_PE_udata2: + addressValue = GetU16(offset_ptr); + break; + case DW_EH_PE_udata4: + addressValue = GetU32(offset_ptr); + break; + case DW_EH_PE_udata8: + addressValue = GetU64(offset_ptr); + break; + case DW_EH_PE_sleb128: + addressValue = GetSLEB128(offset_ptr); + break; + case DW_EH_PE_sdata2: + addressValue = (int16_t)GetU16(offset_ptr); + break; + case DW_EH_PE_sdata4: + addressValue = (int32_t)GetU32(offset_ptr); + break; + case DW_EH_PE_sdata8: + addressValue = (int64_t)GetU64(offset_ptr); + break; + default: + // Unhandled encoding type + assert(eh_ptr_enc); + break; + } + + // Since we promote everything to 64 bit, we may need to sign extend + if (signExtendValue && addr_size < sizeof(baseAddress)) { + uint64_t sign_bit = 1ull << ((addr_size * 8ull) - 1ull); + if (sign_bit & addressValue) { + uint64_t mask = ~sign_bit + 1; + addressValue |= mask; + } + } + return baseAddress + addressValue; +} + +lldb::offset_t DataExtractorEx::Dump( + 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 + ExecutionContextScope *exe_scope) const { + if (s == nullptr) + return start_offset; + + if (item_format == eFormatPointer) { + if (item_byte_size != 4 && item_byte_size != 8) + item_byte_size = s->GetAddressByteSize(); + } + + offset_t offset = start_offset; + + if (item_format == eFormatInstruction) { + TargetSP target_sp; + if (exe_scope) + target_sp = exe_scope->CalculateTarget(); + if (target_sp) { + DisassemblerSP disassembler_sp(Disassembler::FindPlugin( + target_sp->GetArchitecture(), nullptr, nullptr)); + if (disassembler_sp) { + lldb::addr_t addr = base_addr + start_offset; + lldb_private::Address so_addr; + bool data_from_file = true; + if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) { + data_from_file = false; + } + else { + if (target_sp->GetSectionLoadList().IsEmpty() || + !target_sp->GetImages().ResolveFileAddress(addr, so_addr)) + so_addr.SetRawAddress(addr); + } + + size_t bytes_consumed = disassembler_sp->DecodeInstructions( + so_addr, *this, start_offset, item_count, false, data_from_file); + + if (bytes_consumed) { + offset += bytes_consumed; + const bool show_address = base_addr != LLDB_INVALID_ADDRESS; + const bool show_bytes = true; + ExecutionContext exe_ctx; + exe_scope->CalculateExecutionContext(exe_ctx); + disassembler_sp->GetInstructionList().Dump(s, show_address, + show_bytes, &exe_ctx); + } + } + } + else + s->Printf("invalid target"); + + return offset; + } + + if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) && + item_byte_size > 8) + item_format = eFormatHex; + + lldb::offset_t line_start_offset = start_offset; + for (uint32_t count = 0; ValidOffset(offset) && count < item_count; ++count) { + if ((count % num_per_line) == 0) { + if (count > 0) { + if (item_format == eFormatBytesWithASCII && + offset > line_start_offset) { + s->Printf("%*s", + static_cast( + (num_per_line - (offset - line_start_offset)) * 3 + 2), + ""); + Dump(s, line_start_offset, eFormatCharPrintable, 1, + offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, + 0); + } + s->EOL(); + } + if (base_addr != LLDB_INVALID_ADDRESS) + s->Printf("0x%8.8" PRIx64 ": ", + (uint64_t)(base_addr + + (offset - start_offset) / m_target_byte_size)); + + line_start_offset = offset; + } + else if (item_format != eFormatChar && + item_format != eFormatCharPrintable && + item_format != eFormatCharArray && count > 0) { + s->PutChar(' '); + } + + switch (item_format) { + case eFormatBoolean: + if (item_byte_size <= 8) + s->Printf("%s", GetMaxU64Bitfield(&offset, item_byte_size, + item_bit_size, item_bit_offset) + ? "true" + : "false"); + else { + s->Printf("error: unsupported byte size (%" PRIu64 + ") for boolean format", + (uint64_t)item_byte_size); + return offset; + } + break; + + case eFormatBinary: + if (item_byte_size <= 8) { + uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, + item_bit_size, item_bit_offset); + // Avoid std::bitset<64>::to_string() since it is missing in + // earlier C++ libraries + std::string binary_value(64, '0'); + std::bitset<64> bits(uval64); + for (uint32_t i = 0; i < 64; ++i) + if (bits[i]) + binary_value[64 - 1 - i] = '1'; + if (item_bit_size > 0) + s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size); + else if (item_byte_size > 0 && item_byte_size <= 8) + s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8); + } + else { + const bool is_signed = false; + const unsigned radix = 2; + offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); + } + break; + + case eFormatBytes: + case eFormatBytesWithASCII: + for (uint32_t i = 0; i < item_byte_size; ++i) { + s->Printf("%2.2x", GetU8(&offset)); + } + + // Put an extra space between the groups of bytes if more than one + // is being dumped in a group (item_byte_size is more than 1). + if (item_byte_size > 1) + s->PutChar(' '); + break; + + case eFormatChar: + case eFormatCharPrintable: + case eFormatCharArray: { + // If we are only printing one character surround it with single + // quotes + if (item_count == 1 && item_format == eFormatChar) + s->PutChar('\''); + + const uint64_t ch = GetMaxU64Bitfield(&offset, item_byte_size, + item_bit_size, item_bit_offset); + if (isprint(ch)) + s->Printf("%c", (char)ch); + else if (item_format != eFormatCharPrintable) { + switch (ch) { + case '\033': + s->Printf("\\e"); + break; + case '\a': + s->Printf("\\a"); + break; + case '\b': + s->Printf("\\b"); + break; + case '\f': + s->Printf("\\f"); + break; + case '\n': + s->Printf("\\n"); + break; + case '\r': + s->Printf("\\r"); + break; + case '\t': + s->Printf("\\t"); + break; + case '\v': + s->Printf("\\v"); + break; + case '\0': + s->Printf("\\0"); + break; + default: + if (item_byte_size == 1) + s->Printf("\\x%2.2x", (uint8_t)ch); + else + s->Printf("%" PRIu64, ch); + break; + } + } + else { + s->PutChar(NON_PRINTABLE_CHAR); + } + + // If we are only printing one character surround it with single quotes + if (item_count == 1 && item_format == eFormatChar) + s->PutChar('\''); + } break; + + case eFormatEnum: // Print enum value as a signed integer when we don't get + // the enum type + case eFormatDecimal: + if (item_byte_size <= 8) + s->Printf("%" PRId64, + GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset)); + else { + const bool is_signed = true; + const unsigned radix = 10; + offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); + } + break; + + case eFormatUnsigned: + if (item_byte_size <= 8) + s->Printf("%" PRIu64, + GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset)); + else { + const bool is_signed = false; + const unsigned radix = 10; + offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); + } + break; + + case eFormatOctal: + if (item_byte_size <= 8) + s->Printf("0%" PRIo64, + GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset)); + else { + const bool is_signed = false; + const unsigned radix = 8; + offset = DumpAPInt(s, *this, offset, item_byte_size, is_signed, radix); + } + break; + + case eFormatOSType: { + uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, + item_bit_size, item_bit_offset); + s->PutChar('\''); + for (uint32_t i = 0; i < item_byte_size; ++i) { + uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8)); + if (isprint(ch)) + s->Printf("%c", ch); + else { + switch (ch) { + case '\033': + s->Printf("\\e"); + break; + case '\a': + s->Printf("\\a"); + break; + case '\b': + s->Printf("\\b"); + break; + case '\f': + s->Printf("\\f"); + break; + case '\n': + s->Printf("\\n"); + break; + case '\r': + s->Printf("\\r"); + break; + case '\t': + s->Printf("\\t"); + break; + case '\v': + s->Printf("\\v"); + break; + case '\0': + s->Printf("\\0"); + break; + default: + s->Printf("\\x%2.2x", ch); + break; + } + } + } + s->PutChar('\''); + } break; + + case eFormatCString: { + const char *cstr = GetCStr(&offset); + + if (!cstr) { + s->Printf("NULL"); + offset = LLDB_INVALID_OFFSET; + } + else { + s->PutChar('\"'); + + while (const char c = *cstr) { + if (isprint(c)) { + s->PutChar(c); + } + else { + switch (c) { + case '\033': + s->Printf("\\e"); + break; + case '\a': + s->Printf("\\a"); + break; + case '\b': + s->Printf("\\b"); + break; + case '\f': + s->Printf("\\f"); + break; + case '\n': + s->Printf("\\n"); + break; + case '\r': + s->Printf("\\r"); + break; + case '\t': + s->Printf("\\t"); + break; + case '\v': + s->Printf("\\v"); + break; + default: + s->Printf("\\x%2.2x", c); + break; + } + } + + ++cstr; + } + + s->PutChar('\"'); + } + } break; + + case eFormatPointer: + s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset), + sizeof(addr_t)); + break; + + case eFormatComplexInteger: { + size_t complex_int_byte_size = item_byte_size / 2; + + if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) { + s->Printf("%" PRIu64, + GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); + s->Printf(" + %" PRIu64 "i", + GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); + } + else { + s->Printf("error: unsupported byte size (%" PRIu64 + ") for complex integer format", + (uint64_t)item_byte_size); + return offset; + } + } break; + + case eFormatComplex: + if (sizeof(float) * 2 == item_byte_size) { + float f32_1 = GetFloat(&offset); + float f32_2 = GetFloat(&offset); + + s->Printf("%g + %gi", f32_1, f32_2); + break; + } + else if (sizeof(double) * 2 == item_byte_size) { + double d64_1 = GetDouble(&offset); + double d64_2 = GetDouble(&offset); + + s->Printf("%lg + %lgi", d64_1, d64_2); + break; + } + else if (sizeof(long double) * 2 == item_byte_size) { + long double ld64_1 = GetLongDouble(&offset); + long double ld64_2 = GetLongDouble(&offset); + s->Printf("%Lg + %Lgi", ld64_1, ld64_2); + break; + } + else { + s->Printf("error: unsupported byte size (%" PRIu64 + ") for complex float format", + (uint64_t)item_byte_size); + return offset; + } + break; + + default: + case eFormatDefault: + case eFormatHex: + case eFormatHexUppercase: { + bool wantsuppercase = (item_format == eFormatHexUppercase); + switch (item_byte_size) { + case 1: + case 2: + case 4: + case 8: + s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64, + (int)(2 * item_byte_size), (int)(2 * item_byte_size), + GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset)); + break; + default: { + assert(item_bit_size == 0 && item_bit_offset == 0); + const uint8_t *bytes = + (const uint8_t *)GetData(&offset, item_byte_size); + if (bytes) { + s->PutCString("0x"); + uint32_t idx; + if (m_byte_order == eByteOrderBig) { + for (idx = 0; idx < item_byte_size; ++idx) + s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]); + } + else { + for (idx = 0; idx < item_byte_size; ++idx) + s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", + bytes[item_byte_size - 1 - idx]); + } + } + } break; + } + } break; + + case eFormatFloat: { + TargetSP target_sp; + bool used_apfloat = false; + if (exe_scope) + target_sp = exe_scope->CalculateTarget(); + if (target_sp) { + ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext(); + if (clang_ast) { + clang::ASTContext *ast = clang_ast->getASTContext(); + if (ast) { + llvm::SmallVector sv; + // Show full precision when printing float values + const unsigned format_precision = 0; + const unsigned format_max_padding = 100; + size_t item_bit_size = item_byte_size * 8; + + if (item_bit_size == ast->getTypeSize(ast->FloatTy)) { + llvm::APInt apint(item_bit_size, + this->GetMaxU64(&offset, item_byte_size)); + llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy), + apint); + apfloat.toString(sv, format_precision, format_max_padding); + } + else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) { + llvm::APInt apint; + if (GetAPInt(*this, &offset, item_byte_size, apint)) { + llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy), + apint); + apfloat.toString(sv, format_precision, format_max_padding); + } + } + else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) { + const auto &semantics = + ast->getFloatTypeSemantics(ast->LongDoubleTy); + const auto byte_size = + (llvm::APFloat::getSizeInBits(semantics) + 7) / 8; + + llvm::APInt apint; + if (GetAPInt(*this, &offset, byte_size, apint)) { + llvm::APFloat apfloat(semantics, apint); + apfloat.toString(sv, format_precision, format_max_padding); + } + } + else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) { + llvm::APInt apint(item_bit_size, this->GetU16(&offset)); + llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy), + apint); + apfloat.toString(sv, format_precision, format_max_padding); + } + + if (!sv.empty()) { + s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data()); + used_apfloat = true; + } + } + } + } + + if (!used_apfloat) { + std::ostringstream ss; + if (item_byte_size == sizeof(float) || item_byte_size == 2) { + float f; + if (item_byte_size == 2) { + uint16_t half = this->GetU16(&offset); + f = half2float(half); + } + else { + f = GetFloat(&offset); + } + ss.precision(std::numeric_limits::digits10); + ss << f; + } + else if (item_byte_size == sizeof(double)) { + ss.precision(std::numeric_limits::digits10); + ss << GetDouble(&offset); + } + else if (item_byte_size == sizeof(long double) || + item_byte_size == 10) { + ss.precision(std::numeric_limits::digits10); + ss << GetLongDouble(&offset); + } + else { + s->Printf("error: unsupported byte size (%" PRIu64 + ") for float format", + (uint64_t)item_byte_size); + return offset; + } + ss.flush(); + s->Printf("%s", ss.str().c_str()); + } + } break; + + case eFormatUnicode16: + s->Printf("U+%4.4x", GetU16(&offset)); + break; + + case eFormatUnicode32: + s->Printf("U+0x%8.8x", GetU32(&offset)); + break; + + case eFormatAddressInfo: { + addr_t addr = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, + item_bit_offset); + s->Printf("0x%*.*" PRIx64, (int)(2 * item_byte_size), + (int)(2 * item_byte_size), addr); + if (exe_scope) { + TargetSP target_sp(exe_scope->CalculateTarget()); + lldb_private::Address so_addr; + if (target_sp) { + if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, + so_addr)) { + s->PutChar(' '); + so_addr.Dump(s, exe_scope, Address::DumpStyleResolvedDescription, + Address::DumpStyleModuleWithFileAddress); + } + else { + so_addr.SetOffset(addr); + so_addr.Dump(s, exe_scope, + Address::DumpStyleResolvedPointerDescription); + } + } + } + } break; + + case eFormatHexFloat: + if (sizeof(float) == item_byte_size) { + char float_cstr[256]; + llvm::APFloat ap_float(GetFloat(&offset)); + ap_float.convertToHexString(float_cstr, 0, false, + llvm::APFloat::rmNearestTiesToEven); + s->Printf("%s", float_cstr); + break; + } + else if (sizeof(double) == item_byte_size) { + char float_cstr[256]; + llvm::APFloat ap_float(GetDouble(&offset)); + ap_float.convertToHexString(float_cstr, 0, false, + llvm::APFloat::rmNearestTiesToEven); + s->Printf("%s", float_cstr); + break; + } + else { + s->Printf("error: unsupported byte size (%" PRIu64 + ") for hex float format", + (uint64_t)item_byte_size); + return offset; + } + break; + + // please keep the single-item formats below in sync with + // FormatManager::GetSingleItemFormat + // if you fail to do so, users will start getting different outputs + // depending on internal + // implementation details they should not care about || + case eFormatVectorOfChar: // || + s->PutChar('{'); // \/ + offset = Dump(s, offset, eFormatCharArray, 1, item_byte_size, + item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfSInt8: + s->PutChar('{'); + offset = Dump(s, offset, eFormatDecimal, 1, item_byte_size, + item_byte_size, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfUInt8: + s->PutChar('{'); + offset = Dump(s, offset, eFormatHex, 1, item_byte_size, item_byte_size, + LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfSInt16: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatDecimal, sizeof(uint16_t), + item_byte_size / sizeof(uint16_t), + item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfUInt16: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatHex, sizeof(uint16_t), + item_byte_size / sizeof(uint16_t), + item_byte_size / sizeof(uint16_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfSInt32: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatDecimal, sizeof(uint32_t), + item_byte_size / sizeof(uint32_t), + item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfUInt32: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatHex, sizeof(uint32_t), + item_byte_size / sizeof(uint32_t), + item_byte_size / sizeof(uint32_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfSInt64: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatDecimal, sizeof(uint64_t), + item_byte_size / sizeof(uint64_t), + item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfUInt64: + s->PutChar('{'); + offset = + Dump(s, offset, eFormatHex, sizeof(uint64_t), + item_byte_size / sizeof(uint64_t), + item_byte_size / sizeof(uint64_t), LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfFloat16: + s->PutChar('{'); + offset = Dump(s, offset, eFormatFloat, 2, item_byte_size / 2, + item_byte_size / 2, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfFloat32: + s->PutChar('{'); + offset = Dump(s, offset, eFormatFloat, 4, item_byte_size / 4, + item_byte_size / 4, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfFloat64: + s->PutChar('{'); + offset = Dump(s, offset, eFormatFloat, 8, item_byte_size / 8, + item_byte_size / 8, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + + case eFormatVectorOfUInt128: + s->PutChar('{'); + offset = Dump(s, offset, eFormatHex, 16, item_byte_size / 16, + item_byte_size / 16, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('}'); + break; + } + } + + if (item_format == eFormatBytesWithASCII && offset > line_start_offset) { + s->Printf("%*s", static_cast( + (num_per_line - (offset - line_start_offset)) * 3 + 2), + ""); + Dump(s, line_start_offset, eFormatCharPrintable, 1, + offset - line_start_offset, SIZE_MAX, LLDB_INVALID_ADDRESS, 0, 0); + } + return offset; // Return the offset at which we ended up +} + +void DataExtractorEx::DumpHexBytes(Stream *s, const void *src, size_t src_len, + uint32_t bytes_per_line, addr_t base_addr) { + DataExtractorEx data(src, src_len, eByteOrderLittle, 4); + data.Dump(s, + 0, // Offset into "src" + eFormatBytes, // Dump as hex bytes + 1, // Size of each item is 1 for single bytes + src_len, // Number of bytes + bytes_per_line, // Num bytes per line + base_addr, // Base address + 0, 0); // Bitfield info +} Index: lldb/source/Core/Event.cpp =================================================================== --- lldb/source/Core/Event.cpp +++ lldb/source/Core/Event.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Broadcaster.h" -#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Event.h" #include "lldb/Core/State.h" #include "lldb/Target/Process.h" @@ -138,7 +138,7 @@ if (num_printable_chars == m_bytes.size()) { s->Printf("\"%s\"", m_bytes.c_str()); } else if (!m_bytes.empty()) { - DataExtractor data; + DataExtractorEx data; data.SetData(m_bytes.data(), m_bytes.size(), endian::InlHostByteOrder()); data.Dump(s, 0, eFormatBytes, 1, m_bytes.size(), 32, LLDB_INVALID_ADDRESS, 0, 0); Index: lldb/source/Core/RegisterValue.cpp =================================================================== --- lldb/source/Core/RegisterValue.cpp +++ lldb/source/Core/RegisterValue.cpp @@ -19,6 +19,7 @@ // Project includes #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Scalar.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" @@ -33,7 +34,7 @@ bool prefix_with_name, bool prefix_with_alt_name, Format format, uint32_t reg_name_right_align_at) const { - DataExtractor data; + DataExtractorEx data; if (GetData(data)) { bool name_printed = false; // For simplicity, alignment of the register name printing applies only Index: lldb/source/DataFormatters/TypeFormat.cpp =================================================================== --- lldb/source/DataFormatters/TypeFormat.cpp +++ lldb/source/DataFormatters/TypeFormat.cpp @@ -19,6 +19,8 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/SymbolContext.h" @@ -49,7 +51,7 @@ Value &value(valobj->GetValue()); const Value::ContextType context_type = value.GetContextType(); ExecutionContext exe_ctx(valobj->GetExecutionContextRef()); - DataExtractor data; + DataExtractorEx data; if (context_type == Value::eContextTypeRegisterInfo) { const RegisterInfo *reg_info = value.GetRegisterInfo(); @@ -182,7 +184,7 @@ valobj_enum_type = iter->second; if (valobj_enum_type.IsValid() == false) return false; - DataExtractor data; + DataExtractorEx data; Error error; valobj->GetData(data, error); if (error.Fail()) Index: lldb/source/Expression/Materializer.cpp =================================================================== --- lldb/source/Expression/Materializer.cpp +++ lldb/source/Expression/Materializer.cpp @@ -12,6 +12,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Expression/Materializer.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectVariable.h" @@ -370,7 +371,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -398,7 +399,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -708,7 +709,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -739,7 +740,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -978,7 +979,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -1009,7 +1010,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -1146,7 +1147,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), @@ -1322,7 +1323,7 @@ if (!err.Success()) { dump_stream.Printf(" \n"); } else { - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), + DataExtractorEx extractor(data.GetBytes(), data.GetByteSize(), map.GetByteOrder(), map.GetAddressByteSize()); extractor.DumpHexBytes(&dump_stream, data.GetBytes(), Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -17,6 +17,7 @@ #include "RenderScriptScriptGroup.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/ValueObjectVariable.h" @@ -3359,7 +3360,7 @@ // Use data extractor to format output const uint32_t target_ptr_size = GetProcess()->GetTarget().GetArchitecture().GetAddressByteSize(); - DataExtractor alloc_data(buffer.get(), size, GetProcess()->GetByteOrder(), + DataExtractorEx alloc_data(buffer.get(), size, GetProcess()->GetByteOrder(), target_ptr_size); uint32_t offset = 0; // Offset in buffer to next element to be printed Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h @@ -11,18 +11,18 @@ #define liblldb_DWARFDataExtractor_h_ // Other libraries and framework includes. -#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/dwarf.h" namespace lldb_private { -class DWARFDataExtractor : public lldb_private::DataExtractor { +class DWARFDataExtractor : public lldb_private::DataExtractorEx { public: - DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {} + DWARFDataExtractor() : DataExtractorEx(), m_is_dwarf64(false) {} DWARFDataExtractor(const DWARFDataExtractor &data, lldb::offset_t offset, lldb::offset_t length) - : DataExtractor(data, offset, length), m_is_dwarf64(false) {} + : DataExtractorEx(data, offset, length), m_is_dwarf64(false) {} uint64_t GetDWARFInitialLength(lldb::offset_t *offset_ptr) const; Index: lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp =================================================================== --- lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -12,7 +12,7 @@ #include "lldb/Core/Address.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/PluginManager.h" @@ -398,7 +398,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory( EmulateInstruction *instruction, const EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t dst_len) { - DataExtractor data(dst, dst_len, + DataExtractorEx data(dst, dst_len, instruction->GetArchitecture().GetByteOrder(), instruction->GetArchitecture().GetAddressByteSize()); Index: lldb/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/source/Symbol/ClangASTContext.cpp +++ lldb/source/Symbol/ClangASTContext.cpp @@ -73,6 +73,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Utility/Flags.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Scalar.h" @@ -8826,7 +8827,7 @@ void ClangASTContext::DumpValue( lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, - lldb::Format format, const lldb_private::DataExtractor &data, + lldb::Format format, const lldb_private::DataExtractorEx &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, bool show_summary, bool verbose, uint32_t depth) { @@ -9202,7 +9203,7 @@ bool ClangASTContext::DumpTypeValue( lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, - const lldb_private::DataExtractor &data, lldb::offset_t byte_offset, + const lldb_private::DataExtractorEx &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) { if (!type) @@ -9369,7 +9370,7 @@ else buf.resize(256); - lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), + lldb_private::DataExtractorEx cstr_data(&buf.front(), buf.size(), process->GetByteOrder(), 4); buf.back() = '\0'; size_t bytes_read; Index: lldb/source/Symbol/CompilerType.cpp =================================================================== --- lldb/source/Symbol/CompilerType.cpp +++ lldb/source/Symbol/CompilerType.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/StreamFile.h" @@ -745,7 +746,7 @@ void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, - const lldb_private::DataExtractor &data, + const lldb_private::DataExtractorEx &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, @@ -759,7 +760,7 @@ } bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format, - const lldb_private::DataExtractor &data, + const lldb_private::DataExtractorEx &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, @@ -772,7 +773,7 @@ } void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s, - const lldb_private::DataExtractor &data, + const lldb_private::DataExtractorEx &data, lldb::offset_t data_byte_offset, size_t data_byte_size) { if (IsValid()) Index: lldb/source/Symbol/GoASTContext.cpp =================================================================== --- lldb/source/Symbol/GoASTContext.cpp +++ lldb/source/Symbol/GoASTContext.cpp @@ -11,6 +11,7 @@ #include #include +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" @@ -1065,7 +1066,7 @@ void GoASTContext::DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, - lldb::Format format, const DataExtractor &data, + lldb::Format format, const DataExtractorEx &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, @@ -1182,7 +1183,7 @@ } bool GoASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, - lldb::Format format, const DataExtractor &data, + lldb::Format format, const DataExtractorEx &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, Index: lldb/source/Symbol/JavaASTContext.cpp =================================================================== --- lldb/source/Symbol/JavaASTContext.cpp +++ lldb/source/Symbol/JavaASTContext.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" @@ -991,7 +992,7 @@ void JavaASTContext::DumpValue( lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, - lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, + lldb::Format format, const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) { @@ -1000,7 +1001,7 @@ bool JavaASTContext::DumpTypeValue( lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, - const DataExtractor &data, lldb::offset_t data_offset, + const DataExtractorEx &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) { if (IsScalarType(type)) { Index: lldb/source/Symbol/OCamlASTContext.cpp =================================================================== --- lldb/source/Symbol/OCamlASTContext.cpp +++ lldb/source/Symbol/OCamlASTContext.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/OCamlASTContext.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" @@ -595,7 +596,7 @@ void OCamlASTContext::DumpValue( lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, - lldb::Format format, const DataExtractor &data, + lldb::Format format, const DataExtractorEx &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, bool show_summary, bool verbose, uint32_t depth) { @@ -612,7 +613,7 @@ bool OCamlASTContext::DumpTypeValue( lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format, - const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size, + const DataExtractorEx &data, lldb::offset_t byte_offset, size_t byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope) { if (!type) { Index: lldb/source/Symbol/Type.cpp =================================================================== --- lldb/source/Symbol/Type.cpp +++ lldb/source/Symbol/Type.cpp @@ -15,6 +15,7 @@ // Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/DataExtractorEx.h" #include "lldb/Core/Module.h" #include "lldb/Core/Scalar.h" #include "lldb/Utility/StreamString.h" @@ -283,7 +284,7 @@ void Type::DumpTypeName(Stream *s) { GetName().Dump(s, ""); } void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s, - const DataExtractor &data, uint32_t data_byte_offset, + const DataExtractorEx &data, uint32_t data_byte_offset, bool show_types, bool show_summary, bool verbose, lldb::Format format) { if (ResolveClangType(eResolveStateForward)) { @@ -370,7 +371,7 @@ lldb::addr_t address, AddressType address_type, bool show_types, bool show_summary, bool verbose) { if (address != LLDB_INVALID_ADDRESS) { - DataExtractor data; + DataExtractorEx data; Target *target = nullptr; if (exe_ctx) target = exe_ctx->GetTargetPtr();