summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-03-20 11:56:24 +0000
committerPavel Labath <labath@google.com>2018-03-20 11:56:24 +0000
commit16064d354afba2cbfd8826c96e8f3b575977df9d (patch)
treeb486a229b286d08601731e166ce88f45bb2f2b2d /lldb/packages/Python/lldbsuite/test
parent3ce2d7f270380bd7573611f6211b8f4ae6af842d (diff)
downloadbcm5719-llvm-16064d354afba2cbfd8826c96e8f3b575977df9d.tar.gz
bcm5719-llvm-16064d354afba2cbfd8826c96e8f3b575977df9d.zip
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@owenpshaw.net>. llvm-svn: 327970
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py61
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py4
2 files changed, 63 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
new file mode 100644
index 00000000000..cce19a3bfa7
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
@@ -0,0 +1,61 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestGDBRemoteLoad(GDBRemoteTestBase):
+
+ def test_ram_load(self):
+ """Test loading an object file to a target's ram"""
+ target = self.createTarget("a.yaml")
+ process = self.connect(target)
+ self.dbg.HandleCommand("target modules load -l -s0")
+ self.assertPacketLogContains([
+ "M1000,4:c3c3c3c3",
+ "M1004,2:3232"
+ ])
+
+ @skipIfXmlSupportMissing
+ def test_flash_load(self):
+ """Test loading an object file to a target's flash memory"""
+
+ class Responder(MockGDBServerResponder):
+ def qSupported(self, client_supported):
+ return "PacketSize=3fff;QStartNoAckMode+;qXfer:memory-map:read+"
+
+ def qXferRead(self, obj, annex, offset, length):
+ if obj == "memory-map":
+ return (self.MEMORY_MAP[offset:offset + length],
+ offset + length < len(self.MEMORY_MAP))
+ return None, False
+
+ def other(self, packet):
+ if packet[0:11] == "vFlashErase":
+ return "OK"
+ if packet[0:11] == "vFlashWrite":
+ return "OK"
+ if packet == "vFlashDone":
+ return "OK"
+ return ""
+
+ MEMORY_MAP = """<?xml version="1.0"?>
+<memory-map>
+ <memory type="ram" start="0x0" length="0x1000"/>
+ <memory type="flash" start="0x1000" length="0x1000">
+ <property name="blocksize">0x100</property>
+ </memory>
+ <memory type="ram" start="0x2000" length="0x1D400"/>
+</memory-map>
+"""
+
+ self.server.responder = Responder()
+ target = self.createTarget("a.yaml")
+ process = self.connect(target)
+ self.dbg.HandleCommand("target modules load -l -s0")
+ self.assertPacketLogContains([
+ "vFlashErase:1000,100",
+ "vFlashWrite:1000:\xc3\xc3\xc3\xc3",
+ "vFlashWrite:1004:\x32\x32",
+ "vFlashDone"
+ ])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
index e3242295aad..d3c9f32910f 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -453,5 +453,5 @@ class GDBRemoteTestBase(TestBase):
i += 1
j += 1
if i < len(packets):
- self.fail("Did not receive: %s\nLast 10 packets:\n\t%s" %
- (packets[i], '\n\t'.join(log[-10:])))
+ self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" %
+ (packets[i], u'\n\t'.join(log[-10:])))
OpenPOWER on IntegriCloud