proc: fix next when disassembly fails

Next should work even if one or more instructions in the current
function can not be disassembled.
This commit is contained in:
aarzilli 2018-08-27 07:51:48 +02:00 committed by Derek Parker
parent 63c880780f
commit cab09a4bbb
4 changed files with 38 additions and 0 deletions

@ -0,0 +1,7 @@
package main
func asmFunc()
func main() {
asmFunc()
}

@ -0,0 +1,16 @@
#include "textflag.h"
TEXT ·asmFunc(SB),0,$0-0
MOVQ AX, AX
MOVQ AX, AX
MOVQ AX, AX
MOVSS (AX), X2
VBROADCASTSS X2, X2
VMOVDQU (AX), X3
MOVSS (AX), X1
PUNPCKLBW X0, X1
VPUNPCKLWD X0, X1, X1
MOVQ AX, AX
MOVQ AX, AX
MOVQ AX, AX
RET

@ -56,6 +56,9 @@ func (inst *AsmInstruction) Text(flavour AssemblyFlavour, bi *BinaryInfo) string
}
func (inst *AsmInstruction) IsCall() bool {
if inst.Inst == nil {
return false
}
return inst.Inst.Op == x86asm.CALL || inst.Inst.Op == x86asm.LCALL
}

@ -3996,3 +3996,15 @@ func TestReadDefer(t *testing.T) {
}
})
}
func TestNextUnknownInstr(t *testing.T) {
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 10) {
t.Skip("versions of Go before 1.10 can't assemble the instruction VPUNPCKLWD")
}
withTestProcess("nodisasm/", t, func(p proc.Process, fixture protest.Fixture) {
_, err := setFunctionBreakpoint(p, "main.asmFunc")
assertNoError(err, t, "setFunctionBreakpoint()")
assertNoError(proc.Continue(p), t, "Continue()")
assertNoError(proc.Next(p), t, "Next()")
})
}