diff options
author | Tom de Vries <tdevries@suse.de> | 2022-12-13 13:06:15 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-12-13 13:06:15 +0100 |
commit | fa59ab98685e4b5431d2be423f449df5069a454e (patch) | |
tree | 5966e579d9113fe0c93d200b9617dbab2d686671 /gdb/testsuite/gdb.python/py-disasm.py | |
parent | 969b9a36506bfb386f8ce30f88f1a6a6ebbaca6e (diff) | |
download | binutils-fa59ab98685e4b5431d2be423f449df5069a454e.zip binutils-fa59ab98685e4b5431d2be423f449df5069a454e.tar.gz binutils-fa59ab98685e4b5431d2be423f449df5069a454e.tar.bz2 |
[gdb/testsuite] Fix gdb.python/py-disasm.exp on s390x
On s390x-linux, I run into:
...
(gdb) disassemble test^M
Dump of assembler code for function test:^M
0x0000000001000638 <+0>: stg %r11,88(%r15)^M
0x000000000100063e <+6>: lgr %r11,%r15^M
0x0000000001000642 <+10>: nop 0^M
=> 0x0000000001000646 <+14>: nop 0^M
0x000000000100064a <+18>: nop 0^M
0x000000000100064e <+22>: lhi %r1,0^M
0x0000000001000652 <+26>: lgfr %r1,%r1^M
0x0000000001000656 <+30>: lgr %r2,%r1^M
0x000000000100065a <+34>: lg %r11,88(%r11)^M
0x0000000001000660 <+40>: br %r14^M
End of assembler dump.^M
(gdb) FAIL: gdb.python/py-disasm.exp: global_disassembler=: disassemble test
...
The problem is that the test-case expects "nop" but on s390x we have instead
"nop\t0".
Fix this by allowing the insn.
Tested on s390x-linux and x86_64-linux.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-disasm.py')
-rw-r--r-- | gdb/testsuite/gdb.python/py-disasm.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py index 3b9008b..ed9901e 100644 --- a/gdb/testsuite/gdb.python/py-disasm.py +++ b/gdb/testsuite/gdb.python/py-disasm.py @@ -25,6 +25,10 @@ from gdb.disassembler import Disassembler, DisassemblerResult current_pc = None +def is_nop(s): + return s == "nop" or s == "nop\t0" + + # Remove all currently registered disassemblers. def remove_all_python_disassemblers(): for a in gdb.architecture_names(): @@ -581,7 +585,7 @@ class AnalyzingDisassembler(Disassembler): result = gdb.disassembler.builtin_disassemble(info) # Record some informaiton about the first 'nop' instruction we find. - if self._nop_index is None and result.string == "nop": + if self._nop_index is None and is_nop(result.string): self._nop_index = len(self._pass_1_length) # The offset in the following read_memory call defaults to 0. self._nop_bytes = info.read_memory(result.length) @@ -616,7 +620,7 @@ class AnalyzingDisassembler(Disassembler): if ( idx > 0 and idx != nop_idx - and self._pass_1_insn[idx] != "nop" + and not is_nop(self._pass_1_insn[idx]) and self._pass_1_length[idx] > self._pass_1_length[nop_idx] and self._pass_1_length[idx] % self._pass_1_length[nop_idx] == 0 ): @@ -631,7 +635,7 @@ class AnalyzingDisassembler(Disassembler): if ( idx > 0 and idx != nop_idx - and self._pass_1_insn[idx] != "nop" + and not is_nop(self._pass_1_insn[idx]) and self._pass_1_length[idx] == self._pass_1_length[nop_idx] ): replace_idx = idx @@ -654,7 +658,8 @@ class AnalyzingDisassembler(Disassembler): # identified above with a series of 'nop' instructions. self._check = list(self._pass_1_insn) nop_count = int(self._pass_1_length[replace_idx] / self._pass_1_length[nop_idx]) - nops = ["nop"] * nop_count + nop_insn = self._pass_1_insn[nop_idx] + nops = [nop_insn] * nop_count self._check[replace_idx : (replace_idx + 1)] = nops def check(self): |