aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-disasm.py
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.python/py-disasm.py')
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py
index 2741fdb..9761337 100644
--- a/gdb/testsuite/gdb.python/py-disasm.py
+++ b/gdb/testsuite/gdb.python/py-disasm.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2021-2024 Free Software Foundation, Inc.
+# Copyright (C) 2021-2025 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -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")
@@ -294,6 +294,24 @@ class ResultOfWrongType(TestDisassembler):
return self.Blah(1, "ABC")
+class ResultOfVeryWrongType(TestDisassembler):
+ """Return something that is not a DisassemblerResult from disassemble
+ method. The thing returned will raise an exception if used in an
+ isinstance() call, or in PyObject_IsInstance from C++.
+ """
+
+ class Blah:
+ def __init__(self):
+ pass
+
+ @property
+ def __class__(self):
+ raise RuntimeError("error from __class__ in Blah")
+
+ def disassemble(self, info):
+ return self.Blah()
+
+
class TaggingDisassembler(TestDisassembler):
"""A simple disassembler that just tags the output."""