From: Jonas Devlieghere Date: Fri, 8 Jan 2021 04:54:30 +0000 (-0800) Subject: [lldb] Make DoReadMemory a protected method. X-Git-Tag: llvmorg-13-init~1753 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57e0cd356287321c4847a9e0a9177516dae0cbc1;p=platform%2Fupstream%2Fllvm.git [lldb] Make DoReadMemory a protected method. DoReadMemory is LLDB's internal implementation and shouldn't be called directly. Differential revision: https://reviews.llvm.org/D94284 --- diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index e8dd884..6f30787 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1414,35 +1414,6 @@ public: /// this process. virtual bool WarnBeforeDetach() const { return true; } - /// Actually do the reading of memory from a process. - /// - /// Subclasses must override this function and can return fewer bytes than - /// requested when memory requests are too large. This class will break up - /// the memory requests and keep advancing the arguments along as needed. - /// - /// \param[in] vm_addr - /// A virtual load address that indicates where to start reading - /// memory from. - /// - /// \param[in] size - /// The number of bytes to read. - /// - /// \param[out] buf - /// A byte buffer that is at least \a size bytes long that - /// will receive the memory bytes. - /// - /// \param[out] error - /// An error that indicates the success or failure of this - /// operation. If error indicates success (error.Success()), - /// then the value returned can be trusted, otherwise zero - /// will be returned. - /// - /// \return - /// The number of bytes that were actually read into \a buf. - /// Zero is returned in the case of an error. - virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, - Status &error) = 0; - /// Read of memory from a process. /// /// This function will read memory from the current process's address space @@ -2570,6 +2541,35 @@ void PruneThreadPlans(); bool trap_exceptions = false); protected: + /// Actually do the reading of memory from a process. + /// + /// Subclasses must override this function and can return fewer bytes than + /// requested when memory requests are too large. This class will break up + /// the memory requests and keep advancing the arguments along as needed. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. + /// Zero is returned in the case of an error. + virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + Status &error) = 0; + void SetState(lldb::EventSP &event_sp); lldb::StateType GetPrivateState(); diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index d0d5a99..fd1916d 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -400,7 +400,7 @@ DynamicLoaderDarwinKernel::ReadMachHeader(addr_t addr, Process *process, llvm::M *read_error = false; // Read the mach header and see whether it looks like a kernel - if (process->DoReadMemory (addr, &header, sizeof(header), error) != + if (process->ReadMemory(addr, &header, sizeof(header), error) != sizeof(header)) { if (read_error) *read_error = true; @@ -790,7 +790,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule( // For the kernel, we really do need an on-disk file copy of the binary // to do anything useful. This will force a call to dsymForUUID if it - // exists, instead of depending on the DebugSymbols preferences being + // exists, instead of depending on the DebugSymbols preferences being // set. if (IsKernel()) { if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) { diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp index af76056..5e2a866 100644 --- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp +++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp @@ -246,7 +246,7 @@ std::string HexagonDYLDRendezvous::ReadStringFromMemory(addr_t addr) { return std::string(); for (;;) { - size = m_process->DoReadMemory(addr, &c, 1, error); + size = m_process->ReadMemory(addr, &c, 1, error); if (size != 1 || error.Fail()) return std::string(); if (c == 0) diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index cbeef60..16c474f 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -291,8 +291,8 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) { jit_descriptor jit_desc; const size_t jit_desc_size = sizeof(jit_desc); Status error; - size_t bytes_read = m_process->DoReadMemory(m_jit_descriptor_addr, &jit_desc, - jit_desc_size, error); + size_t bytes_read = m_process->ReadMemory(m_jit_descriptor_addr, &jit_desc, + jit_desc_size, error); if (bytes_read != jit_desc_size || !error.Success()) { LLDB_LOGF(log, "JITLoaderGDB::%s failed to read JIT descriptor", __FUNCTION__);