From 0863f6757953684400162f2ad418f3e8e28af278 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 18 Feb 2020 10:37:04 +0100 Subject: [PATCH] [lldb] Remove DataExtractor::GetPointer This function is equivalent to GetAddress, but getAddress is also present on the llvm version of the data extractor. --- lldb/include/lldb/Utility/DataExtractor.h | 21 +-------------------- lldb/source/Core/ValueObject.cpp | 2 +- lldb/source/Core/ValueObjectDynamicValue.cpp | 2 +- lldb/source/Expression/DWARFExpression.cpp | 2 +- lldb/source/Expression/Materializer.cpp | 4 ++-- .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp | 14 +++++++------- lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp | 6 +++--- .../ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp | 4 ++-- .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp | 2 +- .../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 4 ++-- .../AppleObjCTrampolineHandler.cpp | 4 ++-- .../Process/MacOSX-Kernel/CommunicationKDP.cpp | 2 +- .../Plugins/Process/elf-core/ThreadElfCore.cpp | 22 +++++++++++----------- .../SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp | 14 +++++++------- .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 2 +- lldb/source/Symbol/DWARFCallFrameInfo.cpp | 2 +- lldb/source/Utility/DataExtractor.cpp | 11 ----------- 17 files changed, 44 insertions(+), 74 deletions(-) diff --git a/lldb/include/lldb/Utility/DataExtractor.h b/lldb/include/lldb/Utility/DataExtractor.h index 7f09b71..8f82ae5 100644 --- a/lldb/include/lldb/Utility/DataExtractor.h +++ b/lldb/include/lldb/Utility/DataExtractor.h @@ -573,24 +573,6 @@ public: uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset) const; - /// Extract an pointer from \a *offset_ptr. - /// - /// Extract a single pointer from the data and update the offset pointed to - /// by \a offset_ptr. The size of the extracted pointer comes from the \a - /// m_addr_size member variable and should be set correctly prior to - /// extracting any pointer values. - /// - /// \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. - /// - /// \return - /// The extracted pointer value as a 64 integer. - uint64_t GetPointer(lldb::offset_t *offset_ptr) const; - /// Get the current byte order value. /// /// \return @@ -1003,8 +985,7 @@ protected: *m_end; ///< A pointer to the byte that is past the end of the data. lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from. - uint32_t m_addr_size; ///< The address size to use when extracting pointers or - /// addresses + uint32_t m_addr_size; ///< The address size to use when extracting addresses. /// The shared pointer to data that can be shared among multiple instances lldb::DataBufferSP m_data_sp; const uint32_t m_target_byte_size; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 71ceef7..e1d0ca9 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1551,7 +1551,7 @@ addr_t ValueObject::GetPointerValue(AddressType *address_type) { case Value::eValueTypeLoadAddress: case Value::eValueTypeFileAddress: { lldb::offset_t data_offset = 0; - address = m_data.GetPointer(&data_offset); + address = m_data.GetAddress(&data_offset); } break; } diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index 149984d..ca66740 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -327,7 +327,7 @@ bool ValueObjectDynamicValue::SetData(DataExtractor &data, Status &error) { // but NULL'ing out a value should always be allowed lldb::offset_t offset = 0; - if (data.GetPointer(&offset) != 0) { + if (data.GetAddress(&offset) != 0) { error.SetErrorString( "unable to modify dynamic value, use 'expression' command"); return false; diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 849c96d..7f12d06 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -1182,7 +1182,7 @@ bool DWARFExpression::Evaluate( break; default: stack.back().GetScalar() = - addr_data.GetPointer(&addr_data_offset); + addr_data.GetAddress(&addr_data_offset); } stack.back().ClearContext(); } else { diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 0d210ca..33c061e 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -698,7 +698,7 @@ public: lldb::offset_t offset; - ptr = extractor.GetPointer(&offset); + ptr = extractor.GetAddress(&offset); dump_stream.PutChar('\n'); } @@ -972,7 +972,7 @@ public: lldb::offset_t offset; - ptr = extractor.GetPointer(&offset); + ptr = extractor.GetAddress(&offset); dump_stream.PutChar('\n'); } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index a6db648..d425b35 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -481,17 +481,17 @@ bool DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure() { offset = 0; m_dyld_all_image_infos.version = data.GetU32(&offset); m_dyld_all_image_infos.dylib_info_count = data.GetU32(&offset); - m_dyld_all_image_infos.dylib_info_addr = data.GetPointer(&offset); - m_dyld_all_image_infos.notification = data.GetPointer(&offset); + m_dyld_all_image_infos.dylib_info_addr = data.GetAddress(&offset); + m_dyld_all_image_infos.notification = data.GetAddress(&offset); m_dyld_all_image_infos.processDetachedFromSharedRegion = data.GetU8(&offset); m_dyld_all_image_infos.libSystemInitialized = data.GetU8(&offset); // Adjust for padding. offset += addr_size - 2; - m_dyld_all_image_infos.dyldImageLoadAddress = data.GetPointer(&offset); + m_dyld_all_image_infos.dyldImageLoadAddress = data.GetAddress(&offset); if (m_dyld_all_image_infos.version >= 11) { offset += addr_size * 8; - uint64_t dyld_all_image_infos_addr = data.GetPointer(&offset); + uint64_t dyld_all_image_infos_addr = data.GetAddress(&offset); // When we started, we were given the actual address of the // all_image_infos struct (probably via TASK_DYLD_INFO) in memory - @@ -671,9 +671,9 @@ bool DynamicLoaderMacOSXDYLD::ReadImageInfos( for (size_t i = 0; i < image_infos.size() && info_data_ref.ValidOffset(info_data_offset); i++) { - image_infos[i].address = info_data_ref.GetPointer(&info_data_offset); - lldb::addr_t path_addr = info_data_ref.GetPointer(&info_data_offset); - image_infos[i].mod_date = info_data_ref.GetPointer(&info_data_offset); + image_infos[i].address = info_data_ref.GetAddress(&info_data_offset); + lldb::addr_t path_addr = info_data_ref.GetAddress(&info_data_offset); + image_infos[i].mod_date = info_data_ref.GetAddress(&info_data_offset); char raw_path[PATH_MAX]; m_process->ReadCStringFromMemory(path_addr, raw_path, sizeof(raw_path), diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index df9f700..cbeef60 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -134,9 +134,9 @@ bool ReadJITEntry(const addr_t from_addr, Process *process, DataExtractor extractor(data.GetBytes(), data.GetByteSize(), process->GetByteOrder(), sizeof(ptr_t)); lldb::offset_t offset = 0; - entry->next_entry = extractor.GetPointer(&offset); - entry->prev_entry = extractor.GetPointer(&offset); - entry->symfile_addr = extractor.GetPointer(&offset); + entry->next_entry = extractor.GetAddress(&offset); + entry->prev_entry = extractor.GetAddress(&offset); + entry->symfile_addr = extractor.GetAddress(&offset); offset = llvm::alignTo(offset, uint64_align_bytes); entry->symfile_size = extractor.GetU64(&offset); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index cca6911..0fe0d92 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -538,8 +538,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException( if (error.Fail()) return ThreadSP(); lldb::offset_t data_offset = 0; - auto dict_entry_key = data.GetPointer(&data_offset); - auto dict_entry_value = data.GetPointer(&data_offset); + auto dict_entry_key = data.GetAddress(&data_offset); + auto dict_entry_value = data.GetAddress(&data_offset); auto key_nsstring = objc_object_from_address(dict_entry_key, "key"); StreamString key_summary; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index 3d3c69a..46b0cbc 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -362,7 +362,7 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() { lldb::offset_t offset = addr_size; // Skip prototype const uint32_t count = data.GetU32(&offset); const uint32_t num_buckets = data.GetU32(&offset); - const addr_t buckets_ptr = data.GetPointer(&offset); + const addr_t buckets_ptr = data.GetAddress(&offset); if (m_hash_signature.NeedsUpdate(count, num_buckets, buckets_ptr)) { m_hash_signature.UpdateSignature(count, num_buckets, buckets_ptr); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 0f89550..50b5f2e2 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1497,7 +1497,7 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data, // Iterate through all ClassInfo structures lldb::offset_t offset = 0; for (uint32_t i = 0; i < num_class_infos; ++i) { - ObjCISA isa = data.GetPointer(&offset); + ObjCISA isa = data.GetAddress(&offset); if (isa == 0) { if (should_log) @@ -2548,7 +2548,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( lldb::offset_t offset = 0; for (unsigned i = 0; i != num_new_classes; ++i) - m_indexed_isa_cache.push_back(data.GetPointer(&offset)); + m_indexed_isa_cache.push_back(data.GetAddress(&offset)); } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 9b5e677..0fe9dc3 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -318,7 +318,7 @@ void AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::SetUpRegion() { const uint16_t descriptor_size = data.GetU16(&offset); const size_t num_descriptors = data.GetU32(&offset); - m_next_region = data.GetPointer(&offset); + m_next_region = data.GetAddress(&offset); // If the header size is 0, that means we've come in too early before this // data is set up. @@ -547,7 +547,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines( error = argument_values.GetValueAtIndex(0)->GetValueAsData(&exe_ctx, data, nullptr); lldb::offset_t offset = 0; - lldb::addr_t region_addr = data.GetPointer(&offset); + lldb::addr_t region_addr = data.GetAddress(&offset); if (region_addr != 0) vtable_handler->ReadRegions(region_addr); diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 7b36c5d..d8b3b04 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -788,7 +788,7 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) { const uint32_t region_count = packet.GetU32(&offset); s.Printf(" (count = %u", region_count); for (uint32_t i = 0; i < region_count; ++i) { - const addr_t region_addr = packet.GetPointer(&offset); + const addr_t region_addr = packet.GetAddress(&offset); const uint32_t region_size = packet.GetU32(&offset); const uint32_t region_prot = packet.GetU32(&offset); s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64 diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp index 8975337..c3ae95a 100644 --- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -296,25 +296,25 @@ Status ELFLinuxPrStatus::Parse(const DataExtractor &data, pr_cursig = data.GetU16(&offset); offset += 2; // pad - pr_sigpend = data.GetPointer(&offset); - pr_sighold = data.GetPointer(&offset); + pr_sigpend = data.GetAddress(&offset); + pr_sighold = data.GetAddress(&offset); pr_pid = data.GetU32(&offset); pr_ppid = data.GetU32(&offset); pr_pgrp = data.GetU32(&offset); pr_sid = data.GetU32(&offset); - pr_utime.tv_sec = data.GetPointer(&offset); - pr_utime.tv_usec = data.GetPointer(&offset); + pr_utime.tv_sec = data.GetAddress(&offset); + pr_utime.tv_usec = data.GetAddress(&offset); - pr_stime.tv_sec = data.GetPointer(&offset); - pr_stime.tv_usec = data.GetPointer(&offset); + pr_stime.tv_sec = data.GetAddress(&offset); + pr_stime.tv_usec = data.GetAddress(&offset); - pr_cutime.tv_sec = data.GetPointer(&offset); - pr_cutime.tv_usec = data.GetPointer(&offset); + pr_cutime.tv_sec = data.GetAddress(&offset); + pr_cutime.tv_usec = data.GetAddress(&offset); - pr_cstime.tv_sec = data.GetPointer(&offset); - pr_cstime.tv_usec = data.GetPointer(&offset); + pr_cstime.tv_sec = data.GetAddress(&offset); + pr_cstime.tv_usec = data.GetAddress(&offset); return error; } @@ -367,7 +367,7 @@ Status ELFLinuxPrPsInfo::Parse(const DataExtractor &data, offset += 4; } - pr_flag = data.GetPointer(&offset); + pr_flag = data.GetAddress(&offset); if (arch.IsMIPS()) { // The pr_uid and pr_gid is always 32 bit irrespective of platforms diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 25db5fe..50f53e5 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -795,8 +795,8 @@ SystemRuntimeMacOSX::GetPendingItemRefsForQueue(lldb::addr_t queue) { static_cast(i) < pending_items_pointer.count) { offset = start_of_array_offset + (i * item_size); ItemRefAndCodeAddress item; - item.item_ref = extractor.GetPointer(&offset); - item.code_address = extractor.GetPointer(&offset); + item.item_ref = extractor.GetAddress(&offset); + item.code_address = extractor.GetAddress(&offset); pending_item_refs.item_refs_and_code_addresses.push_back(item); i++; } @@ -806,7 +806,7 @@ SystemRuntimeMacOSX::GetPendingItemRefsForQueue(lldb::addr_t queue) { while (offset < pending_items_pointer.items_buffer_size && static_cast(i) < pending_items_pointer.count) { ItemRefAndCodeAddress item; - item.item_ref = extractor.GetPointer(&offset); + item.item_ref = extractor.GetAddress(&offset); item.code_address = LLDB_INVALID_ADDRESS; pending_item_refs.item_refs_and_code_addresses.push_back(item); i++; @@ -913,7 +913,7 @@ void SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR( uint32_t offset_to_next = extractor.GetU32(&offset); offset += 4; // Skip over the 4 bytes of reserved space - addr_t queue = extractor.GetPointer(&offset); + addr_t queue = extractor.GetAddress(&offset); uint64_t serialnum = extractor.GetU64(&offset); uint32_t running_work_items_count = extractor.GetU32(&offset); uint32_t pending_work_items_count = extractor.GetU32(&offset); @@ -954,8 +954,8 @@ SystemRuntimeMacOSX::ItemInfo SystemRuntimeMacOSX::ExtractItemInfoFromBuffer( offset_t offset = 0; - item.item_that_enqueued_this = extractor.GetPointer(&offset); - item.function_or_block = extractor.GetPointer(&offset); + item.item_that_enqueued_this = extractor.GetAddress(&offset); + item.function_or_block = extractor.GetAddress(&offset); item.enqueuing_thread_id = extractor.GetU64(&offset); item.enqueuing_queue_serialnum = extractor.GetU64(&offset); item.target_queue_serialnum = extractor.GetU64(&offset); @@ -965,7 +965,7 @@ SystemRuntimeMacOSX::ItemInfo SystemRuntimeMacOSX::ExtractItemInfoFromBuffer( offset = m_lib_backtrace_recording_info.item_info_data_offset; for (uint32_t i = 0; i < item.enqueuing_callstack_frame_count; i++) { - item.enqueuing_callstack.push_back(extractor.GetPointer(&offset)); + item.enqueuing_callstack.push_back(extractor.GetAddress(&offset)); } item.enqueuing_thread_label = extractor.GetCStr(&offset); item.enqueuing_queue_label = extractor.GetCStr(&offset); diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 475c927..275911a 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -240,7 +240,7 @@ static lldb::addr_t GetVTableAddress(Process &process, if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size) return LLDB_INVALID_ADDRESS; - return data.GetPointer(&vbtable_ptr_offset); + return data.GetAddress(&vbtable_ptr_offset); } static int64_t ReadVBaseOffsetFromVTable(Process &process, diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index 707e263..3111c33 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -690,7 +690,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, UnwindPlan::Row *newrow = new UnwindPlan::Row; *newrow = *row.get(); row.reset(newrow); - row->SetOffset(m_cfi_data.GetPointer(&offset) - + row->SetOffset(m_cfi_data.GetAddress(&offset) - startaddr.GetFileAddress()); break; } diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp index da88620..fd4b764 100644 --- a/lldb/source/Utility/DataExtractor.cpp +++ b/lldb/source/Utility/DataExtractor.cpp @@ -689,17 +689,6 @@ uint64_t DataExtractor::GetAddress_unchecked(offset_t *offset_ptr) const { return GetMaxU64_unchecked(offset_ptr, m_addr_size); } -// Extract a single pointer from the data and update the offset pointed to by -// "offset_ptr". The size of the extracted pointer comes from the -// "this->m_addr_size" member variable and should be set correctly prior to -// extracting any pointer values. -// -// RETURNS the pointer that was extracted, or zero on failure. -uint64_t DataExtractor::GetPointer(offset_t *offset_ptr) const { - assert(m_addr_size == 4 || m_addr_size == 8); - return GetMaxU64(offset_ptr, m_addr_size); -} - size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length, ByteOrder dst_byte_order, void *dst) const { const uint8_t *src = PeekData(offset, length); -- 2.7.4