feat(cmd): add gasm dis and share the decoder with the debugger
This commit is contained in:
@@ -8,7 +8,8 @@ package debug
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/arch/riscv64/riscv64asm"
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/arch"
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/disasm"
|
||||
)
|
||||
|
||||
// Disassemble decodes the instruction at the given address in the debuggee's
|
||||
@@ -18,12 +19,11 @@ func (s *Session) Disassemble(addr uint64) (string, int, error) {
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
inst, err := riscv64asm.Decode(mem)
|
||||
ins, err := disasm.Decode(arch.RISCV, mem, addr)
|
||||
if err != nil {
|
||||
return "???", 4, nil
|
||||
return "", 0, err
|
||||
}
|
||||
text := riscv64asm.GoSyntax(inst, addr, nil, nil)
|
||||
return text, inst.Len, nil
|
||||
return ins.Text, ins.Len, nil
|
||||
}
|
||||
|
||||
// DisassembleN decodes up to n instructions starting at addr.
|
||||
|
||||
Reference in New Issue
Block a user