diff options
author | Tom de Vries <tdevries@suse.de> | 2024-07-31 13:24:20 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-07-31 13:24:20 +0200 |
commit | 61ed16ee6341535924e5e601964afc6c256258e6 (patch) | |
tree | a1ff4f63677ba2de6ea7d2a87a1e34109d3d33f3 /gdb/testsuite/gdb.python/py-disasm.py | |
parent | 50fb268a6ff81c5a88119474ffe61cd4df1a8248 (diff) | |
download | binutils-61ed16ee6341535924e5e601964afc6c256258e6.zip binutils-61ed16ee6341535924e5e601964afc6c256258e6.tar.gz binutils-61ed16ee6341535924e5e601964afc6c256258e6.tar.bz2 |
[gdb/testsuite] Add gdb.python/py-disasm-{exec,obj}.exp
I tried to reproduce a problem in test-case gdb.python/py-disasm.exp on a
s390x machine, but when running with target board unix/-m31 I saw that the
required libraries were missing, so I couldn't generate an executable.
However, I realized that I did have an object file, and the test-case should
mostly also work with an object file.
I've renamed gdb.python/py-disasm.exp to gdb.python/py-disasm.exp.tcl and
included it from two new minimal test-case wrappers:
- gdb.python/py-disasm-exec.exp, and
- gdb.python/py-disasm-obj.exp
where the former uses an executable as before, and the latter uses an object
file.
Using an object file required changing the info.read_memory calls in
gdb.python/py-disasm.py:
...
- info.read_memory(1, -info.address + 2)
+ info.read_memory(1, -info.address - 1)
...
because reading from address 2 succeeds. Using address -1 instead does
generate the expected gdb.MemoryError.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-disasm.py')
-rw-r--r-- | gdb/testsuite/gdb.python/py-disasm.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py index 2741fdb..f105657 100644 --- a/gdb/testsuite/gdb.python/py-disasm.py +++ b/gdb/testsuite/gdb.python/py-disasm.py @@ -252,7 +252,7 @@ class MemoryErrorEarlyDisassembler(TestDisassembler): def disassemble(self, info): tag = "## FAIL" try: - info.read_memory(1, -info.address + 2) + info.read_memory(1, -info.address - 1) except gdb.MemoryError: tag = "## AFTER ERROR" result = builtin_disassemble_wrapper(info) @@ -267,7 +267,7 @@ class MemoryErrorLateDisassembler(TestDisassembler): def disassemble(self, info): result = builtin_disassemble_wrapper(info) # The following read will throw an error. - info.read_memory(1, -info.address + 2) + info.read_memory(1, -info.address - 1) return DisassemblerResult(1, "BAD") @@ -276,9 +276,9 @@ class RethrowMemoryErrorDisassembler(TestDisassembler): def disassemble(self, info): try: - info.read_memory(1, -info.address + 2) + info.read_memory(1, -info.address - 1) except gdb.MemoryError as e: - raise gdb.MemoryError("cannot read code at address 0x2") + raise gdb.MemoryError("cannot read code at address -1") return DisassemblerResult(1, "BAD") |