From f1b117394d7f9ae6decf9730ed9d443ca1b54769 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Wed, 27 Nov 2019 09:46:56 +0100 Subject: [PATCH] [lldb][NFC] Remove unused CompilerType memory functions Summary: All these functions are unused from what I can see. Unless I'm missing something here, this code can go the way of the Dodo. Reviewers: labath Reviewed By: labath Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70770 --- lldb/include/lldb/Symbol/CompilerType.h | 8 -- lldb/source/Symbol/CompilerType.cpp | 167 -------------------------------- 2 files changed, 175 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index cedd252..91d9c5e 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -357,14 +357,6 @@ public: bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value) const; - bool SetValueFromScalar(const Scalar &value, Stream &strm); - - bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr, - AddressType address_type, DataExtractor &data); - - bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr, - AddressType address_type, StreamString &new_value); - void Clear() { m_type = nullptr; m_type_system = nullptr; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 571a857..d352131 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -874,173 +874,6 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data, return false; } -bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) { - if (!IsValid()) - return false; - - // Aggregate types don't have scalar values - if (!IsAggregateType()) { - strm.GetFlags().Set(Stream::eBinary); - uint64_t count = 0; - lldb::Encoding encoding = GetEncoding(count); - - if (encoding == lldb::eEncodingInvalid || count != 1) - return false; - - llvm::Optional bit_width = GetBitSize(nullptr); - if (!bit_width) - return false; - - // This function doesn't currently handle non-byte aligned assignments - if ((*bit_width % 8) != 0) - return false; - - const uint64_t byte_size = (*bit_width + 7) / 8; - switch (encoding) { - case lldb::eEncodingInvalid: - break; - case lldb::eEncodingVector: - break; - case lldb::eEncodingUint: - switch (byte_size) { - case 1: - strm.PutHex8(value.UInt()); - return true; - case 2: - strm.PutHex16(value.UInt()); - return true; - case 4: - strm.PutHex32(value.UInt()); - return true; - case 8: - strm.PutHex64(value.ULongLong()); - return true; - default: - break; - } - break; - - case lldb::eEncodingSint: - switch (byte_size) { - case 1: - strm.PutHex8(value.SInt()); - return true; - case 2: - strm.PutHex16(value.SInt()); - return true; - case 4: - strm.PutHex32(value.SInt()); - return true; - case 8: - strm.PutHex64(value.SLongLong()); - return true; - default: - break; - } - break; - - case lldb::eEncodingIEEE754: - if (byte_size <= sizeof(long double)) { - if (byte_size == sizeof(float)) { - strm.PutFloat(value.Float()); - return true; - } else if (byte_size == sizeof(double)) { - strm.PutDouble(value.Double()); - return true; - } else if (byte_size == sizeof(long double)) { - strm.PutDouble(value.LongDouble()); - return true; - } - } - break; - } - } - return false; -} - -bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx, - lldb::addr_t addr, AddressType address_type, - lldb_private::DataExtractor &data) { - if (!IsValid()) - return false; - - // Can't convert a file address to anything valid without more context (which - // Module it came from) - if (address_type == eAddressTypeFile) - return false; - - if (!GetCompleteType()) - return false; - - auto byte_size = - GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr); - if (!byte_size) - return false; - - if (data.GetByteSize() < *byte_size) { - lldb::DataBufferSP data_sp(new DataBufferHeap(*byte_size, '\0')); - data.SetData(data_sp); - } - - uint8_t *dst = const_cast(data.PeekData(0, *byte_size)); - if (dst != nullptr) { - if (address_type == eAddressTypeHost) { - if (addr == 0) - return false; - // The address is an address in this process, so just copy it - memcpy(dst, reinterpret_cast(addr), *byte_size); - return true; - } else { - Process *process = nullptr; - if (exe_ctx) - process = exe_ctx->GetProcessPtr(); - if (process) { - Status error; - return process->ReadMemory(addr, dst, *byte_size, error) == *byte_size; - } - } - } - return false; -} - -bool CompilerType::WriteToMemory(lldb_private::ExecutionContext *exe_ctx, - lldb::addr_t addr, AddressType address_type, - StreamString &new_value) { - if (!IsValid()) - return false; - - // Can't convert a file address to anything valid without more context (which - // Module it came from) - if (address_type == eAddressTypeFile) - return false; - - if (!GetCompleteType()) - return false; - - auto byte_size = - GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr); - if (!byte_size) - return false; - - if (*byte_size > 0) { - if (address_type == eAddressTypeHost) { - // The address is an address in this process, so just copy it - memcpy((void *)addr, new_value.GetData(), *byte_size); - return true; - } else { - Process *process = nullptr; - if (exe_ctx) - process = exe_ctx->GetProcessPtr(); - if (process) { - Status error; - return process->WriteMemory(addr, new_value.GetData(), *byte_size, - error) == *byte_size; - } - } - } - return false; -} - bool lldb_private::operator==(const lldb_private::CompilerType &lhs, const lldb_private::CompilerType &rhs) { return lhs.GetTypeSystem() == rhs.GetTypeSystem() && -- 2.7.4