[Lldb-commits] [lldb] f1b1173 - [lldb][NFC] Remove unused CompilerType memory functions
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Wed Nov 27 00:52:13 PST 2019
Author: Raphael Isemann
Date: 2019-11-27T09:51:50+01:00
New Revision: f1b117394d7f9ae6decf9730ed9d443ca1b54769
URL: https://github.com/llvm/llvm-project/commit/f1b117394d7f9ae6decf9730ed9d443ca1b54769
DIFF: https://github.com/llvm/llvm-project/commit/f1b117394d7f9ae6decf9730ed9d443ca1b54769.diff
LOG: [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
Added:
Modified:
lldb/include/lldb/Symbol/CompilerType.h
lldb/source/Symbol/CompilerType.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index cedd2523a5a8..91d9c5e48d20 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -357,14 +357,6 @@ class CompilerType {
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 571a8570a43b..d35213120b4d 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<uint64_t> 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<uint8_t *>(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<uint8_t *>(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() &&
More information about the lldb-commits
mailing list