aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.exp9
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.py13
2 files changed, 14 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp
index 2fe20c3..a83c670 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp
@@ -66,9 +66,10 @@ proc py_remove_all_disassemblers {} {
#
# Each different disassembler tests some different feature of the
# Python disassembler API.
+set nop "(nop|nop\t0)"
set unknown_error_pattern "unknown disassembler error \\(error = -1\\)"
set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
-set base_pattern "${addr_pattern}nop"
+set base_pattern "${addr_pattern}${nop}"
set test_plans \
[list \
[list "" "${base_pattern}\r\n.*"] \
@@ -87,9 +88,9 @@ set test_plans \
[list "ReadMemoryMemoryErrorDisassembler" "${addr_pattern}Cannot access memory at address ${curr_pc_pattern}"] \
[list "ReadMemoryGdbErrorDisassembler" "${addr_pattern}read_memory raised GdbError\r\n${unknown_error_pattern}"] \
[list "ReadMemoryRuntimeErrorDisassembler" "${addr_pattern}Python Exception <class 'RuntimeError'>: read_memory raised RuntimeError\r\n\r\n${unknown_error_pattern}"] \
- [list "ReadMemoryCaughtMemoryErrorDisassembler" "${addr_pattern}nop\r\n.*"] \
- [list "ReadMemoryCaughtGdbErrorDisassembler" "${addr_pattern}nop\r\n.*"] \
- [list "ReadMemoryCaughtRuntimeErrorDisassembler" "${addr_pattern}nop\r\n.*"] \
+ [list "ReadMemoryCaughtMemoryErrorDisassembler" "${addr_pattern}${nop}\r\n.*"] \
+ [list "ReadMemoryCaughtGdbErrorDisassembler" "${addr_pattern}${nop}\r\n.*"] \
+ [list "ReadMemoryCaughtRuntimeErrorDisassembler" "${addr_pattern}${nop}\r\n.*"] \
[list "MemorySourceNotABufferDisassembler" "${addr_pattern}Python Exception <class 'TypeError'>: Result from read_memory is not a buffer\r\n\r\n${unknown_error_pattern}"] \
[list "MemorySourceBufferTooLongDisassembler" "${addr_pattern}Python Exception <class 'ValueError'>: Buffer returned from read_memory is sized $decimal instead of the expected $decimal\r\n\r\n${unknown_error_pattern}"] \
[list "ResultOfWrongType" "${addr_pattern}Python Exception <class 'TypeError'>: Result is not a DisassemblerResult.\r\n.*"] \
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):