From 16064d354afba2cbfd8826c96e8f3b575977df9d Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 20 Mar 2018 11:56:24 +0000 Subject: Re-land: [lldb] Use vFlash commands when writing to target's flash memory regions The difference between this and the previous patch is that now we use ELF physical addresses only for loading objects into the target (and the rest of the module load address logic still uses virtual addresses). Summary: When writing an object file over gdb-remote, use the vFlashErase, vFlashWrite, and vFlashDone commands if the write address is in a flash memory region. A bare metal target may have this kind of setup. - Update ObjectFileELF to set load addresses using physical addresses. A typical case may be a data section with a physical address in ROM and a virtual address in RAM, which should be loaded to the ROM address. - Add support for querying the target's qXfer:memory-map, which contains information about flash memory regions, leveraging MemoryRegionInfo data structures with minor modifications - Update ProcessGDBRemote to use vFlash commands in DoWriteMemory when the target address is in a flash region Original discussion at http://lists.llvm.org/pipermail/lldb-dev/2018-January/013093.html Reviewers: clayborg, labath Reviewed By: labath Subscribers: llvm-commits, arichardson, emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D42145 Patch by Owen Shaw . llvm-svn: 327970 --- lldb/source/Target/Process.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lldb/source/Target/Process.cpp') diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index c40894b357d..e9809d5bada 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2533,6 +2533,17 @@ size_t Process::ReadScalarIntegerFromMemory(addr_t addr, uint32_t byte_size, return 0; } +Status Process::WriteObjectFile(std::vector entries) { + Status error; + for (const auto &Entry : entries) { + WriteMemory(Entry.Dest, Entry.Contents.data(), Entry.Contents.size(), + error); + if (!error.Success()) + break; + } + return error; +} + #define USE_ALLOCATE_MEMORY_CACHE 1 addr_t Process::AllocateMemory(size_t size, uint32_t permissions, Status &error) { -- cgit v1.2.3