Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lldb-server: add support for binary memory reads
Summary: This commit adds support for binary memory reads ($x) to lldb-server. It also removes the "0x" prefix from the $x client packet, to make it more compatible with the old $m packet. This allows us to use almost the same code for handling both packet types. I have verified that debugserver correctly handles $x packets even without the leading "0x". I have added a test which verifies that the stub returns the same memory contents for both kinds of memory reads ($x and $m). Reviewers: tberghammer, jasonmolenda Subscribers: iancottrell, lldb-commits Differential Revision: http://reviews.llvm.org/D13695 llvm-svn: 250295
- Loading branch information
Showing
6 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Tests the binary ($x) and hex ($m) memory read packets of the remote stub | ||
""" | ||
|
||
import os | ||
import unittest2 | ||
import lldb | ||
from lldbtest import * | ||
import lldbutil | ||
import binascii | ||
|
||
|
||
class MemoryReadTestCase(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@skipUnlessPlatform(getDarwinOSTriples()+["linux"]) | ||
def test_memory_read(self): | ||
self.build() | ||
exe = os.path.join (os.getcwd(), "a.out") | ||
|
||
target = self.dbg.CreateTarget(exe) | ||
lldbutil.run_break_set_by_symbol(self, "main") | ||
|
||
process = target.LaunchSimple (None, None, self.get_process_working_directory()) | ||
self.assertTrue(process, PROCESS_IS_VALID) | ||
self.assertEqual(process.GetState(), lldb.eStateStopped, "Process is stopped") | ||
|
||
pc = process.GetSelectedThread().GetSelectedFrame().GetPC() | ||
for size in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]: | ||
error = lldb.SBError() | ||
memory = process.ReadMemory(pc, size, error) | ||
self.assertTrue(error.Success()) | ||
self.match("process plugin packet send x%x,%x" % (pc, size), ["response:", memory]) | ||
self.match("process plugin packet send m%x,%x" % (pc, size), ["response:", binascii.hexlify(memory)]) | ||
|
||
process.Continue() | ||
self.assertEqual(process.GetState(), lldb.eStateExited, "Process exited") | ||
|
||
|
||
if __name__ == '__main__': | ||
import atexit | ||
lldb.SBDebugger.Initialize() | ||
atexit.register(lambda: lldb.SBDebugger.Terminate()) | ||
unittest2.main() |