[v2] gdb/DAP Fix disassemble bug
Commit Message
v2.
Since GDB's current design apparently isn't well suited to backwards
disassembly, I've changed the patch to just return "invalid values"
prior to "current pc".
Though one approach would be to use dwarf's line number
program info to get "logical breakpoint locations" and disassemble from
these as "sources of known truth". This would require that parts of my
"next expression patch", that also works with DAP's "next statement"
request gets accepted, so that the line number program stuff can be used)
v1.
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 | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -27,8 +27,12 @@ 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:]:
+ if skip_insns < 0:
+ for i in range(0, -skip_insns):
+ result.append({"address": 0, "instruction": "unknown"})
+ skip_insns = 0
+
+ for elt in arch.disassemble(pc, count=count + skip_insns)[skip_insns:]:
result.append(
{
"address": hex(elt["addr"]),
@@ -50,7 +54,7 @@ def disassemble(
instructionCount: int,
**extra
):
- pc = int(memoryReference, 0) + offset
+ pc = int(memoryReference, 0)
return send_gdb_with_response(
lambda: _disassemble(pc, instructionOffset, instructionCount)
)