[PATCH v1] gdb/DAP Fix disassemble bug

Simon Farre via Gdb-patches
2023-06-26T16:17:33Z

Fixes disassembleRequest

The field instructionOffset can be negative. Previous patch made it so
that sometimes the request got calculated to 0 instructions, when it
meant to retrieve disasm for -50 to 0 (current position).
---
gdb/python/lib/gdb/dap/disassemble.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/disassemble.py b/gdb/python/lib/gdb/dap/disassemble.py
index bc091eb2c89..1ee6cf2ff48 100644
--- a/gdb/python/lib/gdb/dap/disassemble.py
+++ b/gdb/python/lib/gdb/dap/disassemble.py
@@ -27,8 +27,8 @@ def _disassemble(pc, skip_insns, count):
# Maybe there was no frame.
arch = gdb.selected_inferior().architecture()
result = []
- total_count = skip_insns + count
- for elt in arch.disassemble(pc, count=total_count)[skip_insns:]:
+
+ for elt in arch.disassemble(pc + skip_insns, count=count):
result.append(
{
"address": hex(elt["addr"]),
--
2.41.0