2 Test the 'memory write' command.
6 import lldbsuite
.test
.lldbutil
as lldbutil
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
12 class MemoryWriteTestCase(TestBase
):
14 # Call super's setUp().
16 # Find the line number to break inside main().
17 self
.line
= line_number("main.c", "// Set break point at this line.")
19 def build_run_stop(self
):
21 exe
= self
.getBuildArtifact("a.out")
22 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
24 # Break in main() after the variables are assigned values.
25 lldbutil
.run_break_set_by_file_and_line(
26 self
, "main.c", self
.line
, num_expected_locations
=1, loc_exact
=True
29 self
.runCmd("run", RUN_SUCCEEDED
)
31 # The stop reason of the thread should be breakpoint.
34 STOPPED_DUE_TO_BREAKPOINT
,
35 substrs
=["stopped", "stop reason = breakpoint"],
38 # The breakpoint should have a hit count of 1.
39 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)
42 def test_memory_write(self
):
43 """Test the 'memory write' command for writing values and file contents."""
47 "memory read --format c --size 7 --count 1 `&my_string`",
51 self
.expect("memory write --format c --size 7 `&my_string` ABCDEFG")
54 "memory read --format c --size 7 --count 1 `&my_string`",
59 "memory write --infile file.txt --size 7 `&my_string`",
60 substrs
=["7 bytes were written"],
64 "memory read --format c --size 7 --count 1 `&my_string`",
69 "memory write --infile file.txt --size 7 `&my_string` ABCDEFG",
72 "error: memory write takes only a destination address when writing file contents"
77 "memory write --infile file.txt --size 7",
80 "error: memory write takes a destination address when writing file contents"
85 def test_memory_write_command_usage_syntax(self
):
86 """Test that 'memory write' command usage syntax shows it does not take values when writing file contents."""
90 "memory write [-f <format>] [-s <byte-size>] <address> <value> [<value> [...]]",
91 "memory write -i <filename> [-s <byte-size>] [-o <offset>] <address>",